浏览代码

Merge pull request #6026 from BabylonJS/dispose-fix

Associated with #6019
David Catuhe 6 年之前
父节点
当前提交
e934ac13a8
共有 1 个文件被更改,包括 27 次插入3 次删除
  1. 27 3
      src/assetContainer.ts

+ 27 - 3
src/assetContainer.ts

@@ -132,7 +132,7 @@ export class AssetContainer extends AbstractScene {
             this.scene.removeReflectionProbe(o);
         });
 
-        if (this.environmentTexture == this.scene.environmentTexture) {
+        if (this.environmentTexture === this.scene.environmentTexture) {
             this.scene.environmentTexture = null;
         }
 
@@ -148,42 +148,66 @@ export class AssetContainer extends AbstractScene {
         this.cameras.forEach((o) => {
             o.dispose();
         });
+        this.cameras = [];
+
         this.lights.forEach((o) => {
             o.dispose();
         });
+        this.lights = [];
+
         this.meshes.forEach((o) => {
             o.dispose();
         });
+        this.meshes = [];
+
         this.skeletons.forEach((o) => {
             o.dispose();
         });
+        this.skeletons = [];
+
         this.animationGroups.forEach((o) => {
             o.dispose();
         });
+        this.animationGroups = [];
+
         this.multiMaterials.forEach((o) => {
             o.dispose();
         });
+        this.multiMaterials = [];
+
         this.materials.forEach((o) => {
             o.dispose();
         });
+        this.materials = [];
+
         this.geometries.forEach((o) => {
             o.dispose();
         });
+        this.geometries = [];
+        
         this.transformNodes.forEach((o) => {
             o.dispose();
         });
+        this.transformNodes = [];
+
         this.actionManagers.forEach((o) => {
             o.dispose();
         });
+        this.actionManagers = [];
+
         this.textures.forEach((o) => {
             o.dispose();
         });
+        this.textures = [];
+
         this.reflectionProbes.forEach((o) => {
             o.dispose();
         });
+        this.reflectionProbes = [];
 
-        if (this.scene.environmentTexture) {
-            this.scene.environmentTexture.dispose();
+        if (this.environmentTexture) {
+            this.environmentTexture.dispose();
+            this.environmentTexture = null;
         }
 
         for (let component of this.scene._serializableComponents) {