Browse Source

Update babylon.assetContainer.ts

Updating to include camera keeping logic added by Hololite http://www.html5gamedevs.com/topic/35120-how-to-createadd-assets-directly-to-the-assetcontainer/
Trevor Baron 7 years ago
parent
commit
b037942eda
1 changed files with 21 additions and 3 deletions
  1. 21 3
      src/babylon.assetContainer.ts

+ 21 - 3
src/babylon.assetContainer.ts

@@ -116,10 +116,27 @@ module BABYLON {
             })
         }
         
-        moveAllFromScene(): void {
+        moveAllFromScene(keepCameras?: BABYLON.Camera[]): void {
             Array.prototype.push.apply(this.actionManagers, this.scene._actionManagers);
             Array.prototype.push.apply(this.animations, this.scene.animations);
-            Array.prototype.push.apply(this.cameras, this.scene.cameras);
+
+            if (keepCameras === undefined) {
+                keepCameras = [];
+            }
+            for (let camera of this.scene.cameras) {
+                let moveCamera = true;
+                for (let keepCamera of keepCameras) {
+                    if (camera === keepCamera) {
+                        moveCamera = false;
+                        break;
+                    }
+                }
+
+                if (moveCamera) {
+                    this.cameras.push(camera);
+                }
+            }
+
             Array.prototype.push.apply(this.geometries, this.scene.getGeometries());
             Array.prototype.push.apply(this.lensFlareSystems, this.scene.lensFlareSystems);
             Array.prototype.push.apply(this.lights, this.scene.lights);
@@ -131,7 +148,8 @@ module BABYLON {
             Array.prototype.push.apply(this.particleSystems, this.scene.particleSystems);
             Array.prototype.push.apply(this.sounds, this.scene.mainSoundTrack.soundCollection);
             Array.prototype.push.apply(this.transformNodes, this.scene.transformNodes);
+
             this.removeAllFromScene();
         }
     }
-}
+}