Una mesh che ha uno [page:Skeleton scheletro] con [page:Bone ossa] che può essere utilizzata per animare i vertici della geometria.
const geometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
// crea manualmente gli indici della pelle e i pesi della pelle
// (tipicamente un loader leggerebbe questi dati da un modello 3D per te)
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 );
// calcola skinIndex e skinWeight in base ad alcuni dati di configurazione
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 ) );
// crea skinned mesh e skeleton
const mesh = new THREE.SkinnedMesh( geometry, material );
const skeleton = new THREE.Skeleton( bones );
// vedi esempio da THREE.Skeleton
const rootBone = skeleton.bones[ 0 ];
mesh.add( rootBone );
// lega lo scheletro alla mesh
mesh.bind( skeleton );
// muove le ossa e manipola il modello
skeleton.bones[ 0 ].rotation.x = -0.1;
skeleton.bones[ 1 ].rotation.x = 0.2;
[page:BufferGeometry geometry] - un'istanza di [page:BufferGeometry].
[page:Material material] - (opzionale) un'istanza di [page:Material]. Il valore predefinito è un nuovo [page:MeshBasicMaterial].
Vedi la classe base [page:Mesh] per le proprietà comuni.
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`.
La matrice di base che viene utilizzata per le trasformazioni ossee vincolate.
La matrice di base che viene utilizzata per reimpostare le trasformazioni ossee vincolate.
Bounding box per la [name], che può essere calcolato con [page:.computeBoundingBox](). Il valore predefinito è `null`.
Bounding sphere per la [name], che può essere calcolato con [page:.computeBoundingSphere](). Il valore predefinito è `null`.
Flag di sola lettura per verificare se l'oggetto dato è di tipo [name].
[page:Skeleton] che rappresenta la gerarchia ossea della skinned mesh.
Vedi la classe base [page:Mesh] per i metodi comuni.
[page:Skeleton skeleton] - [page:Skeleton] creato da un albero di [page:Bone Bones].
[page:Matrix4 bindMatrix] - [page:Matrix4] che rappresenta la trasformazione base dello scheletro.
Lega uno scheletro alla skinned mesh. Il bindMatrix viene salvato nella proprietà .bindMatrix
e il .bindMatrixInverse viene calcolato.
Questo metodo attualmente non clona correttamente un'istanza di [name]. Si prega di utilizzare [page:SkeletonUtils.clone]() nel frattempo.
Computes the bounding box, updating [page:.boundingBox] attribute.
Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
If an instance of [name] is animated, this method should be called per frame to compute a correct bounding box.
Computes the bounding sphere, updating [page:.boundingSphere] attribute.
Bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
If an instance of [name] is animated, this method should be called per frame to compute a correct bounding sphere.
Normalizza i pesi della skin.
Questo metodo imposta la skinned mesh nella posa di riposo (reimposta la posa).
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]