Registering view breaks the render loop


I have an application where the user can navigate away from the the canvas that contains the scene. So when the user navigates back there is a new canvas element where I would like to display the scene. I have found that it is possible to use multiple canvases (Babylon.js docs) with the engine using views. I also saw that there was a similar question (How to switch canvas?) but I still have problems.

I am trying to register a view with the engine but when doing so the render loop doesn’t run anymore. I’m not sure what I’m missing.

Thanks for the help! :slight_smile:

by doing this:

engine.runRenderLoop(() => {

You are not asking the scene to render anymore. Your renderloop is simply writing a message
The goal of the render loop is to render :slight_smile:

Yes, it’s fine that it’s only writing a message in this example as I just wanted to demonstrate that it seems like that the render loop doesn’t run when line 3 is included in the PG because "Hello" doesn’t appear in the console. But when I comment out line 3 then the message appears.

I guess I need to do something extra when I want to register a view for everything to work correctly. So I guess my question is what do I need to do here to get the message in the console?

Sorry for any confusion. :slight_smile:

haha ok I get it!

Yes this is expected. Where they are views, the renderLoop is skipped because the engine takes control of the rendering to dispatch and copy the views.

Why do you need to control the renderLoop? Maybe we can find a way to do that with the views

Okay, I see. So is there a way to get the scene rendered while using views? Or do I need to have my own mechanism similar to the render loop?

Let me check!

Ok the issue in the PG is that the registerView is registering a view on a canvas where we already have attached the engine on it