Documentation
    Preparing search index...

    Class LookAtConstraint

    §12's look-at constraint: a component that turns its node's −Z axis towards a target every fixed step, optionally rate-limited.

    The aim itself is Node.lookAt — the same primitive an application calls, so a constrained camera and a hand-aimed one agree exactly (R-36). What this component adds is the three things a per-step aim needs and a one-off call does not: a target that may be a moving node, a survivable answer to the degenerate configurations lookAt refuses, and a slew limit.

    With maxAngularSpeed set, the node turns towards the aim at no more than that many radians per second, along the shortest arc (Quaternion.slerp's rule), and never overshoots: a rig that is θ radians off arrives in θ / maxAngularSpeed seconds and stops there, because the goal is recomputed from the target every step rather than integrated.

    It is implemented by writing the rotation twice on a limited step — once by lookAt, which lands on the goal, then once by slerping back from the rotation captured before the call. That is deliberate. The alternative is a second copy of lookAt's world-rotation-to-local-rotation division, which is the one piece of that method with a real subtlety in it (the parent's world rotation, recovered by decomposition), and two copies of it would be two things to keep in agreement. Two writes cost one extra Transform.version bump on a step that was already recomputing a world matrix.

    Implements

    Index
    host: ComponentHost | null = null

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

    maxAngularSpeed: number | undefined

    Largest turn rate in rad/s, or undefined for an unlimited snap.

    skippedSteps: number = 0

    Steps on which the aim was degenerate and the rotation was left untouched.

    Not incremented by a §42 refusal — see the module note on why the two states are kept apart — and not by an idle constraint.

    target: RigTarget | null

    What the node aims at, or null for an idle constraint — one that writes nothing, and therefore raises no §42 conflict on a node it does not own.

    up: Vector3 = ...

    Reference up direction, in world space. The rig's own copy, written in place; a (0, 0, 0) or non-finite value is not refused here but makes every step a skipped one, exactly as an aim parallel to it does.

    typeName: "look-at-constraint"

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

    • Aims node at the target. Called by ConstraintSystem once per fixed step, after the §42 authority check and after the placement components.

      Parameters

      • node: Node

        the node being aimed

      • deltaSeconds: number

        the fixed step, in seconds (§7a)

      Returns boolean

      true when the rotation was written. false — and a bumped LookAtConstraint.skippedSteps — when the target's world position is not finite, coincides with the node's own, or leaves the roll undetermined; an idle constraint returns false without counting a skip.