David Catuhe 7 lat temu
rodzic
commit
3992f4a9a7

Plik diff jest za duży
+ 1939 - 1942
Playground/babylon.d.txt


Plik diff jest za duży
+ 1937 - 1944
dist/preview release/babylon.d.ts


Plik diff jest za duży
+ 1 - 1
dist/preview release/babylon.js


+ 148 - 105
dist/preview release/babylon.max.js

@@ -17651,6 +17651,12 @@ var BABYLON;
             this._currentRenderId = -1;
             this._currentRenderId = -1;
             this._parentRenderId = -1;
             this._parentRenderId = -1;
             this._childRenderId = -1;
             this._childRenderId = -1;
+            /** @hidden */
+            this._worldMatrixWasUpdated = false;
+            /** @hidden */
+            this._worldMatrix = BABYLON.Matrix.Zero();
+            /** @hidden */
+            this._worldMatrixDeterminant = 0;
             this._animationPropertiesOverride = null;
             this._animationPropertiesOverride = null;
             /**
             /**
             * An event triggered when the mesh is disposed
             * An event triggered when the mesh is disposed
@@ -17855,16 +17861,30 @@ var BABYLON;
             return null;
             return null;
         };
         };
         /**
         /**
-         * Returns the world matrix of the node
-         * @returns a matrix containing the node's world matrix
+         * Returns the latest update of the World matrix
+         * @returns a Matrix
          */
          */
         Node.prototype.getWorldMatrix = function () {
         Node.prototype.getWorldMatrix = function () {
-            return BABYLON.Matrix.Identity();
+            if (this._currentRenderId !== this.getScene().getRenderId()) {
+                this.computeWorldMatrix();
+            }
+            return this._worldMatrix;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype._getWorldMatrixDeterminant = function () {
         Node.prototype._getWorldMatrixDeterminant = function () {
-            return 1;
+            return this._worldMatrixDeterminant;
         };
         };
+        Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
+            /**
+             * Returns directly the latest state of the mesh World matrix.
+             * A Matrix is returned.
+             */
+            get: function () {
+                return this._worldMatrix;
+            },
+            enumerable: true,
+            configurable: true
+        });
         // override it in derived class if you add new variables to the cache
         // override it in derived class if you add new variables to the cache
         // and call the parent class method
         // and call the parent class method
         /** @hidden */
         /** @hidden */
@@ -17891,34 +17911,37 @@ var BABYLON;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype._markSyncedWithParent = function () {
         Node.prototype._markSyncedWithParent = function () {
-            if (this.parent) {
-                this._parentRenderId = this.parent._childRenderId;
+            if (this._parentNode) {
+                this._parentRenderId = this._parentNode._childRenderId;
             }
             }
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype.isSynchronizedWithParent = function () {
         Node.prototype.isSynchronizedWithParent = function () {
-            if (!this.parent) {
+            if (!this._parentNode) {
                 return true;
                 return true;
             }
             }
-            if (this._parentRenderId !== this.parent._childRenderId) {
+            if (this._parentRenderId !== this._parentNode._childRenderId) {
                 return false;
                 return false;
             }
             }
-            return this.parent.isSynchronized();
+            return this._parentNode.isSynchronized();
         };
         };
         /** @hidden */
         /** @hidden */
-        Node.prototype.isSynchronized = function (updateCache) {
+        Node.prototype.isSynchronized = function (useWasUpdatedFlag) {
             var check = this.hasNewParent();
             var check = this.hasNewParent();
-            check = check || !this.isSynchronizedWithParent();
+            if (!useWasUpdatedFlag) {
+                check = check || !this.isSynchronizedWithParent();
+            }
+            else if (this._parentNode) {
+                check = this._parentNode._worldMatrixWasUpdated;
+            }
             check = check || !this._isSynchronized();
             check = check || !this._isSynchronized();
-            if (updateCache)
-                this.updateCache(true);
             return !check;
             return !check;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype.hasNewParent = function () {
         Node.prototype.hasNewParent = function () {
-            if (this._cache.parent === this.parent)
+            if (this._cache.parent === this._parentNode)
                 return false;
                 return false;
-            this._cache.parent = this.parent;
+            this._cache.parent = this._parentNode;
             return true;
             return true;
         };
         };
         /**
         /**
@@ -17944,8 +17967,8 @@ var BABYLON;
             if (this._isEnabled === false) {
             if (this._isEnabled === false) {
                 return false;
                 return false;
             }
             }
-            if (this.parent !== undefined && this.parent !== null) {
-                return this.parent.isEnabled(checkAncestors);
+            if (this._parentNode !== undefined && this._parentNode !== null) {
+                return this._parentNode.isEnabled(checkAncestors);
             }
             }
             return true;
             return true;
         };
         };
@@ -18139,10 +18162,14 @@ var BABYLON;
         /**
         /**
          * Computes the world matrix of the node
          * Computes the world matrix of the node
          * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
          * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
          * @returns the world matrix
          * @returns the world matrix
          */
          */
-        Node.prototype.computeWorldMatrix = function (force) {
-            return BABYLON.Matrix.Identity();
+        Node.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            return this._worldMatrix;
         };
         };
         /**
         /**
          * Releases resources associated with this node.
          * Releases resources associated with this node.
@@ -18671,6 +18698,7 @@ var BABYLON;
             _this._right = new BABYLON.Vector3(1, 0, 0);
             _this._right = new BABYLON.Vector3(1, 0, 0);
             _this._rightInverted = new BABYLON.Vector3(-1, 0, 0);
             _this._rightInverted = new BABYLON.Vector3(-1, 0, 0);
             // Properties
             // Properties
+            _this._position = BABYLON.Vector3.Zero();
             _this._rotation = BABYLON.Vector3.Zero();
             _this._rotation = BABYLON.Vector3.Zero();
             _this._scaling = BABYLON.Vector3.One();
             _this._scaling = BABYLON.Vector3.One();
             _this._isDirty = false;
             _this._isDirty = false;
@@ -18694,12 +18722,7 @@ var BABYLON;
              * By default the system will update normals to compensate
              * By default the system will update normals to compensate
              */
              */
             _this.ignoreNonUniformScaling = false;
             _this.ignoreNonUniformScaling = false;
-            _this.position = BABYLON.Vector3.Zero();
             _this._localWorld = BABYLON.Matrix.Zero();
             _this._localWorld = BABYLON.Matrix.Zero();
-            /** @hidden */
-            _this._worldMatrix = BABYLON.Matrix.Zero();
-            /** @hidden */
-            _this._worldMatrixDeterminant = 0;
             _this._absolutePosition = BABYLON.Vector3.Zero();
             _this._absolutePosition = BABYLON.Vector3.Zero();
             _this._pivotMatrix = BABYLON.Matrix.Identity();
             _this._pivotMatrix = BABYLON.Matrix.Identity();
             _this._postMultiplyPivotMatrix = false;
             _this._postMultiplyPivotMatrix = false;
@@ -18721,44 +18744,53 @@ var BABYLON;
         TransformNode.prototype.getClassName = function () {
         TransformNode.prototype.getClassName = function () {
             return "TransformNode";
             return "TransformNode";
         };
         };
+        Object.defineProperty(TransformNode.prototype, "position", {
+            /**
+              * Gets or set the node position (default is (0.0, 0.0, 0.0))
+              */
+            get: function () {
+                return this._position;
+            },
+            set: function (newPosition) {
+                this._position = newPosition;
+                this._isDirty = true;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(TransformNode.prototype, "rotation", {
         Object.defineProperty(TransformNode.prototype, "rotation", {
             /**
             /**
-              * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
-              * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
-              * Default : (0.0, 0.0, 0.0)
+              * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z  (default is (0.0, 0.0, 0.0)).
+              * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
               */
               */
             get: function () {
             get: function () {
                 return this._rotation;
                 return this._rotation;
             },
             },
             set: function (newRotation) {
             set: function (newRotation) {
                 this._rotation = newRotation;
                 this._rotation = newRotation;
+                this._isDirty = true;
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
         Object.defineProperty(TransformNode.prototype, "scaling", {
         Object.defineProperty(TransformNode.prototype, "scaling", {
             /**
             /**
-             * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
-             * Default : (1.0, 1.0, 1.0)
+             * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
              */
              */
             get: function () {
             get: function () {
                 return this._scaling;
                 return this._scaling;
             },
             },
-            /**
-             * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
-             * Default : (1.0, 1.0, 1.0)
-            */
             set: function (newScaling) {
             set: function (newScaling) {
                 this._scaling = newScaling;
                 this._scaling = newScaling;
+                this._isDirty = true;
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
         Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
         Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
             /**
             /**
-             * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
-             * It's null by default.
-             * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
+             * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
+             * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
              */
              */
             get: function () {
             get: function () {
                 return this._rotationQuaternion;
                 return this._rotationQuaternion;
@@ -18804,31 +18836,6 @@ var BABYLON;
             configurable: true
             configurable: true
         });
         });
         /**
         /**
-         * Returns the latest update of the World matrix
-         * Returns a Matrix.
-         */
-        TransformNode.prototype.getWorldMatrix = function () {
-            if (this._currentRenderId !== this.getScene().getRenderId()) {
-                this.computeWorldMatrix();
-            }
-            return this._worldMatrix;
-        };
-        /** @hidden */
-        TransformNode.prototype._getWorldMatrixDeterminant = function () {
-            return this._worldMatrixDeterminant;
-        };
-        Object.defineProperty(TransformNode.prototype, "worldMatrixFromCache", {
-            /**
-             * Returns directly the latest state of the mesh World matrix.
-             * A Matrix is returned.
-             */
-            get: function () {
-                return this._worldMatrix;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        /**
          * Copies the parameter passed Matrix into the mesh Pose matrix.
          * Copies the parameter passed Matrix into the mesh Pose matrix.
          * Returns the TransformNode.
          * Returns the TransformNode.
          */
          */
@@ -18856,15 +18863,15 @@ var BABYLON;
             if (this.infiniteDistance) {
             if (this.infiniteDistance) {
                 return false;
                 return false;
             }
             }
-            if (!this._cache.position.equals(this.position))
+            if (!this._cache.position.equals(this._position))
                 return false;
                 return false;
             if (this._rotationQuaternion) {
             if (this._rotationQuaternion) {
                 if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion))
                 if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion))
                     return false;
                     return false;
             }
             }
-            if (!this._cache.rotation.equals(this.rotation))
+            if (!this._cache.rotation.equals(this._rotation))
                 return false;
                 return false;
-            if (!this._cache.scaling.equals(this.scaling))
+            if (!this._cache.scaling.equals(this._scaling))
                 return false;
                 return false;
             return true;
             return true;
         };
         };
@@ -19341,20 +19348,20 @@ var BABYLON;
             return this;
             return this;
         };
         };
         /**
         /**
-         * Computes the mesh World matrix and returns it.
-         * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
-         * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
-         * If the parameter `force`is set to `true`, the actual computation is done.
-         * Returns the mesh World Matrix.
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        TransformNode.prototype.computeWorldMatrix = function (force) {
+        TransformNode.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
             if (this._isWorldMatrixFrozen) {
             if (this._isWorldMatrixFrozen) {
                 return this._worldMatrix;
                 return this._worldMatrix;
             }
             }
-            if (!force && this.isSynchronized(true)) {
+            if (!force && this.isSynchronized(useWasUpdatedFlag)) {
                 this._currentRenderId = this.getScene().getRenderId();
                 this._currentRenderId = this.getScene().getRenderId();
                 return this._worldMatrix;
                 return this._worldMatrix;
             }
             }
+            this._updateCache();
             this._cache.position.copyFrom(this.position);
             this._cache.position.copyFrom(this.position);
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.pivotMatrixUpdated = false;
             this._cache.pivotMatrixUpdated = false;
@@ -19362,6 +19369,7 @@ var BABYLON;
             this._currentRenderId = this.getScene().getRenderId();
             this._currentRenderId = this.getScene().getRenderId();
             this._childRenderId = this.getScene().getRenderId();
             this._childRenderId = this.getScene().getRenderId();
             this._isDirty = false;
             this._isDirty = false;
+            this._worldMatrixWasUpdated = true;
             // Scaling
             // Scaling
             BABYLON.Matrix.ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, BABYLON.Tmp.Matrix[1]);
             BABYLON.Matrix.ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, BABYLON.Tmp.Matrix[1]);
             // Rotation
             // Rotation
@@ -19606,13 +19614,16 @@ var BABYLON;
         TransformNode._lookAtVectorCache = new BABYLON.Vector3(0, 0, 0);
         TransformNode._lookAtVectorCache = new BABYLON.Vector3(0, 0, 0);
         TransformNode._rotationAxisCache = new BABYLON.Quaternion();
         TransformNode._rotationAxisCache = new BABYLON.Quaternion();
         __decorate([
         __decorate([
-            BABYLON.serializeAsVector3()
+            BABYLON.serializeAsVector3("position")
+        ], TransformNode.prototype, "_position", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3("rotation")
         ], TransformNode.prototype, "_rotation", void 0);
         ], TransformNode.prototype, "_rotation", void 0);
         __decorate([
         __decorate([
-            BABYLON.serializeAsQuaternion()
+            BABYLON.serializeAsQuaternion("rotationQuaternion")
         ], TransformNode.prototype, "_rotationQuaternion", void 0);
         ], TransformNode.prototype, "_rotationQuaternion", void 0);
         __decorate([
         __decorate([
-            BABYLON.serializeAsVector3()
+            BABYLON.serializeAsVector3("scaling")
         ], TransformNode.prototype, "_scaling", void 0);
         ], TransformNode.prototype, "_scaling", void 0);
         __decorate([
         __decorate([
             BABYLON.serialize()
             BABYLON.serialize()
@@ -19626,9 +19637,6 @@ var BABYLON;
         __decorate([
         __decorate([
             BABYLON.serialize()
             BABYLON.serialize()
         ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
         ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
-        __decorate([
-            BABYLON.serializeAsVector3()
-        ], TransformNode.prototype, "position", void 0);
         return TransformNode;
         return TransformNode;
     }(BABYLON.Node));
     }(BABYLON.Node));
     BABYLON.TransformNode = TransformNode;
     BABYLON.TransformNode = TransformNode;
@@ -21826,24 +21834,6 @@ var BABYLON;
             return true;
             return true;
         };
         };
         /**
         /**
-         * Computes and Returns the light World matrix.
-         * @returns the world matrix
-         */
-        Light.prototype.getWorldMatrix = function () {
-            this._currentRenderId = this.getScene().getRenderId();
-            this._childRenderId = this._currentRenderId;
-            var worldMatrix = this._getWorldMatrix();
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._parentedWorldMatrix) {
-                    this._parentedWorldMatrix = BABYLON.Matrix.Identity();
-                }
-                worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
-                this._markSyncedWithParent();
-                return this._parentedWorldMatrix;
-            }
-            return worldMatrix;
-        };
-        /**
          * Sort function to order lights for rendering.
          * Sort function to order lights for rendering.
          * @param a First Light object to compare to second.
          * @param a First Light object to compare to second.
          * @param b Second Light object to compare first.
          * @param b Second Light object to compare first.
@@ -22311,7 +22301,6 @@ var BABYLON;
             _this._computedViewMatrix = BABYLON.Matrix.Identity();
             _this._computedViewMatrix = BABYLON.Matrix.Identity();
             _this._projectionMatrix = new BABYLON.Matrix();
             _this._projectionMatrix = new BABYLON.Matrix();
             _this._doNotComputeProjectionMatrix = false;
             _this._doNotComputeProjectionMatrix = false;
-            _this._worldMatrix = BABYLON.Matrix.Identity();
             _this._postProcesses = new Array();
             _this._postProcesses = new Array();
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._activeMeshes = new BABYLON.SmartArray(256);
             _this._activeMeshes = new BABYLON.SmartArray(256);
@@ -27504,6 +27493,26 @@ var BABYLON;
             this._activeMeshesFrozen = false;
             this._activeMeshesFrozen = false;
             return this;
             return this;
         };
         };
+        Scene.prototype._computeAllWorldMatricesforBranch = function (node) {
+            node.computeWorldMatrix(false, true);
+            var children = node.getChildren();
+            if (children) {
+                for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
+                    var child = children_2[_i];
+                    this._computeAllWorldMatricesforBranch(child);
+                }
+            }
+            node._worldMatrixWasUpdated = false;
+        };
+        /**
+         * This function will traverse the scene graph and makes sure that all worldMatrix are up to date
+         */
+        Scene.prototype.computeAllWorldMatrices = function () {
+            for (var _i = 0, _a = this.rootNodes; _i < _a.length; _i++) {
+                var node = _a[_i];
+                this._computeAllWorldMatricesforBranch(node);
+            }
+        };
         Scene.prototype._evaluateActiveMeshes = function () {
         Scene.prototype._evaluateActiveMeshes = function () {
             if (this._activeMeshesFrozen && this._activeMeshes.length) {
             if (this._activeMeshesFrozen && this._activeMeshes.length) {
                 return;
                 return;
@@ -27523,6 +27532,8 @@ var BABYLON;
                 var step = _a[_i];
                 var step = _a[_i];
                 step.action();
                 step.action();
             }
             }
+            // World matrices
+            this.computeAllWorldMatrices();
             // Determine mesh candidates
             // Determine mesh candidates
             var meshes = this.getActiveMeshCandidates();
             var meshes = this.getActiveMeshCandidates();
             // Check each mesh
             // Check each mesh
@@ -27536,7 +27547,6 @@ var BABYLON;
                 if (!mesh.isReady() || !mesh.isEnabled()) {
                 if (!mesh.isReady() || !mesh.isEnabled()) {
                     continue;
                     continue;
                 }
                 }
-                mesh.computeWorldMatrix();
                 // Intersections
                 // Intersections
                 if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionManager.OnIntersectionExitTrigger)) {
                 if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionManager.OnIntersectionExitTrigger)) {
                     this._meshesForIntersections.pushNoDuplicate(mesh);
                     this._meshesForIntersections.pushNoDuplicate(mesh);
@@ -34108,7 +34118,7 @@ var BABYLON;
         };
         };
         Object.defineProperty(SubMesh.prototype, "IsGlobal", {
         Object.defineProperty(SubMesh.prototype, "IsGlobal", {
             get: function () {
             get: function () {
-                return (this.verticesStart === 0 && this.verticesCount == this._mesh.getTotalVertices());
+                return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
@@ -48682,9 +48692,12 @@ var BABYLON;
             return this;
             return this;
         };
         };
         /**
         /**
-         * @hidden internal use only.
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        HemisphericLight.prototype._getWorldMatrix = function () {
+        HemisphericLight.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
             if (!this._worldMatrix) {
             if (!this._worldMatrix) {
                 this._worldMatrix = BABYLON.Matrix.Identity();
                 this._worldMatrix = BABYLON.Matrix.Identity();
             }
             }
@@ -48895,15 +48908,41 @@ var BABYLON;
         ShadowLight.prototype.forceProjectionMatrixCompute = function () {
         ShadowLight.prototype.forceProjectionMatrixCompute = function () {
             this._needProjectionMatrixCompute = true;
             this._needProjectionMatrixCompute = true;
         };
         };
+        /** @hidden */
+        ShadowLight.prototype._initCache = function () {
+            _super.prototype._initCache.call(this);
+            this._cache.position = BABYLON.Vector3.Zero();
+        };
+        /** @hidden */
+        ShadowLight.prototype._isSynchronized = function () {
+            if (!this._cache.position.equals(this.position))
+                return false;
+            return true;
+        };
         /**
         /**
-         * Get the world matrix of the sahdow lights.
-         * @hidden Internal Use Only
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        ShadowLight.prototype._getWorldMatrix = function () {
+        ShadowLight.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
+            if (!force && this.isSynchronized(useWasUpdatedFlag)) {
+                this._currentRenderId = this.getScene().getRenderId();
+                return this._worldMatrix;
+            }
+            this._updateCache();
+            this._cache.position.copyFrom(this.position);
+            this._worldMatrixWasUpdated = true;
             if (!this._worldMatrix) {
             if (!this._worldMatrix) {
                 this._worldMatrix = BABYLON.Matrix.Identity();
                 this._worldMatrix = BABYLON.Matrix.Identity();
             }
             }
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            if (this.parent && this.parent.getWorldMatrix) {
+                this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
+                this._markSyncedWithParent();
+            }
+            // Cache the determinant
+            this._worldMatrixDeterminant = this._worldMatrix.determinant();
             return this._worldMatrix;
             return this._worldMatrix;
         };
         };
         /**
         /**
@@ -109784,12 +109823,16 @@ var BABYLON;
     };
     };
     // We also need to update AbstractMesh as there is a portion of the code there
     // We also need to update AbstractMesh as there is a portion of the code there
     BABYLON.AbstractMesh.prototype._checkOcclusionQuery = function () {
     BABYLON.AbstractMesh.prototype._checkOcclusionQuery = function () {
+        if (this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_NONE) {
+            this._isOccluded = false;
+            return;
+        }
         var engine = this.getEngine();
         var engine = this.getEngine();
-        if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
+        if (engine.webGLVersion < 2) {
             this._isOccluded = false;
             this._isOccluded = false;
             return;
             return;
         }
         }
-        if (engine.webGLVersion < 2 || this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_NONE) {
+        if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
             this._isOccluded = false;
             this._isOccluded = false;
             return;
             return;
         }
         }

+ 148 - 105
dist/preview release/babylon.no-module.max.js

@@ -17618,6 +17618,12 @@ var BABYLON;
             this._currentRenderId = -1;
             this._currentRenderId = -1;
             this._parentRenderId = -1;
             this._parentRenderId = -1;
             this._childRenderId = -1;
             this._childRenderId = -1;
+            /** @hidden */
+            this._worldMatrixWasUpdated = false;
+            /** @hidden */
+            this._worldMatrix = BABYLON.Matrix.Zero();
+            /** @hidden */
+            this._worldMatrixDeterminant = 0;
             this._animationPropertiesOverride = null;
             this._animationPropertiesOverride = null;
             /**
             /**
             * An event triggered when the mesh is disposed
             * An event triggered when the mesh is disposed
@@ -17822,16 +17828,30 @@ var BABYLON;
             return null;
             return null;
         };
         };
         /**
         /**
-         * Returns the world matrix of the node
-         * @returns a matrix containing the node's world matrix
+         * Returns the latest update of the World matrix
+         * @returns a Matrix
          */
          */
         Node.prototype.getWorldMatrix = function () {
         Node.prototype.getWorldMatrix = function () {
-            return BABYLON.Matrix.Identity();
+            if (this._currentRenderId !== this.getScene().getRenderId()) {
+                this.computeWorldMatrix();
+            }
+            return this._worldMatrix;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype._getWorldMatrixDeterminant = function () {
         Node.prototype._getWorldMatrixDeterminant = function () {
-            return 1;
+            return this._worldMatrixDeterminant;
         };
         };
+        Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
+            /**
+             * Returns directly the latest state of the mesh World matrix.
+             * A Matrix is returned.
+             */
+            get: function () {
+                return this._worldMatrix;
+            },
+            enumerable: true,
+            configurable: true
+        });
         // override it in derived class if you add new variables to the cache
         // override it in derived class if you add new variables to the cache
         // and call the parent class method
         // and call the parent class method
         /** @hidden */
         /** @hidden */
@@ -17858,34 +17878,37 @@ var BABYLON;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype._markSyncedWithParent = function () {
         Node.prototype._markSyncedWithParent = function () {
-            if (this.parent) {
-                this._parentRenderId = this.parent._childRenderId;
+            if (this._parentNode) {
+                this._parentRenderId = this._parentNode._childRenderId;
             }
             }
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype.isSynchronizedWithParent = function () {
         Node.prototype.isSynchronizedWithParent = function () {
-            if (!this.parent) {
+            if (!this._parentNode) {
                 return true;
                 return true;
             }
             }
-            if (this._parentRenderId !== this.parent._childRenderId) {
+            if (this._parentRenderId !== this._parentNode._childRenderId) {
                 return false;
                 return false;
             }
             }
-            return this.parent.isSynchronized();
+            return this._parentNode.isSynchronized();
         };
         };
         /** @hidden */
         /** @hidden */
-        Node.prototype.isSynchronized = function (updateCache) {
+        Node.prototype.isSynchronized = function (useWasUpdatedFlag) {
             var check = this.hasNewParent();
             var check = this.hasNewParent();
-            check = check || !this.isSynchronizedWithParent();
+            if (!useWasUpdatedFlag) {
+                check = check || !this.isSynchronizedWithParent();
+            }
+            else if (this._parentNode) {
+                check = this._parentNode._worldMatrixWasUpdated;
+            }
             check = check || !this._isSynchronized();
             check = check || !this._isSynchronized();
-            if (updateCache)
-                this.updateCache(true);
             return !check;
             return !check;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype.hasNewParent = function () {
         Node.prototype.hasNewParent = function () {
-            if (this._cache.parent === this.parent)
+            if (this._cache.parent === this._parentNode)
                 return false;
                 return false;
-            this._cache.parent = this.parent;
+            this._cache.parent = this._parentNode;
             return true;
             return true;
         };
         };
         /**
         /**
@@ -17911,8 +17934,8 @@ var BABYLON;
             if (this._isEnabled === false) {
             if (this._isEnabled === false) {
                 return false;
                 return false;
             }
             }
-            if (this.parent !== undefined && this.parent !== null) {
-                return this.parent.isEnabled(checkAncestors);
+            if (this._parentNode !== undefined && this._parentNode !== null) {
+                return this._parentNode.isEnabled(checkAncestors);
             }
             }
             return true;
             return true;
         };
         };
@@ -18106,10 +18129,14 @@ var BABYLON;
         /**
         /**
          * Computes the world matrix of the node
          * Computes the world matrix of the node
          * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
          * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
          * @returns the world matrix
          * @returns the world matrix
          */
          */
-        Node.prototype.computeWorldMatrix = function (force) {
-            return BABYLON.Matrix.Identity();
+        Node.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            return this._worldMatrix;
         };
         };
         /**
         /**
          * Releases resources associated with this node.
          * Releases resources associated with this node.
@@ -18638,6 +18665,7 @@ var BABYLON;
             _this._right = new BABYLON.Vector3(1, 0, 0);
             _this._right = new BABYLON.Vector3(1, 0, 0);
             _this._rightInverted = new BABYLON.Vector3(-1, 0, 0);
             _this._rightInverted = new BABYLON.Vector3(-1, 0, 0);
             // Properties
             // Properties
+            _this._position = BABYLON.Vector3.Zero();
             _this._rotation = BABYLON.Vector3.Zero();
             _this._rotation = BABYLON.Vector3.Zero();
             _this._scaling = BABYLON.Vector3.One();
             _this._scaling = BABYLON.Vector3.One();
             _this._isDirty = false;
             _this._isDirty = false;
@@ -18661,12 +18689,7 @@ var BABYLON;
              * By default the system will update normals to compensate
              * By default the system will update normals to compensate
              */
              */
             _this.ignoreNonUniformScaling = false;
             _this.ignoreNonUniformScaling = false;
-            _this.position = BABYLON.Vector3.Zero();
             _this._localWorld = BABYLON.Matrix.Zero();
             _this._localWorld = BABYLON.Matrix.Zero();
-            /** @hidden */
-            _this._worldMatrix = BABYLON.Matrix.Zero();
-            /** @hidden */
-            _this._worldMatrixDeterminant = 0;
             _this._absolutePosition = BABYLON.Vector3.Zero();
             _this._absolutePosition = BABYLON.Vector3.Zero();
             _this._pivotMatrix = BABYLON.Matrix.Identity();
             _this._pivotMatrix = BABYLON.Matrix.Identity();
             _this._postMultiplyPivotMatrix = false;
             _this._postMultiplyPivotMatrix = false;
@@ -18688,44 +18711,53 @@ var BABYLON;
         TransformNode.prototype.getClassName = function () {
         TransformNode.prototype.getClassName = function () {
             return "TransformNode";
             return "TransformNode";
         };
         };
+        Object.defineProperty(TransformNode.prototype, "position", {
+            /**
+              * Gets or set the node position (default is (0.0, 0.0, 0.0))
+              */
+            get: function () {
+                return this._position;
+            },
+            set: function (newPosition) {
+                this._position = newPosition;
+                this._isDirty = true;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(TransformNode.prototype, "rotation", {
         Object.defineProperty(TransformNode.prototype, "rotation", {
             /**
             /**
-              * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
-              * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
-              * Default : (0.0, 0.0, 0.0)
+              * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z  (default is (0.0, 0.0, 0.0)).
+              * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
               */
               */
             get: function () {
             get: function () {
                 return this._rotation;
                 return this._rotation;
             },
             },
             set: function (newRotation) {
             set: function (newRotation) {
                 this._rotation = newRotation;
                 this._rotation = newRotation;
+                this._isDirty = true;
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
         Object.defineProperty(TransformNode.prototype, "scaling", {
         Object.defineProperty(TransformNode.prototype, "scaling", {
             /**
             /**
-             * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
-             * Default : (1.0, 1.0, 1.0)
+             * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
              */
              */
             get: function () {
             get: function () {
                 return this._scaling;
                 return this._scaling;
             },
             },
-            /**
-             * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
-             * Default : (1.0, 1.0, 1.0)
-            */
             set: function (newScaling) {
             set: function (newScaling) {
                 this._scaling = newScaling;
                 this._scaling = newScaling;
+                this._isDirty = true;
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
         Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
         Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
             /**
             /**
-             * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
-             * It's null by default.
-             * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
+             * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
+             * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
              */
              */
             get: function () {
             get: function () {
                 return this._rotationQuaternion;
                 return this._rotationQuaternion;
@@ -18771,31 +18803,6 @@ var BABYLON;
             configurable: true
             configurable: true
         });
         });
         /**
         /**
-         * Returns the latest update of the World matrix
-         * Returns a Matrix.
-         */
-        TransformNode.prototype.getWorldMatrix = function () {
-            if (this._currentRenderId !== this.getScene().getRenderId()) {
-                this.computeWorldMatrix();
-            }
-            return this._worldMatrix;
-        };
-        /** @hidden */
-        TransformNode.prototype._getWorldMatrixDeterminant = function () {
-            return this._worldMatrixDeterminant;
-        };
-        Object.defineProperty(TransformNode.prototype, "worldMatrixFromCache", {
-            /**
-             * Returns directly the latest state of the mesh World matrix.
-             * A Matrix is returned.
-             */
-            get: function () {
-                return this._worldMatrix;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        /**
          * Copies the parameter passed Matrix into the mesh Pose matrix.
          * Copies the parameter passed Matrix into the mesh Pose matrix.
          * Returns the TransformNode.
          * Returns the TransformNode.
          */
          */
@@ -18823,15 +18830,15 @@ var BABYLON;
             if (this.infiniteDistance) {
             if (this.infiniteDistance) {
                 return false;
                 return false;
             }
             }
-            if (!this._cache.position.equals(this.position))
+            if (!this._cache.position.equals(this._position))
                 return false;
                 return false;
             if (this._rotationQuaternion) {
             if (this._rotationQuaternion) {
                 if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion))
                 if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion))
                     return false;
                     return false;
             }
             }
-            if (!this._cache.rotation.equals(this.rotation))
+            if (!this._cache.rotation.equals(this._rotation))
                 return false;
                 return false;
-            if (!this._cache.scaling.equals(this.scaling))
+            if (!this._cache.scaling.equals(this._scaling))
                 return false;
                 return false;
             return true;
             return true;
         };
         };
@@ -19308,20 +19315,20 @@ var BABYLON;
             return this;
             return this;
         };
         };
         /**
         /**
-         * Computes the mesh World matrix and returns it.
-         * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
-         * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
-         * If the parameter `force`is set to `true`, the actual computation is done.
-         * Returns the mesh World Matrix.
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        TransformNode.prototype.computeWorldMatrix = function (force) {
+        TransformNode.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
             if (this._isWorldMatrixFrozen) {
             if (this._isWorldMatrixFrozen) {
                 return this._worldMatrix;
                 return this._worldMatrix;
             }
             }
-            if (!force && this.isSynchronized(true)) {
+            if (!force && this.isSynchronized(useWasUpdatedFlag)) {
                 this._currentRenderId = this.getScene().getRenderId();
                 this._currentRenderId = this.getScene().getRenderId();
                 return this._worldMatrix;
                 return this._worldMatrix;
             }
             }
+            this._updateCache();
             this._cache.position.copyFrom(this.position);
             this._cache.position.copyFrom(this.position);
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.pivotMatrixUpdated = false;
             this._cache.pivotMatrixUpdated = false;
@@ -19329,6 +19336,7 @@ var BABYLON;
             this._currentRenderId = this.getScene().getRenderId();
             this._currentRenderId = this.getScene().getRenderId();
             this._childRenderId = this.getScene().getRenderId();
             this._childRenderId = this.getScene().getRenderId();
             this._isDirty = false;
             this._isDirty = false;
+            this._worldMatrixWasUpdated = true;
             // Scaling
             // Scaling
             BABYLON.Matrix.ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, BABYLON.Tmp.Matrix[1]);
             BABYLON.Matrix.ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, BABYLON.Tmp.Matrix[1]);
             // Rotation
             // Rotation
@@ -19573,13 +19581,16 @@ var BABYLON;
         TransformNode._lookAtVectorCache = new BABYLON.Vector3(0, 0, 0);
         TransformNode._lookAtVectorCache = new BABYLON.Vector3(0, 0, 0);
         TransformNode._rotationAxisCache = new BABYLON.Quaternion();
         TransformNode._rotationAxisCache = new BABYLON.Quaternion();
         __decorate([
         __decorate([
-            BABYLON.serializeAsVector3()
+            BABYLON.serializeAsVector3("position")
+        ], TransformNode.prototype, "_position", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3("rotation")
         ], TransformNode.prototype, "_rotation", void 0);
         ], TransformNode.prototype, "_rotation", void 0);
         __decorate([
         __decorate([
-            BABYLON.serializeAsQuaternion()
+            BABYLON.serializeAsQuaternion("rotationQuaternion")
         ], TransformNode.prototype, "_rotationQuaternion", void 0);
         ], TransformNode.prototype, "_rotationQuaternion", void 0);
         __decorate([
         __decorate([
-            BABYLON.serializeAsVector3()
+            BABYLON.serializeAsVector3("scaling")
         ], TransformNode.prototype, "_scaling", void 0);
         ], TransformNode.prototype, "_scaling", void 0);
         __decorate([
         __decorate([
             BABYLON.serialize()
             BABYLON.serialize()
@@ -19593,9 +19604,6 @@ var BABYLON;
         __decorate([
         __decorate([
             BABYLON.serialize()
             BABYLON.serialize()
         ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
         ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
-        __decorate([
-            BABYLON.serializeAsVector3()
-        ], TransformNode.prototype, "position", void 0);
         return TransformNode;
         return TransformNode;
     }(BABYLON.Node));
     }(BABYLON.Node));
     BABYLON.TransformNode = TransformNode;
     BABYLON.TransformNode = TransformNode;
@@ -21793,24 +21801,6 @@ var BABYLON;
             return true;
             return true;
         };
         };
         /**
         /**
-         * Computes and Returns the light World matrix.
-         * @returns the world matrix
-         */
-        Light.prototype.getWorldMatrix = function () {
-            this._currentRenderId = this.getScene().getRenderId();
-            this._childRenderId = this._currentRenderId;
-            var worldMatrix = this._getWorldMatrix();
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._parentedWorldMatrix) {
-                    this._parentedWorldMatrix = BABYLON.Matrix.Identity();
-                }
-                worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
-                this._markSyncedWithParent();
-                return this._parentedWorldMatrix;
-            }
-            return worldMatrix;
-        };
-        /**
          * Sort function to order lights for rendering.
          * Sort function to order lights for rendering.
          * @param a First Light object to compare to second.
          * @param a First Light object to compare to second.
          * @param b Second Light object to compare first.
          * @param b Second Light object to compare first.
@@ -22278,7 +22268,6 @@ var BABYLON;
             _this._computedViewMatrix = BABYLON.Matrix.Identity();
             _this._computedViewMatrix = BABYLON.Matrix.Identity();
             _this._projectionMatrix = new BABYLON.Matrix();
             _this._projectionMatrix = new BABYLON.Matrix();
             _this._doNotComputeProjectionMatrix = false;
             _this._doNotComputeProjectionMatrix = false;
-            _this._worldMatrix = BABYLON.Matrix.Identity();
             _this._postProcesses = new Array();
             _this._postProcesses = new Array();
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._activeMeshes = new BABYLON.SmartArray(256);
             _this._activeMeshes = new BABYLON.SmartArray(256);
@@ -27471,6 +27460,26 @@ var BABYLON;
             this._activeMeshesFrozen = false;
             this._activeMeshesFrozen = false;
             return this;
             return this;
         };
         };
+        Scene.prototype._computeAllWorldMatricesforBranch = function (node) {
+            node.computeWorldMatrix(false, true);
+            var children = node.getChildren();
+            if (children) {
+                for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
+                    var child = children_2[_i];
+                    this._computeAllWorldMatricesforBranch(child);
+                }
+            }
+            node._worldMatrixWasUpdated = false;
+        };
+        /**
+         * This function will traverse the scene graph and makes sure that all worldMatrix are up to date
+         */
+        Scene.prototype.computeAllWorldMatrices = function () {
+            for (var _i = 0, _a = this.rootNodes; _i < _a.length; _i++) {
+                var node = _a[_i];
+                this._computeAllWorldMatricesforBranch(node);
+            }
+        };
         Scene.prototype._evaluateActiveMeshes = function () {
         Scene.prototype._evaluateActiveMeshes = function () {
             if (this._activeMeshesFrozen && this._activeMeshes.length) {
             if (this._activeMeshesFrozen && this._activeMeshes.length) {
                 return;
                 return;
@@ -27490,6 +27499,8 @@ var BABYLON;
                 var step = _a[_i];
                 var step = _a[_i];
                 step.action();
                 step.action();
             }
             }
+            // World matrices
+            this.computeAllWorldMatrices();
             // Determine mesh candidates
             // Determine mesh candidates
             var meshes = this.getActiveMeshCandidates();
             var meshes = this.getActiveMeshCandidates();
             // Check each mesh
             // Check each mesh
@@ -27503,7 +27514,6 @@ var BABYLON;
                 if (!mesh.isReady() || !mesh.isEnabled()) {
                 if (!mesh.isReady() || !mesh.isEnabled()) {
                     continue;
                     continue;
                 }
                 }
-                mesh.computeWorldMatrix();
                 // Intersections
                 // Intersections
                 if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionManager.OnIntersectionExitTrigger)) {
                 if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionManager.OnIntersectionExitTrigger)) {
                     this._meshesForIntersections.pushNoDuplicate(mesh);
                     this._meshesForIntersections.pushNoDuplicate(mesh);
@@ -34075,7 +34085,7 @@ var BABYLON;
         };
         };
         Object.defineProperty(SubMesh.prototype, "IsGlobal", {
         Object.defineProperty(SubMesh.prototype, "IsGlobal", {
             get: function () {
             get: function () {
-                return (this.verticesStart === 0 && this.verticesCount == this._mesh.getTotalVertices());
+                return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
@@ -48649,9 +48659,12 @@ var BABYLON;
             return this;
             return this;
         };
         };
         /**
         /**
-         * @hidden internal use only.
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        HemisphericLight.prototype._getWorldMatrix = function () {
+        HemisphericLight.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
             if (!this._worldMatrix) {
             if (!this._worldMatrix) {
                 this._worldMatrix = BABYLON.Matrix.Identity();
                 this._worldMatrix = BABYLON.Matrix.Identity();
             }
             }
@@ -48862,15 +48875,41 @@ var BABYLON;
         ShadowLight.prototype.forceProjectionMatrixCompute = function () {
         ShadowLight.prototype.forceProjectionMatrixCompute = function () {
             this._needProjectionMatrixCompute = true;
             this._needProjectionMatrixCompute = true;
         };
         };
+        /** @hidden */
+        ShadowLight.prototype._initCache = function () {
+            _super.prototype._initCache.call(this);
+            this._cache.position = BABYLON.Vector3.Zero();
+        };
+        /** @hidden */
+        ShadowLight.prototype._isSynchronized = function () {
+            if (!this._cache.position.equals(this.position))
+                return false;
+            return true;
+        };
         /**
         /**
-         * Get the world matrix of the sahdow lights.
-         * @hidden Internal Use Only
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        ShadowLight.prototype._getWorldMatrix = function () {
+        ShadowLight.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
+            if (!force && this.isSynchronized(useWasUpdatedFlag)) {
+                this._currentRenderId = this.getScene().getRenderId();
+                return this._worldMatrix;
+            }
+            this._updateCache();
+            this._cache.position.copyFrom(this.position);
+            this._worldMatrixWasUpdated = true;
             if (!this._worldMatrix) {
             if (!this._worldMatrix) {
                 this._worldMatrix = BABYLON.Matrix.Identity();
                 this._worldMatrix = BABYLON.Matrix.Identity();
             }
             }
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            if (this.parent && this.parent.getWorldMatrix) {
+                this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
+                this._markSyncedWithParent();
+            }
+            // Cache the determinant
+            this._worldMatrixDeterminant = this._worldMatrix.determinant();
             return this._worldMatrix;
             return this._worldMatrix;
         };
         };
         /**
         /**
@@ -109751,12 +109790,16 @@ var BABYLON;
     };
     };
     // We also need to update AbstractMesh as there is a portion of the code there
     // We also need to update AbstractMesh as there is a portion of the code there
     BABYLON.AbstractMesh.prototype._checkOcclusionQuery = function () {
     BABYLON.AbstractMesh.prototype._checkOcclusionQuery = function () {
+        if (this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_NONE) {
+            this._isOccluded = false;
+            return;
+        }
         var engine = this.getEngine();
         var engine = this.getEngine();
-        if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
+        if (engine.webGLVersion < 2) {
             this._isOccluded = false;
             this._isOccluded = false;
             return;
             return;
         }
         }
-        if (engine.webGLVersion < 2 || this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_NONE) {
+        if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
             this._isOccluded = false;
             this._isOccluded = false;
             return;
             return;
         }
         }

Plik diff jest za duży
+ 1 - 1
dist/preview release/babylon.worker.js


+ 148 - 105
dist/preview release/es6.js

@@ -17618,6 +17618,12 @@ var BABYLON;
             this._currentRenderId = -1;
             this._currentRenderId = -1;
             this._parentRenderId = -1;
             this._parentRenderId = -1;
             this._childRenderId = -1;
             this._childRenderId = -1;
+            /** @hidden */
+            this._worldMatrixWasUpdated = false;
+            /** @hidden */
+            this._worldMatrix = BABYLON.Matrix.Zero();
+            /** @hidden */
+            this._worldMatrixDeterminant = 0;
             this._animationPropertiesOverride = null;
             this._animationPropertiesOverride = null;
             /**
             /**
             * An event triggered when the mesh is disposed
             * An event triggered when the mesh is disposed
@@ -17822,16 +17828,30 @@ var BABYLON;
             return null;
             return null;
         };
         };
         /**
         /**
-         * Returns the world matrix of the node
-         * @returns a matrix containing the node's world matrix
+         * Returns the latest update of the World matrix
+         * @returns a Matrix
          */
          */
         Node.prototype.getWorldMatrix = function () {
         Node.prototype.getWorldMatrix = function () {
-            return BABYLON.Matrix.Identity();
+            if (this._currentRenderId !== this.getScene().getRenderId()) {
+                this.computeWorldMatrix();
+            }
+            return this._worldMatrix;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype._getWorldMatrixDeterminant = function () {
         Node.prototype._getWorldMatrixDeterminant = function () {
-            return 1;
+            return this._worldMatrixDeterminant;
         };
         };
+        Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
+            /**
+             * Returns directly the latest state of the mesh World matrix.
+             * A Matrix is returned.
+             */
+            get: function () {
+                return this._worldMatrix;
+            },
+            enumerable: true,
+            configurable: true
+        });
         // override it in derived class if you add new variables to the cache
         // override it in derived class if you add new variables to the cache
         // and call the parent class method
         // and call the parent class method
         /** @hidden */
         /** @hidden */
@@ -17858,34 +17878,37 @@ var BABYLON;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype._markSyncedWithParent = function () {
         Node.prototype._markSyncedWithParent = function () {
-            if (this.parent) {
-                this._parentRenderId = this.parent._childRenderId;
+            if (this._parentNode) {
+                this._parentRenderId = this._parentNode._childRenderId;
             }
             }
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype.isSynchronizedWithParent = function () {
         Node.prototype.isSynchronizedWithParent = function () {
-            if (!this.parent) {
+            if (!this._parentNode) {
                 return true;
                 return true;
             }
             }
-            if (this._parentRenderId !== this.parent._childRenderId) {
+            if (this._parentRenderId !== this._parentNode._childRenderId) {
                 return false;
                 return false;
             }
             }
-            return this.parent.isSynchronized();
+            return this._parentNode.isSynchronized();
         };
         };
         /** @hidden */
         /** @hidden */
-        Node.prototype.isSynchronized = function (updateCache) {
+        Node.prototype.isSynchronized = function (useWasUpdatedFlag) {
             var check = this.hasNewParent();
             var check = this.hasNewParent();
-            check = check || !this.isSynchronizedWithParent();
+            if (!useWasUpdatedFlag) {
+                check = check || !this.isSynchronizedWithParent();
+            }
+            else if (this._parentNode) {
+                check = this._parentNode._worldMatrixWasUpdated;
+            }
             check = check || !this._isSynchronized();
             check = check || !this._isSynchronized();
-            if (updateCache)
-                this.updateCache(true);
             return !check;
             return !check;
         };
         };
         /** @hidden */
         /** @hidden */
         Node.prototype.hasNewParent = function () {
         Node.prototype.hasNewParent = function () {
-            if (this._cache.parent === this.parent)
+            if (this._cache.parent === this._parentNode)
                 return false;
                 return false;
-            this._cache.parent = this.parent;
+            this._cache.parent = this._parentNode;
             return true;
             return true;
         };
         };
         /**
         /**
@@ -17911,8 +17934,8 @@ var BABYLON;
             if (this._isEnabled === false) {
             if (this._isEnabled === false) {
                 return false;
                 return false;
             }
             }
-            if (this.parent !== undefined && this.parent !== null) {
-                return this.parent.isEnabled(checkAncestors);
+            if (this._parentNode !== undefined && this._parentNode !== null) {
+                return this._parentNode.isEnabled(checkAncestors);
             }
             }
             return true;
             return true;
         };
         };
@@ -18106,10 +18129,14 @@ var BABYLON;
         /**
         /**
          * Computes the world matrix of the node
          * Computes the world matrix of the node
          * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
          * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
          * @returns the world matrix
          * @returns the world matrix
          */
          */
-        Node.prototype.computeWorldMatrix = function (force) {
-            return BABYLON.Matrix.Identity();
+        Node.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
+            if (!this._worldMatrix) {
+                this._worldMatrix = BABYLON.Matrix.Identity();
+            }
+            return this._worldMatrix;
         };
         };
         /**
         /**
          * Releases resources associated with this node.
          * Releases resources associated with this node.
@@ -18638,6 +18665,7 @@ var BABYLON;
             _this._right = new BABYLON.Vector3(1, 0, 0);
             _this._right = new BABYLON.Vector3(1, 0, 0);
             _this._rightInverted = new BABYLON.Vector3(-1, 0, 0);
             _this._rightInverted = new BABYLON.Vector3(-1, 0, 0);
             // Properties
             // Properties
+            _this._position = BABYLON.Vector3.Zero();
             _this._rotation = BABYLON.Vector3.Zero();
             _this._rotation = BABYLON.Vector3.Zero();
             _this._scaling = BABYLON.Vector3.One();
             _this._scaling = BABYLON.Vector3.One();
             _this._isDirty = false;
             _this._isDirty = false;
@@ -18661,12 +18689,7 @@ var BABYLON;
              * By default the system will update normals to compensate
              * By default the system will update normals to compensate
              */
              */
             _this.ignoreNonUniformScaling = false;
             _this.ignoreNonUniformScaling = false;
-            _this.position = BABYLON.Vector3.Zero();
             _this._localWorld = BABYLON.Matrix.Zero();
             _this._localWorld = BABYLON.Matrix.Zero();
-            /** @hidden */
-            _this._worldMatrix = BABYLON.Matrix.Zero();
-            /** @hidden */
-            _this._worldMatrixDeterminant = 0;
             _this._absolutePosition = BABYLON.Vector3.Zero();
             _this._absolutePosition = BABYLON.Vector3.Zero();
             _this._pivotMatrix = BABYLON.Matrix.Identity();
             _this._pivotMatrix = BABYLON.Matrix.Identity();
             _this._postMultiplyPivotMatrix = false;
             _this._postMultiplyPivotMatrix = false;
@@ -18688,44 +18711,53 @@ var BABYLON;
         TransformNode.prototype.getClassName = function () {
         TransformNode.prototype.getClassName = function () {
             return "TransformNode";
             return "TransformNode";
         };
         };
+        Object.defineProperty(TransformNode.prototype, "position", {
+            /**
+              * Gets or set the node position (default is (0.0, 0.0, 0.0))
+              */
+            get: function () {
+                return this._position;
+            },
+            set: function (newPosition) {
+                this._position = newPosition;
+                this._isDirty = true;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(TransformNode.prototype, "rotation", {
         Object.defineProperty(TransformNode.prototype, "rotation", {
             /**
             /**
-              * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
-              * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
-              * Default : (0.0, 0.0, 0.0)
+              * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z  (default is (0.0, 0.0, 0.0)).
+              * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
               */
               */
             get: function () {
             get: function () {
                 return this._rotation;
                 return this._rotation;
             },
             },
             set: function (newRotation) {
             set: function (newRotation) {
                 this._rotation = newRotation;
                 this._rotation = newRotation;
+                this._isDirty = true;
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
         Object.defineProperty(TransformNode.prototype, "scaling", {
         Object.defineProperty(TransformNode.prototype, "scaling", {
             /**
             /**
-             * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
-             * Default : (1.0, 1.0, 1.0)
+             * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
              */
              */
             get: function () {
             get: function () {
                 return this._scaling;
                 return this._scaling;
             },
             },
-            /**
-             * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
-             * Default : (1.0, 1.0, 1.0)
-            */
             set: function (newScaling) {
             set: function (newScaling) {
                 this._scaling = newScaling;
                 this._scaling = newScaling;
+                this._isDirty = true;
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
         Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
         Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
             /**
             /**
-             * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
-             * It's null by default.
-             * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
+             * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
+             * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
              */
              */
             get: function () {
             get: function () {
                 return this._rotationQuaternion;
                 return this._rotationQuaternion;
@@ -18771,31 +18803,6 @@ var BABYLON;
             configurable: true
             configurable: true
         });
         });
         /**
         /**
-         * Returns the latest update of the World matrix
-         * Returns a Matrix.
-         */
-        TransformNode.prototype.getWorldMatrix = function () {
-            if (this._currentRenderId !== this.getScene().getRenderId()) {
-                this.computeWorldMatrix();
-            }
-            return this._worldMatrix;
-        };
-        /** @hidden */
-        TransformNode.prototype._getWorldMatrixDeterminant = function () {
-            return this._worldMatrixDeterminant;
-        };
-        Object.defineProperty(TransformNode.prototype, "worldMatrixFromCache", {
-            /**
-             * Returns directly the latest state of the mesh World matrix.
-             * A Matrix is returned.
-             */
-            get: function () {
-                return this._worldMatrix;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        /**
          * Copies the parameter passed Matrix into the mesh Pose matrix.
          * Copies the parameter passed Matrix into the mesh Pose matrix.
          * Returns the TransformNode.
          * Returns the TransformNode.
          */
          */
@@ -18823,15 +18830,15 @@ var BABYLON;
             if (this.infiniteDistance) {
             if (this.infiniteDistance) {
                 return false;
                 return false;
             }
             }
-            if (!this._cache.position.equals(this.position))
+            if (!this._cache.position.equals(this._position))
                 return false;
                 return false;
             if (this._rotationQuaternion) {
             if (this._rotationQuaternion) {
                 if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion))
                 if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion))
                     return false;
                     return false;
             }
             }
-            if (!this._cache.rotation.equals(this.rotation))
+            if (!this._cache.rotation.equals(this._rotation))
                 return false;
                 return false;
-            if (!this._cache.scaling.equals(this.scaling))
+            if (!this._cache.scaling.equals(this._scaling))
                 return false;
                 return false;
             return true;
             return true;
         };
         };
@@ -19308,20 +19315,20 @@ var BABYLON;
             return this;
             return this;
         };
         };
         /**
         /**
-         * Computes the mesh World matrix and returns it.
-         * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
-         * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
-         * If the parameter `force`is set to `true`, the actual computation is done.
-         * Returns the mesh World Matrix.
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        TransformNode.prototype.computeWorldMatrix = function (force) {
+        TransformNode.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
             if (this._isWorldMatrixFrozen) {
             if (this._isWorldMatrixFrozen) {
                 return this._worldMatrix;
                 return this._worldMatrix;
             }
             }
-            if (!force && this.isSynchronized(true)) {
+            if (!force && this.isSynchronized(useWasUpdatedFlag)) {
                 this._currentRenderId = this.getScene().getRenderId();
                 this._currentRenderId = this.getScene().getRenderId();
                 return this._worldMatrix;
                 return this._worldMatrix;
             }
             }
+            this._updateCache();
             this._cache.position.copyFrom(this.position);
             this._cache.position.copyFrom(this.position);
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.scaling.copyFrom(this.scaling);
             this._cache.pivotMatrixUpdated = false;
             this._cache.pivotMatrixUpdated = false;
@@ -19329,6 +19336,7 @@ var BABYLON;
             this._currentRenderId = this.getScene().getRenderId();
             this._currentRenderId = this.getScene().getRenderId();
             this._childRenderId = this.getScene().getRenderId();
             this._childRenderId = this.getScene().getRenderId();
             this._isDirty = false;
             this._isDirty = false;
+            this._worldMatrixWasUpdated = true;
             // Scaling
             // Scaling
             BABYLON.Matrix.ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, BABYLON.Tmp.Matrix[1]);
             BABYLON.Matrix.ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, BABYLON.Tmp.Matrix[1]);
             // Rotation
             // Rotation
@@ -19573,13 +19581,16 @@ var BABYLON;
         TransformNode._lookAtVectorCache = new BABYLON.Vector3(0, 0, 0);
         TransformNode._lookAtVectorCache = new BABYLON.Vector3(0, 0, 0);
         TransformNode._rotationAxisCache = new BABYLON.Quaternion();
         TransformNode._rotationAxisCache = new BABYLON.Quaternion();
         __decorate([
         __decorate([
-            BABYLON.serializeAsVector3()
+            BABYLON.serializeAsVector3("position")
+        ], TransformNode.prototype, "_position", void 0);
+        __decorate([
+            BABYLON.serializeAsVector3("rotation")
         ], TransformNode.prototype, "_rotation", void 0);
         ], TransformNode.prototype, "_rotation", void 0);
         __decorate([
         __decorate([
-            BABYLON.serializeAsQuaternion()
+            BABYLON.serializeAsQuaternion("rotationQuaternion")
         ], TransformNode.prototype, "_rotationQuaternion", void 0);
         ], TransformNode.prototype, "_rotationQuaternion", void 0);
         __decorate([
         __decorate([
-            BABYLON.serializeAsVector3()
+            BABYLON.serializeAsVector3("scaling")
         ], TransformNode.prototype, "_scaling", void 0);
         ], TransformNode.prototype, "_scaling", void 0);
         __decorate([
         __decorate([
             BABYLON.serialize()
             BABYLON.serialize()
@@ -19593,9 +19604,6 @@ var BABYLON;
         __decorate([
         __decorate([
             BABYLON.serialize()
             BABYLON.serialize()
         ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
         ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
-        __decorate([
-            BABYLON.serializeAsVector3()
-        ], TransformNode.prototype, "position", void 0);
         return TransformNode;
         return TransformNode;
     }(BABYLON.Node));
     }(BABYLON.Node));
     BABYLON.TransformNode = TransformNode;
     BABYLON.TransformNode = TransformNode;
@@ -21793,24 +21801,6 @@ var BABYLON;
             return true;
             return true;
         };
         };
         /**
         /**
-         * Computes and Returns the light World matrix.
-         * @returns the world matrix
-         */
-        Light.prototype.getWorldMatrix = function () {
-            this._currentRenderId = this.getScene().getRenderId();
-            this._childRenderId = this._currentRenderId;
-            var worldMatrix = this._getWorldMatrix();
-            if (this.parent && this.parent.getWorldMatrix) {
-                if (!this._parentedWorldMatrix) {
-                    this._parentedWorldMatrix = BABYLON.Matrix.Identity();
-                }
-                worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
-                this._markSyncedWithParent();
-                return this._parentedWorldMatrix;
-            }
-            return worldMatrix;
-        };
-        /**
          * Sort function to order lights for rendering.
          * Sort function to order lights for rendering.
          * @param a First Light object to compare to second.
          * @param a First Light object to compare to second.
          * @param b Second Light object to compare first.
          * @param b Second Light object to compare first.
@@ -22278,7 +22268,6 @@ var BABYLON;
             _this._computedViewMatrix = BABYLON.Matrix.Identity();
             _this._computedViewMatrix = BABYLON.Matrix.Identity();
             _this._projectionMatrix = new BABYLON.Matrix();
             _this._projectionMatrix = new BABYLON.Matrix();
             _this._doNotComputeProjectionMatrix = false;
             _this._doNotComputeProjectionMatrix = false;
-            _this._worldMatrix = BABYLON.Matrix.Identity();
             _this._postProcesses = new Array();
             _this._postProcesses = new Array();
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._transformMatrix = BABYLON.Matrix.Zero();
             _this._activeMeshes = new BABYLON.SmartArray(256);
             _this._activeMeshes = new BABYLON.SmartArray(256);
@@ -27471,6 +27460,26 @@ var BABYLON;
             this._activeMeshesFrozen = false;
             this._activeMeshesFrozen = false;
             return this;
             return this;
         };
         };
+        Scene.prototype._computeAllWorldMatricesforBranch = function (node) {
+            node.computeWorldMatrix(false, true);
+            var children = node.getChildren();
+            if (children) {
+                for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
+                    var child = children_2[_i];
+                    this._computeAllWorldMatricesforBranch(child);
+                }
+            }
+            node._worldMatrixWasUpdated = false;
+        };
+        /**
+         * This function will traverse the scene graph and makes sure that all worldMatrix are up to date
+         */
+        Scene.prototype.computeAllWorldMatrices = function () {
+            for (var _i = 0, _a = this.rootNodes; _i < _a.length; _i++) {
+                var node = _a[_i];
+                this._computeAllWorldMatricesforBranch(node);
+            }
+        };
         Scene.prototype._evaluateActiveMeshes = function () {
         Scene.prototype._evaluateActiveMeshes = function () {
             if (this._activeMeshesFrozen && this._activeMeshes.length) {
             if (this._activeMeshesFrozen && this._activeMeshes.length) {
                 return;
                 return;
@@ -27490,6 +27499,8 @@ var BABYLON;
                 var step = _a[_i];
                 var step = _a[_i];
                 step.action();
                 step.action();
             }
             }
+            // World matrices
+            this.computeAllWorldMatrices();
             // Determine mesh candidates
             // Determine mesh candidates
             var meshes = this.getActiveMeshCandidates();
             var meshes = this.getActiveMeshCandidates();
             // Check each mesh
             // Check each mesh
@@ -27503,7 +27514,6 @@ var BABYLON;
                 if (!mesh.isReady() || !mesh.isEnabled()) {
                 if (!mesh.isReady() || !mesh.isEnabled()) {
                     continue;
                     continue;
                 }
                 }
-                mesh.computeWorldMatrix();
                 // Intersections
                 // Intersections
                 if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionManager.OnIntersectionExitTrigger)) {
                 if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionManager.OnIntersectionExitTrigger)) {
                     this._meshesForIntersections.pushNoDuplicate(mesh);
                     this._meshesForIntersections.pushNoDuplicate(mesh);
@@ -34075,7 +34085,7 @@ var BABYLON;
         };
         };
         Object.defineProperty(SubMesh.prototype, "IsGlobal", {
         Object.defineProperty(SubMesh.prototype, "IsGlobal", {
             get: function () {
             get: function () {
-                return (this.verticesStart === 0 && this.verticesCount == this._mesh.getTotalVertices());
+                return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
             },
             },
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
@@ -48649,9 +48659,12 @@ var BABYLON;
             return this;
             return this;
         };
         };
         /**
         /**
-         * @hidden internal use only.
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        HemisphericLight.prototype._getWorldMatrix = function () {
+        HemisphericLight.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
             if (!this._worldMatrix) {
             if (!this._worldMatrix) {
                 this._worldMatrix = BABYLON.Matrix.Identity();
                 this._worldMatrix = BABYLON.Matrix.Identity();
             }
             }
@@ -48862,15 +48875,41 @@ var BABYLON;
         ShadowLight.prototype.forceProjectionMatrixCompute = function () {
         ShadowLight.prototype.forceProjectionMatrixCompute = function () {
             this._needProjectionMatrixCompute = true;
             this._needProjectionMatrixCompute = true;
         };
         };
+        /** @hidden */
+        ShadowLight.prototype._initCache = function () {
+            _super.prototype._initCache.call(this);
+            this._cache.position = BABYLON.Vector3.Zero();
+        };
+        /** @hidden */
+        ShadowLight.prototype._isSynchronized = function () {
+            if (!this._cache.position.equals(this.position))
+                return false;
+            return true;
+        };
         /**
         /**
-         * Get the world matrix of the sahdow lights.
-         * @hidden Internal Use Only
+         * Computes the world matrix of the node
+         * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
+         * @param useWasUpdatedFlag defines a reserved property
+         * @returns the world matrix
          */
          */
-        ShadowLight.prototype._getWorldMatrix = function () {
+        ShadowLight.prototype.computeWorldMatrix = function (force, useWasUpdatedFlag) {
+            if (!force && this.isSynchronized(useWasUpdatedFlag)) {
+                this._currentRenderId = this.getScene().getRenderId();
+                return this._worldMatrix;
+            }
+            this._updateCache();
+            this._cache.position.copyFrom(this.position);
+            this._worldMatrixWasUpdated = true;
             if (!this._worldMatrix) {
             if (!this._worldMatrix) {
                 this._worldMatrix = BABYLON.Matrix.Identity();
                 this._worldMatrix = BABYLON.Matrix.Identity();
             }
             }
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
             BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
+            if (this.parent && this.parent.getWorldMatrix) {
+                this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
+                this._markSyncedWithParent();
+            }
+            // Cache the determinant
+            this._worldMatrixDeterminant = this._worldMatrix.determinant();
             return this._worldMatrix;
             return this._worldMatrix;
         };
         };
         /**
         /**
@@ -109751,12 +109790,16 @@ var BABYLON;
     };
     };
     // We also need to update AbstractMesh as there is a portion of the code there
     // We also need to update AbstractMesh as there is a portion of the code there
     BABYLON.AbstractMesh.prototype._checkOcclusionQuery = function () {
     BABYLON.AbstractMesh.prototype._checkOcclusionQuery = function () {
+        if (this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_NONE) {
+            this._isOccluded = false;
+            return;
+        }
         var engine = this.getEngine();
         var engine = this.getEngine();
-        if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
+        if (engine.webGLVersion < 2) {
             this._isOccluded = false;
             this._isOccluded = false;
             return;
             return;
         }
         }
-        if (engine.webGLVersion < 2 || this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_NONE) {
+        if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
             this._isOccluded = false;
             this._isOccluded = false;
             return;
             return;
         }
         }

+ 4 - 0
dist/preview release/gui/babylon.gui.d.ts

@@ -1731,6 +1731,10 @@ declare module BABYLON.GUI {
             buttonBackground: string;
             buttonBackground: string;
             /** Gets or sets the color of separator bar */
             /** Gets or sets the color of separator bar */
             barColor: string;
             barColor: string;
+            /** Gets or sets the height of separator bar */
+            barHeight: string;
+            /** Gets or sets the height of spacers*/
+            spacerHeight: string;
             /** Add a group to the selection panel
             /** Add a group to the selection panel
                 * @param group is the selector group to add
                 * @param group is the selector group to add
                 */
                 */

Plik diff jest za duży
+ 1 - 1
dist/preview release/gui/babylon.gui.js


Plik diff jest za duży
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


Plik diff jest za duży
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js.map


+ 8 - 0
dist/preview release/gui/babylon.gui.module.d.ts

@@ -1873,6 +1873,10 @@ declare module 'babylonjs-gui/2D/controls/selector' {
             buttonBackground: string;
             buttonBackground: string;
             /** Gets or sets the color of separator bar */
             /** Gets or sets the color of separator bar */
             barColor: string;
             barColor: string;
+            /** Gets or sets the height of separator bar */
+            barHeight: string;
+            /** Gets or sets the height of spacers*/
+            spacerHeight: string;
             /** Add a group to the selection panel
             /** Add a group to the selection panel
                 * @param group is the selector group to add
                 * @param group is the selector group to add
                 */
                 */
@@ -4539,6 +4543,10 @@ declare module BABYLON.GUI {
             buttonBackground: string;
             buttonBackground: string;
             /** Gets or sets the color of separator bar */
             /** Gets or sets the color of separator bar */
             barColor: string;
             barColor: string;
+            /** Gets or sets the height of separator bar */
+            barHeight: string;
+            /** Gets or sets the height of spacers*/
+            spacerHeight: string;
             /** Add a group to the selection panel
             /** Add a group to the selection panel
                 * @param group is the selector group to add
                 * @param group is the selector group to add
                 */
                 */

+ 2 - 7
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
 {
-  "errors": 3875,
+  "errors": 3874,
   "babylon.typedoc.json": {
   "babylon.typedoc.json": {
-    "errors": 3875,
+    "errors": 3874,
     "AnimationGroup": {
     "AnimationGroup": {
       "Constructor": {
       "Constructor": {
         "new AnimationGroup": {
         "new AnimationGroup": {
@@ -18226,11 +18226,6 @@
             "MissingText": true
             "MissingText": true
           }
           }
         },
         },
-        "position": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
         "scalingDeterminant": {
         "scalingDeterminant": {
           "Comments": {
           "Comments": {
             "MissingText": true
             "MissingText": true

+ 86 - 5
dist/preview release/viewer/babylon.viewer.d.ts

@@ -168,11 +168,11 @@ declare module BabylonViewer {
                 * Mainly used for help and errors
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the overlay screen.
                 * Hide the overlay screen.
                 */
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * show the viewer (in case it was hidden)
                 * show the viewer (in case it was hidden)
                 *
                 *
@@ -189,11 +189,11 @@ declare module BabylonViewer {
                 * Show the loading screen.
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 * The loading screen can be configured using the configuration object
                 */
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the loading screen
                 * Hide the loading screen
                 */
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
     }
@@ -924,7 +924,7 @@ declare module BabylonViewer {
       * @param name the name of the custom optimizer configuration
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
@@ -1558,6 +1558,20 @@ declare module BabylonViewer {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+declare module BabylonViewer {
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
     export interface IEnvironmentMapConfiguration {
     export interface IEnvironmentMapConfiguration {
@@ -2101,6 +2115,73 @@ declare module BabylonViewer {
     }
     }
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
+    /**
+        * A single template configuration object
+        */
+    export interface ITemplateConfiguration {
+            /**
+                * can be either the id of the template's html element or a URL.
+                * See - http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
+                */
+            location?: string;
+            /**
+                * If no location is provided you can provide here the raw html of this template.
+                * See http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
+                */
+            html?: string;
+            id?: string;
+            /**
+                * Parameters that will be delivered to the template and will render it accordingly.
+                */
+            params?: {
+                    [key: string]: string | number | boolean | object;
+            };
+            /**
+                * Events to attach to this template.
+                * event name is the key. the value can either be a boolean (attach to the parent element)
+                * or a map of html id elements.
+                *
+                * See - http://doc.babylonjs.com/extensions/the_templating_system#event-binding
+                */
+            events?: {
+                    pointerdown?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerup?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointermove?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerover?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerout?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerenter?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerleave?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointercancel?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    click?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    dragstart?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    drop?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    [key: string]: boolean | {
+                            [id: string]: boolean;
+                    } | undefined;
+            };
+    }
 }
 }
 declare module BabylonViewer {
 declare module BabylonViewer {
     export interface IVRConfiguration {
     export interface IVRConfiguration {

Plik diff jest za duży
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


Plik diff jest za duży
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 89 - 6
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -200,11 +200,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Mainly used for help and errors
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the overlay screen.
                 * Hide the overlay screen.
                 */
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * show the viewer (in case it was hidden)
                 * show the viewer (in case it was hidden)
                 *
                 *
@@ -221,11 +221,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Show the loading screen.
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 * The loading screen can be configured using the configuration object
                 */
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the loading screen
                 * Hide the loading screen
                 */
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
     }
@@ -985,13 +985,14 @@ declare module 'babylonjs-viewer/templating/viewerTemplatePlugin' {
 }
 }
 
 
 declare module 'babylonjs-viewer/optimizer/custom' {
 declare module 'babylonjs-viewer/optimizer/custom' {
+    import { extendedUpgrade } from "babylonjs-viewer/optimizer/custom/extended";
     import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
     import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
     /**
     /**
       *
       *
       * @param name the name of the custom optimizer configuration
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 }
 
 
@@ -1662,6 +1663,22 @@ declare module 'babylonjs-viewer/loader/plugins' {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 }
 
 
+declare module 'babylonjs-viewer/optimizer/custom/extended' {
+    import { SceneManager } from 'babylonjs-viewer/managers/sceneManager';
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+
 declare module 'babylonjs-viewer/configuration/interfaces' {
 declare module 'babylonjs-viewer/configuration/interfaces' {
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';
@@ -2260,7 +2277,73 @@ declare module 'babylonjs-viewer/configuration/interfaces/skyboxConfiguration' {
 }
 }
 
 
 declare module 'babylonjs-viewer/configuration/interfaces/templateConfiguration' {
 declare module 'babylonjs-viewer/configuration/interfaces/templateConfiguration' {
-    
+    /**
+        * A single template configuration object
+        */
+    export interface ITemplateConfiguration {
+            /**
+                * can be either the id of the template's html element or a URL.
+                * See - http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
+                */
+            location?: string;
+            /**
+                * If no location is provided you can provide here the raw html of this template.
+                * See http://doc.babylonjs.com/extensions/the_templating_system#location-vs-html
+                */
+            html?: string;
+            id?: string;
+            /**
+                * Parameters that will be delivered to the template and will render it accordingly.
+                */
+            params?: {
+                    [key: string]: string | number | boolean | object;
+            };
+            /**
+                * Events to attach to this template.
+                * event name is the key. the value can either be a boolean (attach to the parent element)
+                * or a map of html id elements.
+                *
+                * See - http://doc.babylonjs.com/extensions/the_templating_system#event-binding
+                */
+            events?: {
+                    pointerdown?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerup?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointermove?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerover?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerout?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerenter?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointerleave?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    pointercancel?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    click?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    dragstart?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    drop?: boolean | {
+                            [id: string]: boolean;
+                    };
+                    [key: string]: boolean | {
+                            [id: string]: boolean;
+                    } | undefined;
+            };
+    }
 }
 }
 
 
 declare module 'babylonjs-viewer/configuration/interfaces/vrConfiguration' {
 declare module 'babylonjs-viewer/configuration/interfaces/vrConfiguration' {