浏览代码

use Tmp.Vector3

Julien Barrois 7 年之前
父节点
当前提交
814ac9e096
共有 1 个文件被更改,包括 7 次插入15 次删除
  1. 7 15
      src/Culling/babylon.boundingBox.ts

+ 7 - 15
src/Culling/babylon.boundingBox.ts

@@ -1,13 +1,5 @@
 module BABYLON {
 
-    
-    /**
-     * @hidden
-     */
-    const tempVector3Diff = new Vector3();
-    const tempVector3Min = new Vector3();
-    const tempVector3Max = new Vector3();
-
     /**
      * Class used to store bounding box information
      */
@@ -143,15 +135,15 @@
          * @returns the current bounding box
          */
         public scale(factor: number): BoundingBox {
-            tempVector3Diff.copyFrom(this.maximum).subtractInPlace(this.minimum);
-            let distance = tempVector3Diff.length() * factor;
-            tempVector3Diff.normalize();
-            let newRadius = tempVector3Diff.scaleInPlace(distance * 0.5);
+            const diff = Tmp.Vector3[0].copyFrom(this.maximum).subtractInPlace(this.minimum);
+            let distance = diff.length() * factor;
+            diff.normalize();
+            let newRadius = diff.scaleInPlace(distance * 0.5);
 
-            tempVector3Min.copyFrom(this.center).subtractInPlace(newRadius);
-            tempVector3Max.copyFrom(this.center).addInPlace(newRadius);
+            const min = Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(newRadius);
+            const max = Tmp.Vector3[2].copyFrom(this.center).addInPlace(newRadius);
 
-            this.reConstruct(tempVector3Min, tempVector3Max);
+            this.reConstruct(min, max);
 
             return this;
         }