浏览代码

Merge pull request #6703 from TatumCreative/SkinnedMesh-calculate-inverses

SkinnedMesh.bind calculates the skeleton inverses
Mr.doob 10 年之前
父节点
当前提交
d2fb8f231c

+ 0 - 3
docs/api/objects/SkinnedMesh.html

@@ -43,9 +43,6 @@
 		// Bind the skeleton to the mesh
 		mesh.bind( armSkeleton );
 		
-		// Update the inverse matrices in the skeleton to reflect the newly bound skeleton
-		armSkeleton.calculateInverses();
-		
 		// Move the bones and manipulate the model
 		armSkeleton.bones[ 0 ].rotation.x = -0.1;
 		armSkeleton.bones[ 1 ].rotation.x = 0.2;

+ 0 - 1
docs/scenes/bones-browser.html

@@ -159,7 +159,6 @@
 				mesh.add( bones[ 0 ] );
 	
 				mesh.bind( skeleton );
-				skeleton.calculateInverses();
 
 				skeletonHelper = new THREE.SkeletonHelper( mesh );
 				skeletonHelper.material.linewidth = 2;

+ 1 - 1
examples/js/loaders/gltf/glTFLoader.js

@@ -1209,7 +1209,7 @@ THREE.glTFLoader.prototype.load = function( url, callback ) {
 								}
 							}
 
-							threeMesh.bind(new THREE.Skeleton(bones, boneInverses, false));
+							threeMesh.bind( new THREE.Skeleton( bones, boneInverses, false ), threeMesh.matrixWorld );
 						}
 
 						if (threeMesh) {

+ 3 - 1
src/objects/SkinnedMesh.js

@@ -60,7 +60,7 @@ THREE.SkinnedMesh = function ( geometry, material, useVertexTexture ) {
 	this.normalizeSkinWeights();
 
 	this.updateMatrixWorld( true );
-	this.bind( new THREE.Skeleton( bones, undefined, useVertexTexture ) );
+	this.bind( new THREE.Skeleton( bones, undefined, useVertexTexture ), this.matrixWorld );
 
 };
 
@@ -75,6 +75,8 @@ THREE.SkinnedMesh.prototype.bind = function( skeleton, bindMatrix ) {
 	if ( bindMatrix === undefined ) {
 
 		this.updateMatrixWorld( true );
+		
+		this.skeleton.calculateInverses();
 
 		bindMatrix = this.matrixWorld;