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 v3d.Bone(); const elbow = new v3d.Bone(); const hand = new v3d.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 v3d.Skeleton(bones);

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

Constructor

Skeleton(bones : Array, boneInverses : Array)

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

Creates a new Skeleton.

Properties

.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 : Array

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

.boneMatrices : Float32Array

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

.boneTexture : DataTexture

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

.boneTextureSize : Integer

The size of the .boneTexture.

Methods

.clone () : Skeleton

Returns a clone of this Skeleton object.

.calculateInverses () : undefined

Generates the boneInverses array if not provided in the constructor.

.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 () : undefined

Returns the skeleton to the base pose.

.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 (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 () : undefined

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

Source

For more info on how to obtain the source code of this module see this page.