Browse Source

complete Euler class, update examples, update Object3D, update unit tests.

Ben Houston 12 years ago
parent
commit
a16a9f6775

+ 2 - 2
examples/css3d_molecules.html

@@ -433,7 +433,7 @@
 
 						var objMatrix = new THREE.Matrix4().makeRotationAxis( axis.normalize(), radians );
 						object.matrix = objMatrix;
-						object.rotation.setEulerFromRotationMatrix( object.matrix, object.eulerOrder );
+						object.rotation.setFromRotationMatrix( object.matrix, object.rotation.order );
 
 						object.matrixAutoUpdate = false;
 						object.updateMatrix();
@@ -453,7 +453,7 @@
 						joint.position.lerp( end, 0.5 );
 
 						joint.matrix.copy( objMatrix );
-						joint.rotation.setEulerFromRotationMatrix( joint.matrix, joint.eulerOrder );
+						joint.rotation.setFromRotationMatrix( joint.matrix, joint.rotation.order );
 
 						joint.matrixAutoUpdate = false;
 						joint.updateMatrix();

+ 1 - 1
examples/js/controls/FlyControls.js

@@ -199,7 +199,7 @@ THREE.FlyControls = function ( object, domElement ) {
 		this.object.quaternion.multiply( this.tmpQuaternion );
 
 		// expose the rotation vector for convenience
-		this.object.rotation.setEulerFromQuaternion( this.object.quaternion, this.object.eulerOrder );
+		this.object.rotation.setFromQuaternion( this.object.quaternion, this.object.rotation.order );
 
 
 	};

+ 8 - 8
examples/js/controls/TransformControls.js

@@ -379,11 +379,11 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
 
 		this.object.updateMatrixWorld();
 		worldPosition.getPositionFromMatrix( this.object.matrixWorld );
-		worldRotation.setEulerFromRotationMatrix( tempMatrix.extractRotation(this.object.matrixWorld ));
+		worldRotation.setFromRotationMatrix( tempMatrix.extractRotation(this.object.matrixWorld ));
 
 		this.camera.updateMatrixWorld();
 		camPosition.getPositionFromMatrix( this.camera.matrixWorld );
-		camRotation.setEulerFromRotationMatrix( tempMatrix.extractRotation( this.camera.matrixWorld ));
+		camRotation.setFromRotationMatrix( tempMatrix.extractRotation( this.camera.matrixWorld ));
 
 		scale = worldPosition.distanceTo( camPosition ) / 6 * this.scale;
 		this.gizmo.position.copy( worldPosition )
@@ -399,7 +399,7 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
 				if ( name.search('E') != -1 ){
 
 					lookAtMatrix.lookAt( camPosition, worldPosition, tempVector.set( 0, 1, 0 ));
-					object.rotation.setEulerFromRotationMatrix( lookAtMatrix );
+					object.rotation.setFromRotationMatrix( lookAtMatrix );
 
 				} else {
 
@@ -431,7 +431,7 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
 
 						}
 
-						object.rotation.setEulerFromQuaternion( tempQuaternion );
+						object.rotation.setFromQuaternion( tempQuaternion );
 
 					} else if ( this.space == 'world' ) {
 
@@ -789,7 +789,7 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
 						tempQuaternion.multiplyQuaternions( tempQuaternion, quaternionE );
 						tempQuaternion.multiplyQuaternions( tempQuaternion, quaternionXYZ );
 
-						scope.object.rotation.setEulerFromQuaternion( tempQuaternion );
+						scope.object.rotation.setFromQuaternion( tempQuaternion );
 
 					} else if ( scope.active == "RXYZE" ) {
 
@@ -802,7 +802,7 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
 						tempQuaternion.multiplyQuaternions( tempQuaternion, quaternionX );
 						tempQuaternion.multiplyQuaternions( tempQuaternion, quaternionXYZ );
 
-						scope.object.rotation.setEulerFromQuaternion( tempQuaternion );
+						scope.object.rotation.setFromQuaternion( tempQuaternion );
 
 					} else if ( scope.space == 'local' ) {
 
@@ -822,7 +822,7 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
 						if ( scope.active == "RY" ) quaternionXYZ.multiplyQuaternions( quaternionXYZ, quaternionY );
 						if ( scope.active == "RZ" ) quaternionXYZ.multiplyQuaternions( quaternionXYZ, quaternionZ );
 
-						scope.object.rotation.setEulerFromQuaternion( quaternionXYZ );
+						scope.object.rotation.setFromQuaternion( quaternionXYZ );
 
 					} else if ( scope.space == 'world' ) {
 
@@ -842,7 +842,7 @@ THREE.TransformControls = function ( camera, domElement, doc ) {
 
 						tempQuaternion.multiplyQuaternions( tempQuaternion, quaternionXYZ );
 
-						scope.object.rotation.setEulerFromQuaternion( tempQuaternion );
+						scope.object.rotation.setFromQuaternion( tempQuaternion );
 
 					}
 

+ 1 - 1
examples/webgl_geometry_extrude_splines.html

@@ -380,7 +380,7 @@
 			if (!lookAhead)
 			lookAt.copy( pos ).add( dir );
 			splineCamera.matrix.lookAt(splineCamera.position, lookAt, normal);
-			splineCamera.rotation.setEulerFromRotationMatrix( splineCamera.matrix, splineCamera.eulerOrder );
+			splineCamera.rotation.setFromRotationMatrix( splineCamera.matrix, splineCamera.rotation.order );
 
 			cameraHelper.update();
 

+ 1 - 1
examples/webgl_multiple_windows.html

@@ -192,7 +192,7 @@
 					dst.up.copy( src.up );
 					dst.position.copy( src.position );
 					dst.scale.copy( src.scale );
-					dst.eulerOrder = src.eulerOrder;
+					dst.rotation.copy( src.rotation );
 					dst.quaternion.copy( src.quaternion );
 
 				};

+ 1 - 1
src/cameras/Camera.js

@@ -33,7 +33,7 @@ THREE.Camera.prototype.lookAt = function () {
 
 		} else {
 
-			this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder );
+			this.rotation.setFromRotationMatrix( m1, this.rotation.Order );
 
 		}
 

+ 8 - 10
src/core/Object3D.js

@@ -17,8 +17,7 @@ THREE.Object3D = function () {
 	this.up = new THREE.Vector3( 0, 1, 0 );
 
 	this.position = new THREE.Vector3();
-	this.rotation = new THREE.Vector3();
-	this.eulerOrder = THREE.Object3D.defaultEulerOrder;
+	this.rotation = new THREE.Euler();
 	this.scale = new THREE.Vector3( 1, 1, 1 );
 
 	this.renderDepth = null;
@@ -75,7 +74,7 @@ THREE.Object3D.prototype = {
 
 			} else {
 
-				this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder );
+				this.rotation.setFromRotationMatrix( m1, this.rotation.order );
 
 			}
 
@@ -101,10 +100,10 @@ THREE.Object3D.prototype = {
 
 			} else {
 
-				q2.setFromEuler( this.rotation, this.eulerOrder );
+				q2.setFromEuler( this.rotation );
 				q2.multiply( q1 );
 
-				this.rotation.setEulerFromQuaternion( q2, this.eulerOrder );
+				this.rotation.setFromQuaternion( q2, this.rotation.order );
 
 			}
 
@@ -131,7 +130,7 @@ THREE.Object3D.prototype = {
 
 			} else {
 
-				v1.applyEuler( this.rotation, this.eulerOrder );
+				v1.applyEuler( this.rotation );
 
 			}
 
@@ -220,7 +219,7 @@ THREE.Object3D.prototype = {
 
 			} else {
 
-				this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder );
+				this.rotation.setFromRotationMatrix( m1, this.rotation.order );
 
 			}
 
@@ -398,7 +397,7 @@ THREE.Object3D.prototype = {
 
 		if ( this.useQuaternion === false )  {
 
-			this.matrix.makeFromPositionEulerScale( this.position, this.rotation, this.eulerOrder, this.scale );
+			this.matrix.makeFromPositionEulerScale( this.position, this.rotation, this.scale );
 
 		} else {
 
@@ -451,8 +450,7 @@ THREE.Object3D.prototype = {
 		object.up.copy( this.up );
 
 		object.position.copy( this.position );
-		if ( object.rotation instanceof THREE.Vector3 ) object.rotation.copy( this.rotation ); // because of Sprite madness
-		object.eulerOrder = this.eulerOrder;
+		if ( object.rotation instanceof THREE.Euler ) object.rotation.copy( this.rotation ); // because of Sprite madness
 		object.scale.copy( this.scale );
 
 		object.renderDepth = this.renderDepth;

+ 32 - 8
src/math/Euler3.js → src/math/Euler.js

@@ -1,21 +1,25 @@
 /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author WestLangley / http://github.com/WestLangley
  * @author bhouston / http://exocortex.com
  */
 
-THREE.Euler3 = function ( x, y, z, order ) {
+THREE.Euler = function ( x, y, z, order ) {
 
 	this.x = x || 0;
 	this.y = y || 0;
 	this.z = z || 0;
-	this.order = order || "XYZ";
+	this.order = order || THREE.Euler.DefaultOrder;
 
 };
 
-THREE.Euler3.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
+THREE.Euler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];
 
-THREE.Euler3.prototype = {
+THREE.Euler.DefaultOrder = 'XYZ';
 
-	constructor: THREE.Euler3,
+THREE.Euler.prototype = {
+
+	constructor: THREE.Euler,
 
 	set: function ( x, y, z, order ) {
 
@@ -226,30 +230,50 @@ THREE.Euler3.prototype = {
 	clamp: function() {
 
 		// todo
+		console.error( "ERROR: Euler.clamp() is not yet implemented.");
 		
 	},
 
 	reorder: function( newOrder ) {
 
 		// todo.
+		console.error( "ERROR: Euler.reorder() is not yet implemented.");
 
 	},
 
 	alternativeSolution: function() {
 
 		// todo.
+		console.error( "ERROR: Euler.alternativeSolution() is not yet implemented.");
+
+	},
+
+	fromArray: function ( array ) {
+
+		this.x = array[ 0 ];
+		this.y = array[ 1 ];
+		this.z = array[ 2 ];
+		this.order = array[ 3 ];
+
+		return this;
+
+	},
+
+	toArray: function () {
+
+		return [ this.x, this.y, this.z, this.order ];
 
 	},
 
-	equals: function ( e ) {
+	equals: function ( rotation ) {
 
-		return ( ( e.x === this.x ) && ( e.y === this.y ) && ( e.z === this.z ) && ( e.order === this.order ) );
+		return ( ( rotation.x === this.x ) && ( rotation.y === this.y ) && ( rotation.z === this.z ) && ( rotation.order === this.order ) );
 
 	},
 
 	clone: function () {
 
-		return new THREE.Euler3( this.x, this.y, this.z, this.order );
+		return new THREE.Euler( this.x, this.y, this.z, this.order );
 
 	}
 

+ 17 - 17
src/math/Matrix4.js

@@ -126,24 +126,20 @@ THREE.Matrix4.prototype = {
 
 	}(),
 
-	setRotationFromEuler: function ( v, order ) {
+	makeRotationFromEuler: function ( rotation ) {
 
-		console.warn( 'DEPRECATED: Matrix4\'s .setRotationFromEuler() has been deprecated in favor of makeRotationFromEuler.  Please update your code.' );
-
-		return this.makeRotationFromEuler( v, order );
-
-	},
-
-	makeRotationFromEuler: function ( v, order ) {
+		if( typeof rotation['order'] === undefined ) {
+			console.error( 'ERROR: Matrix\'s .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.  Please update your code.' );
+		}
 
 		var te = this.elements;
 
-		var x = v.x, y = v.y, z = v.z;
+		var x = rotation.x, y = rotation.y, z = rotation.z;
 		var a = Math.cos( x ), b = Math.sin( x );
 		var c = Math.cos( y ), d = Math.sin( y );
 		var e = Math.cos( z ), f = Math.sin( z );
 
-		if ( order === undefined || order === 'XYZ' ) {
+		if ( rotation.order === undefined || rotation.order === 'XYZ' ) {
 
 			var ae = a * e, af = a * f, be = b * e, bf = b * f;
 
@@ -159,7 +155,7 @@ THREE.Matrix4.prototype = {
 			te[6] = be + af * d;
 			te[10] = a * c;
 
-		} else if ( order === 'YXZ' ) {
+		} else if ( rotation.order === 'YXZ' ) {
 
 			var ce = c * e, cf = c * f, de = d * e, df = d * f;
 
@@ -175,7 +171,7 @@ THREE.Matrix4.prototype = {
 			te[6] = df + ce * b;
 			te[10] = a * c;
 
-		} else if ( order === 'ZXY' ) {
+		} else if ( rotation.order === 'ZXY' ) {
 
 			var ce = c * e, cf = c * f, de = d * e, df = d * f;
 
@@ -191,7 +187,7 @@ THREE.Matrix4.prototype = {
 			te[6] = b;
 			te[10] = a * c;
 
-		} else if ( order === 'ZYX' ) {
+		} else if ( rotation.order === 'ZYX' ) {
 
 			var ae = a * e, af = a * f, be = b * e, bf = b * f;
 
@@ -207,7 +203,7 @@ THREE.Matrix4.prototype = {
 			te[6] = b * c;
 			te[10] = a * c;
 
-		} else if ( order === 'YZX' ) {
+		} else if ( rotation.order === 'YZX' ) {
 
 			var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
 
@@ -223,7 +219,7 @@ THREE.Matrix4.prototype = {
 			te[6] = ad * f + bc;
 			te[10] = ac - bd * f;
 
-		} else if ( order === 'XZY' ) {
+		} else if ( rotation.order === 'XZY' ) {
 
 			var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
 
@@ -843,9 +839,13 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	makeFromPositionEulerScale: function ( position, rotation, eulerOrder, scale ) {
+	makeFromPositionEulerScale: function ( position, rotation, scale ) {
+
+		if( typeof rotation['order'] === undefined ) {
+			console.error( 'ERROR: Matrix4\'s .makeFromPositionEulerScale() now expects a Euler rotation rather than a Vector3 and order.  Please update your code.' );
+		}
 
-		this.makeRotationFromEuler( rotation, eulerOrder );
+		this.makeRotationFromEuler( rotation );
 		this.scale( scale );
 		this.setPosition( position );
 

+ 17 - 13
src/math/Quaternion.js

@@ -40,55 +40,59 @@ THREE.Quaternion.prototype = {
 
 	},
 
-	setFromEuler: function ( v, order ) {
+	setFromEuler: function ( rotation ) {
+
+		if( typeof rotation['order'] === undefined ) {
+			console.error( 'ERROR: Quaternion\'s .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.  Please update your code.' );
+		}
 
 		// http://www.mathworks.com/matlabcentral/fileexchange/
 		// 	20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
 		//	content/SpinCalc.m
 
-		var c1 = Math.cos( v.x / 2 );
-		var c2 = Math.cos( v.y / 2 );
-		var c3 = Math.cos( v.z / 2 );
-		var s1 = Math.sin( v.x / 2 );
-		var s2 = Math.sin( v.y / 2 );
-		var s3 = Math.sin( v.z / 2 );
+		var c1 = Math.cos( rotation.x / 2 );
+		var c2 = Math.cos( rotation.y / 2 );
+		var c3 = Math.cos( rotation.z / 2 );
+		var s1 = Math.sin( rotation.x / 2 );
+		var s2 = Math.sin( rotation.y / 2 );
+		var s3 = Math.sin( rotation.z / 2 );
 
-		if ( order === undefined || order === 'XYZ' ) {
+		if ( rotation.order === undefined || rotation.order === 'XYZ' ) {
 
 			this.x = s1 * c2 * c3 + c1 * s2 * s3;
 			this.y = c1 * s2 * c3 - s1 * c2 * s3;
 			this.z = c1 * c2 * s3 + s1 * s2 * c3;
 			this.w = c1 * c2 * c3 - s1 * s2 * s3;
 
-		} else if ( order === 'YXZ' ) {
+		} else if ( rotation.order === 'YXZ' ) {
 
 			this.x = s1 * c2 * c3 + c1 * s2 * s3;
 			this.y = c1 * s2 * c3 - s1 * c2 * s3;
 			this.z = c1 * c2 * s3 - s1 * s2 * c3;
 			this.w = c1 * c2 * c3 + s1 * s2 * s3;
 
-		} else if ( order === 'ZXY' ) {
+		} else if ( rotation.order === 'ZXY' ) {
 
 			this.x = s1 * c2 * c3 - c1 * s2 * s3;
 			this.y = c1 * s2 * c3 + s1 * c2 * s3;
 			this.z = c1 * c2 * s3 + s1 * s2 * c3;
 			this.w = c1 * c2 * c3 - s1 * s2 * s3;
 
-		} else if ( order === 'ZYX' ) {
+		} else if ( rotation.order === 'ZYX' ) {
 
 			this.x = s1 * c2 * c3 - c1 * s2 * s3;
 			this.y = c1 * s2 * c3 + s1 * c2 * s3;
 			this.z = c1 * c2 * s3 - s1 * s2 * c3;
 			this.w = c1 * c2 * c3 + s1 * s2 * s3;
 
-		} else if ( order === 'YZX' ) {
+		} else if ( rotation.order === 'YZX' ) {
 
 			this.x = s1 * c2 * c3 + c1 * s2 * s3;
 			this.y = c1 * s2 * c3 + s1 * c2 * s3;
 			this.z = c1 * c2 * s3 - s1 * s2 * c3;
 			this.w = c1 * c2 * c3 - s1 * s2 * s3;
 
-		} else if ( order === 'XZY' ) {
+		} else if ( rotation.order === 'XZY' ) {
 
 			this.x = s1 * c2 * c3 - c1 * s2 * s3;
 			this.y = c1 * s2 * c3 - s1 * c2 * s3;

+ 6 - 182
src/math/Vector3.js

@@ -516,186 +516,6 @@ THREE.Vector3.prototype = {
 
 	},
 
-	setEulerFromRotationMatrix: function ( m, order ) {
-
-		// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
-
-		// clamp, to handle numerical problems
-
-		function clamp( x ) {
-
-			return Math.min( Math.max( x, -1 ), 1 );
-
-		}
-
-		var te = m.elements;
-		var m11 = te[0], m12 = te[4], m13 = te[8];
-		var m21 = te[1], m22 = te[5], m23 = te[9];
-		var m31 = te[2], m32 = te[6], m33 = te[10];
-
-		if ( order === undefined || order === 'XYZ' ) {
-
-			this.y = Math.asin( clamp( m13 ) );
-
-			if ( Math.abs( m13 ) < 0.99999 ) {
-
-				this.x = Math.atan2( - m23, m33 );
-				this.z = Math.atan2( - m12, m11 );
-
-			} else {
-
-				this.x = Math.atan2( m32, m22 );
-				this.z = 0;
-
-			}
-
-		} else if ( order === 'YXZ' ) {
-
-			this.x = Math.asin( - clamp( m23 ) );
-
-			if ( Math.abs( m23 ) < 0.99999 ) {
-
-				this.y = Math.atan2( m13, m33 );
-				this.z = Math.atan2( m21, m22 );
-
-			} else {
-
-				this.y = Math.atan2( - m31, m11 );
-				this.z = 0;
-
-			}
-
-		} else if ( order === 'ZXY' ) {
-
-			this.x = Math.asin( clamp( m32 ) );
-
-			if ( Math.abs( m32 ) < 0.99999 ) {
-
-				this.y = Math.atan2( - m31, m33 );
-				this.z = Math.atan2( - m12, m22 );
-
-			} else {
-
-				this.y = 0;
-				this.z = Math.atan2( m21, m11 );
-
-			}
-
-		} else if ( order === 'ZYX' ) {
-
-			this.y = Math.asin( - clamp( m31 ) );
-
-			if ( Math.abs( m31 ) < 0.99999 ) {
-
-				this.x = Math.atan2( m32, m33 );
-				this.z = Math.atan2( m21, m11 );
-
-			} else {
-
-				this.x = 0;
-				this.z = Math.atan2( - m12, m22 );
-
-			}
-
-		} else if ( order === 'YZX' ) {
-
-			this.z = Math.asin( clamp( m21 ) );
-
-			if ( Math.abs( m21 ) < 0.99999 ) {
-
-				this.x = Math.atan2( - m23, m22 );
-				this.y = Math.atan2( - m31, m11 );
-
-			} else {
-
-				this.x = 0;
-				this.y = Math.atan2( m13, m33 );
-
-			}
-
-		} else if ( order === 'XZY' ) {
-
-			this.z = Math.asin( - clamp( m12 ) );
-
-			if ( Math.abs( m12 ) < 0.99999 ) {
-
-				this.x = Math.atan2( m32, m22 );
-				this.y = Math.atan2( m13, m11 );
-
-			} else {
-
-				this.x = Math.atan2( - m23, m33 );
-				this.y = 0;
-
-			}
-
-		}
-
-		return this;
-
-	},
-
-	setEulerFromQuaternion: function ( q, order ) {
-
-		// q is assumed to be normalized
-
-		// clamp, to handle numerical problems
-
-		function clamp( x ) {
-
-			return Math.min( Math.max( x, -1 ), 1 );
-
-		}
-
-		// http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
-
-		var sqx = q.x * q.x;
-		var sqy = q.y * q.y;
-		var sqz = q.z * q.z;
-		var sqw = q.w * q.w;
-
-		if ( order === undefined || order === 'XYZ' ) {
-
-			this.x = Math.atan2( 2 * ( q.x * q.w - q.y * q.z ), ( sqw - sqx - sqy + sqz ) );
-			this.y = Math.asin(  clamp( 2 * ( q.x * q.z + q.y * q.w ) ) );
-			this.z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw + sqx - sqy - sqz ) );
-
-		} else if ( order ===  'YXZ' ) {
-
-			this.x = Math.asin(  clamp( 2 * ( q.x * q.w - q.y * q.z ) ) );
-			this.y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw - sqx - sqy + sqz ) );
-			this.z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw - sqx + sqy - sqz ) );
-
-		} else if ( order === 'ZXY' ) {
-
-			this.x = Math.asin(  clamp( 2 * ( q.x * q.w + q.y * q.z ) ) );
-			this.y = Math.atan2( 2 * ( q.y * q.w - q.z * q.x ), ( sqw - sqx - sqy + sqz ) );
-			this.z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw - sqx + sqy - sqz ) );
-
-		} else if ( order === 'ZYX' ) {
-
-			this.x = Math.atan2( 2 * ( q.x * q.w + q.z * q.y ), ( sqw - sqx - sqy + sqz ) );
-			this.y = Math.asin(  clamp( 2 * ( q.y * q.w - q.x * q.z ) ) );
-			this.z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw + sqx - sqy - sqz ) );
-
-		} else if ( order === 'YZX' ) {
-
-			this.x = Math.atan2( 2 * ( q.x * q.w - q.z * q.y ), ( sqw - sqx + sqy - sqz ) );
-			this.y = Math.atan2( 2 * ( q.y * q.w - q.x * q.z ), ( sqw + sqx - sqy - sqz ) );
-			this.z = Math.asin(  clamp( 2 * ( q.x * q.y + q.z * q.w ) ) );
-
-		} else if ( order === 'XZY' ) {
-
-			this.x = Math.atan2( 2 * ( q.x * q.w + q.y * q.z ), ( sqw - sqx + sqy - sqz ) );
-			this.y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw + sqx - sqy - sqz ) );
-			this.z = Math.asin(  clamp( 2 * ( q.z * q.w - q.x * q.y ) ) );
-
-		}
-
-		return this;
-
-	},
-
 	getPositionFromMatrix: function ( m ) {
 
 		this.x = m.elements[12];
@@ -769,9 +589,13 @@ THREE.extend( THREE.Vector3.prototype, {
 
 		var q1 = new THREE.Quaternion();
 
-		return function ( v, eulerOrder ) {
+		return function ( rotation ) {
+
+			if( typeof rotation['order'] === undefined ) {
+				console.error( 'ERROR: Vector3\'s .applyEuler() now expects a Euler rotation rather than a Vector3 and order.  Please update your code.' );
+			}
 
-			var quaternion = q1.setFromEuler( v, eulerOrder );
+			var quaternion = q1.setFromEuler( rotation );
 
 			this.applyQuaternion( quaternion );
 

+ 2 - 2
src/objects/Sprite.js

@@ -22,8 +22,8 @@ THREE.Sprite.prototype = Object.create( THREE.Object3D.prototype );
 
 THREE.Sprite.prototype.updateMatrix = function () {
 
-	this.rotation3d.set( 0, 0, this.rotation );
-	this.quaternion.setFromEuler( this.rotation3d, this.eulerOrder );
+	this.rotation3d.set( 0, 0, this.rotation, this.rotation3d.order );
+	this.quaternion.setFromEuler( this.rotation3d );
 	this.matrix.makeFromPositionQuaternionScale( this.position, this.quaternion, this.scale );
 
 	this.matrixWorldNeedsUpdate = true;

+ 4 - 4
test/unit/math/Quaternion.js

@@ -91,16 +91,16 @@ test( "setFromAxisAngle", function() {
 });
 
 
-test( "setFromEuler/setEulerFromQuaternion", function() {
+test( "setFromEuler/setFromQuaternion", function() {
 
 	var angles = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ];
 
 	// ensure euler conversion to/from Quaternion matches.
 	for( var i = 0; i < orders.length; i ++ ) {
 		for( var j = 0; j < angles.length; j ++ ) {
-			var eulers2 = new THREE.Vector3().setEulerFromQuaternion( new THREE.Quaternion().setFromEuler( angles[j], orders[i] ), orders[i] );
-
-			ok( eulers2.distanceTo( angles[j] ) < 0.001, "Passed!" );
+			var eulers2 = new THREE.Euler().setFromQuaternion( new THREE.Quaternion().setFromEuler( new THREE.Euler( angles[j].x, angles[j].y, angles[j].z, orders[i] ) ), orders[i] );
+			var newAngle = new THREE.Vector3( eulers2.x, eulers2.y, eulers2.z );
+			ok( newAngle.distanceTo( angles[j] ) < 0.001, "Passed!" );
 		}
 	}
 

+ 1 - 0
test/unit/unittests_sources.html

@@ -17,6 +17,7 @@
   <script src="../../src/math/Vector2.js"></script>
   <script src="../../src/math/Vector3.js"></script>
   <script src="../../src/math/Vector4.js"></script>
+  <script src="../../src/math/Euler.js"></script>
   <script src="../../src/math/Line3.js"></script>
   <script src="../../src/math/Box2.js"></script>
   <script src="../../src/math/Box3.js"></script>

+ 1 - 0
utils/build/includes/common.json

@@ -5,6 +5,7 @@
 	"src/math/Vector2.js",
 	"src/math/Vector3.js",
 	"src/math/Vector4.js",
+	"src/math/Euler.js",
 	"src/math/Line3.js",
 	"src/math/Box2.js",
 	"src/math/Box3.js",

+ 1 - 0
utils/build/includes/math.json

@@ -5,6 +5,7 @@
 	"src/math/Vector2.js",
 	"src/math/Vector3.js",
 	"src/math/Vector4.js",
+	"src/math/Euler.js",
 	"src/math/Line3.js",
 	"src/math/Box2.js",
 	"src/math/Box3.js",