Forráskód Böngészése

Now deal with AssetContainer for effect layers

Julien MOREAU-MATHIS 7 éve
szülő
commit
c1da5fa29c

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

@@ -360,7 +360,8 @@
             // Effect layers
             if (parsedData.effectLayers) {
                 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.
          */
         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.
          */
         public textures = new Array<Texture>();
+        /**
+         * Effect layers populated in the container.
+         */
+        public effectLayers = new Array<EffectLayer>();
 
         /**
          * Instantiates an AssetContainer.
@@ -212,7 +220,10 @@ module BABYLON {
                 this.scene.mainSoundTrack.AddSound(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.scene.removeTexture(o);
             });
+            this.effectLayers.forEach((o) => {
+                this.scene.removeEffectLayer(o);
+            });
         }
 
         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.transformNodes, this.transformNodes, keepAssets.transformNodes);
             this._moveAssets(this.scene.textures, this.textures, keepAssets.textures);
+            this._moveAssets(this.scene.effectLayers, this.effectLayers, keepAssets.effectLayers);
 
             this.removeAllFromScene();
         }

+ 23 - 0
src/babylon.scene.ts

@@ -3075,6 +3075,21 @@
             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.
          * @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
          * @param newActionManager The action manager to add
          */