Documentation
    Preparing search index...

    Interface TrackSampleSink

    Where AnimationClip.sampleAll gets its scratch and sends its results.

    Split in two so the clip can sample without allocating and without knowing anything about targets. The mixer implements it over arrays indexed the same way as AnimationClip.tracks: one PropertyBinding per track, resolved once (§16), and one scratch value per track, allocated once.

    const sink: TrackSampleSink = {
    outFor: (index) => scratch[index],
    applySample: (index, _track, value) => { bindings[index].set(value); },
    };
    clip.sampleAll(localTime, sink); // allocates nothing

    The two-step shape exists because of the mutatesInPlace split in ./values.js: for a Vector3 track the sampled value is the scratch object handed out by outFor, while for a number track it is a fresh primitive that outFor's storage never saw. Passing the result back through applySample is the only way to serve both without branching per sample.

    interface TrackSampleSink {
        applySample(
            trackIndex: number,
            track: AnimationTrackLike,
            value: unknown,
        ): void;
        outFor(trackIndex: number, track: AnimationTrackLike): unknown;
    }
    Index
    • Receives the effective sampled value for track trackIndex — the object returned by TrackSampleSink.outFor for in-place kinds, the sampled primitive or discrete value otherwise.

      Parameters

      Returns void

    • Storage for track trackIndex's sample. Must be a value of that track's type and must not alias one of its keyframe values. Ignored — but still requested — for value kinds whose adapter reports mutatesInPlace: false.

      Parameters

      Returns unknown