|
@@ -2,6 +2,7 @@
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author mikael emtinger / http://gomo.se/
|
|
* @author mikael emtinger / http://gomo.se/
|
|
* @author alteredq / http://alteredqualia.com/
|
|
* @author alteredq / http://alteredqualia.com/
|
|
|
|
+ * @author WestLangley / http://github.com/WestLangley
|
|
*/
|
|
*/
|
|
|
|
|
|
THREE.Object3D = function () {
|
|
THREE.Object3D = function () {
|
|
@@ -51,18 +52,33 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
constructor: THREE.Object3D,
|
|
constructor: THREE.Object3D,
|
|
|
|
|
|
- applyMatrix: function ( matrix ) {
|
|
|
|
|
|
+ applyMatrix: function () {
|
|
|
|
|
|
- this.matrix.multiplyMatrices( matrix, this.matrix );
|
|
|
|
|
|
+ var m1 = new THREE.Matrix4();
|
|
|
|
|
|
- this.scale.getScaleFromMatrix( this.matrix );
|
|
|
|
|
|
+ return function ( matrix ) {
|
|
|
|
|
|
- var mat = new THREE.Matrix4().extractRotation( this.matrix );
|
|
|
|
- this.rotation.setEulerFromRotationMatrix( mat, this.eulerOrder );
|
|
|
|
|
|
+ this.matrix.multiplyMatrices( matrix, this.matrix );
|
|
|
|
|
|
- this.position.getPositionFromMatrix( this.matrix );
|
|
|
|
|
|
+ this.position.getPositionFromMatrix( this.matrix );
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ this.scale.getScaleFromMatrix( this.matrix );
|
|
|
|
+
|
|
|
|
+ m1.extractRotation( this.matrix );
|
|
|
|
+
|
|
|
|
+ if ( this.useQuaternion === true ) {
|
|
|
|
+
|
|
|
|
+ this.quaternion.setFromRotationMatrix( m1 );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }(),
|
|
|
|
|
|
translate: function ( distance, axis ) {
|
|
translate: function ( distance, axis ) {
|
|
|
|
|
|
@@ -95,33 +111,41 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- worldToLocal: function ( vector ) {
|
|
|
|
|
|
+ worldToLocal: function () {
|
|
|
|
|
|
- return vector.applyMatrix4( THREE.Object3D.__m1.getInverse( this.matrixWorld ) );
|
|
|
|
|
|
+ var m1 = new THREE.Matrix4();
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ return function ( vector ) {
|
|
|
|
+
|
|
|
|
+ return vector.applyMatrix4( m1.getInverse( this.matrixWorld ) );
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
|
|
- lookAt: function ( vector ) {
|
|
|
|
|
|
+ }(),
|
|
|
|
|
|
- // TODO: Add hierarchy support.
|
|
|
|
|
|
+ lookAt: function () {
|
|
|
|
|
|
- this.matrix.lookAt( vector, this.position, this.up );
|
|
|
|
|
|
+ // This routine does not support objects with rotated and/or translated parent(s)
|
|
|
|
|
|
- if ( this.rotationAutoUpdate ) {
|
|
|
|
|
|
+ var m1 = new THREE.Matrix4();
|
|
|
|
|
|
- if ( this.useQuaternion === false ) {
|
|
|
|
|
|
+ return function ( vector ) {
|
|
|
|
|
|
- this.rotation.setEulerFromRotationMatrix( this.matrix, this.eulerOrder );
|
|
|
|
|
|
+ m1.lookAt( vector, this.position, this.up );
|
|
|
|
+
|
|
|
|
+ if ( this.useQuaternion === true ) {
|
|
|
|
+
|
|
|
|
+ this.quaternion.setFromRotationMatrix( m1 );
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- this.quaternion.copy( this.matrix.decompose()[ 1 ] );
|
|
|
|
|
|
+ this.rotation.setEulerFromRotationMatrix( m1, this.eulerOrder );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
|
|
|
+ }(),
|
|
|
|
|
|
add: function ( object ) {
|
|
add: function ( object ) {
|
|
|
|
|
|
@@ -353,7 +377,6 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
-THREE.Object3D.__m1 = new THREE.Matrix4();
|
|
|
|
THREE.Object3D.defaultEulerOrder = 'XYZ',
|
|
THREE.Object3D.defaultEulerOrder = 'XYZ',
|
|
|
|
|
|
THREE.Object3DIdCount = 0;
|
|
THREE.Object3DIdCount = 0;
|