A mesh that has a [page:Skeleton] with [page:Bone bones] that can then be used to animate the vertices of the geometry.
const geometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
// create the skin indices and skin weights manually
// (typically a loader would read this data from a 3D model for you)
const position = geometry.attributes.position;
const vertex = new THREE.Vector3();
const skinIndices = [];
const skinWeights = [];
for ( let i = 0; i < position.count; i ++ ) {
vertex.fromBufferAttribute( position, i );
// compute skinIndex and skinWeight based on some configuration data
const y = ( vertex.y + sizing.halfHeight );
const skinIndex = Math.floor( y / sizing.segmentHeight );
const skinWeight = ( y % sizing.segmentHeight ) / sizing.segmentHeight;
skinIndices.push( skinIndex, skinIndex + 1, 0, 0 );
skinWeights.push( 1 - skinWeight, skinWeight, 0, 0 );
}
geometry.setAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( skinIndices, 4 ) );
geometry.setAttribute( 'skinWeight', new THREE.Float32BufferAttribute( skinWeights, 4 ) );
// create skinned mesh and skeleton
const mesh = new THREE.SkinnedMesh( geometry, material );
const skeleton = new THREE.Skeleton( bones );
// see example from THREE.Skeleton
const rootBone = skeleton.bones[ 0 ];
mesh.add( rootBone );
// bind the skeleton to the mesh
mesh.bind( skeleton );
// move the bones and manipulate the model
skeleton.bones[ 0 ].rotation.x = -0.1;
skeleton.bones[ 1 ].rotation.x = 0.2;
[page:BufferGeometry geometry] - an instance of [page:BufferGeometry].
[page:Material material] - (optional) an instance of [page:Material].
Default is a new [page:MeshBasicMaterial].
See the base [page:Mesh] class for common properties.
Either `AttachedBindMode` or `DetachedBindMode`. `AttachedBindMode` means the skinned mesh shares the same world space as the skeleton. This is not true when using `DetachedBindMode` which is useful when sharing a skeleton across multiple skinned meshes. Default is `AttachedBindMode`.
The base matrix that is used for the bound bone transforms.
The base matrix that is used for resetting the bound bone transforms.
The bounding box of the [name]. Can be calculated with [page:.computeBoundingBox](). Default is `null`.
The bounding sphere of the [name]. Can be calculated with [page:.computeBoundingSphere](). Default is `null`.
Read-only flag to check if a given object is of type [name].
[page:Skeleton] representing the bone hierarchy of the skinned mesh.
See the base [page:Mesh] class for common methods.
[page:Skeleton skeleton] - [page:Skeleton] created from a [page:Bone Bones] tree.
[page:Matrix4 bindMatrix] - [page:Matrix4] that represents the base
transform of the skeleton.
Bind a skeleton to the skinned mesh. The bindMatrix gets saved to
.bindMatrix property and the .bindMatrixInverse gets calculated.
This method does currently not clone an instance of [name] correctly. Please use [page:SkeletonUtils.clone]() in the meanwhile.
Computes the bounding box of the skinned mesh, and updates the [page:.boundingBox] attribute. The bounding box is not computed by the engine; it must be computed by your app. If the skinned mesh is animated, the bounding box should be recomputed per frame.
Computes the bounding sphere of the skinned mesh, and updates the [page:.boundingSphere] attribute. The bounding sphere is automatically computed by the engine when it is needed, e.g., for ray casting and view frustum culling. If the skinned mesh is animated, the bounding sphere should be recomputed per frame.
Normalizes the skin weights.
This method sets the skinned mesh in the rest pose (resets the pose).
Applies the bone transform associated with the given index to the given position vector. Returns the updated vector.
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]