|
@@ -33,38 +33,38 @@
|
|
|
</script>
|
|
|
|
|
|
<h2>Example</h2>
|
|
|
-
|
|
|
+
|
|
|
<code>
|
|
|
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 ) );
|
|
|
-
|
|
|
+ geometry.skinWeights.push( new THREE.Vector4( 1 - skinWeight, skinWeight, 0, 0 ) );
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var mesh = 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;
|
|
|
</code>
|
|
|
-
|
|
|
+
|
|
|
<h2>Constructor</h2>
|
|
|
|
|
|
<h3>[name]( [page:Geometry geometry], [page:Material material], [page:boolean useVertexTexture] )</h3>
|
|
@@ -75,6 +75,7 @@
|
|
|
</div>
|
|
|
|
|
|
<h2>Properties</h2>
|
|
|
+ <div>See the base [page:Object3D] class for common properties.</div>
|
|
|
|
|
|
<h3>[property:array bones]</h3>
|
|
|
<div>
|
|
@@ -101,7 +102,7 @@
|
|
|
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].
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
<h3>[property:Matrix4 bindMatrix]</h3>
|
|
|
<div>
|
|
|
The base matrix that is used for the bound bone transforms.
|
|
@@ -113,6 +114,7 @@
|
|
|
</div>
|
|
|
|
|
|
<h2>Methods</h2>
|
|
|
+ <div>See the base [page:Object3D] class for common methods.</div>
|
|
|
|
|
|
<h3>[method:null bind]( [page:Skeleton skeleton], [page:Matrix4 bindMatrix] )</h3>
|
|
|
<div>
|
|
@@ -123,7 +125,7 @@
|
|
|
Bind a skeleton to the skinned mesh. The bindMatrix gets saved to .bindMatrix property and the .bindMatrixInverse
|
|
|
gets calculated.
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
<h3>[method:null normalizeSkinWeights]()</h3>
|
|
|
<div>
|
|
|
Normalizes the [page:Geometry.skinWeights] vectors. Does not affect [page:BufferGeometry].
|