I am trying to show/hide parts of a 3D model exported as .glb
I have no idea how to read the name or id of the parte int glb file and make them hide or show from a list of buttons.
Thank you for answering!.
I know the sandbox. I understand there, how the .gld file is loaded and the porperties that I can control. However, I have not been able to make any intercaction with the āmeshesā or nodes only with the whole object.
I do not how to hide /show the parts, how to code that.
Hi,
As briefly explained by @nogalo, there are different ways to show/hide a mesh.
Though, Iām not sure that as a newcomer I would have understood it all
So, hereās just a quick example PG for you.
My advise, use the āInspectorā in your scene. Simply call
scene.debugLayer.show();
towards the end of your script (before returning āsceneā)
From the Inspector, in tab āscene explorerā, unfold the first category of āNodesā. This will show all the meshes loaded or created in your scene. Click on any plus button to unfold the hierarchy. This is where you will find all nodes/meshes that have been parented to this root node. In nodes, everything that has a cube icon is a mesh. The other icon shows a transformNode which does not have geometry.
Typically, hiding a tranformNode will not hide the meshes set as child of this transformNode.
The eye icon you see to the right of the mesh or transformNode name is the show/hide. Better said, it calls the property of āisVisibleā (mesh.isVisible = true) to show a mesh, or (mesh.isVisible = false) to hide it. You can click on it in the Inspector to display or hide the mesh.
You can act with any mesh (or transformNode) loaded through a model AFTER the model is successfuly loaded or within the IMPORT function.
You can select a mesh (after import) by its ānameā or its āidā.
You can also declare a mesh after or within the import sequence and next use this variable to access it.
Hello!.. Thank you for your answer. I could figure out how to turn on and of a mesh but I canāt add more buttons, checks buttosn to do it⦠could you please tellme how can I add more buttons?
Thanks
Hi,
At what time do you want to add more buttons? Do you want to have just more buttons visible at all time OR do you want to add a button depending on certain condition(s)?
To really help here we would need a PG.
Did you check how to [import external assets in PG] ?(Using External Assets In the Playground | Babylon.js Documentation)
Else, we donāt really care about the model. You could use any model (I.E. those from the asset library)
What we need to see here is the code you are using to create your button(s) and how you hook them to whatever function. From there, we can simply debug or enhance your PG and explain on the side.
Hi,
First, congrats for the PG set-up. This works for me.
As for the above quote after the comment from @sebavan, I would say ānot reallyā
You forgot the promise (await in this case), meaning your script is processing elements that have not yet loaded. This includes the ADT AND the meshes.
So, for the adt (when loaded async), it should read somethink like: