瀏覽代碼

Update babylon.scene.ts

When disposing a camera, its reference was still in activeCamera and activeCameras
Temechon 10 年之前
父節點
當前提交
75c72c8c59
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      Babylon/babylon.scene.ts

+ 11 - 1
Babylon/babylon.scene.ts

@@ -760,6 +760,16 @@
                 // Remove from the scene if mesh found 
                 this.cameras.splice(index, 1);
             }
+            // Remove from activeCameras
+            var index2 = this.activeCameras.indexOf(toRemove);
+            if (index2 !== -1) {
+                // Remove from the scene if mesh found
+                this.activeCameras.splice(index2, 1);
+            }
+            // Reset the activeCamera
+            if (this.activeCamera === toRemove) {
+                this.activeCamera = null;
+            }
             if (this.onCameraRemoved) {
                 this.onCameraRemoved(toRemove);
             }
@@ -2160,4 +2170,4 @@
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
         }
     }
-} 
+}