David Catuhe 6 年之前
父节点
当前提交
457ba2cb30
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/babylon.node.ts

+ 4 - 3
src/babylon.node.ts

@@ -143,7 +143,7 @@ module BABYLON {
                     this._parentNode._children.splice(index, 1);
                 }
 
-                if (!parent) {
+                if (!parent && !this._isDisposed) {
                     this.addToSceneRootNodes();
                 }
             }
@@ -692,7 +692,9 @@ module BABYLON {
          * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
          * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
          */
-        public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {
+        public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {            
+            this._isDisposed = true;
+
             if (!doNotRecurse) {
                 const nodes = this.getDescendants(true);
                 for (const node of nodes) {
@@ -722,7 +724,6 @@ module BABYLON {
             }
 
             this._behaviors = [];
-            this._isDisposed = true;
         }
 
         /**