Quickly swapping between views with different show/hide states

Hi, I have scenes with between 100 and 4000 meshes.

I have a function that allows to toggle between ‘show only’ a mesh and it’s children or ‘show the whole scene’. Some meshes must stay hidden at all times. Everything belongs to the same glb. Currently I go thru a list of meshes I turn on and off for the “see all” then go thru the children of that mesh the user wants to see only and toggle visible and enabled.

The loop that goes thru all the meshes to make them visible and enabled takes too long. Is there a way to have two “views” and just toggle between them? Or toggle between two render groups?

Thanks!

This is a cool question that I think can have multiple solutions.

Option one which you mentioned is having two “views”. there are a couple of ways to do this. You can have them all loaded into the same scene but just different areas in space and then just switch camera viewports. Area 1 of your scene has all the objects visible and enabled while area 2 has none of them visible and you are just toggling the single that the use selects instance on and off. While I think this should lead to a faster switch between all meshes and only 1 mesh you will now have double the objects in your scene.

Option 2 have different scenes. With the same concept as option 1. Here is a demo that showcases this Babylon.js Playground Not sure if the switch will be slow with 4000+ objects. Time to find out :slight_smile:

Hope this is what you’re looking for and let me know if you need any help with this.

Layer masks might be another option.

1 Like

WIll try both, thank you guys!

1 Like