Browse Source

improved Matrix4 type checking on Euler, Matrix3 and Quaternion for ambiguous cases.

Ben Houston 10 years ago
parent
commit
448326bb40
3 changed files with 6 additions and 1 deletions
  1. 3 1
      src/math/Euler.js
  2. 2 0
      src/math/Matrix3.js
  3. 1 0
      src/math/Quaternion.js

+ 3 - 1
src/math/Euler.js

@@ -103,6 +103,8 @@ THREE.Euler.prototype = {
 
 	setFromRotationMatrix: function ( m, order, update ) {
 
+		if ( ! ( m instanceof THREE.Matrix4 ) ) throw new Error( 'expecting a Matrix4' );
+
 		var clamp = THREE.Math.clamp;
 
 		// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
@@ -279,7 +281,7 @@ THREE.Euler.prototype = {
 		return [ this._x, this._y, this._z, this._order ];
 
 	},
-	
+
 	toVector3: function ( optionalResult ) {
 
 		if( optionalResult ) {

+ 2 - 0
src/math/Matrix3.js

@@ -137,6 +137,8 @@ THREE.Matrix3.prototype = {
 
 	getInverse: function ( matrix, throwOnInvertible ) {
 
+		if ( ! ( matrix instanceof THREE.Matrix4 ) ) throw new Error( 'expecting a Matrix4' );
+
 		// input: THREE.Matrix4
 		// ( based on http://code.google.com/p/webgl-mjs/ )
 

+ 1 - 0
src/math/Quaternion.js

@@ -190,6 +190,7 @@ THREE.Quaternion.prototype = {
 		// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
 
 		// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+		if ( ! ( m instanceof THREE.Matrix4 ) ) throw new Error( 'expecting a Matrix4' );
 
 		var te = m.elements,