Browse Source

Improve BufferGeometry closure performance

Tristan VALCKE 8 years ago
parent
commit
1be8253803
1 changed files with 6 additions and 18 deletions
  1. 6 18
      src/core/BufferGeometry.js

+ 6 - 18
src/core/BufferGeometry.js

@@ -166,12 +166,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 
 		// rotate geometry around world x-axis
 		// rotate geometry around world x-axis
 
 
-		var m1;
+		var m1 = new Matrix4();
 
 
 		return function rotateX( angle ) {
 		return function rotateX( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new Matrix4();
-
 			m1.makeRotationX( angle );
 			m1.makeRotationX( angle );
 
 
 			this.applyMatrix( m1 );
 			this.applyMatrix( m1 );
@@ -186,12 +184,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 
 		// rotate geometry around world y-axis
 		// rotate geometry around world y-axis
 
 
-		var m1;
+		var m1 = new Matrix4();
 
 
 		return function rotateY( angle ) {
 		return function rotateY( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new Matrix4();
-
 			m1.makeRotationY( angle );
 			m1.makeRotationY( angle );
 
 
 			this.applyMatrix( m1 );
 			this.applyMatrix( m1 );
@@ -206,12 +202,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 
 		// rotate geometry around world z-axis
 		// rotate geometry around world z-axis
 
 
-		var m1;
+		var m1 = new Matrix4();
 
 
 		return function rotateZ( angle ) {
 		return function rotateZ( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new Matrix4();
-
 			m1.makeRotationZ( angle );
 			m1.makeRotationZ( angle );
 
 
 			this.applyMatrix( m1 );
 			this.applyMatrix( m1 );
@@ -226,12 +220,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 
 		// translate geometry
 		// translate geometry
 
 
-		var m1;
+		var m1 = new Matrix4();
 
 
 		return function translate( x, y, z ) {
 		return function translate( x, y, z ) {
 
 
-			if ( m1 === undefined ) m1 = new Matrix4();
-
 			m1.makeTranslation( x, y, z );
 			m1.makeTranslation( x, y, z );
 
 
 			this.applyMatrix( m1 );
 			this.applyMatrix( m1 );
@@ -246,12 +238,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 
 		// scale geometry
 		// scale geometry
 
 
-		var m1;
+		var m1 = new Matrix4();
 
 
 		return function scale( x, y, z ) {
 		return function scale( x, y, z ) {
 
 
-			if ( m1 === undefined ) m1 = new Matrix4();
-
 			m1.makeScale( x, y, z );
 			m1.makeScale( x, y, z );
 
 
 			this.applyMatrix( m1 );
 			this.applyMatrix( m1 );
@@ -264,12 +254,10 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 
 	lookAt: function () {
 	lookAt: function () {
 
 
-		var obj;
+		var obj = new Object3D();
 
 
 		return function lookAt( vector ) {
 		return function lookAt( vector ) {
 
 
-			if ( obj === undefined ) obj = new Object3D();
-
 			obj.lookAt( vector );
 			obj.lookAt( vector );
 
 
 			obj.updateMatrix();
 			obj.updateMatrix();