How To

Use an AssetContainer

To add and remove assets from a scene an AssetContainer can be used.

It can be created manually

var container = new BABYLON.AssetContainer(scene);

Or by loading from a file. See loading from files

The container can then be used to add or remove contents of the container from the scene.

// Add all objects in the asset container to the scene

// Remove all objects in the container from the scene

Demo -

This can be used to add/remove all objects in a scene without the need to exit WebVR. Demo -

When creating assets manually the moveAllFromScene method can be used to move all assets currently in a scene into an AssetContainer and remove them from the scene for later use.

var keepAssets = new BABYLON.KeepAssets();

Demo -