Skip to main content

SkinnedMesh

Struct SkinnedMesh 

Source
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: AssetId

Asset identity; injected via inject_name. Not part of args.

§source: String

Optional 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: u32

Which 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: u32

Number 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: u32

How 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

Source§

fn clone(&self) -> SkinnedMesh

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SkinnedMesh

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SkinnedMesh

Source§

fn default() -> SkinnedMesh

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SkinnedMesh

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<SkinnedMesh, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ResourceAsset for SkinnedMesh

Source§

impl Serialize for SkinnedMesh

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SkinnedMeshGeometry for SkinnedMesh

Source§

fn model_matrix(&self) -> [[f32; 4]; 4]

Column-major world matrix built from the mesh’s transform.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more