|
@@ -17,9 +17,12 @@ THREE.Object3D = function () {
|
|
|
this.up = new THREE.Vector3( 0, 1, 0 );
|
|
|
|
|
|
this.position = new THREE.Vector3();
|
|
|
- this.rotation = new THREE.Euler();
|
|
|
+ this.quaternion = new THREE.Quaternion();
|
|
|
this.scale = new THREE.Vector3( 1, 1, 1 );
|
|
|
|
|
|
+ // for backwards compatibility (maps changes to this.rotation onto this.quaternion)
|
|
|
+ this.rotation = new THREE.Rotation( this.quaternion );
|
|
|
+
|
|
|
this.renderDepth = null;
|
|
|
|
|
|
this.rotationAutoUpdate = true;
|
|
@@ -30,9 +33,6 @@ THREE.Object3D = function () {
|
|
|
this.matrixAutoUpdate = true;
|
|
|
this.matrixWorldNeedsUpdate = true;
|
|
|
|
|
|
- this.quaternion = new THREE.Quaternion();
|
|
|
- this.useQuaternion = false;
|
|
|
-
|
|
|
this.visible = true;
|
|
|
|
|
|
this.castShadow = false;
|
|
@@ -68,15 +68,7 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
m1.extractRotation( this.matrix );
|
|
|
|
|
|
- if ( this.useQuaternion === true ) {
|
|
|
-
|
|
|
- this.quaternion.setFromRotationMatrix( m1 );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- this.rotation.setFromRotationMatrix( m1, this.rotation.order );
|
|
|
-
|
|
|
- }
|
|
|
+ this.quaternion.setFromRotationMatrix( m1 );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -94,18 +86,7 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
q1.setFromAxisAngle( axis, angle );
|
|
|
|
|
|
- if ( this.useQuaternion === true ) {
|
|
|
-
|
|
|
- this.quaternion.multiply( q1 );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- q2.setFromEuler( this.rotation );
|
|
|
- q2.multiply( q1 );
|
|
|
-
|
|
|
- this.rotation.setFromQuaternion( q2, this.rotation.order );
|
|
|
-
|
|
|
- }
|
|
|
+ this.quaternion.multiply( q1 );
|
|
|
|
|
|
return this;
|
|
|
|
|
@@ -124,15 +105,7 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
v1.copy( axis );
|
|
|
|
|
|
- if ( this.useQuaternion === true ) {
|
|
|
-
|
|
|
- v1.applyQuaternion( this.quaternion );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- v1.applyEuler( this.rotation );
|
|
|
-
|
|
|
- }
|
|
|
+ v1.applyQuaternion( this.quaternion );
|
|
|
|
|
|
this.position.add( v1.multiplyScalar( distance ) );
|
|
|
|
|
@@ -213,15 +186,7 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
m1.lookAt( vector, this.position, this.up );
|
|
|
|
|
|
- if ( this.useQuaternion === true ) {
|
|
|
-
|
|
|
- this.quaternion.setFromRotationMatrix( m1 );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- this.rotation.setFromRotationMatrix( m1, this.rotation.order );
|
|
|
-
|
|
|
- }
|
|
|
+ this.quaternion.setFromRotationMatrix( m1 );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -393,17 +358,7 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
updateMatrix: function () {
|
|
|
|
|
|
- // if we are not using a quaternion directly, convert Euler rotation to this.quaternion.
|
|
|
-
|
|
|
- if ( this.useQuaternion === false ) {
|
|
|
-
|
|
|
- this.matrix.makeFromPositionEulerScale( this.position, this.rotation, this.scale );
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- this.matrix.makeFromPositionQuaternionScale( this.position, this.quaternion, this.scale );
|
|
|
-
|
|
|
- }
|
|
|
+ this.matrix.makeFromPositionQuaternionScale( this.position, this.quaternion, this.scale );
|
|
|
|
|
|
this.matrixWorldNeedsUpdate = true;
|
|
|
|
|
@@ -450,7 +405,8 @@ THREE.Object3D.prototype = {
|
|
|
object.up.copy( this.up );
|
|
|
|
|
|
object.position.copy( this.position );
|
|
|
- if ( object.rotation instanceof THREE.Euler ) object.rotation.copy( this.rotation ); // because of Sprite madness
|
|
|
+ object.quaternion.copy( this.quaternion );
|
|
|
+ object.rotation = new THREE.Rotation( object.quaternion );
|
|
|
object.scale.copy( this.scale );
|
|
|
|
|
|
object.renderDepth = this.renderDepth;
|
|
@@ -463,9 +419,6 @@ THREE.Object3D.prototype = {
|
|
|
object.matrixAutoUpdate = this.matrixAutoUpdate;
|
|
|
object.matrixWorldNeedsUpdate = this.matrixWorldNeedsUpdate;
|
|
|
|
|
|
- object.quaternion.copy( this.quaternion );
|
|
|
- object.useQuaternion = this.useQuaternion;
|
|
|
-
|
|
|
object.visible = this.visible;
|
|
|
|
|
|
object.castShadow = this.castShadow;
|