AnimationState

Hoisted, observable playback state for a single glTF Animator, created with rememberAnimationState and passed to GltfInstance. It auto-advances on every frame and cross-fades smoothly whenever animationIndex changes, covering the common "play idle, blend into walk" case without dropping to the onUpdate escape hatch.

Filament's animator blends exactly two clips at a time (the incoming clip plus the outgoing one it is fading from), so this drives one active animation with an automatic transition rather than an arbitrary N-track mixer. For full manual control use GltfInstance's onUpdate and call the Animator directly.

val anim = rememberAnimationState(animationIndex = 0)
GltfInstance(asset = character, animationState = anim)

// later, from a click handler — cross-fades over crossFadeDuration seconds:
anim.animationIndex = walkIndex

Properties

Link copied to clipboard

The animation to play. Assigning a new value cross-fades from the current one. Null pauses.

Link copied to clipboard

Cross-fade length in seconds applied when animationIndex changes. 0 = hard cut.

Link copied to clipboard

True while a cross-fade transition is in progress. Read-only.

Link copied to clipboard

Whether the active animation wraps at its end (true) or holds the final frame (false).

Link copied to clipboard

Playback rate multiplier (1 = real time, negative plays backwards).

Link copied to clipboard
val time: Float

Current playback time of the active animation in seconds. Read-only, updates per frame.