瀏覽代碼

Now deal with AssetContainer for effect layers

Julien MOREAU-MATHIS 7 年之前
父節點
當前提交
c1da5fa29c
共有 3 個文件被更改,包括 41 次插入2 次删除
  1. 2 1
      src/Loading/Plugins/babylon.babylonFileLoader.ts
  2. 16 1
      src/babylon.assetContainer.ts
  3. 23 0
      src/babylon.scene.ts

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

@@ -360,7 +360,8 @@
             // Effect layers
             // Effect layers
             if (parsedData.effectLayers) {
             if (parsedData.effectLayers) {
                 for (index = 0; index < parsedData.effectLayers.length; index++) {
                 for (index = 0; index < parsedData.effectLayers.length; index++) {
-                    EffectLayer.Parse(parsedData.effectLayers[index], scene, rootUrl);
+                    var effectLayer = EffectLayer.Parse(parsedData.effectLayers[index], scene, rootUrl);
+                    container.effectLayers.push(effectLayer);
                 }
                 }
             }
             }
 
 

+ 16 - 1
src/babylon.assetContainer.ts

@@ -71,6 +71,10 @@ module BABYLON {
          * Textures to keep.
          * Textures to keep.
          */
          */
         public textures = new Array<Texture>();
         public textures = new Array<Texture>();
+        /**
+         * Effect layers to keep.
+         */
+        public effectLayers = new Array<EffectLayer>();
     }
     }
 
 
     /**
     /**
@@ -151,6 +155,10 @@ module BABYLON {
          * Textures populated in the container.
          * Textures populated in the container.
          */
          */
         public textures = new Array<Texture>();
         public textures = new Array<Texture>();
+        /**
+         * Effect layers populated in the container.
+         */
+        public effectLayers = new Array<EffectLayer>();
 
 
         /**
         /**
          * Instantiates an AssetContainer.
          * Instantiates an AssetContainer.
@@ -212,7 +220,10 @@ module BABYLON {
                 this.scene.mainSoundTrack.AddSound(o);
                 this.scene.mainSoundTrack.AddSound(o);
             });
             });
             this.textures.forEach((o) => {
             this.textures.forEach((o) => {
-                this.scene.addTexture
+                this.scene.addTexture(o);
+            });
+            this.effectLayers.forEach((o) => {
+                this.scene.addEffectLayer(o);
             });
             });
         }
         }
 
 
@@ -270,6 +281,9 @@ module BABYLON {
             this.textures.forEach((o) => {
             this.textures.forEach((o) => {
                 this.scene.removeTexture(o);
                 this.scene.removeTexture(o);
             });
             });
+            this.effectLayers.forEach((o) => {
+                this.scene.removeEffectLayer(o);
+            });
         }
         }
 
 
         private _moveAssets<T>(sourceAssets: T[], targetAssets: T[], keepAssets: T[]): void {
         private _moveAssets<T>(sourceAssets: T[], targetAssets: T[], keepAssets: T[]): void {
@@ -314,6 +328,7 @@ module BABYLON {
             this._moveAssets(this.scene.mainSoundTrack.soundCollection, this.sounds, keepAssets.sounds);
             this._moveAssets(this.scene.mainSoundTrack.soundCollection, this.sounds, keepAssets.sounds);
             this._moveAssets(this.scene.transformNodes, this.transformNodes, keepAssets.transformNodes);
             this._moveAssets(this.scene.transformNodes, this.transformNodes, keepAssets.transformNodes);
             this._moveAssets(this.scene.textures, this.textures, keepAssets.textures);
             this._moveAssets(this.scene.textures, this.textures, keepAssets.textures);
+            this._moveAssets(this.scene.effectLayers, this.effectLayers, keepAssets.effectLayers);
 
 
             this.removeAllFromScene();
             this.removeAllFromScene();
         }
         }

+ 23 - 0
src/babylon.scene.ts

@@ -3075,6 +3075,21 @@
             return index;
             return index;
         }
         }
 
 
+        
+        /**
+         * Removes the given effect layer from this scene.
+         * @param toRemove defines the effect layer to remove
+         * @returns the index of the removed effect layer
+         */    
+        public removeEffectLayer(toRemove: EffectLayer): number {
+            var index = this.effectLayers.indexOf(toRemove);
+            if (index !== -1) {
+                this.effectLayers.splice(index, 1);
+            }
+
+            return index;
+        }
+
         /**
         /**
          * Removes the given texture from this scene.
          * Removes the given texture from this scene.
          * @param toRemove The texture to remove
          * @param toRemove The texture to remove
@@ -3198,6 +3213,14 @@
         }
         }
 
 
         /**
         /**
+         * Adds the given effect layer to this scene
+         * @param newEffectLayer defines the effect layer to add
+         */     
+        public addEffectLayer(newEffectLayer: EffectLayer): void {
+            this.effectLayers.push(newEffectLayer);
+        }
+
+        /**
          * Adds the given action manager to this scene
          * Adds the given action manager to this scene
          * @param newActionManager The action manager to add
          * @param newActionManager The action manager to add
          */   
          */