Procházet zdrojové kódy

Ensure computeWorldMatrix() is forced in freeze & unfreeze
Also added a getter for app to know if frozen or not

jeff Palmer před 10 roky
rodič
revize
69d3e0d626

+ 11 - 2
Babylon/Mesh/babylon.abstractMesh.js

@@ -176,13 +176,21 @@ var BABYLON;
             configurable: true
         });
         AbstractMesh.prototype.freezeWorldMatrix = function () {
+            this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
             this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = true;
         };
         AbstractMesh.prototype.unfreezeWorldMatrix = function () {
-            this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = false;
+            this.computeWorldMatrix(true);
         };
+        Object.defineProperty(AbstractMesh.prototype, "isWorldMatrixFrozen", {
+            get: function () {
+                return this._isWorldMatrixFrozen;
+            },
+            enumerable: true,
+            configurable: true
+        });
         AbstractMesh.prototype.rotate = function (axis, amount, space) {
             if (!this.rotationQuaternion) {
                 this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
@@ -806,4 +814,5 @@ var BABYLON;
     })(BABYLON.Node);
     BABYLON.AbstractMesh = AbstractMesh;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.abstractMesh.js.map
+
+//# sourceMappingURL=../Mesh/babylon.abstractMesh.js.map

+ 6 - 1
Babylon/Mesh/babylon.abstractMesh.ts

@@ -187,13 +187,18 @@
         }
 
         public freezeWorldMatrix() {
+            this._isWorldMatrixFrozen = false;  // no guarantee world is not already frozen, switch off temporarily
             this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = true;
         }
 
         public unfreezeWorldMatrix() {
-            this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = false;
+            this.computeWorldMatrix(true);
+        }
+        
+        public get isWorldMatrixFrozen() :boolean {
+            return this._isWorldMatrixFrozen;
         }
 
         public rotate(axis: Vector3, amount: number, space: Space): void {