Skip to content

@modoki/engine / index / Animator

Variable: Animator

const Animator: Trait<{ activeClip: string; clip: string; clips: string; fadeDuration: number; fadeElapsed: number; fadeFrom: string; fadeFromTime: number; loop: boolean; playing: boolean; speed: number; time: number; }>

Animator — plays keyframe animation clips on this entity and its descendants.

Holds a NAMED LIST of clips (clips, a JSON-string bank of {name, clip(GUID), speed?, loop?, fadeDuration?}) and plays ONE at a time, chosen by clip (the active clip NAME; empty → first entry). Switch clip to "play a track" — the play loop restarts the new clip and picks it up next frame (mirrors SkeletalAnimator / SpriteAnimator). Each entry's clip is a GUID referencing a .anim.json asset (resolved via the asset manifest); the entity carrying the Animator is the clip's binding root, tracks target descendants by relative name-path.

The clips bank is decoded by animation/animClipBank.ts (parseAnimClipBank / resolveActiveClip) — the ONE decoder, shared by the play loop, the resource collector, and the build tree-shaker (same JSON-string-scalar pattern as AudioSource.clips). speed/loop here are the fallbacks a per-clip override wins over.

Built with Modoki.