Documentation
    Preparing search index...

    Class FollowRig

    §44's follow rig and spring arm: a node held at an offset from a target, optionally smoothed.

    // A chase camera 4 m behind and 2 m above the player, critically damped:
    camera.addComponent(
    new FollowRig({
    target: player,
    offset: new Vector3(0, 2, 4),
    frame: "target",
    spring: new SpringDamper({ frequencyHz: 2, dampingRatio: 1 }),
    }),
    );

    §44 names "follow rigs" and "spring arms" separately, and they differ in exactly two independent bits: which frame the offset is read in, and whether the result is smoothed. Two classes would have shared every line and forced an application that wanted a smoothed world-axis follow (an isometric camera) or an unsmoothed target-frame arm (a rigid boom) to pick the wrong one and fight it.

    • frame: "world" reads the offset along the world axes, so the camera keeps its bearing while the target turns — the isometric/side-on follow.
    • frame: "target" reads it in the target's own frame, so it swings around behind the target as the target turns — the third-person boom. The basis is the target's world matrix columns normalized, so an ancestor's scale moves the arm's anchor without stretching the arm. A Vector3 target has no orientation, so it falls back to the world axes.
    • spring omitted snaps to the goal every step; supplied, the placement is the exact exponential step of SpringDamper towards it, integrated in world space so the smoothing does not change when the rig is reparented.

    The smoother's state is captured lazily, on the first step that writes: a rig starts from wherever its node actually is rather than easing in from the origin. It keeps advancing on a step whose write is refused by a degenerate parent — the goal is a property of the target, not of the write — but not on a step the §42 check refuses, because that step never reaches this component at all (ConstraintSystem freezes a refused node, exactly as KinematicSystem freezes a refused command).

    Implements

    Index

    Which frame FollowRig.offset is read in. Fixed at construction.

    host: ComponentHost | null

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

    offset: Vector3

    Offset from the target, in the frame FollowRig.frame names. Written in place — the instance is the rig's own copy of what the constructor was given, so moving a camera's boom is rig.offset.set(...).

    skippedSteps: number

    Steps on which the rig declined to place its node — see FollowRig.apply.

    spring: SpringDamper | null

    The smoother, or null for a rig that snaps. Fixed at construction.

    target: RigTarget | null

    What the rig follows, or null for an idle rig. See OrbitRig.target.

    typeName: "follow-rig"

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

    • get smoothing(): boolean

      Whether the smoother holds state, i.e. at least one step has been written.

      Returns boolean

    • Places node at its offset from the target, smoothing when the rig has a spring. Called by ConstraintSystem once per fixed step, after the §42 authority check.

      Parameters

      • node: Node

        the node being placed

      • deltaSeconds: number

        the fixed step, in seconds (§7a)

      Returns boolean

      true when the node was placed. false — and a bumped FollowRig.skippedSteps — when the target's world position is not finite, when a "target" frame has a collapsed basis, or when the node's parent has no invertible world matrix; an idle rig returns false without counting a skip.

    • Drops the smoother's captured state, so the next step starts from the node's position then instead of springing across the gap.

      What a teleport needs: moving a followed target by kilometres would otherwise send the camera sailing after it for a second.

      Returns void