|
@@ -750,11 +750,17 @@ Object.assign( Vector2.prototype, {
|
|
|
|
|
|
clampScalar: function () {
|
|
|
|
|
|
- var min = new Vector2();
|
|
|
- var max = new Vector2();
|
|
|
+ var min, max;
|
|
|
|
|
|
return function clampScalar( minVal, maxVal ) {
|
|
|
|
|
|
+ if ( min === undefined ) {
|
|
|
+
|
|
|
+ min = new Vector2();
|
|
|
+ max = new Vector2();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
min.set( minVal, minVal );
|
|
|
max.set( maxVal, maxVal );
|
|
|
|
|
@@ -2313,8 +2319,7 @@ Object.assign( Quaternion.prototype, {
|
|
|
|
|
|
// assumes direction vectors vFrom and vTo are normalized
|
|
|
|
|
|
- var v1 = new Vector3();
|
|
|
- var r;
|
|
|
+ var v1, r;
|
|
|
|
|
|
var EPS = 0.000001;
|
|
|
|
|
@@ -2800,7 +2805,7 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
applyEuler: function () {
|
|
|
|
|
|
- var quaternion = new Quaternion();
|
|
|
+ var quaternion;
|
|
|
|
|
|
return function applyEuler( euler ) {
|
|
|
|
|
@@ -2810,6 +2815,8 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( quaternion === undefined ) quaternion = new Quaternion();
|
|
|
+
|
|
|
return this.applyQuaternion( quaternion.setFromEuler( euler ) );
|
|
|
|
|
|
};
|
|
@@ -2818,10 +2825,12 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
applyAxisAngle: function () {
|
|
|
|
|
|
- var quaternion = new Quaternion();
|
|
|
+ var quaternion;
|
|
|
|
|
|
return function applyAxisAngle( axis, angle ) {
|
|
|
|
|
|
+ if ( quaternion === undefined ) quaternion = new Quaternion();
|
|
|
+
|
|
|
return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
|
|
|
|
|
|
};
|
|
@@ -2879,10 +2888,12 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
project: function () {
|
|
|
|
|
|
- var matrix = new Matrix4();
|
|
|
+ var matrix;
|
|
|
|
|
|
return function project( camera ) {
|
|
|
|
|
|
+ if ( matrix === undefined ) matrix = new Matrix4();
|
|
|
+
|
|
|
matrix.multiplyMatrices( camera.projectionMatrix, matrix.getInverse( camera.matrixWorld ) );
|
|
|
return this.applyMatrix4( matrix );
|
|
|
|
|
@@ -2892,10 +2903,12 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
unproject: function () {
|
|
|
|
|
|
- var matrix = new Matrix4();
|
|
|
+ var matrix;
|
|
|
|
|
|
return function unproject( camera ) {
|
|
|
|
|
|
+ if ( matrix === undefined ) matrix = new Matrix4();
|
|
|
+
|
|
|
matrix.multiplyMatrices( camera.matrixWorld, matrix.getInverse( camera.projectionMatrix ) );
|
|
|
return this.applyMatrix4( matrix );
|
|
|
|
|
@@ -2969,11 +2982,17 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
clampScalar: function () {
|
|
|
|
|
|
- var min = new Vector3();
|
|
|
- var max = new Vector3();
|
|
|
+ var min, max;
|
|
|
|
|
|
return function clampScalar( minVal, maxVal ) {
|
|
|
|
|
|
+ if ( min === undefined ) {
|
|
|
+
|
|
|
+ min = new Vector3();
|
|
|
+ max = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
min.set( minVal, minVal, minVal );
|
|
|
max.set( maxVal, maxVal, maxVal );
|
|
|
|
|
@@ -3137,10 +3156,12 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
projectOnPlane: function () {
|
|
|
|
|
|
- var v1 = new Vector3();
|
|
|
+ var v1;
|
|
|
|
|
|
return function projectOnPlane( planeNormal ) {
|
|
|
|
|
|
+ if ( v1 === undefined ) v1 = new Vector3();
|
|
|
+
|
|
|
v1.copy( this ).projectOnVector( planeNormal );
|
|
|
|
|
|
return this.sub( v1 );
|
|
@@ -3154,10 +3175,12 @@ Object.assign( Vector3.prototype, {
|
|
|
// reflect incident vector off plane orthogonal to normal
|
|
|
// normal is assumed to have unit length
|
|
|
|
|
|
- var v1 = new Vector3();
|
|
|
+ var v1;
|
|
|
|
|
|
return function reflect( normal ) {
|
|
|
|
|
|
+ if ( v1 === undefined ) v1 = new Vector3();
|
|
|
+
|
|
|
return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
|
|
|
|
|
|
};
|
|
@@ -3413,10 +3436,12 @@ Object.assign( Matrix4.prototype, {
|
|
|
|
|
|
extractRotation: function () {
|
|
|
|
|
|
- var v1 = new Vector3();
|
|
|
+ var v1;
|
|
|
|
|
|
return function extractRotation( m ) {
|
|
|
|
|
|
+ if ( v1 === undefined ) v1 = new Vector3();
|
|
|
+
|
|
|
var te = this.elements;
|
|
|
var me = m.elements;
|
|
|
|
|
@@ -3609,12 +3634,18 @@ Object.assign( Matrix4.prototype, {
|
|
|
|
|
|
lookAt: function () {
|
|
|
|
|
|
- var x = new Vector3();
|
|
|
- var y = new Vector3();
|
|
|
- var z = new Vector3();
|
|
|
+ var x, y, z;
|
|
|
|
|
|
return function lookAt( eye, target, up ) {
|
|
|
|
|
|
+ if ( x === undefined ) {
|
|
|
+
|
|
|
+ x = new Vector3();
|
|
|
+ y = new Vector3();
|
|
|
+ z = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var te = this.elements;
|
|
|
|
|
|
z.subVectors( eye, target );
|
|
@@ -3726,10 +3757,12 @@ Object.assign( Matrix4.prototype, {
|
|
|
|
|
|
applyToBufferAttribute: function () {
|
|
|
|
|
|
- var v1 = new Vector3();
|
|
|
+ var v1;
|
|
|
|
|
|
return function applyToBufferAttribute( attribute ) {
|
|
|
|
|
|
+ if ( v1 === undefined ) v1 = new Vector3();
|
|
|
+
|
|
|
for ( var i = 0, l = attribute.count; i < l; i ++ ) {
|
|
|
|
|
|
v1.x = attribute.getX( i );
|
|
@@ -4046,11 +4079,17 @@ Object.assign( Matrix4.prototype, {
|
|
|
|
|
|
decompose: function () {
|
|
|
|
|
|
- var vector = new Vector3();
|
|
|
- var matrix = new Matrix4();
|
|
|
+ var vector, matrix;
|
|
|
|
|
|
return function decompose( position, quaternion, scale ) {
|
|
|
|
|
|
+ if ( vector === undefined ) {
|
|
|
+
|
|
|
+ vector = new Vector3();
|
|
|
+ matrix = new Matrix4();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var te = this.elements;
|
|
|
|
|
|
var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
|
|
@@ -7934,10 +7973,12 @@ Object.assign( Box3.prototype, {
|
|
|
|
|
|
intersectsSphere: ( function () {
|
|
|
|
|
|
- var closestPoint = new Vector3();
|
|
|
+ var closestPoint;
|
|
|
|
|
|
return function intersectsSphere( sphere ) {
|
|
|
|
|
|
+ if ( closestPoint === undefined ) closestPoint = new Vector3();
|
|
|
+
|
|
|
// Find the point on the AABB closest to the sphere center.
|
|
|
this.clampPoint( sphere.center, closestPoint );
|
|
|
|
|
@@ -8132,10 +8173,12 @@ Object.assign( Sphere.prototype, {
|
|
|
|
|
|
setFromPoints: function () {
|
|
|
|
|
|
- var box = new Box3();
|
|
|
+ var box;
|
|
|
|
|
|
return function setFromPoints( points, optionalCenter ) {
|
|
|
|
|
|
+ if ( box === undefined ) box = new Box3(); // see #10547
|
|
|
+
|
|
|
var center = this.center;
|
|
|
|
|
|
if ( optionalCenter !== undefined ) {
|
|
@@ -8372,10 +8415,12 @@ Object.assign( Matrix3.prototype, {
|
|
|
|
|
|
applyToBufferAttribute: function () {
|
|
|
|
|
|
- var v1 = new Vector3();
|
|
|
+ var v1;
|
|
|
|
|
|
return function applyToBufferAttribute( attribute ) {
|
|
|
|
|
|
+ if ( v1 === undefined ) v1 = new Vector3();
|
|
|
+
|
|
|
for ( var i = 0, l = attribute.count; i < l; i ++ ) {
|
|
|
|
|
|
v1.x = attribute.getX( i );
|
|
@@ -10258,10 +10303,12 @@ Object.assign( Euler.prototype, {
|
|
|
|
|
|
setFromQuaternion: function () {
|
|
|
|
|
|
- var matrix = new Matrix4();
|
|
|
+ var matrix;
|
|
|
|
|
|
return function setFromQuaternion( q, order, update ) {
|
|
|
|
|
|
+ if ( matrix === undefined ) matrix = new Matrix4();
|
|
|
+
|
|
|
matrix.makeRotationFromQuaternion( q );
|
|
|
|
|
|
return this.setFromRotationMatrix( matrix, order, update );
|
|
@@ -11456,13 +11503,19 @@ Object.assign( Triangle.prototype, {
|
|
|
|
|
|
closestPointToPoint: function () {
|
|
|
|
|
|
- var plane = new Plane();
|
|
|
- var edgeList = [ new Line3(), new Line3(), new Line3() ];
|
|
|
- var projectedPoint = new Vector3();
|
|
|
- var closestPoint = new Vector3();
|
|
|
+ var plane, edgeList, projectedPoint, closestPoint;
|
|
|
|
|
|
return function closestPointToPoint( point, optionalTarget ) {
|
|
|
|
|
|
+ if ( plane === undefined ) {
|
|
|
+
|
|
|
+ plane = new Plane();
|
|
|
+ edgeList = [ new Line3(), new Line3(), new Line3() ];
|
|
|
+ projectedPoint = new Vector3();
|
|
|
+ closestPoint = new Vector3();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var result = optionalTarget || new Vector3();
|
|
|
var minDistance = Infinity;
|
|
|
|
|
@@ -12493,10 +12546,12 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// rotate geometry around world x-axis
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function rotateX( angle ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeRotationX( angle );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -12511,10 +12566,12 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// rotate geometry around world y-axis
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function rotateY( angle ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeRotationY( angle );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -12529,10 +12586,12 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// rotate geometry around world z-axis
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function rotateZ( angle ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeRotationZ( angle );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -12547,10 +12606,12 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// translate geometry
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function translate( x, y, z ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeTranslation( x, y, z );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -12565,10 +12626,12 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// scale geometry
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function scale( x, y, z ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeScale( x, y, z );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -12581,10 +12644,12 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
lookAt: function () {
|
|
|
|
|
|
- var obj = new Object3D();
|
|
|
+ var obj;
|
|
|
|
|
|
return function lookAt( vector ) {
|
|
|
|
|
|
+ if ( obj === undefined ) obj = new Object3D();
|
|
|
+
|
|
|
obj.lookAt( vector );
|
|
|
|
|
|
obj.updateMatrix();
|
|
@@ -13979,10 +14044,12 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// rotate geometry around world x-axis
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function rotateX( angle ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeRotationX( angle );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -13997,10 +14064,12 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// rotate geometry around world y-axis
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function rotateY( angle ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeRotationY( angle );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -14015,10 +14084,12 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// rotate geometry around world z-axis
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function rotateZ( angle ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeRotationZ( angle );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -14033,10 +14104,12 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// translate geometry
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function translate( x, y, z ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeTranslation( x, y, z );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -14051,10 +14124,12 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
// scale geometry
|
|
|
|
|
|
- var m1 = new Matrix4();
|
|
|
+ var m1;
|
|
|
|
|
|
return function scale( x, y, z ) {
|
|
|
|
|
|
+ if ( m1 === undefined ) m1 = new Matrix4();
|
|
|
+
|
|
|
m1.makeScale( x, y, z );
|
|
|
|
|
|
this.applyMatrix( m1 );
|
|
@@ -14067,10 +14142,12 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
|
|
|
|
|
|
lookAt: function () {
|
|
|
|
|
|
- var obj = new Object3D();
|
|
|
+ var obj;
|
|
|
|
|
|
return function lookAt( vector ) {
|
|
|
|
|
|
+ if ( obj === undefined ) obj = new Object3D();
|
|
|
+
|
|
|
obj.lookAt( vector );
|
|
|
|
|
|
obj.updateMatrix();
|
|
@@ -32511,12 +32588,14 @@ Object.assign( Loader.prototype, {
|
|
|
CustomBlending: CustomBlending
|
|
|
};
|
|
|
|
|
|
- var color = new Color();
|
|
|
- var textureLoader = new TextureLoader();
|
|
|
- var materialLoader = new MaterialLoader();
|
|
|
+ var color, textureLoader, materialLoader;
|
|
|
|
|
|
return function createMaterial( m, texturePath, crossOrigin ) {
|
|
|
|
|
|
+ if ( color === undefined ) color = new Color();
|
|
|
+ if ( textureLoader === undefined ) textureLoader = new TextureLoader();
|
|
|
+ if ( materialLoader === undefined ) materialLoader = new MaterialLoader();
|
|
|
+
|
|
|
// convert from old material format
|
|
|
|
|
|
var textures = {};
|