model
Garnet Model
require "garnet-model" provides renderer-independent mesh assets, node hierarchies, skins, and clips. Build a procedural asset with Model::Builder or supply geometry to Mesh3D directly. Model::Geometry builds a centered unit box with per-face UVs and normals, lofts, tubes, sweeps and surfaces of revolution. Sweep frames are parallel transported. Optional end caps are intended for planar convex profiles. Repeated placements share their original mesh streams.
Sample a model with asset.pose(time, clip: clip, loop: true). A pose exposes draws and joint_matrix(node_index) for attachments. Use pose.draws(mesh_names: Set{"hat", "coat"}) to select named parts while gathering a consistent skeleton. Draws carry shared skin binding streams and the instance's palette. CPU skinning is available via gpu_skinning: false and is used for rigs above the shared GPU palette limit.
Publish these draws through Scene::Components::Drawables3D to use the same World hierarchy, projection and material system as procedural shapes.
Clips can use step, linear and cubic channels for transforms and morph weights. pose.blend(other, amount) blends local transforms and morph weights before constructing the joint palette.
Pass a Math::Transform3D to Builder#group or Builder#place for nodes targeted by translation, rotation or scale channels. Matrix placements support static geometry and affine composition.
Use Player to give each model instance its own clock and transitions. asset.instantiate creates one, matching instantiate on Spine, Effekseer and Lottie assets.
player = asset.instantiate
player.play(idle, loop: true)
player.advance(frame_delta)
player.play(walk, loop: true, fade: 180.milliseconds)
player.advance(frame_delta)
entity << Garnet::Scene::Components::Drawables3D.new(player.pose.draws)
A new fade starts at the visible pose, including when it interrupts a running fade. Games supply the frame delta and choose when to play each clip. One-shot playback clamps at the last key, and finished? accounts for a fade that is still in progress. Use asset.bind_clip(clip, from: source_asset) to remap tracks between compatible rigs by unique node name. Supply nodes: with explicit source-to-target indices where names differ.
For manual publication and scheduled ECS playback, see the optional model scene adapter.
model
- 0
- 0
- 0
- 2
- 2
- 2 days ago
- November 30, 2026
MIT License
Wed, 02 Dec 2026 13:44:46 GMT