Browse Source

Change rotationMin/Max type to Vector3

Takahiro 7 years ago
parent
commit
5165c047a5
2 changed files with 20 additions and 12 deletions
  1. 2 3
      examples/js/animation/CCDIKSolver.js
  2. 18 9
      examples/js/loaders/MMDLoader.js

+ 2 - 3
examples/js/animation/CCDIKSolver.js

@@ -56,7 +56,6 @@ THREE.CCDIKSolver = ( function () {
 			var linkScale = new THREE.Vector3();
 			var axis = new THREE.Vector3();
 			var vector = new THREE.Vector3();
-			var vector2 = new THREE.Vector3();
 
 			return function update() {
 
@@ -166,7 +165,7 @@ THREE.CCDIKSolver = ( function () {
 								link.rotation.setFromVector3(
 									link.rotation
 										.toVector3( vector )
-										.max( vector2.fromArray( rotationMin ) ) );
+										.max( rotationMin ) );
 
 							}
 
@@ -175,7 +174,7 @@ THREE.CCDIKSolver = ( function () {
 								link.rotation.setFromVector3(
 									link.rotation
 										.toVector3( vector )
-										.min( vector2.fromArray( rotationMax ) ) );
+										.min( rotationMax ) );
 
 							}
 

+ 18 - 9
examples/js/loaders/MMDLoader.js

@@ -576,15 +576,24 @@ THREE.MMDLoader = ( function () {
 
 						if ( ik.links[ j ].angleLimitation === 1 ) {
 
-							link.rotationMin = ik.links[ j ].lowerLimitationAngle;
-							link.rotationMax = ik.links[ j ].upperLimitationAngle;
-
-							var tmp1 = - link.rotationMax[ 0 ];
-							var tmp2 = - link.rotationMax[ 1 ];
-							link.rotationMax[ 0 ] = - link.rotationMin[ 0 ];
-							link.rotationMax[ 1 ] = - link.rotationMin[ 1 ];
-							link.rotationMin[ 0 ] = tmp1;
-							link.rotationMin[ 1 ] = tmp2;
+							// Revert if rotationMin/Max doesn't work well
+							// link.limitation = new THREE.Vector3( 1.0, 0.0, 0.0 );
+
+							var rotationMin = ik.links[ j ].lowerLimitationAngle;
+							var rotationMax = ik.links[ j ].upperLimitationAngle;
+
+							// Convert Left to Right coordinate by myself because
+							// MMDParser doesn't convert. It's a MMDParser's bug
+
+							var tmp1 = - rotationMax[ 0 ];
+							var tmp2 = - rotationMax[ 1 ];
+							rotationMax[ 0 ] = - rotationMin[ 0 ];
+							rotationMax[ 1 ] = - rotationMin[ 1 ];
+							rotationMin[ 0 ] = tmp1;
+							rotationMin[ 1 ] = tmp2;
+
+							link.rotationMin = new THREE.Vector3().fromArray( rotationMin );
+							link.rotationMax = new THREE.Vector3().fromArray( rotationMax );
 
 						}