Capítulo 772 de 859
Class for representing the armatures in three.js. The skeleton is defined by a hierarchy of bones.
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 , elbow, hand);
shoulder.position.y = -5;
elbow.position.y = 0;
hand.position.y = 5;
const armSkeleton = new THREE.Skeleton( bones );
Constructor
| Signature |
|---|
new Skeleton( bones : Array.<Bone>, boneInverses : Array.<Matrix4> ) |
Properties
| Property | Description |
|---|---|
.boneInverses : Array.<Matrix4> | An array of bone inverse matrices. |
.boneMatrices : Float32Array | An array buffer holding the bone data. Input data for Skeleton#boneTexture. |
.boneTexture : DataTexture | A texture holding the bone data for use in the vertex shader. |
.bones : Array.<Bone> | An array of bones defining the skeleton. |
Methods
| Method | Description |
|---|---|
.calculateInverses() | Computes the bone inverse matrices. This method resets Skeleton#boneInverses and fills it with new matrices. |
.clone() : Skeleton | Returns a new skeleton with copied values from this instance. |
.computeBoneTexture() : Skeleton | Computes a data texture for passing bone data to the vertex shader. |
.dispose() | Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app. |
.fromJSON( json : Object, bones : Object.<string, Bone> ) : Skeleton | Setups the skeleton by the given JSON and bones. |
| `.getBoneByName( name : string ) : Bone | undefined` |
.init() | Initializes the skeleton. This method gets automatically called by the constructor but depending on how the skeleton is created it might be necessary to call this method manually. |
.pose() | Resets the skeleton to the base pose. |
.toJSON() : Object | Serializes the skeleton into JSON. |
.update() | Resets the skeleton to the base pose. |