Playground Link
I need to load new scene and dispose the old one. But it shows nothing.
Set ActiveCamera like this post doesn’t work
I need to load new scene with the imported data and dispose the old scene. But it seems that the new scene got frozen after rendered, i created the simple background here: https://www.babylonjs-playground.com/#KC5W6L#6 .
I got three questions below, actually they all can be summarized into one question: What is the proper way to replace the old scene with new scene?
Do i need to dispose the old engine and create new one?
Since the new scene carries with camera data, do i need to create new cam…
Thanks for helping!
Solution:
The problem is solved by 2 actions:
Change the scene target when create guiMenu
const guiMenu = AdvancedDynamicTexture.CreateFullscreenUI(‘ui’, true, sceneToLoad);
Add active camera after change scene from old scene to new scene
The second actions should be the difference between Babylon version 5 vs 6
In version 5, no need active camera, version 6 needs it
11128
July 20, 2023, 7:25am
2
The PG you posted has multiple issues to begin with
doesn’t work at all
it’s a ts type code, but it’s a js type pg
you imported your local project, so it’s different from PG’s render rules
Here’s what we found
If I press a button in scene 1, scene 2 (maybe Game?) should run after scene 1 is discarded?
Maybe what you’re missing is the part about dispose and render.
check PG then tell me if there are any more special conditions
https://www.babylonjs-playground.com/#KC5W6L#13
2 Likes
11128
July 20, 2023, 7:27am
3
Generally speaking, if it is entered as a parameter of a scene when created, it will be inherited by the scene and removed on dispose, and you will need to create a new one.
ex
var camera = new BABYLON.ArcRotateCamera(“Camera”, 5, 1, 15, new BABYLON.Vector3(0, 0, 0), scene
);
2 Likes