Animation · function

solveTwoBone

Reach target with the chain root → mid → tip, writing the two rotations into pose.

Explained in Animation.

function solveTwoBone(skeleton: Skeleton, pose: Pose, root: number, mid: number, tip: number, target: ArrayLike<number>, poleHint: ArrayLike<number>): boolean
import { solveTwoBone } from '@driftengine/animation';

Parameters

ParameterTypeDescription
skeletonSkeleton
posePose
rootnumber
midnumber
tipnumber
targetArrayLike<number>
poleHintArrayLike<number>

In depth

Returns whether the target was reachable. An unreachable one straightens the chain toward it, which is the behaviour a limb should have: an arm reaching for something too far away extends, it does not give up or fold.

poleHint decides the one thing the target cannot — which way the joint bends. A world-space point or direction the mid joint should lean toward; without it, a chain that is already straight has no plane to bend in and the elbow would flip unpredictably as a character turned.

The skeleton's world matrices are refreshed as it goes, so they are current when this returns.