How to remove or hide all instances from a scene?

Hello, I need some help with instances. I’m using LoadAssetContainer to load the assets and I’m trying to remove all instances from one container and the source of these instances are more than one, my question is if there is a way to remove all these instances if I don’t know the name of the sources, I also using removeAllFromScene to removes meshes based in this example:

https://playground.babylonjs.com/#JA1ND3#210

In the example, the boxes are the instances they always appear.

You can reference the isAnInstance property of the mesh to check if mesh is instance. I have noticed that if there is a lot of meshes they may not all be removed in a single frame.

For example - I have it set to remove instances when Z is pressed in your example but it does take multiple attempts to get rid of all of them.

https://playground.babylonjs.com/#JA1ND3#211

See line 62 which is the basic idea

Thanks, I forgot to mention that I want the instances back when the assetContainers is in index 2 (the scene with boxes)

Ok you can use setEnabled for this

https://playground.babylonjs.com/#JA1ND3#212

2 Likes

Thanks, Michael it works

1 Like