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 (packages/editor/template/src/examples/ik/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.