Multi scenes with same canvas

I’m a bit confused! I want that I can create different scenes and whenever players click on the button they can switch to that scene.
This means by default having a scene of playground1 and whenever the player clicks on the button or chose another scene from the dropdown the whole scene will change to playground2 or whatever player selected.
Can anyone suggest to me any PG or any proper way to achieve this?

Thanks and Regards

When you create a scene, you must put it in an array:

var scenes = [];
scenes["SCENE1"] = new BABYLON.Scene(engine);
scenes["SCENE2"] = new BABYLON.Scene(engine);

And in your render loop, you display the scene of your choice.

var activeScene = "SCENE2";
engine.runRenderLoop(() => {
1 Like

Thanks, this helps me a lot.

1 Like