Documentation
    Preparing search index...

    Class KinematicController

    Prescribed kinematic motion attached to a node (§12), advanced by KinematicSystem.

    const controller = node.addComponent(new KinematicController());
    node.transformAuthority = "kinematic"; // §42 — required, see below
    system.track(node);

    controller.moveTo(new Vector3(10, 0, 0), { duration: 2 });
    controller.rotateTo(target, { duration: 1 }); // runs concurrently

    A component per plan D2: a class with a static readonly typeName, one per node, holding no reference to its node (host is assigned by the registry). All behaviour is in KinematicController.step, which the system calls once per fixed step.

    See the module documentation for the channel model, the lazy start-pose capture, completion semantics, and the §42 authority rules.

    Implements

    Index
    host: ComponentHost | null = null

    The node this component is attached to, or null. Written by the ComponentRegistry alone (§6a); never assign it.

    typeName: "kinematic-controller"

    Component key (plan D2) and §79 serialization name.

    • get commandGeneration(): number

      Number of commands accepted by this controller, counting both channels and every explicit cancel.

      Monotonic, starts at 0, and changes only through the command API — never when a command completes on its own. Capture it when you issue a command and compare later: an unchanged value means your command is still the one that owns its channel (combine with translationActive / rotationActive to tell "still running" from "finished").

      Returns number

    • get translationActive(): boolean

      Whether a moveTo or followPath is currently running.

      true from the moment the command is issued until the step that completes it (inclusive of that step's write); a looping followPath keeps it true indefinitely. Polled, not announced — see the module note.

      Returns boolean

    • Drives the node along trajectory (§13), replacing any active translation command — path following claims the translation channel, so it cancels an in-flight moveTo and is cancelled by the next one.

      The node is placed at trajectory.samplePosition(t) each step, with t the seconds of simulation processed since the path started (so the node jumps onto the path on its first step rather than easing onto it — prefix a moveTo if you need to approach it). t is clamped to trajectory.duration, at which point the command completes; with options.loop it wraps (t % duration) and never completes.

      A trajectory whose duration is not a finite positive number — Infinity for an endless path, and any degenerate 0/negative/NaN value — is neither clamped nor wrapped: t simply keeps increasing and the command runs until it is replaced or cancelled. §13 trajectories extrapolate their closed form outside [0, duration], so that is well defined.

      The trajectory is held by reference and must not be mutated while it is being followed. duration is read every step, so a trajectory that recomputes its own extent stays honest.

      Parameters

      Returns void

    • Moves the node to position over options.duration seconds, replacing any active translation command (moveTo or followPath).

      position is copied. Interpolation is linear, from the node's position at the first fixed step after this call to position; the completing step writes position exactly.

      Parameters

      Returns void

      RangeError if duration is not a finite number >= 0.

    • Rotates the node to rotation over options.duration seconds, replacing any active rotation command. Does not touch the translation channel.

      rotation is copied and assumed to be a unit quaternion (as everywhere in @fourjs/math). Interpolation is spherical along the shortest arc (plan D8 — Quaternion.slerp negates the target when the dot product is negative), from the node's rotation at the first fixed step after this call; the completing step writes rotation's components exactly, so the node finishes on the quaternion you asked for rather than on its antipode.

      Parameters

      Returns void

      RangeError if duration is not a finite number >= 0.

    • Advances both channels by deltaSeconds and writes the results into transform.

      Called by KinematicSystem once per fixed step. Calling it directly is supported (a controller driven without a system, or a unit test), but it performs no §42 authority check — that belongs to the system, which knows the node; this method only knows a transform.

      An idle channel costs one comparison and writes nothing, so a controller with no active command never bumps Transform.version.

      Parameters

      Returns void