|
@@ -22,12 +22,16 @@ module BABYLON {
|
|
|
/**
|
|
|
* ParticleSystems to keep.
|
|
|
*/
|
|
|
- public particleSystems = new Array<ParticleSystem>();
|
|
|
+ public particleSystems = new Array<IParticleSystem>();
|
|
|
/**
|
|
|
* Animations to keep.
|
|
|
*/
|
|
|
public animations = new Array<Animation>();
|
|
|
/**
|
|
|
+ * AnimationGroups to keep.
|
|
|
+ */
|
|
|
+ public animationGroups = new Array<AnimationGroup>();
|
|
|
+ /**
|
|
|
* MultiMaterials to keep.
|
|
|
*/
|
|
|
public multiMaterials = new Array<MultiMaterial>();
|
|
@@ -63,6 +67,10 @@ module BABYLON {
|
|
|
* Sounds to keep.
|
|
|
*/
|
|
|
public sounds = new Array<Sound>();
|
|
|
+ /**
|
|
|
+ * Textures to keep.
|
|
|
+ */
|
|
|
+ public textures = new Array<Texture>();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -100,6 +108,10 @@ module BABYLON {
|
|
|
*/
|
|
|
public animations = new Array<Animation>();
|
|
|
/**
|
|
|
+ * AnimationGroups populated in the container.
|
|
|
+ */
|
|
|
+ public animationGroups = new Array<AnimationGroup>();
|
|
|
+ /**
|
|
|
* MultiMaterials populated in the container.
|
|
|
*/
|
|
|
public multiMaterials = new Array<MultiMaterial>();
|
|
@@ -135,115 +147,131 @@ module BABYLON {
|
|
|
* Sounds populated in the container.
|
|
|
*/
|
|
|
public sounds = new Array<Sound>();
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Textures populated in the container.
|
|
|
+ */
|
|
|
+ public textures = new Array<Texture>();
|
|
|
+
|
|
|
/**
|
|
|
* Instantiates an AssetContainer.
|
|
|
* @param scene The scene the AssetContainer belongs to.
|
|
|
*/
|
|
|
- constructor(scene:Scene){
|
|
|
+ constructor(scene: Scene) {
|
|
|
this.scene = scene;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Adds all the assets from the container to the scene.
|
|
|
*/
|
|
|
- public addAllToScene(){
|
|
|
- this.cameras.forEach((o)=>{
|
|
|
+ public addAllToScene() {
|
|
|
+ this.cameras.forEach((o) => {
|
|
|
this.scene.addCamera(o);
|
|
|
});
|
|
|
- this.lights.forEach((o)=>{
|
|
|
+ this.lights.forEach((o) => {
|
|
|
this.scene.addLight(o);
|
|
|
});
|
|
|
- this.meshes.forEach((o)=>{
|
|
|
+ this.meshes.forEach((o) => {
|
|
|
this.scene.addMesh(o);
|
|
|
});
|
|
|
- this.skeletons.forEach((o)=>{
|
|
|
+ this.skeletons.forEach((o) => {
|
|
|
this.scene.addSkeleton(o);
|
|
|
});
|
|
|
- this.particleSystems.forEach((o)=>{
|
|
|
+ this.particleSystems.forEach((o) => {
|
|
|
this.scene.addParticleSystem(o);
|
|
|
});
|
|
|
- this.animations.forEach((o)=>{
|
|
|
+ this.animations.forEach((o) => {
|
|
|
this.scene.addAnimation(o);
|
|
|
});
|
|
|
- this.multiMaterials.forEach((o)=>{
|
|
|
+ this.animationGroups.forEach((o) => {
|
|
|
+ this.scene.addAnimationGroup(o);
|
|
|
+ });
|
|
|
+ this.multiMaterials.forEach((o) => {
|
|
|
this.scene.addMultiMaterial(o);
|
|
|
});
|
|
|
- this.materials.forEach((o)=>{
|
|
|
+ this.materials.forEach((o) => {
|
|
|
this.scene.addMaterial(o);
|
|
|
});
|
|
|
- this.morphTargetManagers.forEach((o)=>{
|
|
|
+ this.morphTargetManagers.forEach((o) => {
|
|
|
this.scene.addMorphTargetManager(o);
|
|
|
});
|
|
|
- this.geometries.forEach((o)=>{
|
|
|
+ this.geometries.forEach((o) => {
|
|
|
this.scene.addGeometry(o);
|
|
|
});
|
|
|
- this.transformNodes.forEach((o)=>{
|
|
|
+ this.transformNodes.forEach((o) => {
|
|
|
this.scene.addTransformNode(o);
|
|
|
});
|
|
|
- this.lensFlareSystems.forEach((o)=>{
|
|
|
+ this.lensFlareSystems.forEach((o) => {
|
|
|
this.scene.addLensFlareSystem(o);
|
|
|
});
|
|
|
- this.actionManagers.forEach((o)=>{
|
|
|
+ this.actionManagers.forEach((o) => {
|
|
|
this.scene.addActionManager(o);
|
|
|
});
|
|
|
- this.sounds.forEach((o)=>{
|
|
|
+ this.sounds.forEach((o) => {
|
|
|
o.play();
|
|
|
- o.autoplay=true;
|
|
|
+ o.autoplay = true;
|
|
|
this.scene.mainSoundTrack.AddSound(o);
|
|
|
- })
|
|
|
+ });
|
|
|
+ this.textures.forEach((o) => {
|
|
|
+ this.scene.addTexture
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Removes all the assets in the container from the scene
|
|
|
*/
|
|
|
- public removeAllFromScene(){
|
|
|
- this.cameras.forEach((o)=>{
|
|
|
+ public removeAllFromScene() {
|
|
|
+ this.cameras.forEach((o) => {
|
|
|
this.scene.removeCamera(o);
|
|
|
});
|
|
|
- this.lights.forEach((o)=>{
|
|
|
+ this.lights.forEach((o) => {
|
|
|
this.scene.removeLight(o);
|
|
|
});
|
|
|
- this.meshes.forEach((o)=>{
|
|
|
+ this.meshes.forEach((o) => {
|
|
|
this.scene.removeMesh(o);
|
|
|
});
|
|
|
- this.skeletons.forEach((o)=>{
|
|
|
+ this.skeletons.forEach((o) => {
|
|
|
this.scene.removeSkeleton(o);
|
|
|
});
|
|
|
- this.particleSystems.forEach((o)=>{
|
|
|
+ this.particleSystems.forEach((o) => {
|
|
|
this.scene.removeParticleSystem(o);
|
|
|
});
|
|
|
- this.animations.forEach((o)=>{
|
|
|
+ this.animations.forEach((o) => {
|
|
|
this.scene.removeAnimation(o);
|
|
|
});
|
|
|
- this.multiMaterials.forEach((o)=>{
|
|
|
+ this.animationGroups.forEach((o) => {
|
|
|
+ this.scene.removeAnimationGroup(o);
|
|
|
+ });
|
|
|
+ this.multiMaterials.forEach((o) => {
|
|
|
this.scene.removeMultiMaterial(o);
|
|
|
});
|
|
|
- this.materials.forEach((o)=>{
|
|
|
+ this.materials.forEach((o) => {
|
|
|
this.scene.removeMaterial(o);
|
|
|
});
|
|
|
- this.morphTargetManagers.forEach((o)=>{
|
|
|
+ this.morphTargetManagers.forEach((o) => {
|
|
|
this.scene.removeMorphTargetManager(o);
|
|
|
});
|
|
|
- this.geometries.forEach((o)=>{
|
|
|
+ this.geometries.forEach((o) => {
|
|
|
this.scene.removeGeometry(o);
|
|
|
});
|
|
|
- this.transformNodes.forEach((o)=>{
|
|
|
+ this.transformNodes.forEach((o) => {
|
|
|
this.scene.removeTransformNode(o);
|
|
|
});
|
|
|
- this.lensFlareSystems.forEach((o)=>{
|
|
|
+ this.lensFlareSystems.forEach((o) => {
|
|
|
this.scene.removeLensFlareSystem(o);
|
|
|
});
|
|
|
- this.actionManagers.forEach((o)=>{
|
|
|
+ this.actionManagers.forEach((o) => {
|
|
|
this.scene.removeActionManager(o);
|
|
|
});
|
|
|
- this.sounds.forEach((o)=>{
|
|
|
+ this.sounds.forEach((o) => {
|
|
|
o.stop();
|
|
|
o.autoplay = false;
|
|
|
this.scene.mainSoundTrack.RemoveSound(o);
|
|
|
- })
|
|
|
+ });
|
|
|
+ this.textures.forEach((o) => {
|
|
|
+ this.scene.removeTexture(o);
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private _moveAssets<T>(sourceAssets: T[], targetAssets: T[], keepAssets: T[]): void {
|
|
|
for (let asset of sourceAssets) {
|
|
|
let move = true;
|
|
@@ -253,7 +281,7 @@ module BABYLON {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (move) {
|
|
|
targetAssets.push(asset);
|
|
|
}
|
|
@@ -269,13 +297,14 @@ module BABYLON {
|
|
|
if (keepAssets === undefined) {
|
|
|
keepAssets = new KeepAssets();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this._moveAssets(this.scene.cameras, this.cameras, keepAssets.cameras);
|
|
|
this._moveAssets(this.scene.meshes, this.meshes, keepAssets.meshes);
|
|
|
this._moveAssets(this.scene.getGeometries(), this.geometries, keepAssets.geometries);
|
|
|
this._moveAssets(this.scene.materials, this.materials, keepAssets.materials);
|
|
|
this._moveAssets(this.scene._actionManagers, this.actionManagers, keepAssets.actionManagers);
|
|
|
this._moveAssets(this.scene.animations, this.animations, keepAssets.animations);
|
|
|
+ this._moveAssets(this.scene.animationGroups, this.animationGroups, keepAssets.animationGroups);
|
|
|
this._moveAssets(this.scene.lensFlareSystems, this.lensFlareSystems, keepAssets.lensFlareSystems);
|
|
|
this._moveAssets(this.scene.lights, this.lights, keepAssets.lights);
|
|
|
this._moveAssets(this.scene.morphTargetManagers, this.morphTargetManagers, keepAssets.morphTargetManagers);
|
|
@@ -284,7 +313,8 @@ module BABYLON {
|
|
|
this._moveAssets(this.scene.particleSystems, this.particleSystems, keepAssets.particleSystems);
|
|
|
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.removeAllFromScene();
|
|
|
}
|
|
|
}
|