David Catuhe 7 年 前
コミット
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);
                     this._parentNode._children.splice(index, 1);
                 }
                 }
 
 
-                if (!parent) {
+                if (!parent && !this._isDisposed) {
                     this.addToSceneRootNodes();
                     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 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)
          * @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) {
             if (!doNotRecurse) {
                 const nodes = this.getDescendants(true);
                 const nodes = this.getDescendants(true);
                 for (const node of nodes) {
                 for (const node of nodes) {
@@ -722,7 +724,6 @@ module BABYLON {
             }
             }
 
 
             this._behaviors = [];
             this._behaviors = [];
-            this._isDisposed = true;
         }
         }
 
 
         /**
         /**