|
@@ -17,9 +17,20 @@ import { TrianglesDrawMode } from '../constants.js';
|
|
*/
|
|
*/
|
|
|
|
|
|
var _object3DId = 0;
|
|
var _object3DId = 0;
|
|
-var _m1, _q1, _v1;
|
|
|
|
-var _xAxis, _yAxis, _zAxis;
|
|
|
|
-var _target, _position, _scale, _quaternion;
|
|
|
|
|
|
+
|
|
|
|
+var _v1 = new Vector3();
|
|
|
|
+var _q1 = new Quaternion();
|
|
|
|
+var _m1 = new Matrix4();
|
|
|
|
+var _target = new Vector3();
|
|
|
|
+
|
|
|
|
+var _position = new Vector3();
|
|
|
|
+var _scale = new Vector3();
|
|
|
|
+var _quaternion = new Quaternion();
|
|
|
|
+
|
|
|
|
+var _xAxis = new Vector3( 1, 0, 0 );
|
|
|
|
+var _yAxis = new Vector3( 0, 1, 0 );
|
|
|
|
+var _zAxis = new Vector3( 0, 0, 1 );
|
|
|
|
+
|
|
var _addedEvent = { type: 'added' };
|
|
var _addedEvent = { type: 'added' };
|
|
var _removedEvent = { type: 'removed' };
|
|
var _removedEvent = { type: 'removed' };
|
|
|
|
|
|
@@ -170,8 +181,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
// rotate object on axis in object space
|
|
// rotate object on axis in object space
|
|
// axis is assumed to be normalized
|
|
// axis is assumed to be normalized
|
|
|
|
|
|
- if ( _q1 === undefined ) _q1 = new Quaternion();
|
|
|
|
-
|
|
|
|
_q1.setFromAxisAngle( axis, angle );
|
|
_q1.setFromAxisAngle( axis, angle );
|
|
|
|
|
|
this.quaternion.multiply( _q1 );
|
|
this.quaternion.multiply( _q1 );
|
|
@@ -186,8 +195,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
// axis is assumed to be normalized
|
|
// axis is assumed to be normalized
|
|
// method assumes no rotated parent
|
|
// method assumes no rotated parent
|
|
|
|
|
|
- if ( _q1 === undefined ) _q1 = new Quaternion();
|
|
|
|
-
|
|
|
|
_q1.setFromAxisAngle( axis, angle );
|
|
_q1.setFromAxisAngle( axis, angle );
|
|
|
|
|
|
this.quaternion.premultiply( _q1 );
|
|
this.quaternion.premultiply( _q1 );
|
|
@@ -198,24 +205,18 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
rotateX: function ( angle ) {
|
|
rotateX: function ( angle ) {
|
|
|
|
|
|
- if ( _xAxis === undefined ) _xAxis = new Vector3( 1, 0, 0 );
|
|
|
|
-
|
|
|
|
return this.rotateOnAxis( _xAxis, angle );
|
|
return this.rotateOnAxis( _xAxis, angle );
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
rotateY: function ( angle ) {
|
|
rotateY: function ( angle ) {
|
|
|
|
|
|
- if ( _yAxis === undefined ) _yAxis = new Vector3( 0, 1, 0 );
|
|
|
|
-
|
|
|
|
return this.rotateOnAxis( _yAxis, angle );
|
|
return this.rotateOnAxis( _yAxis, angle );
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
rotateZ: function ( angle ) {
|
|
rotateZ: function ( angle ) {
|
|
|
|
|
|
- if ( _zAxis === undefined ) _zAxis = new Vector3( 0, 0, 1 );
|
|
|
|
-
|
|
|
|
return this.rotateOnAxis( _zAxis, angle );
|
|
return this.rotateOnAxis( _zAxis, angle );
|
|
|
|
|
|
},
|
|
},
|
|
@@ -225,8 +226,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
// translate object by distance along axis in object space
|
|
// translate object by distance along axis in object space
|
|
// axis is assumed to be normalized
|
|
// axis is assumed to be normalized
|
|
|
|
|
|
- if ( _v1 === undefined ) _v1 = new Vector3();
|
|
|
|
-
|
|
|
|
_v1.copy( axis ).applyQuaternion( this.quaternion );
|
|
_v1.copy( axis ).applyQuaternion( this.quaternion );
|
|
|
|
|
|
this.position.add( _v1.multiplyScalar( distance ) );
|
|
this.position.add( _v1.multiplyScalar( distance ) );
|
|
@@ -237,24 +236,18 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
translateX: function ( distance ) {
|
|
translateX: function ( distance ) {
|
|
|
|
|
|
- if ( _xAxis === undefined ) _xAxis = new Vector3( 1, 0, 0 );
|
|
|
|
-
|
|
|
|
return this.translateOnAxis( _xAxis, distance );
|
|
return this.translateOnAxis( _xAxis, distance );
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
translateY: function ( distance ) {
|
|
translateY: function ( distance ) {
|
|
|
|
|
|
- if ( _yAxis === undefined ) _yAxis = new Vector3( 0, 1, 0 );
|
|
|
|
-
|
|
|
|
return this.translateOnAxis( _yAxis, distance );
|
|
return this.translateOnAxis( _yAxis, distance );
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
translateZ: function ( distance ) {
|
|
translateZ: function ( distance ) {
|
|
|
|
|
|
- if ( _zAxis === undefined ) _zAxis = new Vector3( 0, 0, 1 );
|
|
|
|
-
|
|
|
|
return this.translateOnAxis( _zAxis, distance );
|
|
return this.translateOnAxis( _zAxis, distance );
|
|
|
|
|
|
},
|
|
},
|
|
@@ -267,8 +260,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
worldToLocal: function ( vector ) {
|
|
worldToLocal: function ( vector ) {
|
|
|
|
|
|
- if ( _m1 === undefined ) _m1 = new Matrix4();
|
|
|
|
-
|
|
|
|
return vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) );
|
|
return vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) );
|
|
|
|
|
|
},
|
|
},
|
|
@@ -277,15 +268,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
// This method does not support objects having non-uniformly-scaled parent(s)
|
|
// This method does not support objects having non-uniformly-scaled parent(s)
|
|
|
|
|
|
- if ( _target === undefined ) {
|
|
|
|
-
|
|
|
|
- _q1 = new Quaternion();
|
|
|
|
- _m1 = new Matrix4();
|
|
|
|
- _target = new Vector3();
|
|
|
|
- _position = new Vector3();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if ( x.isVector3 ) {
|
|
if ( x.isVector3 ) {
|
|
|
|
|
|
_target.copy( x );
|
|
_target.copy( x );
|
|
@@ -401,8 +383,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
// adds object as a child of this, while maintaining the object's world transform
|
|
// adds object as a child of this, while maintaining the object's world transform
|
|
|
|
|
|
- if ( _m1 === undefined ) _m1 = new Matrix4();
|
|
|
|
-
|
|
|
|
this.updateWorldMatrix( true, false );
|
|
this.updateWorldMatrix( true, false );
|
|
|
|
|
|
_m1.getInverse( this.matrixWorld );
|
|
_m1.getInverse( this.matrixWorld );
|
|
@@ -475,13 +455,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
getWorldQuaternion: function ( target ) {
|
|
getWorldQuaternion: function ( target ) {
|
|
|
|
|
|
- if ( _scale === undefined ) {
|
|
|
|
-
|
|
|
|
- _position = new Vector3();
|
|
|
|
- _scale = new Vector3();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if ( target === undefined ) {
|
|
if ( target === undefined ) {
|
|
|
|
|
|
console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );
|
|
console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );
|
|
@@ -499,12 +472,6 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
|
|
|
|
|
|
getWorldScale: function ( target ) {
|
|
getWorldScale: function ( target ) {
|
|
|
|
|
|
- if ( _quaternion === undefined ) {
|
|
|
|
-
|
|
|
|
- _position = new Vector3();
|
|
|
|
- _quaternion = new Quaternion();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
if ( target === undefined ) {
|
|
if ( target === undefined ) {
|
|
|
|
|