I’m wondering what code would replicate what the Playground Run button does.
For instance, clicking a button would restart the scene in exactly the same way.
I found various forum posts referencing createScene() and scene.dispose(), but my scene crashes when I call those functions.
Just curious if I should keep working with those options, or if there is a better way now to restart a scene.
Do you get any console errors?
If you’re using a createScene function setup like the playgound (creates and returns the scene object)
Let myScene = createScene()
myScene = createScene()
Something like the above should work
And in the engine renderloop, check
myScene && myScene.isReady()
Before calling myScene.render()
Here’s a PG that demonstrates what I’ve attempted so far:
I’m new to programming and Babylon.js, so I don’t fully understand how to implement the code you provided. As you’ll see in the PG, calling scene.dispose() freezes the scene. I’m not sure if that’s a successful first step or not
Also, hello @holger, and thanks for the link. I did read that post. The solution definitely seems to be there (just like with what @aWeirdo is providing), but I just don’t see it at my current level of understanding. The code makes sense, I guess I just don’t know where it all goes without a working example.
Perhaps with this discussion a functional PG can be made that demonstrates how this works for those with the same question in the future
I only have a couple minutes atm, so i can’t explain in detail.
Check out the html template on this doc page, maybe that helps you get a better understanding
First Steps - Babylon.js Documentation
Great, I’ll check that out. Thanks for the help!