Load and Clear Meshes

Is there an example PG that shows how to load a mesh, then remove it and load another mesh? I’m trying to do this with a .glb file and I cannot seem to remove the mesh.
Thanks,
~Shane

By “remove”, do you mean “hide” or “dispose”?

You may be interested by AssetContainers: Use an AssetContainer - Babylon.js Documentation

1 Like

Hi,
Thanks for getting back. The ideal functionality would be on a button click or slider movement the mesh is gone and when the slide movement is in the same location the mesh is back. Not sure if dispose or hide is better but I’ll look into both.
~Shane

This can be useful for swapping Mesh - Babylon.js Documentation

When enabled is false it is not considered in render loop

1 Like

Looks like you could be interested in the asset container ?

https://doc.babylonjs.com/how_to/how_to_use_assetcontainer

1 Like

Hello,

I updated the demo in the docs linked @sebavan and @JohnK to try and accomplish what you’re looking for. I created 2 containers and added a mesh (sphere or box) to each one. Using container.addAllToScene() and container.removeAllFromScene() is was able to load a mesh, remove it, then add in another on key press. Hope this helped!

https://www.babylonjs-playground.com/#5NFRVE#28

1 Like