pub struct SkinnedMesh {Show 17 fields
pub asset_id: AssetId,
pub source: String,
pub skin_index: u32,
pub vertices: Vec<SkinnedVertexData>,
pub indices: Vec<u16>,
pub morph_target_names: Vec<String>,
pub morph_deltas: Vec<MorphDelta>,
pub material: Option<MaterialHandle>,
pub texture: Option<TextureHandle>,
pub position: [f32; 3],
pub rotation_deg: [f32; 3],
pub scale: [f32; 3],
pub lod_levels: u32,
pub lod_distances: Vec<f32>,
pub max_instances: u32,
pub capsule: Option<CharacterCapsule>,
pub locator: Option<PayloadLocator>,
}Expand description
A skeletally animated mesh placed directly in the world.
Unlike a Mesh, a SkinnedMesh carries its own world transform and a
skeleton (a joint hierarchy with a bind pose). Each vertex is bound to up
to four joints; an Animation targeting this mesh deforms it at
runtime. With no animation the mesh renders in its bind pose.
The geometry + skeleton may be authored inline (vertices / indices /
skeleton) or imported with source from a glTF (.glb / .gltf) or
binary .fbx file. The import fills the mesh, the skeleton bind pose,
and (for glTF) any morph targets; animations are imported separately by
Animation assets referencing the same file.
The customize_character example ships a neutral unclothed body
(base_humanoid.glb, about 21k vertices, A-pose bind) with a 25-joint
skeleton (root, hips, spine, chest,
upper_chest, neck, head, and clavicle / upper_arm / forearm /
hand / thumb / thigh / shin / foot / toe with an _l / _r
suffix), the morph targets a CharacterShape slider set
names (weight+/-, muscle, shoulders+/-, hips+/-, chest+/-,
belly, head+/-, jaw+/-, nose+/-, brow, cheeks+/-,
chin+/-, eyes+/-, lips+/-, mouth_width+/-, ears+/-,
cheekbones+/-), and a rotation-only idle clip an Animation can import from
the same file; a CharacterModel is the usual way to
declare it.
The skeleton (joint hierarchy and bind pose) is provided as an arg
(authored inline alongside vertices/indices, or filled in from the
imported .glb) and is baked into the mesh at build time.
Normals and tangents are computed automatically at build time. Do not supply them.
SkinnedMesh {
position: [0.0, 1.0, 0.0],
..Default::default()
};Fields§
§asset_id: AssetIdAsset identity; injected via inject_name. Not part of args.
source: StringOptional path to a .glb / .gltf / .fbx file. When set, the
build imports vertices / indices / skeleton from it; an
inline-authored mesh leaves this empty.
skin_index: u32Which skinned mesh of source to import, in file declaration order
(default 0). A character split into several meshes bound to one
skeleton (body, hair, clothes) needs one SkinnedMesh per part, each
naming its own index.
vertices: Vec<SkinnedVertexData>Skinned vertex list.
indices: Vec<u16>Triangle index list.
morph_target_names: Vec<String>Morph-target names, one per target, in target order. Filled from the source file’s target names when importing; empty for a mesh without morph targets.
morph_deltas: Vec<MorphDelta>Dense morph-target deltas, target-major: entry t * vertex_count + v
is target t’s delta for vertex v. Length must be
morph_target_names.len() * vertices.len(). An Animation
with a morph_track drives the per-target weights at runtime.
material: Option<MaterialHandle>Material; provides the albedo texture plus lighting parameters.
texture: Option<TextureHandle>Texture (older path); ignored when material is set.
position: [f32; 3]World-space position.
rotation_deg: [f32; 3]World rotation, Euler degrees [pitch, yaw, roll], YXZ order.
scale: [f32; 3]World scale.
lod_levels: u32Number of level-of-detail versions to generate, including the original.
1 (the default) generates none; values are clamped to [1, 8].
lod_distances: Vec<f32>Camera distances at which to switch to each lower-detail version. When
non-empty, must have exactly lod_levels - 1 entries; empty lets the
build choose defaults.
max_instances: u32How many runtime copies of this mesh may exist at once beyond the
authored one. 0 (the default) means the mesh is not runtime-spawnable.
A non-zero value pre-reserves that many extra instance slots at load: the
engine appends that many hidden bind-pose copies to the skinned geometry
so a runtime spawn can claim one without growing any GPU buffer, and a
despawn returns it to the pool. Spawns past the reserve are dropped (a
warning is logged). Capped at 4096.
capsule: Option<CharacterCapsule>Optional character capsule. When set, the mesh collides with the
scene as a kinematic character and is moved by the root motion of its
Animation clips (those with root_motion set): the
capsule slides along obstacles and settles under gravity, and the
rendered mesh follows it. The capsule stands on the mesh origin (its
feet), centred half_height + radius above it.
locator: Option<PayloadLocator>Injected at load time from the compiled blob payload.
Trait Implementations§
Source§impl Clone for SkinnedMesh
impl Clone for SkinnedMesh
Source§fn clone(&self) -> SkinnedMesh
fn clone(&self) -> SkinnedMesh
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more