Explorar o código

CCDIKSolver rotationMin/Max support

Takahiro %!s(int64=7) %!d(string=hai) anos
pai
achega
d19a0fd742
Modificáronse 1 ficheiros con 22 adicións e 0 borrados
  1. 22 0
      examples/js/animation/CCDIKSolver.js

+ 22 - 0
examples/js/animation/CCDIKSolver.js

@@ -55,6 +55,8 @@ THREE.CCDIKSolver = ( function () {
 			var invLinkQ = new THREE.Quaternion();
 			var invLinkQ = new THREE.Quaternion();
 			var linkScale = new THREE.Vector3();
 			var linkScale = new THREE.Vector3();
 			var axis = new THREE.Vector3();
 			var axis = new THREE.Vector3();
+			var vector = new THREE.Vector3();
+			var vector2 = new THREE.Vector3();
 
 
 			return function update() {
 			return function update() {
 
 
@@ -90,6 +92,8 @@ THREE.CCDIKSolver = ( function () {
 							if ( links[ k ].enabled === false ) break;
 							if ( links[ k ].enabled === false ) break;
 
 
 							var limitation = links[ k ].limitation;
 							var limitation = links[ k ].limitation;
+							var rotationMin = links[ k ].rotationMin;
+							var rotationMax = links[ k ].rotationMax;
 
 
 							// don't use getWorldPosition/Quaternion() here for the performance
 							// don't use getWorldPosition/Quaternion() here for the performance
 							// because they call updateMatrixWorld( true ) inside.
 							// because they call updateMatrixWorld( true ) inside.
@@ -157,6 +161,24 @@ THREE.CCDIKSolver = ( function () {
 
 
 							}
 							}
 
 
+							if ( rotationMin !== undefined ) {
+
+								link.rotation.setFromVector3(
+									link.rotation
+										.toVector3( vector )
+										.max( vector2.fromArray( rotationMin ) ) );
+
+							}
+
+							if ( rotationMax !== undefined ) {
+
+								link.rotation.setFromVector3(
+									link.rotation
+										.toVector3( vector )
+										.min( vector2.fromArray( rotationMax ) ) );
+
+							}
+
 							link.updateMatrixWorld( true );
 							link.updateMatrixWorld( true );
 
 
 							rotated = true;
 							rotated = true;