Letting user change aspects of scene

Hey there!

I have my little scene, filled with some boxes and other things where the user can walk around freely. The boxes and ground have collisions enabled, the scene has gravity enabled and shadows are also enabled.
The user should be able to do this after the scene has loaded, at any point.

Is this possible without reloading the whole scene?
And how would I go about doing it? One thought I had is that I could use localStorage to store the settings, but idk how my script would notice that something has changed.

I’m sure I could get it to work somehow by just trying, but I’m looking for thoughts on what would be the best/cleanest way to do this, since I’m relatively new and have no idea how I could approach this.

Edit: I found a way of doing it: I have buttons somewhere on my page for the user to change the behaviour, and in my createScene() I just add event listeners for those buttons to change behaviour of my scene. This seems like a good way to do it to me

Yep event listeners are a great way of doing that :smiley: Another possibility would be Observables | Babylon.js Documentation (babylonjs.com) but they’re also kind of event listeners to me too.

1 Like

Thanks for the reply, and I agree, eventListeners seem like the way to do this.