David Catuhe 7 年之前
父节点
当前提交
42a2e40b87

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


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


+ 38 - 0
dist/preview release/babylon.max.js

@@ -18151,6 +18151,19 @@ var BABYLON;
             this.centerWorld = BABYLON.Vector3.Zero();
             this._update(BABYLON.Matrix.Identity());
         };
+        /**
+         * Scale the current bounding sphere by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        BoundingSphere.prototype.scale = function (factor) {
+            var newRadius = this.radius * factor;
+            var newRadiusVector = new BABYLON.Vector3(newRadius, newRadius, newRadius);
+            var min = this.center.subtract(newRadiusVector);
+            var max = this.center.add(newRadiusVector);
+            this.reConstruct(min, max);
+            return this;
+        };
         // Methods
         BoundingSphere.prototype._update = function (world) {
             BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
@@ -18241,6 +18254,21 @@ var BABYLON;
             this.extendSizeWorld = BABYLON.Vector3.Zero();
             this._update(this._worldMatrix || BABYLON.Matrix.Identity());
         };
+        /**
+         * Scale the current bounding box by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        BoundingBox.prototype.scale = function (factor) {
+            var diff = this.maximum.subtract(this.minimum);
+            var distance = diff.length() * factor;
+            diff.normalize();
+            var newRadius = diff.scale(distance / 2);
+            var min = this.center.subtract(newRadius);
+            var max = this.center.add(newRadius);
+            this.reConstruct(min, max);
+            return this;
+        };
         BoundingBox.prototype.getWorldMatrix = function () {
             return this._worldMatrix;
         };
@@ -18411,6 +18439,16 @@ var BABYLON;
             this.boundingSphere = new BABYLON.BoundingSphere(this.minimum, this.maximum);
             return this;
         };
+        /**
+         * Scale the current bounding info by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding info
+         */
+        BoundingInfo.prototype.scale = function (factor) {
+            this.boundingBox.scale(factor);
+            this.boundingSphere.scale(factor);
+            return this;
+        };
         BoundingInfo.prototype.isInFrustum = function (frustumPlanes) {
             if (!this.boundingSphere.isInFrustum(frustumPlanes))
                 return false;

+ 38 - 0
dist/preview release/babylon.no-module.max.js

@@ -18118,6 +18118,19 @@ var BABYLON;
             this.centerWorld = BABYLON.Vector3.Zero();
             this._update(BABYLON.Matrix.Identity());
         };
+        /**
+         * Scale the current bounding sphere by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        BoundingSphere.prototype.scale = function (factor) {
+            var newRadius = this.radius * factor;
+            var newRadiusVector = new BABYLON.Vector3(newRadius, newRadius, newRadius);
+            var min = this.center.subtract(newRadiusVector);
+            var max = this.center.add(newRadiusVector);
+            this.reConstruct(min, max);
+            return this;
+        };
         // Methods
         BoundingSphere.prototype._update = function (world) {
             BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
@@ -18208,6 +18221,21 @@ var BABYLON;
             this.extendSizeWorld = BABYLON.Vector3.Zero();
             this._update(this._worldMatrix || BABYLON.Matrix.Identity());
         };
+        /**
+         * Scale the current bounding box by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        BoundingBox.prototype.scale = function (factor) {
+            var diff = this.maximum.subtract(this.minimum);
+            var distance = diff.length() * factor;
+            diff.normalize();
+            var newRadius = diff.scale(distance / 2);
+            var min = this.center.subtract(newRadius);
+            var max = this.center.add(newRadius);
+            this.reConstruct(min, max);
+            return this;
+        };
         BoundingBox.prototype.getWorldMatrix = function () {
             return this._worldMatrix;
         };
@@ -18378,6 +18406,16 @@ var BABYLON;
             this.boundingSphere = new BABYLON.BoundingSphere(this.minimum, this.maximum);
             return this;
         };
+        /**
+         * Scale the current bounding info by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding info
+         */
+        BoundingInfo.prototype.scale = function (factor) {
+            this.boundingBox.scale(factor);
+            this.boundingSphere.scale(factor);
+            return this;
+        };
         BoundingInfo.prototype.isInFrustum = function (frustumPlanes) {
             if (!this.boundingSphere.isInFrustum(frustumPlanes))
                 return false;

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


+ 38 - 0
dist/preview release/es6.js

@@ -18118,6 +18118,19 @@ var BABYLON;
             this.centerWorld = BABYLON.Vector3.Zero();
             this._update(BABYLON.Matrix.Identity());
         };
+        /**
+         * Scale the current bounding sphere by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        BoundingSphere.prototype.scale = function (factor) {
+            var newRadius = this.radius * factor;
+            var newRadiusVector = new BABYLON.Vector3(newRadius, newRadius, newRadius);
+            var min = this.center.subtract(newRadiusVector);
+            var max = this.center.add(newRadiusVector);
+            this.reConstruct(min, max);
+            return this;
+        };
         // Methods
         BoundingSphere.prototype._update = function (world) {
             BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
@@ -18208,6 +18221,21 @@ var BABYLON;
             this.extendSizeWorld = BABYLON.Vector3.Zero();
             this._update(this._worldMatrix || BABYLON.Matrix.Identity());
         };
+        /**
+         * Scale the current bounding box by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        BoundingBox.prototype.scale = function (factor) {
+            var diff = this.maximum.subtract(this.minimum);
+            var distance = diff.length() * factor;
+            diff.normalize();
+            var newRadius = diff.scale(distance / 2);
+            var min = this.center.subtract(newRadius);
+            var max = this.center.add(newRadius);
+            this.reConstruct(min, max);
+            return this;
+        };
         BoundingBox.prototype.getWorldMatrix = function () {
             return this._worldMatrix;
         };
@@ -18378,6 +18406,16 @@ var BABYLON;
             this.boundingSphere = new BABYLON.BoundingSphere(this.minimum, this.maximum);
             return this;
         };
+        /**
+         * Scale the current bounding info by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding info
+         */
+        BoundingInfo.prototype.scale = function (factor) {
+            this.boundingBox.scale(factor);
+            this.boundingSphere.scale(factor);
+            return this;
+        };
         BoundingInfo.prototype.isInFrustum = function (frustumPlanes) {
             if (!this.boundingSphere.isInFrustum(frustumPlanes))
                 return false;

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

@@ -33,6 +33,7 @@
 
 ### Core Engine
 
+- Added new `BoundingInfo.scale()` function to let users control the size of the bounding info ([Deltakosh](https://github.com/deltakosh))
 - Added new `Animatable.waitAsync` function to use Promises with animations. Demo [Here](https://www.babylonjs-playground.com/#HZBCXR) ([Deltakosh](https://github.com/deltakosh))
 - Added the choice of [forming a closed loop](http://doc.babylonjs.com/how_to/how_to_use_curve3#catmull-rom-spline) to the catmull-rom-spline curve3 ([johnk](https://github.com/babylonjsguide))
 - Added support for specifying the center of rotation to textures ([bghgary](http://www.github.com/bghgary))

+ 19 - 0
src/Culling/babylon.boundingBox.ts

@@ -73,6 +73,25 @@
             this._update(this._worldMatrix || Matrix.Identity());
         }
 
+        /**
+         * Scale the current bounding box by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        public scale(factor: number): BoundingBox {
+            let diff = this.maximum.subtract(this.minimum);
+            let distance = diff.length() * factor;
+            diff.normalize();
+            let newRadius = diff.scale(distance / 2);
+
+            let min = this.center.subtract(newRadius);
+            let max = this.center.add(newRadius);
+
+            this.reConstruct(min, max);
+
+            return this;
+        }
+
         public getWorldMatrix(): Matrix {
             return this._worldMatrix;
         }

+ 12 - 0
src/Culling/babylon.boundingInfo.ts

@@ -70,6 +70,18 @@
             return this;
         }
 
+        /**
+         * Scale the current bounding info by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding info
+         */
+        public scale(factor: number): BoundingInfo {
+            this.boundingBox.scale(factor);
+            this.boundingSphere.scale(factor);
+
+            return this;
+        }
+
         public isInFrustum(frustumPlanes: Plane[]): boolean {
             if (!this.boundingSphere.isInFrustum(frustumPlanes))
                 return false;

+ 17 - 0
src/Culling/babylon.boundingSphere.ts

@@ -36,6 +36,23 @@
             this._update(Matrix.Identity());            
         }
 
+        /**
+         * Scale the current bounding sphere by applying a scale factor
+         * @param factor defines the scale factor to apply
+         * @returns the current bounding box
+         */
+        public scale(factor: number): BoundingSphere {
+            let newRadius = this.radius * factor;
+            let newRadiusVector = new Vector3(newRadius, newRadius, newRadius);
+
+            let min = this.center.subtract(newRadiusVector);
+            let max = this.center.add(newRadiusVector);
+
+            this.reConstruct(min, max);
+
+            return this;
+        }
+
         // Methods
         public _update(world: Matrix): void {
             Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);