AnimationMixer

A weighted, auto-advancing blend of several glTF clips — a blend tree. Each AnimationTrack contributes its pose by AnimationTrack.weight; weights are normalized so they need not sum to 1.

This is plain state with no @Composable entry point, so it suits an imperative game loop: hold a mixer (e.g. via rememberAnimationMixer), mutate track weights from your own animation state machine, and call apply every frame with the instance's Animator and the frame delta:

val mixer = rememberAnimationMixer()
val walk = remember { mixer.addTrack(walkIndex) }
val run = remember { mixer.addTrack(runIndex, weight = 0f) }
GltfInstance(asset = character, onCreate = { animator = instance.getAnimator() })
OnFrame { frame ->
walk.weight = 1f - moveSpeed; run.weight = moveSpeed
animator?.let { mixer.apply(it, frame.deltaSeconds) }
}

In Compose, AnimationState already wraps one of these as AnimationState.mixer and drives apply for you; rememberAnimationTrack is declarative sugar over addTrack.

Filament blends the whole skeleton per call, so per-bone masks and additive layers are not expressible — drive the Animator yourself for that.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Pauses advancement of every track while true; poses hold in place. Observable, like AnimationState.isPaused.

Link copied to clipboard

The active tracks, in blend order.

Functions

Link copied to clipboard
fun addTrack(index: Int, weight: Float = 1.0f, speed: Float = 1.0f, loop: Boolean = true, time: Float = 0.0f): AnimationTrack

Creates a weighted track, adds it, and returns it for later mutation.

Link copied to clipboard
fun apply(animator: Animator, dtSeconds: Float)

Advances every track by dtSeconds and pushes the blended pose onto animator.

Link copied to clipboard

Removes every track.

Link copied to clipboard

Removes a previously added track.