Skip to main content

Skeleton

Use an array of bones to create a skeleton that can be used by a SkinnedMesh.

Code Example

// Create a simple "arm" const bones = []; const shoulder = new THREE.Bone();
const elbow = new THREE.Bone(); const hand = new THREE.Bone(); shoulder.add(
elbow ); elbow.add( hand ); bones.push( shoulder ); bones.push( elbow );
bones.push( hand ); shoulder.position.y = -5; elbow.position.y = 0;
hand.position.y = 5; const armSkeleton = new THREE.Skeleton( bones );

See the SkinnedMesh page for an example of usage with standard BufferGeometry.

Constructor

Skeleton

function Skeleton( bones: Array, boneInverses: Array ): void;  

bones - The array of bones. Default is an empty array.
boneInverses - (optional) An array of Matrix4s.

Creates a new Skeleton.

Properties

bones

bones: Array;  

The array of bones. Note this is a copy of the original array, not a reference, so you can modify the original array without effecting this one.

boneInverses

boneInverses: Array;  

An array of Matrix4s that represent the inverse of the matrixWorld of the individual bones.

boneMatrices

boneMatrices: Float32Array;  

The array buffer holding the bone data when using a vertex texture.

boneTexture

boneTexture: DataTexture;  

The DataTexture holding the bone data when using a vertex texture.

boneTextureSize

boneTextureSize: Integer;  

The size of the .boneTexture.

Methods

clone

function clone( ): Skeleton;  

Returns a clone of this Skeleton object.

calculateInverses

function calculateInverses( ): undefined;  

Generates the .boneInverses array if not provided in the constructor.

computeBoneTexture

function computeBoneTexture( ): this;  

Computes an instance of DataTexture in order to pass the bone data more efficiently to the shader. The texture is assigned to .boneTexture.

pose

function pose( ): undefined;  

Returns the skeleton to the base pose.

update

function update( ): undefined;  

Updates the boneMatrices and boneTexture after changing the bones. This is called automatically by the WebGLRenderer if the skeleton is used with a SkinnedMesh.

getBoneByName

function getBoneByName( name: String ): Bone;  

name -- String to match to the Bone's .name property.

Searches through the skeleton's bone array and returns the first with a matching name.

dispose

function dispose( ): undefined;  

Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.

Source

src/objects/Skeleton.js