spine-scene

Persistent scene sockets for garnet-spine snapshots

garnet-spine-scene

Optional scene/ECS composition for garnet-spine. It inherits the linked runtime's license requirements. Game code owns the instance and clock; the bridge publishes a copied pose into an ordinary skeleton container and updates persistent socket children.

require "garnet-spine-scene"

alias SS = Garnet::Spine::Scene

world.add_plugin(SS::Plugin.new)

instance = asset.instantiate
instance.play("walk", loop: true)
hero = world.spawn(SS::Skeleton.new(instance, owned: true),
  Garnet::Scene::Components::Transform.new(x: 200_f32, y: 300_f32, scale_y: -1_f32))
weapon = world.spawn(SS::Socket.new("hand"), parent: hero) # or Socket.new("weapon-slot", :slot, offset)

world.schedule.add(:render, name: "game.footsteps") do |w, _|
  w.events(SS::AnimationEvent) { |event| play_step(event.entity) if event.name == "step" }
end

Plugin

  • Skeleton.new(instance, owned: false) drives one instance from an entity. With owned: true, removing the component or destroying the entity closes the instance (an observer). Remove the old component before replacing an owned instance.
  • The "spine.animate" system runs in PostUpdate (pass phase: to change it). One system advances every unpaused Skeleton by the frame delta, publishes its drawing and sockets, and emits an AnimationEvent(entity, event) per timeline event. 200 actors need 200 components, not 200 registrations.
  • Pause, resume and seek through the instance (instance.pause, instance.seek(250.milliseconds)). Paused instances are skipped; call plugin.publish(entity) to show a sought or procedurally edited pose.
  • Adding a Socket under a skeleton publishes it immediately.

Sockets and slots

Place socket entities directly under the skeleton container. Their descendants remain arbitrary scene entities. sync preserves identities, components and children; it does not generate an entity per attachment or bone. The container receives Graphics::Components::Picture. Each live socket receives the Scene::Components::Socket frame, the slot reserved for attachment bridges. The full matrix retains shear, reflections and nonuniform scale. Local composition is Placement * Pose * Socket * Affine * Transform, with the socket offset already included; ancestor world pose is applied once. Because physics writes Pose and sockets write Socket, a socket can also carry a physics body without either bridge overwriting the other. Authored socket Transform can position a weapon relative to its bone frame.

Unknown names reject a sync before any component updates. Dead socket children are ignored; a dead container is rejected. Removing a Socket leaves its last Scene::Components::Socket frame in place; remove that component as well to restore normal placement. Scene.sync(container, instance.snapshot) publishes a pose manually without the plugin. Socket visibility follows ordinary scene visibility, not slot attachment visibility. Slot colors/order are not inherited by socket children. Use normal scene Z/layering for game-owned attachments. Sync is synchronous, belongs to the scene owner, and must happen outside hierarchy iteration/render extraction.

Build the resizable GLFW example with scripts/check-composition example-spine. Run ${TMPDIR:-/tmp}/garnet-spine-sockets; GARNET_SPINE_SMOKE=1 requests 16 deterministic frames. It uses authored fixtures and white texture data, so it needs no asset download or image decoder. The native smoke presented all 16 frames and emitted the authored event; all 219 workspace unit examples and 56 integration examples on each of GL/GLES, Metal and Vulkan pass. See the standalone README for the supported profile and explicit feature limits.

Earlier per-entity binding

Binding.new(actor, instance) and binding.install(schedule) still work but are deprecated: each binding needs its own schedule registration. advance takes a Time::Span; the Float32 overload is deprecated. Spine instances now play once unless play(name, loop: true), matching the other players.

Repository

spine-scene

Owner
Statistic
  • 0
  • 0
  • 0
  • 1
  • 5
  • 1 day ago
  • November 30, 2026
License

Other

Links
Synced at

Wed, 02 Dec 2026 02:09:16 GMT

Languages