Browse Source

Updated builds.

Mr.doob 8 years ago
parent
commit
b79fe24142
3 changed files with 667 additions and 449 deletions
  1. 224 116
      build/three.js
  2. 219 217
      build/three.min.js
  3. 224 116
      build/three.module.js

+ 224 - 116
build/three.js

@@ -1977,10 +1977,10 @@
 
 	function Quaternion( x, y, z, w ) {
 
-		this.x = x || 0;
-		this.y = y || 0;
-		this.z = z || 0;
-		this.w = ( w !== undefined ) ? w : 1;
+		this._x = x || 0;
+		this._y = y || 0;
+		this._z = z || 0;
+		this._w = ( w !== undefined ) ? w : 1;
 
 	}
 
@@ -2056,14 +2056,88 @@
 
 	} );
 
+	Object.defineProperties( Quaternion.prototype, {
+
+		x: {
+
+			get: function () {
+
+				return this._x;
+
+			},
+
+			set: function ( value ) {
+
+				this._x = value;
+				this.onChangeCallback();
+
+			}
+
+		},
+
+		y: {
+
+			get: function () {
+
+				return this._y;
+
+			},
+
+			set: function ( value ) {
+
+				this._y = value;
+				this.onChangeCallback();
+
+			}
+
+		},
+
+		z: {
+
+			get: function () {
+
+				return this._z;
+
+			},
+
+			set: function ( value ) {
+
+				this._z = value;
+				this.onChangeCallback();
+
+			}
+
+		},
+
+		w: {
+
+			get: function () {
+
+				return this._w;
+
+			},
+
+			set: function ( value ) {
+
+				this._w = value;
+				this.onChangeCallback();
+
+			}
+
+		}
+
+	} );
+
 	Object.assign( Quaternion.prototype, {
 
 		set: function ( x, y, z, w ) {
 
-			this.x = x;
-			this.y = y;
-			this.z = z;
-			this.w = w;
+			this._x = x;
+			this._y = y;
+			this._z = z;
+			this._w = w;
+
+			this.onChangeCallback();
 
 			return this;
 
@@ -2071,22 +2145,24 @@
 
 		clone: function () {
 
-			return new this.constructor( this.x, this.y, this.z, this.w );
+			return new this.constructor( this._x, this._y, this._z, this._w );
 
 		},
 
 		copy: function ( quaternion ) {
 
-			this.x = quaternion.x;
-			this.y = quaternion.y;
-			this.z = quaternion.z;
-			this.w = quaternion.w;
+			this._x = quaternion.x;
+			this._y = quaternion.y;
+			this._z = quaternion.z;
+			this._w = quaternion.w;
+
+			this.onChangeCallback();
 
 			return this;
 
 		},
 
-		setFromEuler: function ( euler ) {
+		setFromEuler: function ( euler, update ) {
 
 			if ( ( euler && euler.isEuler ) === false ) {
 
@@ -2094,7 +2170,7 @@
 
 			}
 
-			var x = euler.x, y = euler.y, z = euler.z, order = euler.order;
+			var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
 
 			// http://www.mathworks.com/matlabcentral/fileexchange/
 			// 	20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
@@ -2113,48 +2189,50 @@
 
 			if ( 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;
+				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' ) {
 
-				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;
+				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' ) {
 
-				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;
+				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' ) {
 
-				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;
+				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' ) {
 
-				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;
+				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' ) {
 
-				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;
+				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;
 
 			}
 
+			if ( update !== false ) this.onChangeCallback();
+
 			return this;
 
 		},
@@ -2167,10 +2245,12 @@
 
 			var halfAngle = angle / 2, s = Math.sin( halfAngle );
 
-			this.x = axis.x * s;
-			this.y = axis.y * s;
-			this.z = axis.z * s;
-			this.w = Math.cos( halfAngle );
+			this._x = axis.x * s;
+			this._y = axis.y * s;
+			this._z = axis.z * s;
+			this._w = Math.cos( halfAngle );
+
+			this.onChangeCallback();
 
 			return this;
 
@@ -2195,40 +2275,42 @@
 
 				s = 0.5 / Math.sqrt( trace + 1.0 );
 
-				this.w = 0.25 / s;
-				this.x = ( m32 - m23 ) * s;
-				this.y = ( m13 - m31 ) * s;
-				this.z = ( m21 - m12 ) * s;
+				this._w = 0.25 / s;
+				this._x = ( m32 - m23 ) * s;
+				this._y = ( m13 - m31 ) * s;
+				this._z = ( m21 - m12 ) * s;
 
 			} else if ( m11 > m22 && m11 > m33 ) {
 
 				s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
 
-				this.w = ( m32 - m23 ) / s;
-				this.x = 0.25 * s;
-				this.y = ( m12 + m21 ) / s;
-				this.z = ( m13 + m31 ) / s;
+				this._w = ( m32 - m23 ) / s;
+				this._x = 0.25 * s;
+				this._y = ( m12 + m21 ) / s;
+				this._z = ( m13 + m31 ) / s;
 
 			} else if ( m22 > m33 ) {
 
 				s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
 
-				this.w = ( m13 - m31 ) / s;
-				this.x = ( m12 + m21 ) / s;
-				this.y = 0.25 * s;
-				this.z = ( m23 + m32 ) / s;
+				this._w = ( m13 - m31 ) / s;
+				this._x = ( m12 + m21 ) / s;
+				this._y = 0.25 * s;
+				this._z = ( m23 + m32 ) / s;
 
 			} else {
 
 				s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
 
-				this.w = ( m21 - m12 ) / s;
-				this.x = ( m13 + m31 ) / s;
-				this.y = ( m23 + m32 ) / s;
-				this.z = 0.25 * s;
+				this._w = ( m21 - m12 ) / s;
+				this._x = ( m13 + m31 ) / s;
+				this._y = ( m23 + m32 ) / s;
+				this._z = 0.25 * s;
 
 			}
 
+			this.onChangeCallback();
+
 			return this;
 
 		},
@@ -2270,10 +2352,10 @@
 
 				}
 
-				this.x = v1.x;
-				this.y = v1.y;
-				this.z = v1.z;
-				this.w = r;
+				this._x = v1.x;
+				this._y = v1.y;
+				this._z = v1.z;
+				this._w = r;
 
 				return this.normalize();
 
@@ -2289,9 +2371,11 @@
 
 		conjugate: function () {
 
-			this.x *= - 1;
-			this.y *= - 1;
-			this.z *= - 1;
+			this._x *= - 1;
+			this._y *= - 1;
+			this._z *= - 1;
+
+			this.onChangeCallback();
 
 			return this;
 
@@ -2299,19 +2383,19 @@
 
 		dot: function ( v ) {
 
-			return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
+			return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
 
 		},
 
 		lengthSq: function () {
 
-			return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
+			return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
 
 		},
 
 		length: function () {
 
-			return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
+			return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
 
 		},
 
@@ -2321,22 +2405,24 @@
 
 			if ( l === 0 ) {
 
-				this.x = 0;
-				this.y = 0;
-				this.z = 0;
-				this.w = 1;
+				this._x = 0;
+				this._y = 0;
+				this._z = 0;
+				this._w = 1;
 
 			} else {
 
 				l = 1 / l;
 
-				this.x = this.x * l;
-				this.y = this.y * l;
-				this.z = this.z * l;
-				this.w = this.w * l;
+				this._x = this._x * l;
+				this._y = this._y * l;
+				this._z = this._z * l;
+				this._w = this._w * l;
 
 			}
 
+			this.onChangeCallback();
+
 			return this;
 
 		},
@@ -2364,13 +2450,15 @@
 
 			// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
 
-			var qax = a.x, qay = a.y, qaz = a.z, qaw = a.w;
-			var qbx = b.x, qby = b.y, qbz = b.z, qbw = b.w;
+			var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
+			var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
+
+			this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+			this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+			this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+			this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
 
-			this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
-			this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
-			this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
-			this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+			this.onChangeCallback();
 
 			return this;
 
@@ -2381,18 +2469,18 @@
 			if ( t === 0 ) return this;
 			if ( t === 1 ) return this.copy( qb );
 
-			var x = this.x, y = this.y, z = this.z, w = this.w;
+			var x = this._x, y = this._y, z = this._z, w = this._w;
 
 			// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
 
-			var cosHalfTheta = w * qb.w + x * qb.x + y * qb.y + z * qb.z;
+			var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
 
 			if ( cosHalfTheta < 0 ) {
 
-				this.w = - qb.w;
-				this.x = - qb.x;
-				this.y = - qb.y;
-				this.z = - qb.z;
+				this._w = - qb._w;
+				this._x = - qb._x;
+				this._y = - qb._y;
+				this._z = - qb._z;
 
 				cosHalfTheta = - cosHalfTheta;
 
@@ -2404,10 +2492,10 @@
 
 			if ( cosHalfTheta >= 1.0 ) {
 
-				this.w = w;
-				this.x = x;
-				this.y = y;
-				this.z = z;
+				this._w = w;
+				this._x = x;
+				this._y = y;
+				this._z = z;
 
 				return this;
 
@@ -2417,10 +2505,10 @@
 
 			if ( Math.abs( sinHalfTheta ) < 0.001 ) {
 
-				this.w = 0.5 * ( w + this.w );
-				this.x = 0.5 * ( x + this.x );
-				this.y = 0.5 * ( y + this.y );
-				this.z = 0.5 * ( z + this.z );
+				this._w = 0.5 * ( w + this._w );
+				this._x = 0.5 * ( x + this._x );
+				this._y = 0.5 * ( y + this._y );
+				this._z = 0.5 * ( z + this._z );
 
 				return this;
 
@@ -2430,10 +2518,12 @@
 			var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
 				ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
 
-			this.w = ( w * ratioA + this.w * ratioB );
-			this.x = ( x * ratioA + this.x * ratioB );
-			this.y = ( y * ratioA + this.y * ratioB );
-			this.z = ( z * ratioA + this.z * ratioB );
+			this._w = ( w * ratioA + this._w * ratioB );
+			this._x = ( x * ratioA + this._x * ratioB );
+			this._y = ( y * ratioA + this._y * ratioB );
+			this._z = ( z * ratioA + this._z * ratioB );
+
+			this.onChangeCallback();
 
 			return this;
 
@@ -2441,7 +2531,7 @@
 
 		equals: function ( quaternion ) {
 
-			return ( quaternion.x === this.x ) && ( quaternion.y === this.y ) && ( quaternion.z === this.z ) && ( quaternion.w === this.w );
+			return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
 
 		},
 
@@ -2449,10 +2539,12 @@
 
 			if ( offset === undefined ) offset = 0;
 
-			this.x = array[ offset ];
-			this.y = array[ offset + 1 ];
-			this.z = array[ offset + 2 ];
-			this.w = array[ offset + 3 ];
+			this._x = array[ offset ];
+			this._y = array[ offset + 1 ];
+			this._z = array[ offset + 2 ];
+			this._w = array[ offset + 3 ];
+
+			this.onChangeCallback();
 
 			return this;
 
@@ -2463,14 +2555,24 @@
 			if ( array === undefined ) array = [];
 			if ( offset === undefined ) offset = 0;
 
-			array[ offset ] = this.x;
-			array[ offset + 1 ] = this.y;
-			array[ offset + 2 ] = this.z;
-			array[ offset + 3 ] = this.w;
+			array[ offset ] = this._x;
+			array[ offset + 1 ] = this._y;
+			array[ offset + 2 ] = this._z;
+			array[ offset + 3 ] = this._w;
 
 			return array;
 
-		}
+		},
+
+		onChange: function ( callback ) {
+
+			this.onChangeCallback = callback;
+
+			return this;
+
+		},
+
+		onChangeCallback: function () {}
 
 	} );
 
@@ -3480,7 +3582,7 @@
 
 			var te = this.elements;
 
-			var x = q.x, y = q.y, z = q.z, w = q.w;
+			var x = q._x, y = q._y, z = q._z, w = q._w;
 			var x2 = x + x, y2 = y + y, z2 = z + z;
 			var xx = x * x2, xy = x * y2, xz = x * z2;
 			var yy = y * y2, yz = y * z2, zz = z * z2;
@@ -10252,18 +10354,24 @@
 		this.up = Object3D.DefaultUp.clone();
 
 		var position = new Vector3();
+		var rotation = new Euler();
 		var quaternion = new Quaternion();
 		var scale = new Vector3( 1, 1, 1 );
 
-		var rotation = new Euler();
-
 		function onRotationChange() {
 
-			quaternion.setFromEuler( rotation );
+			quaternion.setFromEuler( rotation, false );
+
+		}
+
+		function onQuaternionChange() {
+
+			rotation.setFromQuaternion( quaternion, undefined, false );
 
 		}
 
 		rotation.onChange( onRotationChange );
+		quaternion.onChange( onQuaternionChange );
 
 		Object.defineProperties( this, {
 			position: {
@@ -10337,7 +10445,7 @@
 
 		setRotationFromEuler: function ( euler ) {
 
-			this.quaternion.setFromEuler( euler );
+			this.quaternion.setFromEuler( euler, true );
 
 		},
 

File diff suppressed because it is too large
+ 219 - 217
build/three.min.js


+ 224 - 116
build/three.module.js

@@ -1971,10 +1971,10 @@ WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true;
 
 function Quaternion( x, y, z, w ) {
 
-	this.x = x || 0;
-	this.y = y || 0;
-	this.z = z || 0;
-	this.w = ( w !== undefined ) ? w : 1;
+	this._x = x || 0;
+	this._y = y || 0;
+	this._z = z || 0;
+	this._w = ( w !== undefined ) ? w : 1;
 
 }
 
@@ -2050,14 +2050,88 @@ Object.assign( Quaternion, {
 
 } );
 
+Object.defineProperties( Quaternion.prototype, {
+
+	x: {
+
+		get: function () {
+
+			return this._x;
+
+		},
+
+		set: function ( value ) {
+
+			this._x = value;
+			this.onChangeCallback();
+
+		}
+
+	},
+
+	y: {
+
+		get: function () {
+
+			return this._y;
+
+		},
+
+		set: function ( value ) {
+
+			this._y = value;
+			this.onChangeCallback();
+
+		}
+
+	},
+
+	z: {
+
+		get: function () {
+
+			return this._z;
+
+		},
+
+		set: function ( value ) {
+
+			this._z = value;
+			this.onChangeCallback();
+
+		}
+
+	},
+
+	w: {
+
+		get: function () {
+
+			return this._w;
+
+		},
+
+		set: function ( value ) {
+
+			this._w = value;
+			this.onChangeCallback();
+
+		}
+
+	}
+
+} );
+
 Object.assign( Quaternion.prototype, {
 
 	set: function ( x, y, z, w ) {
 
-		this.x = x;
-		this.y = y;
-		this.z = z;
-		this.w = w;
+		this._x = x;
+		this._y = y;
+		this._z = z;
+		this._w = w;
+
+		this.onChangeCallback();
 
 		return this;
 
@@ -2065,22 +2139,24 @@ Object.assign( Quaternion.prototype, {
 
 	clone: function () {
 
-		return new this.constructor( this.x, this.y, this.z, this.w );
+		return new this.constructor( this._x, this._y, this._z, this._w );
 
 	},
 
 	copy: function ( quaternion ) {
 
-		this.x = quaternion.x;
-		this.y = quaternion.y;
-		this.z = quaternion.z;
-		this.w = quaternion.w;
+		this._x = quaternion.x;
+		this._y = quaternion.y;
+		this._z = quaternion.z;
+		this._w = quaternion.w;
+
+		this.onChangeCallback();
 
 		return this;
 
 	},
 
-	setFromEuler: function ( euler ) {
+	setFromEuler: function ( euler, update ) {
 
 		if ( ( euler && euler.isEuler ) === false ) {
 
@@ -2088,7 +2164,7 @@ Object.assign( Quaternion.prototype, {
 
 		}
 
-		var x = euler.x, y = euler.y, z = euler.z, order = euler.order;
+		var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
 
 		// http://www.mathworks.com/matlabcentral/fileexchange/
 		// 	20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
@@ -2107,48 +2183,50 @@ Object.assign( Quaternion.prototype, {
 
 		if ( 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;
+			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' ) {
 
-			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;
+			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' ) {
 
-			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;
+			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' ) {
 
-			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;
+			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' ) {
 
-			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;
+			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' ) {
 
-			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;
+			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;
 
 		}
 
+		if ( update !== false ) this.onChangeCallback();
+
 		return this;
 
 	},
@@ -2161,10 +2239,12 @@ Object.assign( Quaternion.prototype, {
 
 		var halfAngle = angle / 2, s = Math.sin( halfAngle );
 
-		this.x = axis.x * s;
-		this.y = axis.y * s;
-		this.z = axis.z * s;
-		this.w = Math.cos( halfAngle );
+		this._x = axis.x * s;
+		this._y = axis.y * s;
+		this._z = axis.z * s;
+		this._w = Math.cos( halfAngle );
+
+		this.onChangeCallback();
 
 		return this;
 
@@ -2189,40 +2269,42 @@ Object.assign( Quaternion.prototype, {
 
 			s = 0.5 / Math.sqrt( trace + 1.0 );
 
-			this.w = 0.25 / s;
-			this.x = ( m32 - m23 ) * s;
-			this.y = ( m13 - m31 ) * s;
-			this.z = ( m21 - m12 ) * s;
+			this._w = 0.25 / s;
+			this._x = ( m32 - m23 ) * s;
+			this._y = ( m13 - m31 ) * s;
+			this._z = ( m21 - m12 ) * s;
 
 		} else if ( m11 > m22 && m11 > m33 ) {
 
 			s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
 
-			this.w = ( m32 - m23 ) / s;
-			this.x = 0.25 * s;
-			this.y = ( m12 + m21 ) / s;
-			this.z = ( m13 + m31 ) / s;
+			this._w = ( m32 - m23 ) / s;
+			this._x = 0.25 * s;
+			this._y = ( m12 + m21 ) / s;
+			this._z = ( m13 + m31 ) / s;
 
 		} else if ( m22 > m33 ) {
 
 			s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
 
-			this.w = ( m13 - m31 ) / s;
-			this.x = ( m12 + m21 ) / s;
-			this.y = 0.25 * s;
-			this.z = ( m23 + m32 ) / s;
+			this._w = ( m13 - m31 ) / s;
+			this._x = ( m12 + m21 ) / s;
+			this._y = 0.25 * s;
+			this._z = ( m23 + m32 ) / s;
 
 		} else {
 
 			s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
 
-			this.w = ( m21 - m12 ) / s;
-			this.x = ( m13 + m31 ) / s;
-			this.y = ( m23 + m32 ) / s;
-			this.z = 0.25 * s;
+			this._w = ( m21 - m12 ) / s;
+			this._x = ( m13 + m31 ) / s;
+			this._y = ( m23 + m32 ) / s;
+			this._z = 0.25 * s;
 
 		}
 
+		this.onChangeCallback();
+
 		return this;
 
 	},
@@ -2264,10 +2346,10 @@ Object.assign( Quaternion.prototype, {
 
 			}
 
-			this.x = v1.x;
-			this.y = v1.y;
-			this.z = v1.z;
-			this.w = r;
+			this._x = v1.x;
+			this._y = v1.y;
+			this._z = v1.z;
+			this._w = r;
 
 			return this.normalize();
 
@@ -2283,9 +2365,11 @@ Object.assign( Quaternion.prototype, {
 
 	conjugate: function () {
 
-		this.x *= - 1;
-		this.y *= - 1;
-		this.z *= - 1;
+		this._x *= - 1;
+		this._y *= - 1;
+		this._z *= - 1;
+
+		this.onChangeCallback();
 
 		return this;
 
@@ -2293,19 +2377,19 @@ Object.assign( Quaternion.prototype, {
 
 	dot: function ( v ) {
 
-		return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
+		return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
 
 	},
 
 	lengthSq: function () {
 
-		return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
+		return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
 
 	},
 
 	length: function () {
 
-		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
+		return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
 
 	},
 
@@ -2315,22 +2399,24 @@ Object.assign( Quaternion.prototype, {
 
 		if ( l === 0 ) {
 
-			this.x = 0;
-			this.y = 0;
-			this.z = 0;
-			this.w = 1;
+			this._x = 0;
+			this._y = 0;
+			this._z = 0;
+			this._w = 1;
 
 		} else {
 
 			l = 1 / l;
 
-			this.x = this.x * l;
-			this.y = this.y * l;
-			this.z = this.z * l;
-			this.w = this.w * l;
+			this._x = this._x * l;
+			this._y = this._y * l;
+			this._z = this._z * l;
+			this._w = this._w * l;
 
 		}
 
+		this.onChangeCallback();
+
 		return this;
 
 	},
@@ -2358,13 +2444,15 @@ Object.assign( Quaternion.prototype, {
 
 		// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
 
-		var qax = a.x, qay = a.y, qaz = a.z, qaw = a.w;
-		var qbx = b.x, qby = b.y, qbz = b.z, qbw = b.w;
+		var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;
+		var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;
+
+		this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+		this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+		this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+		this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
 
-		this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
-		this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
-		this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
-		this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+		this.onChangeCallback();
 
 		return this;
 
@@ -2375,18 +2463,18 @@ Object.assign( Quaternion.prototype, {
 		if ( t === 0 ) return this;
 		if ( t === 1 ) return this.copy( qb );
 
-		var x = this.x, y = this.y, z = this.z, w = this.w;
+		var x = this._x, y = this._y, z = this._z, w = this._w;
 
 		// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
 
-		var cosHalfTheta = w * qb.w + x * qb.x + y * qb.y + z * qb.z;
+		var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
 
 		if ( cosHalfTheta < 0 ) {
 
-			this.w = - qb.w;
-			this.x = - qb.x;
-			this.y = - qb.y;
-			this.z = - qb.z;
+			this._w = - qb._w;
+			this._x = - qb._x;
+			this._y = - qb._y;
+			this._z = - qb._z;
 
 			cosHalfTheta = - cosHalfTheta;
 
@@ -2398,10 +2486,10 @@ Object.assign( Quaternion.prototype, {
 
 		if ( cosHalfTheta >= 1.0 ) {
 
-			this.w = w;
-			this.x = x;
-			this.y = y;
-			this.z = z;
+			this._w = w;
+			this._x = x;
+			this._y = y;
+			this._z = z;
 
 			return this;
 
@@ -2411,10 +2499,10 @@ Object.assign( Quaternion.prototype, {
 
 		if ( Math.abs( sinHalfTheta ) < 0.001 ) {
 
-			this.w = 0.5 * ( w + this.w );
-			this.x = 0.5 * ( x + this.x );
-			this.y = 0.5 * ( y + this.y );
-			this.z = 0.5 * ( z + this.z );
+			this._w = 0.5 * ( w + this._w );
+			this._x = 0.5 * ( x + this._x );
+			this._y = 0.5 * ( y + this._y );
+			this._z = 0.5 * ( z + this._z );
 
 			return this;
 
@@ -2424,10 +2512,12 @@ Object.assign( Quaternion.prototype, {
 		var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
 			ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
 
-		this.w = ( w * ratioA + this.w * ratioB );
-		this.x = ( x * ratioA + this.x * ratioB );
-		this.y = ( y * ratioA + this.y * ratioB );
-		this.z = ( z * ratioA + this.z * ratioB );
+		this._w = ( w * ratioA + this._w * ratioB );
+		this._x = ( x * ratioA + this._x * ratioB );
+		this._y = ( y * ratioA + this._y * ratioB );
+		this._z = ( z * ratioA + this._z * ratioB );
+
+		this.onChangeCallback();
 
 		return this;
 
@@ -2435,7 +2525,7 @@ Object.assign( Quaternion.prototype, {
 
 	equals: function ( quaternion ) {
 
-		return ( quaternion.x === this.x ) && ( quaternion.y === this.y ) && ( quaternion.z === this.z ) && ( quaternion.w === this.w );
+		return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
 
 	},
 
@@ -2443,10 +2533,12 @@ Object.assign( Quaternion.prototype, {
 
 		if ( offset === undefined ) offset = 0;
 
-		this.x = array[ offset ];
-		this.y = array[ offset + 1 ];
-		this.z = array[ offset + 2 ];
-		this.w = array[ offset + 3 ];
+		this._x = array[ offset ];
+		this._y = array[ offset + 1 ];
+		this._z = array[ offset + 2 ];
+		this._w = array[ offset + 3 ];
+
+		this.onChangeCallback();
 
 		return this;
 
@@ -2457,14 +2549,24 @@ Object.assign( Quaternion.prototype, {
 		if ( array === undefined ) array = [];
 		if ( offset === undefined ) offset = 0;
 
-		array[ offset ] = this.x;
-		array[ offset + 1 ] = this.y;
-		array[ offset + 2 ] = this.z;
-		array[ offset + 3 ] = this.w;
+		array[ offset ] = this._x;
+		array[ offset + 1 ] = this._y;
+		array[ offset + 2 ] = this._z;
+		array[ offset + 3 ] = this._w;
 
 		return array;
 
-	}
+	},
+
+	onChange: function ( callback ) {
+
+		this.onChangeCallback = callback;
+
+		return this;
+
+	},
+
+	onChangeCallback: function () {}
 
 } );
 
@@ -3474,7 +3576,7 @@ Object.assign( Matrix4.prototype, {
 
 		var te = this.elements;
 
-		var x = q.x, y = q.y, z = q.z, w = q.w;
+		var x = q._x, y = q._y, z = q._z, w = q._w;
 		var x2 = x + x, y2 = y + y, z2 = z + z;
 		var xx = x * x2, xy = x * y2, xz = x * z2;
 		var yy = y * y2, yz = y * z2, zz = z * z2;
@@ -10246,18 +10348,24 @@ function Object3D() {
 	this.up = Object3D.DefaultUp.clone();
 
 	var position = new Vector3();
+	var rotation = new Euler();
 	var quaternion = new Quaternion();
 	var scale = new Vector3( 1, 1, 1 );
 
-	var rotation = new Euler();
-
 	function onRotationChange() {
 
-		quaternion.setFromEuler( rotation );
+		quaternion.setFromEuler( rotation, false );
+
+	}
+
+	function onQuaternionChange() {
+
+		rotation.setFromQuaternion( quaternion, undefined, false );
 
 	}
 
 	rotation.onChange( onRotationChange );
+	quaternion.onChange( onQuaternionChange );
 
 	Object.defineProperties( this, {
 		position: {
@@ -10331,7 +10439,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 
 	setRotationFromEuler: function ( euler ) {
 
-		this.quaternion.setFromEuler( euler );
+		this.quaternion.setFromEuler( euler, true );
 
 	},
 

Some files were not shown because too many files changed in this diff