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: MeshThe Mesh it extends: geometry and material.
skeleton: Option<Rc<RefCell<Skeleton>>>SkinnedMesh.skeleton.
bind_mode: BindModeSkinnedMesh.bindMode.
bind_matrix: Matrix4SkinnedMesh.bindMatrix.
bind_matrix_inverse: Matrix4SkinnedMesh.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
impl SkinnedMesh
Sourcepub fn new(
geometry: Rc<BufferGeometry>,
material: impl Into<Option<MeshBasicNodeMaterial>>,
) -> ObjectRef
pub fn new( geometry: Rc<BufferGeometry>, material: impl Into<Option<MeshBasicNodeMaterial>>, ) -> ObjectRef
new SkinnedMesh( geometry, material ), as a scene-graph ObjectRef.
Sourcepub fn of(
geometry: Rc<BufferGeometry>,
material: Option<MeshBasicNodeMaterial>,
) -> Self
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.
Sourcepub fn geometry(&self) -> &Rc<BufferGeometry>
pub fn geometry(&self) -> &Rc<BufferGeometry>
SkinnedMesh.geometry.
Sourcepub fn bind(
node: &ObjectRef,
skeleton: Rc<RefCell<Skeleton>>,
bind_matrix: Option<Matrix4>,
)
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.
Sourcepub fn normalize_skin_weights(&mut self)
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).
Sourcepub fn apply_bone_transform(&self, index: usize, vector: &mut Vector3)
pub fn apply_bone_transform(&self, index: usize, vector: &mut Vector3)
SkinnedMesh.applyBoneTransform( index, vector ).
Sourcepub fn compute_bounding_box(&mut self)
pub fn compute_bounding_box(&mut self)
SkinnedMesh.computeBoundingBox().
Sourcepub fn compute_bounding_sphere(&mut self)
pub fn compute_bounding_sphere(&mut self)
SkinnedMesh.computeBoundingSphere().
Sourcepub fn get_vertex_position(&self, index: usize) -> Vector3
pub fn get_vertex_position(&self, index: usize) -> Vector3
SkinnedMesh.getVertexPosition( index, target ) — Mesh’s morphed
position, then applyBoneTransform().
Sourcepub fn raycast(
&mut self,
matrix_world: &Matrix4,
object: &ObjectRef,
raycaster: &Raycaster,
intersects: &mut Vec<Intersection>,
)
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.