Skip to content

@orillusion/core


Class: TwoBoneIK

Defined in: src/components/anim/ik/TwoBoneIK.ts:39

Analytic Two-Bone IK solver.

Given a 3-joint chain [hip, knee, ankle] and a world-space target, computes the hip and knee local rotations so the ankle reaches the target. Uses the law of cosines on the bone-length triangle, then an extra hip rotation to align the chain with the target direction. A "pole" reference point fixes the bend plane (knee direction) — without one the solver picks an arbitrary plane that may flip when the chain crosses its axis.

Runs CPU-side after layer mix in AnimatorComponent.onUpdate. IK chains are tiny (≤4 bones) so the cost is negligible.

Limits:

  • Doesn't handle hierarchies where chain[0]'s parent has non-identity rotation that we don't iterate through. For human rigs (root → hip) this is usually fine.
  • Assumes uniform unit scale on the chain.

Constructors

Constructor

new TwoBoneIK(cfg): TwoBoneIK

Defined in: src/components/anim/ik/TwoBoneIK.ts:66

Parameters

cfg

TwoBoneIKConfig

Returns

TwoBoneIK

Properties

name

name: string

Defined in: src/components/anim/ik/TwoBoneIK.ts:40


chain

chain: [string, string, string]

Defined in: src/components/anim/ik/TwoBoneIK.ts:41


target

target: Object3D | Vector3

Defined in: src/components/anim/ik/TwoBoneIK.ts:42


pole?

optional pole?: Object3D | Vector3

Defined in: src/components/anim/ik/TwoBoneIK.ts:43


weight

weight: number

Defined in: src/components/anim/ik/TwoBoneIK.ts:44

Methods

solve()

solve(animator): void

Defined in: src/components/anim/ik/TwoBoneIK.ts:74

Parameters

animator

AnimatorComponent

Returns

void