model-scene
Model scene playback
Add the local garnet-model-scene shard and require it alongside your model loader. Install the plugin; each entity with an Animator plays its model player.
world.add_plugin(Garnet::Model::Scene::Plugin.new)
player = Garnet::Model::Player.new(asset)
player.play("idle", loop: true)
pilot = world.spawn(Garnet::Model::Scene::Animator.new(player), transform)
world.schedule.add(:update, name: "game.landing") do |w, _|
w.events(Garnet::Model::Scene::ClipFinished) { |event| land(event.entity) if event.clip.name == "jump" }
end
- The
"model.animate"system runs inPostUpdate(passphase:to change it). It advances every unpaused player by the frame delta and publishes the pose's local draws asScene::Components::Drawables3D. Scene extraction composes those draws with the entity and its ancestors. - Adding an
Animatorpublishes the current pose immediately. - When a one-shot clip finishes,
ClipFinished(entity, clip)is emitted once. - Change clips with
player.play(clip_or_name, loop:, fade: 140.milliseconds); hold withplayer.pause; jump withplayer.seek(time).
For manual sampling, call Garnet::Model::Scene.sync(actor, asset.pose(time, clip: clip)).
Binding.new(actor, player) with binding.install(schedule) still works but is deprecated: each binding needs its own registration. binding.preview(time) samples the active clip without moving the playhead.
Shared player contract
Spine instances, Lottie players, Effekseer instances and Model players share one playback shape:
| Method | Meaning |
|---|---|
advance(delta : Time::Span) |
Moves the playhead unless paused. Float32 seconds overloads are deprecated. |
paused?, pause, resume |
Every player starts unpaused. |
seek(time : Time::Span) |
Moves the playhead without reporting events. |
play(name, loop: false) |
Plays once unless loop: true (Spine and Model clips). |
Durations such as Spine mixes and queue delays and Model fades are also Time::Span.
Repository
model-scene
Owner
Statistic
- 0
- 0
- 0
- 1
- 2
- 2 days ago
- November 30, 2026
License
MIT License
Links
Synced at
Thu, 03 Dec 2026 02:11:01 GMT
Languages