Hi,
In my canvas, I want to change lightning or add elements by javascript on click or on change event.
I know about BABYLON.GUI.AdvancedDynamicTexture
But I want to render scenes based on the outside event triggers.
Is it possible to listen to an event trigger inside to create a scene or re-render the scene after an event?
Hello!
If you’re changing scene elements, changing materials, etc, you normally won’t need to listen to anything, the engine itself will render the updated scene on the next frame
You can even do things like HTML elements that drive changes on the scene, and it will automatically re-render: Interacting with HTML elements | Babylon.js Playground (babylonjs.com)
thanks for the reply.
In the example, you showed me you are creating a button inside the scene
But I am dealing with a button or dropdown which is not inside the scene.
Though I figure out the process
The button could have been created outside of the scene too, as long as it has a reference to the scene itself, it can manipulate it and the changes will be reflected. As how to pass and handle javascript references/variables, this is more of a software engineering question than a Babylon.js question. But a very simple example could be done in this way: quick-demos/external-references.html at main · carolhmj/quick-demos (github.com)
1 Like