|
@@ -79,13 +79,45 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
}(),
|
|
|
|
|
|
- translate: function () {
|
|
|
+ rotateOnAxis: function() {
|
|
|
|
|
|
- var v1 = new THREE.Vector3();
|
|
|
+ // rotate object on axis in object space
|
|
|
+ // axis is assumed to be normalized
|
|
|
+
|
|
|
+ var q1 = new THREE.Quaternion();
|
|
|
+ var q2 = new THREE.Quaternion();
|
|
|
+
|
|
|
+ return function ( axis, angle ) {
|
|
|
+
|
|
|
+ q1.setFromAxisAngle( axis, angle );
|
|
|
|
|
|
- return function ( distance, axis ) {
|
|
|
+ if ( this.useQuaternion === true ) {
|
|
|
+
|
|
|
+ this.quaternion.multiply( q1 );
|
|
|
+
|
|
|
+ } else {
|
|
|
|
|
|
- // axis is assumed to be normalized
|
|
|
+ q2.setFromEuler( this.rotation, this.eulerOrder );
|
|
|
+ q2.multiply( q1 );
|
|
|
+
|
|
|
+ this.rotation.setEulerFromQuaternion( q2, this.eulerOrder );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }(),
|
|
|
+
|
|
|
+ translateOnAxis: function () {
|
|
|
+
|
|
|
+ // translate object by distance along axis in object space
|
|
|
+ // axis is assumed to be normalized
|
|
|
+
|
|
|
+ var v1 = new THREE.Vector3();
|
|
|
+
|
|
|
+ return function ( axis, distance ) {
|
|
|
|
|
|
v1.copy( axis );
|
|
|
|
|
@@ -99,23 +131,28 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
- v1.multiplyScalar( distance );
|
|
|
-
|
|
|
- this.position.add( v1 );
|
|
|
+ this.position.add( v1.multiplyScalar( distance ) );
|
|
|
|
|
|
return this;
|
|
|
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
}(),
|
|
|
|
|
|
+ translate: function ( distance, axis ) {
|
|
|
+
|
|
|
+ console.warn( 'DEPRECATED: Object3D\'s .translate() has been removed. Use .translateOnAxis( axis, distance ) instead. Note args have been changed.' );
|
|
|
+ return this.translateOnAxis( axis, distance );
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
translateX: function () {
|
|
|
|
|
|
var v1 = new THREE.Vector3( 1, 0, 0 );
|
|
|
|
|
|
return function ( distance ) {
|
|
|
|
|
|
- return this.translate( distance, v1 );
|
|
|
+ return this.translateOnAxis( v1, distance );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -127,7 +164,7 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
return function ( distance ) {
|
|
|
|
|
|
- return this.translate( distance, v1 );
|
|
|
+ return this.translateOnAxis( v1, distance );
|
|
|
|
|
|
};
|
|
|
|
|
@@ -139,7 +176,7 @@ THREE.Object3D.prototype = {
|
|
|
|
|
|
return function ( distance ) {
|
|
|
|
|
|
- return this.translate( distance, v1 );
|
|
|
+ return this.translateOnAxis( v1, distance );
|
|
|
|
|
|
};
|
|
|
|