Show / Hide Mesh on the click of a button?


I would like to completely remove the mesh from the scene by clicking on the button, and by clicking the button again, return the mesh to the scene. (Show / Hide)
This I did with the help of visibility, but it does not completely remove mesh from the scene.
How to completely remove mesh from scenes and restore it again by clicking on the button ???

This is a babylon playground example:
I tried with meshone.dispose (true); but it does not work …
Does anyone have any idea or there is a regular way ???


Checkout the button code on mesh3 here : It is worth noting that the loaded object wasn’t just a mesh, it was an array with two meshes.


:slight_smile: hmm. What IS the plural form of ‘mesh’? Maybe meshi? mesha? heh.

‘Meshes’ doesn’t feel right. Saying it… causes too much saliva movement and promotes spittle. :blush:

Should we treat him nice some more, TTC?

Gosh, I love that ‘of’ directive. for (mesh of myMeshThree)

I’m going to wear-out that ‘of’ in no-time, so I guess I better order a case of them.

I’m going to pay the extra $$$ … and get the “industrial strength” of’s. :slight_smile:


Meshes :slight_smile:
Thank you for your answers
Wingnut very simple and concise answer …
timetocode. you answered in part to the next question …
To clarify;
My project has a model group that will be named (myMeshesOne, myMeshesTwo …), and each model group will be named by its name. Clicking this button should appear and disappear from the entire model group (myMeshesOne), which we successfully solved.

The next thing I need by clicking on the button is to remove an individual model within the model group (myMeshesOne, myMeshesTwo …). If I do this on a timetocode. example;
myMeshThree [0] .setEnabled (false)
myMeshThree [1] .setEnabled (false)
but if later add more models, a button names and sequence of model names is mixed.

Is there an option to show / hide an individual model within myMeshesOne group clicking the button, but to be based on the model name?
If I click on the button named
Show/Hide myMeshesOne Box One to remove
myMeshOne [BoxOne] .setEnabled (false),
Show/Hide myMeshesOne Box Two to remove
myMeshOne [BoxTwo] .setEnabled (false)

Example of babylon.js playground:
myMeshesOne has two models named BoxOne and BoxTwo
myMeshesTwo has two models named SphereOne and SphereTwo
myMeshesThree has two models named CylinderOne and CylinderTwo

Ooooh, “growing” buttons only AFTER all the mesh arrive in the scene! Cooooool.

Yep, eachMesh.enableDisableButton = a GUI button programmed to enable-disable IT. :smiley: Fun!

Each mesh could have an “info panel” textBlock too… which displays string text-info… that arrived during the load-in… stored in the mesh’s .metadata property. COOOOOOL!

Super-fun when it comes time to display those buttons in a sane/logical way. :slight_smile: yeah!

GUI smart-menu… able to traverse any subsection of the scene hierarchy… but never needing to display TOO MANY buttons at the same time. Menu only displays buttons for the subgroup of the subgroup of the subgroup… that the user is working-within. heh. Wild! Menu re-configs every time a subgroup is “drillied-into”, or “backed-out-of”. Nice.

I think AA is going to use HTML buttons on a sidebar, though (not BJS GUI).

Still, grow THAT HTML drill-able sidebar treeview… after the scene is loaded and after the mesh-names gathered. Yum. I bet others have done that, already. PG inspector, BJS editor, and Dad72’s many editors… all probably generate HTML treeviews… from scene graphs.

Might be a job for BJS Tags, which make great group identifiers and managers. Tags can be used similar to a mesh TYPE, and there’s plenty of Tags System search power to gather/collect all mesh with similar tag-names, from within scene.meshes. Easy to set layerMasks and/or renderGroupIds… based on tag-groups, too. Raspberry YUM!

I wonder if .tags is an unused mesh property on Blender mesh. Could add it via Blender Custom Properties… but I’m not sure that it would make the trip to BJSville.

1 Like

Thank you for your reply…
I found a solution;
Line: 107
Uh …, I’m learning …:wink:
Let’s go to the next level …

1 Like

Hey, nice work! Yeah, you should definitely go to the next level.

You have a brand new machete - quite sharp. You should be able to blaze some amazing and innovative trails… with it.

You could possibly cut some bindings/vines, and maybe chop-up any teddy bears that you might still be hugging. :slight_smile: Take a little drink… from your self-confidence canteen… you’ve earned it.

(What the hell is Wingnut talking about now?) heh.

Good ol’ JS. There’s not really a proper way to do something. Instead, there’s 10 ways to do something. If you want to find the BEST way of 10, it requires performance testing, and analysis of which ways the author/users… like the most.

Hey fellow forum-folk…

Does anyone know-of, or want to try/build… a real-time-generated playground-based sceneGraph-To-HtmlTreeView JS routine?

I know the playground Inspector does that… but… I’m looking for something that we can edit in a playground, and is easy for Aldin to “steal”, if wanted. You know… a generateDrillableHtmlSidebarSceneGraphTreeView() func. :slight_smile:

Extra credit for setEnabled toggle/checkboxes (at branch/group/layer levels, and at individual mesh level)… just like the PG Inspector feature. But, hmm… disabled mesh must not leave the treeView upon being disabled.

(…or else user can’t re-enable. treeView item disappeared because of live treeview updating… no good for enable/disable toggles. Only mesh.dispose can remove a treeView meshItem - duh, Wingy).

DOUBLE extra-credit… for restructureMeshBranchesByTagNames() feature. :wink: (as opposed to default parent/child branch structures). Then Aldin can load in PILES of mesh… in a single file… and use his precision-planned mesh tagNames… to sort his mesh into groups/branches/layers.

Oooh… sort by layerMasks or renderingGroupIds! Coooooool. :slight_smile: (Wingnut grabs a Blender Collection from a 2.80 .blend file… shows it to @JCPalmer and @gryff for no reason whatsoever, and then crams it into a nearby treeView control.)

1 Like

Oooo …, I’ll drink a lot :wink:
Of the 10 ways, the best one is the simplest.
I found one of the solutions but also a small mistake …
If I click on the Show / Hide myMeshesOne Box One button and remove BoxOne, then I click on the Show / Hide MyMeshesOne button to remove everything, an error occurs: BoxOne appears and remove Box Two …
Maybe I should click Show / Hide myMeshesOne Box One to show or hide everything first and then hide or show it all. Any idea?


All your ideas sound good. Test test test… that’s the part that is the most fun.

If you are haunted by cost-of-living deadlines/pressure/terrorism, that can kill experimenting fun. I’m working-on fixing that issue… daily. :open_mouth: :smiley: