Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / index / twoBoneIK

Function: twoBoneIK() ​

ts
function twoBoneIK(
   upper, 
   lower, 
   end, 
   target, 
   pole, 
   forward?): number;

Defined in: animation/ik.ts:43

Two-bone IK: rotates upper and lower so end's origin (the wrist or ankle) reaches target, bending toward pole (pass the animated elbow/knee position to keep the animation's style). Unreachable targets are reached for as far as the limb allows. Returns how far the end stayed from the target (0 when reachable). forward is the way the character faces, for a limb too straight to say which way it bends.

Parameters ​

ParameterTypeDefault value
upperObject3Dundefined
lowerObject3Dundefined
endObject3Dundefined
targetVector3undefined
poleVector3undefined
forwardVector3FORWARD

Returns ​

number