Skip to content

Inverse kinematics

Inverse kinematics (IK) computes the joint rotations needed for a chain’s tip to reach a target β€” the inverse of forward animation. vgai ships IK as a first-class GameComponent, IKChain (examples/ik/src/ik-chain.ts), wrapping Three.js’s own CCDIKSolver.

A bone chain bends so its effector tip reaches a target
The chain bends each frame so its effector reaches the target.

IKChain operates on an entity containing a SkinnedMesh. Each frame it bends a named bone chain so the chain tip (the effector) reaches a world-space target. It runs in the preRender phase, after the animation phase β€” so IK refines the pose that animation produced.

Authored fields (static schema):

  • boneNames β€” bone names from chain root β†’ effector (the tip that reaches the target).
  • targetBoneName β€” the skeleton bone used as the IK goal. If no bone with that name exists, one is appended to the skeleton (and the skin’s bone buffers grown) β€” so IK works on any rig.
  • targetOffset β€” a world-space target position to use when no live target is provided.
  • iterations β€” CCD solver iterations per frame.