Browse Source

avoid garbage collector as all costs per @gero3

Ben Houston 12 years ago
parent
commit
67fdeb97b9
2 changed files with 8 additions and 4 deletions
  1. 4 2
      src/core/Box2.js
  2. 4 2
      src/core/Box3.js

+ 4 - 2
src/core/Box2.js

@@ -63,7 +63,7 @@ THREE.Box2.prototype = {
 
 
 	setFromCenterAndSize: function ( center, size ) {
 	setFromCenterAndSize: function ( center, size ) {
 
 
-		var halfSize = new THREE.Vector2().copy( size ).multiplyScalar( 0.5 );
+		var halfSize = THREE.Box2.__v1.copy( size ).multiplyScalar( 0.5 );
 		this.min.copy( center ).subSelf( halfSize );
 		this.min.copy( center ).subSelf( halfSize );
 		this.max.copy( center ).addSelf( halfSize );
 		this.max.copy( center ).addSelf( halfSize );
 
 
@@ -217,4 +217,6 @@ THREE.Box2.prototype = {
 		return this;
 		return this;
 	}
 	}
 	
 	
-};
+};
+
+THREE.Box2.__v1 = new THREE.Vector2();

+ 4 - 2
src/core/Box3.js

@@ -70,7 +70,7 @@ THREE.Box3.prototype = {
 
 
 	setFromCenterAndSize: function ( center, size ) {
 	setFromCenterAndSize: function ( center, size ) {
 
 
-		var halfSize = new THREE.Vector3().copy( size ).multiplyScalar( 0.5 );
+		var halfSize = THREE.Box3.__v1.copy( size ).multiplyScalar( 0.5 );
 		this.min.copy( center ).subSelf( halfSize );
 		this.min.copy( center ).subSelf( halfSize );
 		this.max.copy( center ).addSelf( halfSize );
 		this.max.copy( center ).addSelf( halfSize );
 
 
@@ -230,4 +230,6 @@ THREE.Box3.prototype = {
 		return this;
 		return this;
 	}
 	}
 	
 	
-};
+};
+
+THREE.Box3.__v1 = new THREE.Vector3();