How to switch canvas?

How can i switch the rendering canvas?
My program sometimes deletes the canvas because the user navigates to another view. When the user navigates back the canvas is replaced with another one with same id, but it seems that Babylon is using the previous one because the screen ends up black.

One solution would be to recreate the engine and scene from scratch when the user navigates back, but I don’t like it because I would have to re-import all of my assets to the new scene.

Chek it Use Multiple Canvases with one Engine - Babylon.js Documentation

It is a new feature, works only with 4.1+

1 Like

Yup all the resources under the hood are tied to the canvas which explains why it is not that easy but @avin answer can definitely help addressing those concerns

Thanks. Well that explains why it didn’t work on my version…