Pause Renderloop with ArcRotateCamera

Hi there,

I want to pause rendering if there has been no change in the scene. A similar question has already been asked and answered here (https://playground.babylonjs.com/#31SIHA#1). However, a “FreeCamera” was used there. In my case (https://playground.babylonjs.com/#31SIHA#2) an “ArcRotateCamera” should be used.
I want the rendering to be active as long as the camera is moving. Since the camera still moves after releasing the mouse button, I don’t know where to start or which event to query.

1 Like

Hm. I am more surprised that it works with a FreeCamera than that it doesn’t with an ArcRotateCamera. If you listen to camera movement to know when to stop rendering the scene, then how can you know when to start rendering again, since the scene is not rendered anymore ?
I thought camera.inputs.attached.keyboard.checkInputs() was the reason why (around line 42), but actually, when you comment this line, the playground with the free cam works just the same… :confused:

Also I logged camera.cameraRotation here (end of the code) and it always returns zero values, even while you’re rotating the camera.

So at this point, I’m thinking : either this is a bug related to ArcRotateCamera, and the property camera.rotation inherited from TargetCamera isn’t working as expected, or I am not understanding some fundamental mechanic about how ArcRotateCamera are working.

I believe @Cedric or @PolygonalSun are experienced with cameras, do you guys have an insight for us ? :slight_smile:

1 Like

Here’s a playground example that only renders the scene if the camera’s projection matrix, view matrix, or mesh target changes. Their observables are used to track changes and the render loop only renders the scene if one of them has changed. It also logs the count of rendered frames so that we can watch the console log as we’re moving/zooming/rotating/resizing/re-targeting for verification. IDK if there’s a better/easier way to check if the camera’s dirty, but this seems to work well…

1 Like

Great!

It was of course clear that it would be so easy once again. :slight_smile:

1 Like