Преглед изворни кода

Eliminate redundant object creation

Instead of creating a new GC'ed object for each object we traverse,
pre-create the _box similarly to other globals. This is slightly awkward
since this needs to be done after we define the ctor.
Arseny Kapoulkine пре 5 година
родитељ
комит
43cd006f03
1 измењених фајлова са 6 додато и 6 уклоњено
  1. 6 6
      src/math/Box3.js

+ 6 - 6
src/math/Box3.js

@@ -41,6 +41,8 @@ function Box3( min, max ) {
 
 }
 
+var _box = new Box3();
+
 Object.assign( Box3.prototype, {
 
 	isBox3: true,
@@ -257,13 +259,11 @@ Object.assign( Box3.prototype, {
 
 			}
 
-			var box = new Box3();
-
-			box.copy( geometry.boundingBox );
-			box.applyMatrix4( object.matrixWorld );
+			_box.copy( geometry.boundingBox );
+			_box.applyMatrix4( object.matrixWorld );
 
-			this.expandByPoint( box.min );
-			this.expandByPoint( box.max );
+			this.expandByPoint( _box.min );
+			this.expandByPoint( _box.max );
 
 		}