A mesh that has a [page:Skeleton] with [page:Bone bones] that can then be used to animate the vertices of the geometry. The material must support skinning and have skinning enabled - see [page:MeshStandardMaterial.skinning].
var geometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
//Create the skin indices and skin weights
for ( var i = 0; i < geometry.vertices.length; i ++ ) {
// Imaginary functions to calculate the indices and weights
// This part will need to be changed depending your skeleton and model
var skinIndex = calculateSkinIndex( geometry.vertices, i );
var skinWeight = calculateSkinWeight( geometry.vertices, i );
// Ease between each bone
geometry.skinIndices.push( new THREE.Vector4( skinIndex, skinIndex + 1, 0, 0 ) );
geometry.skinWeights.push( new THREE.Vector4( 1 - skinWeight, skinWeight, 0, 0 ) );
}
var mesh = new THREE.SkinnedMesh( geometry, material );
// See example from THREE.Skeleton for the armSkeleton
var rootBone = armSkeleton.bones[ 0 ];
mesh.add( rootBone );
// Bind the skeleton to the mesh
mesh.bind( armSkeleton );
// Move the bones and manipulate the model
armSkeleton.bones[ 0 ].rotation.x = -0.1;
armSkeleton.bones[ 1 ].rotation.x = 0.2;
[page:Geometry geometry] - an instance of [page:Geometry] or [page:BufferGeometry] (recommended).
[page:Geometry.skinIndices skinIndices] and [page:Geometry.skinWeights skinWeights] should be set to true on the geometry.
[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 "attached" or "detached". "attached" uses the [page:SkinnedMesh.matrixWorld] property for the base transform matrix of the bones. "detached" uses the [page:SkinnedMesh.bindMatrix]. Default is "attached".
The base matrix that is used for the bound bone transforms.
The base matrix that is used for resetting the bound bone transforms.
Used to check whether this or derived classes are skinned meshes. Default is *true*.
You should not change this, as it used internally for optimisation.
[page:Skeleton] created from the [page:Geometry.bones bones] of the [page:Geometry] passed in the constructor.
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 is called automatically in the constructor, and the skeleton
is created from the [page:Geometry.bones bones] of the [page:Geometry] passed in the
constructor.
Returns a clone of this SkinnedMesh object and any descendants.
Normalizes the [page:Geometry.skinWeights] vectors. Does not affect [page:BufferGeometry].
This method sets the skinned mesh in the rest pose (resets the pose).
Updates the [page:Matrix4 MatrixWorld].
Creates an array of hierarchical [page:Bone bones] objects from the internal geometry.