How to init a scene or engine without canvas?

Hi I’m coding BJ with Ionic/Angular.
Sometimes, the canvas element would be released on iOS, BJ engine is inited like, the constructor takes html element or a WebGL context,

this._engine = new Engine(canvas);

Scene,

this._scene = new Scene(this._engine);

So how to init the engine without a canvas element, or when the canvas element gets disappeared (released by angular), I don’t need to load scene assets again?

then when the canvas will be available how can I attach the canvas to the scene and engine?

Also in such case, how to load assets?

I saw someone pointed out the AssetContainer, but

var container = new BABYLON.AssetContainer(scene);

it still needs scene !

Hi @tomriddle and welcome to the forum. Perhaps Server Side - Babylon.js Documentation might be helpful to you.

thanks for this info, but my code is not running on server side, I still get to render it to canvas when the canvas finish construction.

So how to convert NullEngine to a real engine that can be drawn on canvas?

Unfortunately there is no way to have babylon.js without a canvas if you want to do image rendering.
They are highly coupled because of WebGL.

You must delete/recreate the engine with the canvas

1 Like