Animation · function

sampleSpringChain

Where every link of a chain sits at timeSec. Writes three floats per link into out.

Explained in Animation.

function sampleSpringChain(links: readonly SpringLink[], rootAt: SpringAnchor, timeSec: number, out: Float32Array): void
import { sampleSpringChain } from '@driftengine/animation';

Parameters

ParameterTypeDescription
linksreadonly SpringLink[]
rootAtSpringAnchor
timeSecnumber
outFloat32Array

In depth

The whole chain is marched on one grid rather than each link on its own, and that is not an optimisation. Link n's anchor is link n-1's sprung position, so sampling a link independently would need its parent at every substep, which would need the grandparent at every substep of every one of those: a depth-d chain would cost steps^d anchor calls. Marched together it is steps × d, and it is the same answer.