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

文件差异内容过多而无法显示
+ 2217 - 2223
Playground/babylon.d.txt


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


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


+ 110 - 68
dist/preview release/babylon.max.js

@@ -18920,7 +18920,6 @@ var BABYLON;
 (function (BABYLON) {
     // This matrix is used as a value to reset the bounding box.
     var _identityMatrix = BABYLON.Matrix.Identity();
-    var _tempRadiusVector = new BABYLON.Vector3(0, 0, 0);
     /**
      * Class used to store bounding sphere information
      */
@@ -18933,6 +18932,8 @@ var BABYLON;
         function BoundingSphere(min, max) {
             this.center = BABYLON.Vector3.Zero();
             this.centerWorld = BABYLON.Vector3.Zero();
+            this.minimum = BABYLON.Vector3.Zero();
+            this.maximum = BABYLON.Vector3.Zero();
             this.reConstruct(min, max);
         }
         /**
@@ -18941,8 +18942,8 @@ var BABYLON;
          * @param max defines the new maximum vector (in local space)
          */
         BoundingSphere.prototype.reConstruct = function (min, max) {
-            this.minimum = min.clone();
-            this.maximum = max.clone();
+            this.minimum.copyFrom(min);
+            this.maximum.copyFrom(max);
             var distance = BABYLON.Vector3.Distance(min, max);
             BABYLON.Vector3.LerpToRef(min, max, 0.5, this.center);
             this.radius = distance * 0.5;
@@ -18956,9 +18957,9 @@ var BABYLON;
          */
         BoundingSphere.prototype.scale = function (factor) {
             var newRadius = this.radius * factor;
-            _tempRadiusVector.set(newRadius, newRadius, newRadius);
-            var min = this.center.subtract(_tempRadiusVector);
-            var max = this.center.add(_tempRadiusVector);
+            var tempRadiusVector = BABYLON.Tmp.Vector3[0].set(newRadius, newRadius, newRadius);
+            var min = BABYLON.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(tempRadiusVector);
+            var max = BABYLON.Tmp.Vector3[2].copyFrom(this.center).addInPlace(tempRadiusVector);
             this.reConstruct(min, max);
             return this;
         };
@@ -18966,8 +18967,9 @@ var BABYLON;
         /** @hidden */
         BoundingSphere.prototype._update = function (world) {
             BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
-            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, _tempRadiusVector);
-            this.radiusWorld = Math.max(Math.abs(_tempRadiusVector.x), Math.abs(_tempRadiusVector.y), Math.abs(_tempRadiusVector.z)) * this.radius;
+            var tempVector = BABYLON.Tmp.Vector3[0];
+            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, tempVector);
+            this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
         };
         /**
          * Tests if the bounding sphere is intersecting the frustum planes
@@ -19031,11 +19033,52 @@ var BABYLON;
          */
         function BoundingBox(min, max) {
             /**
+             * Gets the 8 vectors representing the bounding box in local space
+             */
+            this.vectors = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
+             * Gets the center of the bounding box in local space
+             */
+            this.center = BABYLON.Vector3.Zero();
+            /**
+             * Gets the center of the bounding box in world space
+             */
+            this.centerWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the extend size in local space
+             */
+            this.extendSize = BABYLON.Vector3.Zero();
+            /**
+             * Gets the extend size in world space
+             */
+            this.extendSizeWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the OBB (object bounding box) directions
+             */
+            this.directions = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
              * Gets the 8 vectors representing the bounding box in world space
              */
-            this.vectorsWorld = new Array();
+            this.vectorsWorld = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
+             * Gets the minimum vector in world space
+             */
+            this.minimumWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the maximum vector in world space
+             */
+            this.maximumWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the minimum vector in local space
+             */
+            this.minimum = BABYLON.Vector3.Zero();
+            /**
+             * Gets the maximum vector in local space
+             */
+            this.maximum = BABYLON.Vector3.Zero();
             this.reConstruct(min, max);
         }
+        ;
         // Methods
         /**
          * Recreates the entire bounding box from scratch
@@ -19043,19 +19086,17 @@ var BABYLON;
          * @param max defines the new maximum vector (in local space)
          */
         BoundingBox.prototype.reConstruct = function (min, max) {
-            this.minimum = min.clone();
-            this.maximum = max.clone();
+            this.minimum.copyFrom(min);
+            this.maximum.copyFrom(max);
             // Bounding vectors
-            this.vectors = [
-                this.minimum.clone(),
-                this.maximum.clone(),
-                this.minimum.clone(),
-                this.minimum.clone(),
-                this.minimum.clone(),
-                this.maximum.clone(),
-                this.maximum.clone(),
-                this.maximum.clone()
-            ];
+            this.vectors[0].copyFrom(this.minimum);
+            this.vectors[1].copyFrom(this.maximum);
+            this.vectors[2].copyFrom(this.minimum);
+            this.vectors[3].copyFrom(this.minimum);
+            this.vectors[4].copyFrom(this.minimum);
+            this.vectors[5].copyFrom(this.maximum);
+            this.vectors[6].copyFrom(this.maximum);
+            this.vectors[7].copyFrom(this.maximum);
             this.vectors[2].x = this.maximum.x;
             this.vectors[3].y = this.maximum.y;
             this.vectors[4].z = this.maximum.z;
@@ -19063,17 +19104,19 @@ var BABYLON;
             this.vectors[6].x = this.minimum.x;
             this.vectors[7].y = this.minimum.y;
             // OBB
-            this.center = this.maximum.add(this.minimum).scale(0.5);
-            this.extendSize = this.maximum.subtract(this.minimum).scale(0.5);
-            this.directions = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            this.center.copyFrom(this.maximum).addInPlace(this.minimum).scaleInPlace(0.5);
+            this.extendSize.copyFrom(this.maximum).subtractInPlace(this.minimum).scaleInPlace(0.5);
+            for (var index = 0; index < 3; index++) {
+                this.directions[index].copyFromFloats(0, 0, 0);
+            }
             // World
-            for (var index = 0; index < this.vectors.length; index++) {
-                this.vectorsWorld[index] = BABYLON.Vector3.Zero();
+            for (var index = 0; index < 8; index++) {
+                this.vectorsWorld[index].copyFromFloats(0, 0, 0);
             }
-            this.minimumWorld = BABYLON.Vector3.Zero();
-            this.maximumWorld = BABYLON.Vector3.Zero();
-            this.centerWorld = BABYLON.Vector3.Zero();
-            this.extendSizeWorld = BABYLON.Vector3.Zero();
+            this.minimumWorld.copyFromFloats(0, 0, 0);
+            this.maximumWorld.copyFromFloats(0, 0, 0);
+            this.centerWorld.copyFromFloats(0, 0, 0);
+            this.extendSizeWorld.copyFromFloats(0, 0, 0);
             this._update(this._worldMatrix || BABYLON.Matrix.Identity());
         };
         /**
@@ -19082,12 +19125,12 @@ var BABYLON;
          * @returns the current bounding box
          */
         BoundingBox.prototype.scale = function (factor) {
-            var diff = this.maximum.subtract(this.minimum);
+            var diff = BABYLON.Tmp.Vector3[0].copyFrom(this.maximum).subtractInPlace(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);
+            var newRadius = diff.scaleInPlace(distance * 0.5);
+            var min = BABYLON.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(newRadius);
+            var max = BABYLON.Tmp.Vector3[2].copyFrom(this.center).addInPlace(newRadius);
             this.reConstruct(min, max);
             return this;
         };
@@ -19111,21 +19154,11 @@ var BABYLON;
         BoundingBox.prototype._update = function (world) {
             BABYLON.Vector3.FromFloatsToRef(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, this.minimumWorld);
             BABYLON.Vector3.FromFloatsToRef(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE, this.maximumWorld);
-            for (var index = 0; index < this.vectors.length; index++) {
+            for (var index = 0; index < 8; index++) {
                 var v = this.vectorsWorld[index];
                 BABYLON.Vector3.TransformCoordinatesToRef(this.vectors[index], world, v);
-                if (v.x < this.minimumWorld.x)
-                    this.minimumWorld.x = v.x;
-                if (v.y < this.minimumWorld.y)
-                    this.minimumWorld.y = v.y;
-                if (v.z < this.minimumWorld.z)
-                    this.minimumWorld.z = v.z;
-                if (v.x > this.maximumWorld.x)
-                    this.maximumWorld.x = v.x;
-                if (v.y > this.maximumWorld.y)
-                    this.maximumWorld.y = v.y;
-                if (v.z > this.maximumWorld.z)
-                    this.maximumWorld.z = v.z;
+                this.minimumWorld.minimizeInPlace(v);
+                this.maximumWorld.maximizeInPlace(v);
             }
             // Extend
             this.maximumWorld.subtractToRef(this.minimumWorld, this.extendSizeWorld);
@@ -19294,21 +19327,31 @@ var BABYLON;
          * @param minimum min vector of the bounding box/sphere
          * @param maximum max vector of the bounding box/sphere
          */
-        function BoundingInfo(
-        /**
-         * min vector of the bounding box/sphere
-         */
-        minimum, 
-        /**
-         * max vector of the bounding box/sphere
-         */
-        maximum) {
-            this.minimum = minimum;
-            this.maximum = maximum;
+        function BoundingInfo(minimum, maximum) {
             this._isLocked = false;
             this.boundingBox = new BABYLON.BoundingBox(minimum, maximum);
             this.boundingSphere = new BABYLON.BoundingSphere(minimum, maximum);
         }
+        Object.defineProperty(BoundingInfo.prototype, "minimum", {
+            /**
+             * min vector of the bounding box/sphere
+             */
+            get: function () {
+                return this.boundingBox.minimum;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(BoundingInfo.prototype, "maximum", {
+            /**
+             * max vector of the bounding box/sphere
+             */
+            get: function () {
+                return this.boundingBox.maximum;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(BoundingInfo.prototype, "isLocked", {
             /**
              * If the info is locked and won't be updated to avoid perf overhead
@@ -19341,10 +19384,10 @@ var BABYLON;
          * @returns the current bounding info
          */
         BoundingInfo.prototype.centerOn = function (center, extend) {
-            this.minimum = center.subtract(extend);
-            this.maximum = center.add(extend);
-            this.boundingBox = new BABYLON.BoundingBox(this.minimum, this.maximum);
-            this.boundingSphere = new BABYLON.BoundingSphere(this.minimum, this.maximum);
+            var minimum = BABYLON.Tmp.Vector3[0].copyFrom(center).subtractInPlace(extend);
+            var maximum = BABYLON.Tmp.Vector3[1].copyFrom(center).addInPlace(extend);
+            this.boundingBox.reConstruct(minimum, maximum);
+            this.boundingSphere.reConstruct(minimum, maximum);
             return this;
         };
         /**
@@ -20580,9 +20623,6 @@ var BABYLON;
              * @see https://www.babylonjs-playground.com/#10OJSG#13
              */
             _this.edgesColor = new BABYLON.Color4(1, 0, 0, 1);
-            // Cache
-            _this._collisionsTransformMatrix = BABYLON.Matrix.Zero();
-            _this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
             /** @hidden */
             _this._renderId = 0;
             /** @hidden */
@@ -21601,9 +21641,11 @@ var BABYLON;
             if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider))
                 return this;
             // Transformation matrix
-            BABYLON.Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, this._collisionsScalingMatrix);
-            this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix, this._collisionsTransformMatrix);
-            this._processCollisionsForSubMeshes(collider, this._collisionsTransformMatrix);
+            var collisionsScalingMatrix = BABYLON.Tmp.Matrix[0];
+            var collisionsTransformMatrix = BABYLON.Tmp.Matrix[1];
+            BABYLON.Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
+            this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
+            this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
             return this;
         };
         // Picking

+ 110 - 68
dist/preview release/babylon.no-module.max.js

@@ -18887,7 +18887,6 @@ var BABYLON;
 (function (BABYLON) {
     // This matrix is used as a value to reset the bounding box.
     var _identityMatrix = BABYLON.Matrix.Identity();
-    var _tempRadiusVector = new BABYLON.Vector3(0, 0, 0);
     /**
      * Class used to store bounding sphere information
      */
@@ -18900,6 +18899,8 @@ var BABYLON;
         function BoundingSphere(min, max) {
             this.center = BABYLON.Vector3.Zero();
             this.centerWorld = BABYLON.Vector3.Zero();
+            this.minimum = BABYLON.Vector3.Zero();
+            this.maximum = BABYLON.Vector3.Zero();
             this.reConstruct(min, max);
         }
         /**
@@ -18908,8 +18909,8 @@ var BABYLON;
          * @param max defines the new maximum vector (in local space)
          */
         BoundingSphere.prototype.reConstruct = function (min, max) {
-            this.minimum = min.clone();
-            this.maximum = max.clone();
+            this.minimum.copyFrom(min);
+            this.maximum.copyFrom(max);
             var distance = BABYLON.Vector3.Distance(min, max);
             BABYLON.Vector3.LerpToRef(min, max, 0.5, this.center);
             this.radius = distance * 0.5;
@@ -18923,9 +18924,9 @@ var BABYLON;
          */
         BoundingSphere.prototype.scale = function (factor) {
             var newRadius = this.radius * factor;
-            _tempRadiusVector.set(newRadius, newRadius, newRadius);
-            var min = this.center.subtract(_tempRadiusVector);
-            var max = this.center.add(_tempRadiusVector);
+            var tempRadiusVector = BABYLON.Tmp.Vector3[0].set(newRadius, newRadius, newRadius);
+            var min = BABYLON.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(tempRadiusVector);
+            var max = BABYLON.Tmp.Vector3[2].copyFrom(this.center).addInPlace(tempRadiusVector);
             this.reConstruct(min, max);
             return this;
         };
@@ -18933,8 +18934,9 @@ var BABYLON;
         /** @hidden */
         BoundingSphere.prototype._update = function (world) {
             BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
-            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, _tempRadiusVector);
-            this.radiusWorld = Math.max(Math.abs(_tempRadiusVector.x), Math.abs(_tempRadiusVector.y), Math.abs(_tempRadiusVector.z)) * this.radius;
+            var tempVector = BABYLON.Tmp.Vector3[0];
+            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, tempVector);
+            this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
         };
         /**
          * Tests if the bounding sphere is intersecting the frustum planes
@@ -18998,11 +19000,52 @@ var BABYLON;
          */
         function BoundingBox(min, max) {
             /**
+             * Gets the 8 vectors representing the bounding box in local space
+             */
+            this.vectors = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
+             * Gets the center of the bounding box in local space
+             */
+            this.center = BABYLON.Vector3.Zero();
+            /**
+             * Gets the center of the bounding box in world space
+             */
+            this.centerWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the extend size in local space
+             */
+            this.extendSize = BABYLON.Vector3.Zero();
+            /**
+             * Gets the extend size in world space
+             */
+            this.extendSizeWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the OBB (object bounding box) directions
+             */
+            this.directions = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
              * Gets the 8 vectors representing the bounding box in world space
              */
-            this.vectorsWorld = new Array();
+            this.vectorsWorld = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
+             * Gets the minimum vector in world space
+             */
+            this.minimumWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the maximum vector in world space
+             */
+            this.maximumWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the minimum vector in local space
+             */
+            this.minimum = BABYLON.Vector3.Zero();
+            /**
+             * Gets the maximum vector in local space
+             */
+            this.maximum = BABYLON.Vector3.Zero();
             this.reConstruct(min, max);
         }
+        ;
         // Methods
         /**
          * Recreates the entire bounding box from scratch
@@ -19010,19 +19053,17 @@ var BABYLON;
          * @param max defines the new maximum vector (in local space)
          */
         BoundingBox.prototype.reConstruct = function (min, max) {
-            this.minimum = min.clone();
-            this.maximum = max.clone();
+            this.minimum.copyFrom(min);
+            this.maximum.copyFrom(max);
             // Bounding vectors
-            this.vectors = [
-                this.minimum.clone(),
-                this.maximum.clone(),
-                this.minimum.clone(),
-                this.minimum.clone(),
-                this.minimum.clone(),
-                this.maximum.clone(),
-                this.maximum.clone(),
-                this.maximum.clone()
-            ];
+            this.vectors[0].copyFrom(this.minimum);
+            this.vectors[1].copyFrom(this.maximum);
+            this.vectors[2].copyFrom(this.minimum);
+            this.vectors[3].copyFrom(this.minimum);
+            this.vectors[4].copyFrom(this.minimum);
+            this.vectors[5].copyFrom(this.maximum);
+            this.vectors[6].copyFrom(this.maximum);
+            this.vectors[7].copyFrom(this.maximum);
             this.vectors[2].x = this.maximum.x;
             this.vectors[3].y = this.maximum.y;
             this.vectors[4].z = this.maximum.z;
@@ -19030,17 +19071,19 @@ var BABYLON;
             this.vectors[6].x = this.minimum.x;
             this.vectors[7].y = this.minimum.y;
             // OBB
-            this.center = this.maximum.add(this.minimum).scale(0.5);
-            this.extendSize = this.maximum.subtract(this.minimum).scale(0.5);
-            this.directions = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            this.center.copyFrom(this.maximum).addInPlace(this.minimum).scaleInPlace(0.5);
+            this.extendSize.copyFrom(this.maximum).subtractInPlace(this.minimum).scaleInPlace(0.5);
+            for (var index = 0; index < 3; index++) {
+                this.directions[index].copyFromFloats(0, 0, 0);
+            }
             // World
-            for (var index = 0; index < this.vectors.length; index++) {
-                this.vectorsWorld[index] = BABYLON.Vector3.Zero();
+            for (var index = 0; index < 8; index++) {
+                this.vectorsWorld[index].copyFromFloats(0, 0, 0);
             }
-            this.minimumWorld = BABYLON.Vector3.Zero();
-            this.maximumWorld = BABYLON.Vector3.Zero();
-            this.centerWorld = BABYLON.Vector3.Zero();
-            this.extendSizeWorld = BABYLON.Vector3.Zero();
+            this.minimumWorld.copyFromFloats(0, 0, 0);
+            this.maximumWorld.copyFromFloats(0, 0, 0);
+            this.centerWorld.copyFromFloats(0, 0, 0);
+            this.extendSizeWorld.copyFromFloats(0, 0, 0);
             this._update(this._worldMatrix || BABYLON.Matrix.Identity());
         };
         /**
@@ -19049,12 +19092,12 @@ var BABYLON;
          * @returns the current bounding box
          */
         BoundingBox.prototype.scale = function (factor) {
-            var diff = this.maximum.subtract(this.minimum);
+            var diff = BABYLON.Tmp.Vector3[0].copyFrom(this.maximum).subtractInPlace(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);
+            var newRadius = diff.scaleInPlace(distance * 0.5);
+            var min = BABYLON.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(newRadius);
+            var max = BABYLON.Tmp.Vector3[2].copyFrom(this.center).addInPlace(newRadius);
             this.reConstruct(min, max);
             return this;
         };
@@ -19078,21 +19121,11 @@ var BABYLON;
         BoundingBox.prototype._update = function (world) {
             BABYLON.Vector3.FromFloatsToRef(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, this.minimumWorld);
             BABYLON.Vector3.FromFloatsToRef(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE, this.maximumWorld);
-            for (var index = 0; index < this.vectors.length; index++) {
+            for (var index = 0; index < 8; index++) {
                 var v = this.vectorsWorld[index];
                 BABYLON.Vector3.TransformCoordinatesToRef(this.vectors[index], world, v);
-                if (v.x < this.minimumWorld.x)
-                    this.minimumWorld.x = v.x;
-                if (v.y < this.minimumWorld.y)
-                    this.minimumWorld.y = v.y;
-                if (v.z < this.minimumWorld.z)
-                    this.minimumWorld.z = v.z;
-                if (v.x > this.maximumWorld.x)
-                    this.maximumWorld.x = v.x;
-                if (v.y > this.maximumWorld.y)
-                    this.maximumWorld.y = v.y;
-                if (v.z > this.maximumWorld.z)
-                    this.maximumWorld.z = v.z;
+                this.minimumWorld.minimizeInPlace(v);
+                this.maximumWorld.maximizeInPlace(v);
             }
             // Extend
             this.maximumWorld.subtractToRef(this.minimumWorld, this.extendSizeWorld);
@@ -19261,21 +19294,31 @@ var BABYLON;
          * @param minimum min vector of the bounding box/sphere
          * @param maximum max vector of the bounding box/sphere
          */
-        function BoundingInfo(
-        /**
-         * min vector of the bounding box/sphere
-         */
-        minimum, 
-        /**
-         * max vector of the bounding box/sphere
-         */
-        maximum) {
-            this.minimum = minimum;
-            this.maximum = maximum;
+        function BoundingInfo(minimum, maximum) {
             this._isLocked = false;
             this.boundingBox = new BABYLON.BoundingBox(minimum, maximum);
             this.boundingSphere = new BABYLON.BoundingSphere(minimum, maximum);
         }
+        Object.defineProperty(BoundingInfo.prototype, "minimum", {
+            /**
+             * min vector of the bounding box/sphere
+             */
+            get: function () {
+                return this.boundingBox.minimum;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(BoundingInfo.prototype, "maximum", {
+            /**
+             * max vector of the bounding box/sphere
+             */
+            get: function () {
+                return this.boundingBox.maximum;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(BoundingInfo.prototype, "isLocked", {
             /**
              * If the info is locked and won't be updated to avoid perf overhead
@@ -19308,10 +19351,10 @@ var BABYLON;
          * @returns the current bounding info
          */
         BoundingInfo.prototype.centerOn = function (center, extend) {
-            this.minimum = center.subtract(extend);
-            this.maximum = center.add(extend);
-            this.boundingBox = new BABYLON.BoundingBox(this.minimum, this.maximum);
-            this.boundingSphere = new BABYLON.BoundingSphere(this.minimum, this.maximum);
+            var minimum = BABYLON.Tmp.Vector3[0].copyFrom(center).subtractInPlace(extend);
+            var maximum = BABYLON.Tmp.Vector3[1].copyFrom(center).addInPlace(extend);
+            this.boundingBox.reConstruct(minimum, maximum);
+            this.boundingSphere.reConstruct(minimum, maximum);
             return this;
         };
         /**
@@ -20547,9 +20590,6 @@ var BABYLON;
              * @see https://www.babylonjs-playground.com/#10OJSG#13
              */
             _this.edgesColor = new BABYLON.Color4(1, 0, 0, 1);
-            // Cache
-            _this._collisionsTransformMatrix = BABYLON.Matrix.Zero();
-            _this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
             /** @hidden */
             _this._renderId = 0;
             /** @hidden */
@@ -21568,9 +21608,11 @@ var BABYLON;
             if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider))
                 return this;
             // Transformation matrix
-            BABYLON.Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, this._collisionsScalingMatrix);
-            this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix, this._collisionsTransformMatrix);
-            this._processCollisionsForSubMeshes(collider, this._collisionsTransformMatrix);
+            var collisionsScalingMatrix = BABYLON.Tmp.Matrix[0];
+            var collisionsTransformMatrix = BABYLON.Tmp.Matrix[1];
+            BABYLON.Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
+            this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
+            this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
             return this;
         };
         // Picking

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


+ 110 - 68
dist/preview release/es6.js

@@ -18887,7 +18887,6 @@ var BABYLON;
 (function (BABYLON) {
     // This matrix is used as a value to reset the bounding box.
     var _identityMatrix = BABYLON.Matrix.Identity();
-    var _tempRadiusVector = new BABYLON.Vector3(0, 0, 0);
     /**
      * Class used to store bounding sphere information
      */
@@ -18900,6 +18899,8 @@ var BABYLON;
         function BoundingSphere(min, max) {
             this.center = BABYLON.Vector3.Zero();
             this.centerWorld = BABYLON.Vector3.Zero();
+            this.minimum = BABYLON.Vector3.Zero();
+            this.maximum = BABYLON.Vector3.Zero();
             this.reConstruct(min, max);
         }
         /**
@@ -18908,8 +18909,8 @@ var BABYLON;
          * @param max defines the new maximum vector (in local space)
          */
         BoundingSphere.prototype.reConstruct = function (min, max) {
-            this.minimum = min.clone();
-            this.maximum = max.clone();
+            this.minimum.copyFrom(min);
+            this.maximum.copyFrom(max);
             var distance = BABYLON.Vector3.Distance(min, max);
             BABYLON.Vector3.LerpToRef(min, max, 0.5, this.center);
             this.radius = distance * 0.5;
@@ -18923,9 +18924,9 @@ var BABYLON;
          */
         BoundingSphere.prototype.scale = function (factor) {
             var newRadius = this.radius * factor;
-            _tempRadiusVector.set(newRadius, newRadius, newRadius);
-            var min = this.center.subtract(_tempRadiusVector);
-            var max = this.center.add(_tempRadiusVector);
+            var tempRadiusVector = BABYLON.Tmp.Vector3[0].set(newRadius, newRadius, newRadius);
+            var min = BABYLON.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(tempRadiusVector);
+            var max = BABYLON.Tmp.Vector3[2].copyFrom(this.center).addInPlace(tempRadiusVector);
             this.reConstruct(min, max);
             return this;
         };
@@ -18933,8 +18934,9 @@ var BABYLON;
         /** @hidden */
         BoundingSphere.prototype._update = function (world) {
             BABYLON.Vector3.TransformCoordinatesToRef(this.center, world, this.centerWorld);
-            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, _tempRadiusVector);
-            this.radiusWorld = Math.max(Math.abs(_tempRadiusVector.x), Math.abs(_tempRadiusVector.y), Math.abs(_tempRadiusVector.z)) * this.radius;
+            var tempVector = BABYLON.Tmp.Vector3[0];
+            BABYLON.Vector3.TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, world, tempVector);
+            this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
         };
         /**
          * Tests if the bounding sphere is intersecting the frustum planes
@@ -18998,11 +19000,52 @@ var BABYLON;
          */
         function BoundingBox(min, max) {
             /**
+             * Gets the 8 vectors representing the bounding box in local space
+             */
+            this.vectors = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
+             * Gets the center of the bounding box in local space
+             */
+            this.center = BABYLON.Vector3.Zero();
+            /**
+             * Gets the center of the bounding box in world space
+             */
+            this.centerWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the extend size in local space
+             */
+            this.extendSize = BABYLON.Vector3.Zero();
+            /**
+             * Gets the extend size in world space
+             */
+            this.extendSizeWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the OBB (object bounding box) directions
+             */
+            this.directions = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
              * Gets the 8 vectors representing the bounding box in world space
              */
-            this.vectorsWorld = new Array();
+            this.vectorsWorld = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            /**
+             * Gets the minimum vector in world space
+             */
+            this.minimumWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the maximum vector in world space
+             */
+            this.maximumWorld = BABYLON.Vector3.Zero();
+            /**
+             * Gets the minimum vector in local space
+             */
+            this.minimum = BABYLON.Vector3.Zero();
+            /**
+             * Gets the maximum vector in local space
+             */
+            this.maximum = BABYLON.Vector3.Zero();
             this.reConstruct(min, max);
         }
+        ;
         // Methods
         /**
          * Recreates the entire bounding box from scratch
@@ -19010,19 +19053,17 @@ var BABYLON;
          * @param max defines the new maximum vector (in local space)
          */
         BoundingBox.prototype.reConstruct = function (min, max) {
-            this.minimum = min.clone();
-            this.maximum = max.clone();
+            this.minimum.copyFrom(min);
+            this.maximum.copyFrom(max);
             // Bounding vectors
-            this.vectors = [
-                this.minimum.clone(),
-                this.maximum.clone(),
-                this.minimum.clone(),
-                this.minimum.clone(),
-                this.minimum.clone(),
-                this.maximum.clone(),
-                this.maximum.clone(),
-                this.maximum.clone()
-            ];
+            this.vectors[0].copyFrom(this.minimum);
+            this.vectors[1].copyFrom(this.maximum);
+            this.vectors[2].copyFrom(this.minimum);
+            this.vectors[3].copyFrom(this.minimum);
+            this.vectors[4].copyFrom(this.minimum);
+            this.vectors[5].copyFrom(this.maximum);
+            this.vectors[6].copyFrom(this.maximum);
+            this.vectors[7].copyFrom(this.maximum);
             this.vectors[2].x = this.maximum.x;
             this.vectors[3].y = this.maximum.y;
             this.vectors[4].z = this.maximum.z;
@@ -19030,17 +19071,19 @@ var BABYLON;
             this.vectors[6].x = this.minimum.x;
             this.vectors[7].y = this.minimum.y;
             // OBB
-            this.center = this.maximum.add(this.minimum).scale(0.5);
-            this.extendSize = this.maximum.subtract(this.minimum).scale(0.5);
-            this.directions = [BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero(), BABYLON.Vector3.Zero()];
+            this.center.copyFrom(this.maximum).addInPlace(this.minimum).scaleInPlace(0.5);
+            this.extendSize.copyFrom(this.maximum).subtractInPlace(this.minimum).scaleInPlace(0.5);
+            for (var index = 0; index < 3; index++) {
+                this.directions[index].copyFromFloats(0, 0, 0);
+            }
             // World
-            for (var index = 0; index < this.vectors.length; index++) {
-                this.vectorsWorld[index] = BABYLON.Vector3.Zero();
+            for (var index = 0; index < 8; index++) {
+                this.vectorsWorld[index].copyFromFloats(0, 0, 0);
             }
-            this.minimumWorld = BABYLON.Vector3.Zero();
-            this.maximumWorld = BABYLON.Vector3.Zero();
-            this.centerWorld = BABYLON.Vector3.Zero();
-            this.extendSizeWorld = BABYLON.Vector3.Zero();
+            this.minimumWorld.copyFromFloats(0, 0, 0);
+            this.maximumWorld.copyFromFloats(0, 0, 0);
+            this.centerWorld.copyFromFloats(0, 0, 0);
+            this.extendSizeWorld.copyFromFloats(0, 0, 0);
             this._update(this._worldMatrix || BABYLON.Matrix.Identity());
         };
         /**
@@ -19049,12 +19092,12 @@ var BABYLON;
          * @returns the current bounding box
          */
         BoundingBox.prototype.scale = function (factor) {
-            var diff = this.maximum.subtract(this.minimum);
+            var diff = BABYLON.Tmp.Vector3[0].copyFrom(this.maximum).subtractInPlace(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);
+            var newRadius = diff.scaleInPlace(distance * 0.5);
+            var min = BABYLON.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(newRadius);
+            var max = BABYLON.Tmp.Vector3[2].copyFrom(this.center).addInPlace(newRadius);
             this.reConstruct(min, max);
             return this;
         };
@@ -19078,21 +19121,11 @@ var BABYLON;
         BoundingBox.prototype._update = function (world) {
             BABYLON.Vector3.FromFloatsToRef(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, this.minimumWorld);
             BABYLON.Vector3.FromFloatsToRef(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE, this.maximumWorld);
-            for (var index = 0; index < this.vectors.length; index++) {
+            for (var index = 0; index < 8; index++) {
                 var v = this.vectorsWorld[index];
                 BABYLON.Vector3.TransformCoordinatesToRef(this.vectors[index], world, v);
-                if (v.x < this.minimumWorld.x)
-                    this.minimumWorld.x = v.x;
-                if (v.y < this.minimumWorld.y)
-                    this.minimumWorld.y = v.y;
-                if (v.z < this.minimumWorld.z)
-                    this.minimumWorld.z = v.z;
-                if (v.x > this.maximumWorld.x)
-                    this.maximumWorld.x = v.x;
-                if (v.y > this.maximumWorld.y)
-                    this.maximumWorld.y = v.y;
-                if (v.z > this.maximumWorld.z)
-                    this.maximumWorld.z = v.z;
+                this.minimumWorld.minimizeInPlace(v);
+                this.maximumWorld.maximizeInPlace(v);
             }
             // Extend
             this.maximumWorld.subtractToRef(this.minimumWorld, this.extendSizeWorld);
@@ -19261,21 +19294,31 @@ var BABYLON;
          * @param minimum min vector of the bounding box/sphere
          * @param maximum max vector of the bounding box/sphere
          */
-        function BoundingInfo(
-        /**
-         * min vector of the bounding box/sphere
-         */
-        minimum, 
-        /**
-         * max vector of the bounding box/sphere
-         */
-        maximum) {
-            this.minimum = minimum;
-            this.maximum = maximum;
+        function BoundingInfo(minimum, maximum) {
             this._isLocked = false;
             this.boundingBox = new BABYLON.BoundingBox(minimum, maximum);
             this.boundingSphere = new BABYLON.BoundingSphere(minimum, maximum);
         }
+        Object.defineProperty(BoundingInfo.prototype, "minimum", {
+            /**
+             * min vector of the bounding box/sphere
+             */
+            get: function () {
+                return this.boundingBox.minimum;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(BoundingInfo.prototype, "maximum", {
+            /**
+             * max vector of the bounding box/sphere
+             */
+            get: function () {
+                return this.boundingBox.maximum;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(BoundingInfo.prototype, "isLocked", {
             /**
              * If the info is locked and won't be updated to avoid perf overhead
@@ -19308,10 +19351,10 @@ var BABYLON;
          * @returns the current bounding info
          */
         BoundingInfo.prototype.centerOn = function (center, extend) {
-            this.minimum = center.subtract(extend);
-            this.maximum = center.add(extend);
-            this.boundingBox = new BABYLON.BoundingBox(this.minimum, this.maximum);
-            this.boundingSphere = new BABYLON.BoundingSphere(this.minimum, this.maximum);
+            var minimum = BABYLON.Tmp.Vector3[0].copyFrom(center).subtractInPlace(extend);
+            var maximum = BABYLON.Tmp.Vector3[1].copyFrom(center).addInPlace(extend);
+            this.boundingBox.reConstruct(minimum, maximum);
+            this.boundingSphere.reConstruct(minimum, maximum);
             return this;
         };
         /**
@@ -20547,9 +20590,6 @@ var BABYLON;
              * @see https://www.babylonjs-playground.com/#10OJSG#13
              */
             _this.edgesColor = new BABYLON.Color4(1, 0, 0, 1);
-            // Cache
-            _this._collisionsTransformMatrix = BABYLON.Matrix.Zero();
-            _this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
             /** @hidden */
             _this._renderId = 0;
             /** @hidden */
@@ -21568,9 +21608,11 @@ var BABYLON;
             if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider))
                 return this;
             // Transformation matrix
-            BABYLON.Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, this._collisionsScalingMatrix);
-            this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix, this._collisionsTransformMatrix);
-            this._processCollisionsForSubMeshes(collider, this._collisionsTransformMatrix);
+            var collisionsScalingMatrix = BABYLON.Tmp.Matrix[0];
+            var collisionsTransformMatrix = BABYLON.Tmp.Matrix[1];
+            BABYLON.Matrix.ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
+            this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
+            this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
             return this;
         };
         // Picking

+ 5 - 1
dist/preview release/gui/babylon.gui.d.ts

@@ -984,6 +984,10 @@ declare module BABYLON.GUI {
             /** Gets a boolean indicating that the control needs to update its rendering */
             readonly isDirty: boolean;
             /**
+                * Gets the current linked mesh (or null if none)
+                */
+            readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
+            /**
                 * Gets or sets a value indicating the padding to use on the left of the control
                 * @see http://doc.babylonjs.com/how_to/gui#position-and-size
                 */
@@ -1124,7 +1128,7 @@ declare module BABYLON.GUI {
             /** @hidden */
             _markMatrixAsDirty(): void;
             /** @hidden */
-            _markAsDirty(): void;
+            _markAsDirty(force?: boolean): void;
             /** @hidden */
             _markAllAsDirty(): void;
             /** @hidden */

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


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


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


+ 10 - 2
dist/preview release/gui/babylon.gui.module.d.ts

@@ -1087,6 +1087,10 @@ declare module 'babylonjs-gui/2D/controls/control' {
             /** Gets a boolean indicating that the control needs to update its rendering */
             readonly isDirty: boolean;
             /**
+                * Gets the current linked mesh (or null if none)
+                */
+            readonly linkedMesh: Nullable<AbstractMesh>;
+            /**
                 * Gets or sets a value indicating the padding to use on the left of the control
                 * @see http://doc.babylonjs.com/how_to/gui#position-and-size
                 */
@@ -1227,7 +1231,7 @@ declare module 'babylonjs-gui/2D/controls/control' {
             /** @hidden */
             _markMatrixAsDirty(): void;
             /** @hidden */
-            _markAsDirty(): void;
+            _markAsDirty(force?: boolean): void;
             /** @hidden */
             _markAllAsDirty(): void;
             /** @hidden */
@@ -3806,6 +3810,10 @@ declare module BABYLON.GUI {
             /** Gets a boolean indicating that the control needs to update its rendering */
             readonly isDirty: boolean;
             /**
+                * Gets the current linked mesh (or null if none)
+                */
+            readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
+            /**
                 * Gets or sets a value indicating the padding to use on the left of the control
                 * @see http://doc.babylonjs.com/how_to/gui#position-and-size
                 */
@@ -3946,7 +3954,7 @@ declare module BABYLON.GUI {
             /** @hidden */
             _markMatrixAsDirty(): void;
             /** @hidden */
-            _markAsDirty(): void;
+            _markAsDirty(force?: boolean): void;
             /** @hidden */
             _markAllAsDirty(): void;
             /** @hidden */

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


+ 51 - 0
dist/preview release/viewer/babylon.viewer.d.ts

@@ -70,6 +70,57 @@ declare module BabylonViewer {
     export let viewerGlobals: ViewerGlobals;
 }
 declare module BabylonViewer {
+    /**
+        * The viewer manager is the container for all viewers currently registered on this page.
+        * It is possible to have more than one viewer on a single page.
+        */
+    export class ViewerManager {
+            /**
+                * A callback that will be triggered when a new viewer was added
+                */
+            onViewerAdded: (viewer: AbstractViewer) => void;
+            /**
+                * Will notify when a new viewer was added
+                */
+            onViewerAddedObservable: BABYLON.Observable<AbstractViewer>;
+            /**
+                * Will notify when a viewer was removed (disposed)
+                */
+            onViewerRemovedObservable: BABYLON.Observable<string>;
+            constructor();
+            /**
+                * Adding a new viewer to the viewer manager and start tracking it.
+                * @param viewer the viewer to add
+                */
+            addViewer(viewer: AbstractViewer): void;
+            /**
+                * remove a viewer from the viewer manager
+                * @param viewer the viewer to remove
+                */
+            removeViewer(viewer: AbstractViewer): void;
+            /**
+                * Get a viewer by its baseId (if the container element has an ID, it is the this is. if not, a random id was assigned)
+                * @param id the id of the HTMl element (or the viewer's, if none provided)
+                */
+            getViewerById(id: string): AbstractViewer;
+            /**
+                * Get a viewer using a container element
+                * @param element the HTML element to search viewers associated with
+                */
+            getViewerByHTMLElement(element: HTMLElement): AbstractViewer | undefined;
+            /**
+                * Get a promise that will fullfil when this viewer was initialized.
+                * Since viewer initialization and template injection is asynchronous, using the promise will guaranty that
+                * you will get the viewer after everything was already configured.
+                * @param id the viewer id to find
+                */
+            getViewerPromiseById(id: string): Promise<AbstractViewer>;
+            /**
+                * dispose the manager and all of its associated viewers
+                */
+            dispose(): void;
+    }
+    export let viewerManager: ViewerManager;
 }
 declare module BabylonViewer {
     /**

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


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


+ 53 - 1
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -94,7 +94,59 @@ declare module 'babylonjs-viewer/configuration/globals' {
 }
 
 declare module 'babylonjs-viewer/viewer/viewerManager' {
-    
+    import { Observable } from 'babylonjs';
+    import { AbstractViewer } from 'babylonjs-viewer/viewer/viewer';
+    /**
+        * The viewer manager is the container for all viewers currently registered on this page.
+        * It is possible to have more than one viewer on a single page.
+        */
+    export class ViewerManager {
+            /**
+                * A callback that will be triggered when a new viewer was added
+                */
+            onViewerAdded: (viewer: AbstractViewer) => void;
+            /**
+                * Will notify when a new viewer was added
+                */
+            onViewerAddedObservable: Observable<AbstractViewer>;
+            /**
+                * Will notify when a viewer was removed (disposed)
+                */
+            onViewerRemovedObservable: Observable<string>;
+            constructor();
+            /**
+                * Adding a new viewer to the viewer manager and start tracking it.
+                * @param viewer the viewer to add
+                */
+            addViewer(viewer: AbstractViewer): void;
+            /**
+                * remove a viewer from the viewer manager
+                * @param viewer the viewer to remove
+                */
+            removeViewer(viewer: AbstractViewer): void;
+            /**
+                * Get a viewer by its baseId (if the container element has an ID, it is the this is. if not, a random id was assigned)
+                * @param id the id of the HTMl element (or the viewer's, if none provided)
+                */
+            getViewerById(id: string): AbstractViewer;
+            /**
+                * Get a viewer using a container element
+                * @param element the HTML element to search viewers associated with
+                */
+            getViewerByHTMLElement(element: HTMLElement): AbstractViewer | undefined;
+            /**
+                * Get a promise that will fullfil when this viewer was initialized.
+                * Since viewer initialization and template injection is asynchronous, using the promise will guaranty that
+                * you will get the viewer after everything was already configured.
+                * @param id the viewer id to find
+                */
+            getViewerPromiseById(id: string): Promise<AbstractViewer>;
+            /**
+                * dispose the manager and all of its associated viewers
+                */
+            dispose(): void;
+    }
+    export let viewerManager: ViewerManager;
 }
 
 declare module 'babylonjs-viewer/viewer/defaultViewer' {

+ 10 - 3
gui/src/2D/controls/control.ts

@@ -503,7 +503,7 @@ export class Control {
         }
 
         this._isVisible = value;
-        this._markAsDirty();
+        this._markAsDirty(true);
     }
 
     /** Gets a boolean indicating that the control needs to update its rendering */
@@ -512,6 +512,13 @@ export class Control {
     }
 
     /**
+     * Gets the current linked mesh (or null if none)
+     */
+    public get linkedMesh(): Nullable<AbstractMesh> {
+        return this._linkedMesh;
+    }
+
+    /**
      * Gets or sets a value indicating the padding to use on the left of the control
      * @see http://doc.babylonjs.com/how_to/gui#position-and-size
      */
@@ -890,8 +897,8 @@ export class Control {
     }
 
     /** @hidden */
-    public _markAsDirty(): void {
-        if (!this._isVisible) {
+    public _markAsDirty(force = false): void {
+        if (!this._isVisible && !force) {
             return;
         }
 

+ 4 - 8
src/Culling/babylon.boundingSphere.ts

@@ -9,7 +9,7 @@
         /**
          * Gets the center of the bounding sphere in local space
          */
-        public center: Vector3;
+        public center = Vector3.Zero();
         /**
          * Radius of the bounding sphere in local space
          */
@@ -17,7 +17,7 @@
         /**
          * Gets the center of the bounding sphere in world space
          */
-        public centerWorld: Vector3;
+        public centerWorld = Vector3.Zero();
         /**
          * Radius of the bounding sphere in world space
          */
@@ -25,11 +25,11 @@
         /**
          * Gets the minimum vector in local space
          */
-        public minimum: Vector3;
+        public minimum = Vector3.Zero();
         /**
          * Gets the maximum vector in local space
          */
-        public maximum: Vector3;
+        public maximum = Vector3.Zero();
 
         /**
          * Creates a new bounding sphere
@@ -37,10 +37,6 @@
          * @param max defines the maximum vector (in local space)
          */
         constructor(min: Vector3, max: Vector3) {
-            this.center = Vector3.Zero();
-            this.centerWorld = Vector3.Zero();
-            this.minimum = Vector3.Zero();
-            this.maximum = Vector3.Zero();
             this.reConstruct(min, max);
         }
 

+ 3 - 2
src/Mesh/babylon.abstractMesh.ts

@@ -1042,9 +1042,10 @@
             if (!this.subMeshes) {
                 return this;
             }
-            for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
+            let count = this.subMeshes.length;
+            for (var subIndex = 0; subIndex < count; subIndex++) {
                 var subMesh = this.subMeshes[subIndex];
-                if (!subMesh.IsGlobal) {
+                if (count > 1 || !subMesh.IsGlobal) {
                     subMesh.updateBoundingInfo(matrix);
                 }
             }

+ 1 - 1
src/Mesh/babylon.subMesh.ts

@@ -252,7 +252,7 @@
             if (!boundingInfo) {
                 return false;
             }
-            return boundingInfo.isInFrustum(frustumPlanes);
+            return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
         }
 
         /**