Skip to main content

SkinnedMesh

Struct SkinnedMesh 

Source
pub struct SkinnedMesh {
    pub mesh: Mesh,
    pub skeleton: Option<Rc<RefCell<Skeleton>>>,
    pub bind_mode: BindMode,
    pub bind_matrix: Matrix4,
    pub bind_matrix_inverse: Matrix4,
    pub bounding_box: Option<Box3>,
    pub bounding_sphere: Option<Sphere>,
    pub morph_target_influences: Rc<RefCell<Vec<f64>>>,
    pub morph_target_dictionary: Vec<(String, usize)>,
}
Expand description

class SkinnedMesh extends Mesh.

The Mesh half is held rather than inherited, exactly as InstancedMesh holds it, and the whole struct is one node’s Payload — so the renderer’s tree walk finds a skinned mesh wherever it hangs, and the bones (which are ordinary nodes in the same tree) reach it through their shared Skeleton.

Fields§

§mesh: Mesh

The Mesh it extends: geometry and material.

§skeleton: Option<Rc<RefCell<Skeleton>>>

SkinnedMesh.skeleton.

§bind_mode: BindMode

SkinnedMesh.bindMode.

§bind_matrix: Matrix4

SkinnedMesh.bindMatrix.

§bind_matrix_inverse: Matrix4

SkinnedMesh.bindMatrixInverse.

In the default BindMode::Attached this is matrixWorld⁻¹, recomputed every frame by Object3D.updateMatrixWorld() — see SkinnedMesh::update_bind_matrix_inverse, which the tree walk calls for this payload the way three.js’ SkinnedMesh.updateMatrixWorld() override does. A stale or identity value here scales the skin by the node’s own scale and is silent.

§bounding_box: Option<Box3>

Mesh.boundingBox (SkinnedMesh.computeBoundingBox).

§bounding_sphere: Option<Sphere>

Mesh.boundingSphere (SkinnedMesh.computeBoundingSphere).

§morph_target_influences: Rc<RefCell<Vec<f64>>>

Mesh.morphTargetInfluences, which glTF morph animation writes into. Shared, because SceneResolver binds a .morphTargetInfluences track to it while the mesh is owned elsewhere.

§morph_target_dictionary: Vec<(String, usize)>

Mesh.morphTargetDictionary.

Implementations§

Source§

impl SkinnedMesh

Source

pub fn new( geometry: Rc<BufferGeometry>, material: impl Into<Option<MeshBasicNodeMaterial>>, ) -> ObjectRef

new SkinnedMesh( geometry, material ), as a scene-graph ObjectRef.

Source

pub fn of( geometry: Rc<BufferGeometry>, material: Option<MeshBasicNodeMaterial>, ) -> Self

The payload on its own, for a caller that already has the node — GLTFLoader, which builds the node from the glTF node definition first.

Source

pub fn geometry(&self) -> &Rc<BufferGeometry>

SkinnedMesh.geometry.

Source

pub fn bind( node: &ObjectRef, skeleton: Rc<RefCell<Skeleton>>, bind_matrix: Option<Matrix4>, )

SkinnedMesh.bind( skeleton, bindMatrix ) for a mesh that is already a node — the node is needed for three.js’ bindMatrix === undefined branch, which updates the world matrix and takes it.

Source

pub fn pose(&mut self)

SkinnedMesh.pose().

Source

pub fn normalize_skin_weights(&mut self)

SkinnedMesh.normalizeSkinWeights(). Mutates the geometry, so it takes the geometry out of the Rc (three.js mutates in place; an Rc shared with the renderer cannot be).

Source

pub fn apply_bone_transform(&self, index: usize, vector: &mut Vector3)

SkinnedMesh.applyBoneTransform( index, vector ).

Source

pub fn compute_bounding_box(&mut self)

SkinnedMesh.computeBoundingBox().

Source

pub fn compute_bounding_sphere(&mut self)

SkinnedMesh.computeBoundingSphere().

Source

pub fn get_vertex_position(&self, index: usize) -> Vector3

SkinnedMesh.getVertexPosition( index, target ) — Mesh’s morphed position, then applyBoneTransform().

Source

pub fn raycast( &mut self, matrix_world: &Matrix4, object: &ObjectRef, raycaster: &Raycaster, intersects: &mut Vec<Intersection>, )

SkinnedMesh.raycast( raycaster, intersects ) — Mesh.raycast() over the skinned mesh’s own bounds, which follow the bones, with a plain ray.intersectsSphere() test where Mesh checks near / far.

A missing material is three’s default MeshBasicMaterial, as for Mesh::raycast.

Trait Implementations§

Source§

impl Clone for SkinnedMesh

Source§

fn clone(&self) -> Self

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> 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, !>

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.