浏览代码

Merge pull request #486 from Palmer-JC/master

Ensure computeWorldMatrix() is forced in freeze & unfreeze
David Catuhe 10 年之前
父节点
当前提交
793afda416
共有 2 个文件被更改,包括 17 次插入3 次删除
  1. 11 2
      Babylon/Mesh/babylon.abstractMesh.js
  2. 6 1
      Babylon/Mesh/babylon.abstractMesh.ts

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

@@ -176,13 +176,21 @@ var BABYLON;
             configurable: true
             configurable: true
         });
         });
         AbstractMesh.prototype.freezeWorldMatrix = function () {
         AbstractMesh.prototype.freezeWorldMatrix = function () {
+            this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
             this.computeWorldMatrix(true);
             this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = true;
             this._isWorldMatrixFrozen = true;
         };
         };
         AbstractMesh.prototype.unfreezeWorldMatrix = function () {
         AbstractMesh.prototype.unfreezeWorldMatrix = function () {
-            this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = false;
             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) {
         AbstractMesh.prototype.rotate = function (axis, amount, space) {
             if (!this.rotationQuaternion) {
             if (!this.rotationQuaternion) {
                 this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
                 this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
@@ -806,4 +814,5 @@ var BABYLON;
     })(BABYLON.Node);
     })(BABYLON.Node);
     BABYLON.AbstractMesh = AbstractMesh;
     BABYLON.AbstractMesh = AbstractMesh;
 })(BABYLON || (BABYLON = {}));
 })(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() {
         public freezeWorldMatrix() {
+            this._isWorldMatrixFrozen = false;  // no guarantee world is not already frozen, switch off temporarily
             this.computeWorldMatrix(true);
             this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = true;
             this._isWorldMatrixFrozen = true;
         }
         }
 
 
         public unfreezeWorldMatrix() {
         public unfreezeWorldMatrix() {
-            this.computeWorldMatrix(true);
             this._isWorldMatrixFrozen = false;
             this._isWorldMatrixFrozen = false;
+            this.computeWorldMatrix(true);
+        }
+        
+        public get isWorldMatrixFrozen() :boolean {
+            return this._isWorldMatrixFrozen;
         }
         }
 
 
         public rotate(axis: Vector3, amount: number, space: Space): void {
         public rotate(axis: Vector3, amount: number, space: Space): void {