提交 4779db2d 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #11246 from Flightradar24/dev-revert_closure_optimisations

Revert closure optimisations
......@@ -173,10 +173,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 );
......@@ -191,10 +193,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 );
......@@ -209,10 +213,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 );
......@@ -227,10 +233,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 );
......@@ -245,10 +253,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 );
......@@ -261,10 +271,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();
......
......@@ -110,10 +110,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 );
......@@ -128,10 +130,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 );
......@@ -146,10 +150,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 );
......@@ -164,10 +170,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 );
......@@ -182,10 +190,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 );
......@@ -198,10 +208,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();
......
......@@ -106,12 +106,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 = {};
......
......@@ -308,10 +308,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 );
......
......@@ -255,10 +255,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 );
......
......@@ -92,10 +92,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 );
......
......@@ -121,10 +121,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;
......@@ -317,12 +319,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 );
......@@ -434,10 +442,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 );
......@@ -754,11 +764,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();
......
......@@ -351,8 +351,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;
......
......@@ -26,10 +26,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 ) {
......
......@@ -191,13 +191,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;
......
......@@ -268,11 +268,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 );
......
......@@ -234,7 +234,7 @@ Object.assign( Vector3.prototype, {
applyEuler: function () {
var quaternion = new Quaternion();
var quaternion;
return function applyEuler( euler ) {
......@@ -244,6 +244,8 @@ Object.assign( Vector3.prototype, {
}
if ( quaternion === undefined ) quaternion = new Quaternion();
return this.applyQuaternion( quaternion.setFromEuler( euler ) );
};
......@@ -252,10 +254,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 ) );
};
......@@ -313,10 +317,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 );
......@@ -326,10 +332,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 );
......@@ -403,11 +411,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 );
......@@ -571,10 +585,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 );
......@@ -588,10 +604,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 ) ) );
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册