math docs
    Preparing search index...

    Type Alias Chain2

    A chain of bones, from the base (index 0) to the end effector (the last bone's end).

    Allocate one with createChain2, fill it with addBone or addConsecutiveBone, then solve it every frame.

    bones[0].joint is unused - the first bone is governed by the chain's basebone fields instead, so a joint's fields never change meaning with its index.

    type Chain2 = {
        base: vec2.Vec2;
        baseboneAnticlockwise: number;
        baseboneAxis: vec2.Vec2;
        baseboneClockwise: number;
        baseboneConstraintType: fabrik2.BaseboneConstraintType;
        baseboneWorldAxis: vec2.Vec2;
        bestSolution: number[];
        bones: Bone2[];
        embeddedTarget: vec2.Vec2;
        fixedBase: boolean;
        length: number;
        maxIterations: number;
        minIterationChange: number;
        solveDistance: number;
        solveDistanceThreshold: number;
        useEmbeddedTarget: boolean;
    }
    Index
    base: vec2.Vec2

    Where the base of the chain is pinned when fixedBase is set.

    baseboneAnticlockwise: number

    How far the first bone may swing anticlockwise of the baseline, in [0, PI].

    baseboneAxis: vec2.Vec2

    The baseline direction, in the space named by baseboneConstraintType. Unit length.

    baseboneClockwise: number

    How far the first bone may swing clockwise of the baseline, in [0, PI].

    baseboneConstraintType: fabrik2.BaseboneConstraintType

    How the first bone is held; see BaseboneConstraintType.

    baseboneWorldAxis: vec2.Vec2

    baseboneAxis in world space. Equal to it for GLOBAL_ABSOLUTE; resolved by solveStructure otherwise.

    bestSolution: number[]

    Scratch holding the best pose solve has seen, four numbers per bone. Grown by addBone.

    bones: Bone2[]

    The bones, base first and end effector last.

    Neighbours share a point - bone i's end is bone i + 1's start - and the solver keeps it that way, so moving one moves the other.

    embeddedTarget: vec2.Vec2

    The target this chain solves for inside a Structure2 when useEmbeddedTarget is set.

    fixedBase: boolean

    Whether backward pins the base to base. Clear it to let the whole chain drift. Forced on for a chain connected in a structure.

    length: number

    The sum of every bone length - the chain's reach. Maintained by addBone.

    maxIterations: number

    The most iterations solve will run.

    minIterationChange: number

    How still an iteration must be before solve treats the chain as stuck.

    Only consulted on an iteration that fails to beat the best distance so far, and compared against the previous iteration rather than the best - so a solve that is slowly getting worse runs its full budget. That is deliberate: FABRIK often worsens before it improves, and every stricter rule tried here bought fewer iterations at a disproportionate cost in final pose.

    solveDistance: number

    The distance from the effector to the target after the last solve.

    solveDistanceThreshold: number

    solve stops as soon as the effector is this close to the target.

    useEmbeddedTarget: boolean

    Whether this chain solves for its own embeddedTarget instead of the target passed to solveStructure. Ignored outside a Structure2.