Skip to main content

spawn_skinned_from_template

Function spawn_skinned_from_template 

Source
pub fn spawn_skinned_from_template(
    ctx: &mut PipelineContext<'_>,
    template: Entity,
    name: Option<AssetId>,
    transform: Transform,
    lifetime: Option<f32>,
    acquire_slot: impl FnMut(usize, [[f32; 4]; 4]) -> Option<usize>,
) -> Option<Entity>
Expand description

Instantiate a runtime copy of a skinned template (a SkinnedMesh’s SkeletonPose entity) at transform.

Unlike the static path, a skinned instance is not a cloned draw slot: it claims one of the template’s pre-reserved hidden bind-pose copies through acquire_slot, which reveals it and returns its skinned index. The new entity carries its own SkeletonPose (so an animation system drives it, keyed on the shared mesh id, in lockstep with the template), a Transform (so the per-frame model push can move it), and an optional Lifetime. When name is Some the instance is registered so it can be addressed (e.g. despawned) by name. Returns the new entity, or None when the template is not skinned or its instance pool is exhausted.