Selaa lähdekoodia

rename to assetContainer, populate addAllToScene function

Trevor Baron 7 vuotta sitten
vanhempi
commit
4ab7e3d1a9

+ 2 - 2
src/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -624,8 +624,8 @@
 
             return false;
         },
-        loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): SceneAssetContainer =>{
-            var container = new SceneAssetContainer(scene);
+        loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer =>{
+            var container = new AssetContainer(scene);
 
             // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
             // when SceneLoader.debugLogging = true (default), or exception encountered.

+ 4 - 4
src/Loading/babylon.sceneLoader.ts

@@ -27,7 +27,7 @@
         load: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => boolean;
         canDirectLoad?: (data: string) => boolean;
         rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
-        loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => SceneAssetContainer;
+        loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => AssetContainer;
     }
 
     export interface ISceneLoaderPluginAsync {
@@ -37,7 +37,7 @@
         loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
         canDirectLoad?: (data: string) => boolean;
         rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
-        loadAssetsAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: (assets: SceneAssetContainer) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
+        loadAssetsAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: (assets: AssetContainer) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
     }
 
     interface IRegisteredPlugin {
@@ -462,7 +462,7 @@
             rootUrl: string,
             sceneFilename: any,
             scene: Scene,
-            onSuccess: Nullable<(assets: SceneAssetContainer) => void> = null,
+            onSuccess: Nullable<(assets: AssetContainer) => void> = null,
             onProgress: Nullable<(event: SceneLoaderProgressEvent) => void> = null,
             onError: Nullable<(scene: Scene, message: string, exception?: any) => void> = null,
             pluginExtension: Nullable<string> = null
@@ -500,7 +500,7 @@
                 }
             } : undefined;
 
-            var successHandler = (assets: SceneAssetContainer) => {
+            var successHandler = (assets: AssetContainer) => {
                 if (onSuccess) {
                     try {
                         onSuccess(assets);

+ 40 - 5
src/babylon.assetContainer.ts

@@ -1,5 +1,5 @@
 module BABYLON {
-    export class SceneAssetContainer {
+    export class AssetContainer {
         public scene: Scene;
 
         // Objects
@@ -23,7 +23,45 @@ module BABYLON {
         }
         
         addAllToScene(){
-            // TODO
+            this.cameras.forEach((o)=>{
+                this.scene.addCamera(o);
+            });
+            this.lights.forEach((o)=>{
+                this.scene.addLight(o);
+            });
+            this.meshes.forEach((o)=>{
+                this.scene.addMesh(o);
+            });
+            this.skeletons.forEach((o)=>{
+                this.scene.addSkeleton(o);
+            });
+            this.particleSystems.forEach((o)=>{
+                this.scene.addParticleSystem(o);
+            });
+            this.animations.forEach((o)=>{
+                this.scene.addAnimation(o);
+            });
+            this.multiMaterials.forEach((o)=>{
+                this.scene.addMultiMaterial(o);
+            });
+            this.materials.forEach((o)=>{
+                this.scene.addMaterial(o);
+            });
+            this.morphTargetManagers.forEach((o)=>{
+                this.scene.addMorphTargetManager(o);
+            });
+            this.geometries.forEach((o)=>{
+                this.scene.addGeometry(o);
+            });
+            this.transformNodes.forEach((o)=>{
+                this.scene.addTransformNode(o);
+            });
+            this.lensFlareSystems.forEach((o)=>{
+                this.scene.addLensFlareSystem(o);
+            });
+            this.actionManagers.forEach((o)=>{
+                this.scene.addActionManager(o);
+            });
         }
         removeAllFromScene(){
             this.cameras.forEach((o)=>{
@@ -41,9 +79,6 @@ module BABYLON {
             this.particleSystems.forEach((o)=>{
                 this.scene.removeParticleSystem(o);
             });
-            this.particleSystems.forEach((o)=>{
-                this.scene.removeParticleSystem(o);
-            });
             this.animations.forEach((o)=>{
                 this.scene.removeAnimation(o);
             });