Strata - v1.4.10
    Preparing search index...

    Class TwoBoneIKSolver

    Two-Bone IK Solver (Analytical Solution).

    Specialized, high-performance IK solver for exactly 2-bone chains like arms and legs. Uses analytical geometry instead of iterative solving, making it faster and more predictable than FABRIK or CCD for this specific use case.

    When to use TwoBoneIK:

    • Human/creature arms (shoulder → elbow → wrist)
    • Human/creature legs (hip → knee → foot)
    • Any exactly 2-joint system
    • When you need guaranteed single-frame solution
    • When performance is critical

    Features:

    • Analytical solution (no iterations needed)
    • Pole target for controlling elbow/knee direction
    • Handles out-of-reach targets gracefully
    • Deterministic - same input always gives same output
    // Character arm reaching for object
    const solver = new TwoBoneIKSolver();

    // Arm bones
    const shoulder = character.getObjectByName('shoulder');
    const elbow = character.getObjectByName('elbow');
    const wrist = character.getObjectByName('wrist');

    // Where the hand should reach
    const targetPos = pickedUpObject.position;

    // Control elbow direction (point forward)
    const elbowPole = shoulder.position.clone().add(new THREE.Vector3(0, 0, 1));

    // Solve and apply
    solver.solveLimb(shoulder, elbow, wrist, targetPos, elbowPole);
    // Character leg stepping on terrain
    const solver = new TwoBoneIKSolver();

    const hip = character.getObjectByName('leftHip');
    const knee = character.getObjectByName('leftKnee');
    const foot = character.getObjectByName('leftFoot');

    // Ground position from raycast
    const groundPos = raycaster.intersectObject(terrain)[0].point;

    // Knee points forward
    const kneePole = hip.position.clone().add(new THREE.Vector3(0, 0, 1));

    solver.solveLimb(hip, knee, foot, groundPos, kneePole);
    // Low-level API for custom control
    const result = solver.solve(
    shoulderPos,
    elbowPos, // Current position (ignored, recalculated)
    wristPos, // Current position (ignored, recalculated)
    targetPos,
    polePos,
    0.3, // Upper arm length
    0.25 // Forearm length
    );

    // Manually apply result
    elbow.position.copy(result.midPosition);
    wrist.position.copy(result.endPosition);
    shoulder.quaternion.copy(result.upperRotation);
    elbow.quaternion.copy(result.lowerRotation);
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Parameters

      • rootPos: Vector3
      • _midPos: Vector3
      • _endPos: Vector3
      • target: Vector3
      • poleTarget: Vector3
      • upperLength: number
      • lowerLength: number

      Returns {
          endPosition: Vector3;
          lowerRotation: Quaternion;
          midPosition: Vector3;
          upperRotation: Quaternion;
      }

    • Parameters

      • root: Object3D
      • mid: Object3D
      • end: Object3D
      • target: Vector3
      • poleTarget: Vector3

      Returns void