浏览代码

new boundingBox.centerWorld and boundingBox.extendSizeWorld

David Catuhe 8 年之前
父节点
当前提交
2b6bd17eaa

文件差异内容过多而无法显示
+ 10 - 10
dist/preview release/babylon.core.js


文件差异内容过多而无法显示
+ 3365 - 3363
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 10 - 10
dist/preview release/babylon.js


+ 9 - 4
dist/preview release/babylon.max.js

@@ -11388,6 +11388,8 @@ var BABYLON;
             }
             this.minimumWorld = BABYLON.Vector3.Zero();
             this.maximumWorld = BABYLON.Vector3.Zero();
+            this.centerWorld = BABYLON.Vector3.Zero();
+            this.extendSizeWorld = BABYLON.Vector3.Zero();
             this._update(BABYLON.Matrix.Identity());
         }
         // Methods
@@ -11417,9 +11419,12 @@ var BABYLON;
                 if (v.z > this.maximumWorld.z)
                     this.maximumWorld.z = v.z;
             }
+            // Extend
+            this.maximumWorld.subtractToRef(this.minimumWorld, this.extendSizeWorld);
+            this.extendSizeWorld.scaleInPlace(0.5);
             // OBB
-            this.maximumWorld.addToRef(this.minimumWorld, this.center);
-            this.center.scaleInPlace(0.5);
+            this.maximumWorld.addToRef(this.minimumWorld, this.centerWorld);
+            this.centerWorld.scaleInPlace(0.5);
             BABYLON.Vector3.FromFloatArrayToRef(world.m, 0, this.directions[0]);
             BABYLON.Vector3.FromFloatArrayToRef(world.m, 4, this.directions[1]);
             BABYLON.Vector3.FromFloatArrayToRef(world.m, 8, this.directions[2]);
@@ -11504,7 +11509,7 @@ var BABYLON;
 var BABYLON;
 (function (BABYLON) {
     var computeBoxExtents = function (axis, box) {
-        var p = BABYLON.Vector3.Dot(box.center, axis);
+        var p = BABYLON.Vector3.Dot(box.centerWorld, axis);
         var r0 = Math.abs(BABYLON.Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;
         var r1 = Math.abs(BABYLON.Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;
         var r2 = Math.abs(BABYLON.Vector3.Dot(box.directions[2], axis)) * box.extendSize.z;
@@ -18728,7 +18733,7 @@ var BABYLON;
                 return;
             }
             if (toBoundingCenter && target.getBoundingInfo) {
-                this._targetBoundingCenter = target.getBoundingInfo().boundingBox.center.clone();
+                this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
             }
             else {
                 this._targetBoundingCenter = null;

文件差异内容过多而无法显示
+ 3365 - 3363
dist/preview release/babylon.module.d.ts


文件差异内容过多而无法显示
+ 10 - 10
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -16,6 +16,7 @@
  - All deprecated functions and properties were removed ([deltakosh](https://github.com/deltakosh))
 
 ### Updates
+- Introduced `boundingBox.centerWorld` and `boundingBox.extendSizeWorld` ([deltakosh](https://github.com/deltakosh))
 - Improved FXAA post-process ([deltakosh](https://github.com/deltakosh))
 - Added `Light.customProjectionMatrixBuilder` to allow developers to define their own projection matrix for shadows ([deltakosh](https://github.com/deltakosh))
 - Added `set()` function to all basic types ([deltakosh](https://github.com/deltakosh))

+ 1 - 1
src/Cameras/babylon.arcRotateCamera.ts

@@ -415,7 +415,7 @@ module BABYLON {
             }
             
             if (toBoundingCenter && (<any>target).getBoundingInfo){
-                this._targetBoundingCenter = (<any>target).getBoundingInfo().boundingBox.center.clone();
+                this._targetBoundingCenter = (<any>target).getBoundingInfo().boundingBox.centerWorld.clone();
             }else{
                 this._targetBoundingCenter = null;
             }

+ 11 - 2
src/Culling/babylon.boundingBox.ts

@@ -2,12 +2,15 @@
     export class BoundingBox implements ICullable {
         public vectors: Vector3[] = new Array<Vector3>();
         public center: Vector3;
+        public centerWorld: Vector3;
         public extendSize: Vector3;
+        public extendSizeWorld: Vector3;
         public directions: Vector3[];
         public vectorsWorld: Vector3[] = new Array<Vector3>();
         public minimumWorld: Vector3;
         public maximumWorld: Vector3;
 
+
         private _worldMatrix: Matrix;
 
         constructor(public minimum: Vector3, public maximum: Vector3) {
@@ -44,6 +47,8 @@
             }
             this.minimumWorld = Vector3.Zero();
             this.maximumWorld = Vector3.Zero();
+            this.centerWorld = Vector3.Zero();
+            this.extendSizeWorld = Vector3.Zero();
 
             this._update(Matrix.Identity());
         }
@@ -81,9 +86,13 @@
                     this.maximumWorld.z = v.z;
             }
 
+            // Extend
+            this.maximumWorld.subtractToRef(this.minimumWorld, this.extendSizeWorld);
+            this.extendSizeWorld.scaleInPlace(0.5);
+
             // OBB
-            this.maximumWorld.addToRef(this.minimumWorld, this.center);
-            this.center.scaleInPlace(0.5);
+            this.maximumWorld.addToRef(this.minimumWorld, this.centerWorld);
+            this.centerWorld.scaleInPlace(0.5);
 
             Vector3.FromFloatArrayToRef(world.m, 0, this.directions[0]);
             Vector3.FromFloatArrayToRef(world.m, 4, this.directions[1]);

+ 1 - 1
src/Culling/babylon.boundingInfo.ts

@@ -1,6 +1,6 @@
 module BABYLON {
     var computeBoxExtents = (axis: Vector3, box: BoundingBox) => {
-        var p = Vector3.Dot(box.center, axis);
+        var p = Vector3.Dot(box.centerWorld, axis);
 
         var r0 = Math.abs(Vector3.Dot(box.directions[0], axis)) * box.extendSize.x;
         var r1 = Math.abs(Vector3.Dot(box.directions[1], axis)) * box.extendSize.y;