lottie-scene

Lottie scene playback

Require garnet-lottie-scene and install the plugin. Each entity with a Composition plays its Lottie player.

world.add_plugin(Garnet::Lottie::Scene::Plugin.new)
cues = Garnet::Animation::EventTrack.new([Garnet::Animation::Marker.new(250.milliseconds, "pop")])
badge = world.spawn(Garnet::Lottie::Scene::Composition.new(document.instantiate(:loop), cues), transform)

world.schedule.add(:render, name: "game.badge_cues") do |w, _|
  w.events(Garnet::Lottie::Scene::MarkerReached) { |event| sparkle(event.entity) if event.name == "pop" }
end
  • The "lottie.animate" system runs in PostUpdate (pass phase: to change it). One system advances every unpaused player by the frame delta.
  • Adding a Composition publishes its current drawing as Graphics::Components::Picture. Later frames replace the Picture only when the sampled drawing changes, so paused or finished players cost no writes.
  • Crossed markers become MarkerReached(entity, marker) world events. Seeking emits no markers.
  • Pause, resume and seek through the player: player.pause, player.seek(500.milliseconds). Players start playing.

For a single sample without the plugin, call Garnet::Lottie::Scene.sync(actor, document.sample(time)).

Binding.new(actor, player) with binding.install(schedule) still works but is deprecated in favour of the plugin.

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

lottie-scene

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 2
  • about 1 hour ago
  • November 30, 2026
License

MIT License

Links
Synced at

Fri, 04 Dec 2026 02:22:16 GMT

Languages