API Reference · Animation

AnimationTrack

Namespace: Ava3D

public sealed class AnimationTrack

One animated property of one node: a sorted key time array and the values at those times.

Values are held flat rather than as Vector3/Quaternion arrays because AnimationPath.Weights has no fixed width — a mesh with four morph targets stores four floats a key — and one storage shape that covers all four paths is worth more than the typing. AnimationTrack.Stride is that width: 3, 4, or the morph-target count.

A AnimationInterpolation.CubicSpline track stores three times as many values, as glTF does: in-tangent, value, out-tangent for every key.

Constructors

MemberDescription
AnimationTrack(Node target, AnimationPath path, AnimationInterpolation interpolation, int stride, float[] times, float[] values)

Builds a track. values is times.Length × stride long, or three times that for a cubic-spline track.

Properties

MemberDescription
float Duration { get; }

The last key's time. A collapsed constant track reports 0.

AnimationInterpolation Interpolation { get; }

How values between keys are found.

int KeyCount { get; }

Number of keys.

AnimationPath Path { get; }

Which of the node's properties it writes.

int Stride { get; }

Floats per key: 3 for translation and scale, 4 for rotation, the target count for weights.

Node Target { get; }

The node this track writes to.

Methods

MemberDescription
void Sample(float time, Span<float> into)

The value at time, written into into, which must be at least AnimationTrack.Stride long.

The segment is found from a cursor rather than by binary search. Playback is monotonic and the answer is almost always the segment used last frame or the one after it, so the search is two comparisons in the common case; a seek backwards falls through to a scan, which is what a caller setting AnimationState.Time is asking for and is not on any hot path.

Quaternion SampleQuaternion(float time)

Convenience over AnimationTrack.Sample for a rotation track.

Normalised on the way out. Linear interpolation of two unit quaternions is not itself a unit quaternion, and a rotation that is fractionally short scales the geometry it is applied to — over a chain of five joints that compounds into a hand that shrinks as the arm swings.

Vector3 SampleVector3(float time)

Convenience over AnimationTrack.Sample for a 3-component track.

See also