meo
December 16, 2019, 1:28pm
1
Hello I cannot understand how to access a mesh by its name, can somebody help me?
Here is my code, I just want to access an imported mesh, name it and remove from the scene, that simple, but I can’t:
https://www.babylonjs-playground.com/#JUKXQD#237
There are some other topics with the similar name but none of them helped me.
JohnK
December 16, 2019, 1:45pm
2
Hi @meo and welcome to the forum.
This is because line 18 is executed before the skull is loaded and named.
Inside the render loop you can check for its existence before removing, etc
https://www.babylonjs-playground.com/#JUKXQD#238
https://www.babylonjs-playground.com/#JUKXQD#239
otherwise any dealings you have with it must be inside the loader
https://www.babylonjs-playground.com/#JUKXQD#240
1 Like
meo
December 16, 2019, 5:09pm
4
Hello JohnK, your answer solved my problem partially but not fully. What I want actually to do is when a website visitor enters a button I want to delete a STL model from scene and add a new one to scene.
But I cannot access the model or the mesh by its name. I tired this solution but it did not work out, I could not access the the old mesh: https://www.babylonjs-playground.com/#JUKXQD#241
Arte
December 16, 2019, 6:36pm
5
Hi @meo and warm welcome from me.
Function sequence is also important.
https://www.babylonjs-playground.com/#JUKXQD#242
1 Like
meo
December 16, 2019, 7:27pm
6
Thank you, it is a solution, but again it did not solve my whole problem.
I want to have a html button like this:
“Rotate the Object”
for example and want to access some of the meshes through the function rotate1(). Actually I want to delete last object and load another one but let say rotate it. It is easier to check whether it works.
Arte
December 16, 2019, 8:37pm
7
1 Like
meo
December 16, 2019, 8:51pm
8
Hello, thank you but I want to have an html button not a button inside the scene. Like:
<button type="button" onclick="removeObj()">Remove</button>
the function removeObj() should be outside the “createScene” function.
I can do that with three.js but I have problem with it shaders therefore I moved to BJS.
meo
December 16, 2019, 9:04pm
9
I found this topic, but I could not understand fully: does it really mean that is impossible to reach scene elements through html ui even like simple buttons?
Hello, everybody,
I’m standing in front of a project with a very complex user interface and of course I know that BABYLON brings its own GUI system, but I’m afraid I can’t avoid building the UI in HTML.
But first I wanted to ask if there are any reasons against it. Performance slumps for example. Or maybe someone already has experience in combining Babylon-Canvas with the HTML DOM?
I have read some comments on the topic, in connection with other game engines, in which it was said that it was …
JohnK
December 17, 2019, 9:51am
10
First of all if you have a new question start a new topic. You are much more likely to get an answer to your question. Particularly if your first question is solved.
Yes you can use an HTML GUI
Simple example Babylon.js Playground
or dat.gui https://www.babylonjs-playground.com/#NGS9AU#1
or CastorGUI - Babylon.js Documentation
Babylon.GUI is necessary if you are using VR or you want the GUI to be within the 3D world not just overlaying it.
1 Like
meo
December 17, 2019, 10:16am
11
Thank you for your response, I will take your advice next time according to open new topic.
I found yesterday to the solution of CastorGUI but its side is not reachable:
http://www.babylon.actifgames.com/demoCastorGUI/castorGUI.min.js