|
@@ -34,19 +34,20 @@
|
|
}
|
|
}
|
|
|
|
|
|
var mesh = THREE.SkinnedMesh( geometry, material );
|
|
var mesh = THREE.SkinnedMesh( geometry, material );
|
|
-
|
|
|
|
|
|
+
|
|
// See example from THREE.Skeleton for the armSkeleton
|
|
// 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 );
|
|
mesh.bind( armSkeleton );
|
|
|
|
|
|
- // Add the root bone, then recalculate the skeleton inverses
|
|
|
|
- mesh.add( armSkeleton.bones[0] );
|
|
|
|
- mesh.updateMatrixWorld( true ); // ensure the bones matrices are already recomputed
|
|
|
|
|
|
+ // Update the inverse matrices in the skeleton to reflect the newly bound skeleton
|
|
skeleton.calculateInverses();
|
|
skeleton.calculateInverses();
|
|
|
|
|
|
// Move the bones and manipulate the model
|
|
// Move the bones and manipulate the model
|
|
armSkeleton.bones[0].rotation.x = -0.1;
|
|
armSkeleton.bones[0].rotation.x = -0.1;
|
|
armSkeleton.bones[1].rotation.x = 0.2;
|
|
armSkeleton.bones[1].rotation.x = 0.2;
|
|
-
|
|
|
|
</code>
|
|
</code>
|
|
|
|
|
|
|
|
|
|
@@ -55,8 +56,8 @@
|
|
|
|
|
|
<h3>[name]([page:Geometry geometry], [page:Material material], [page:boolean useVertexTexture])</h3>
|
|
<h3>[name]([page:Geometry geometry], [page:Material material], [page:boolean useVertexTexture])</h3>
|
|
<div>
|
|
<div>
|
|
- geometry —- An instance of [page:Geometry]. [page:Geometry.skinIndices] and [page:Geometry.skinWeights] should be set.<br />
|
|
|
|
- material —- An instance of [page:Material] (optional).<br />
|
|
|
|
|
|
+ geometry — An instance of [page:Geometry]. [page:Geometry.skinIndices] and [page:Geometry.skinWeights] should be set.<br />
|
|
|
|
+ material — An instance of [page:Material] (optional).<br />
|
|
useVertexTexture -- Defines whether a vertex texture can be used (optional).
|
|
useVertexTexture -- Defines whether a vertex texture can be used (optional).
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -64,7 +65,6 @@
|
|
<h2>Properties</h2>
|
|
<h2>Properties</h2>
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
<h3>[property:array bones]</h3>
|
|
<h3>[property:array bones]</h3>
|
|
<div>
|
|
<div>
|
|
This contains the array of bones for this mesh. These should be set in the constructor.
|
|
This contains the array of bones for this mesh. These should be set in the constructor.
|
|
@@ -85,19 +85,50 @@
|
|
This array of matrices contains the matrices of the bones. These get calculated in the constructor.
|
|
This array of matrices contains the matrices of the bones. These get calculated in the constructor.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
+ <h3>[property:string bindMode]</h3>
|
|
|
|
+ <div>
|
|
|
|
+ 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.
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <h3>[property:Matrix4 inverseBindMatrix]</h3>
|
|
|
|
+ <div>
|
|
|
|
+ The inverse of the bindMatrix.
|
|
|
|
+ </div>
|
|
|
|
+
|
|
<h2>Methods</h2>
|
|
<h2>Methods</h2>
|
|
|
|
|
|
|
|
+ <h3>[method:null bind]([page:Skeleton skeleton], [page:Matrix4 bindMatrix])</h3>
|
|
|
|
+ <div>
|
|
|
|
+ skeleton — [page:Skeleton]<br/>
|
|
|
|
+ bindMatrix — [page:Matrix4] that represents the base transform of the skeleton
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
|
|
+ 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].
|
|
|
|
+ </div>
|
|
|
|
+
|
|
<h3>[method:null pose]()</h3>
|
|
<h3>[method:null pose]()</h3>
|
|
<div>
|
|
<div>
|
|
- This method sets the skinnedmesh in the rest pose.
|
|
|
|
|
|
+ This method sets the skinned mesh in the rest pose.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h3>[method:Bone addBone]([page:Bone bone])</h3>
|
|
<h3>[method:Bone addBone]([page:Bone bone])</h3>
|
|
<div>
|
|
<div>
|
|
- bone -- This is the bone that needs to be added. (optional)
|
|
|
|
|
|
+ bone — This is the bone that needs to be added. (optional)
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div>
|
|
- This method adds the bone to the skinnedmesh when it is provided. It creates a new bone and adds that when no bone is given.
|
|
|
|
|
|
+ This method adds the bone to the skinned mesh when it is provided. It creates a new bone and adds that when no bone is given.
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h2>Source</h2>
|
|
<h2>Source</h2>
|