# How to prevent runRenderLoop to render scene when user does not interact in the scene and the scene is static

**URL:** <https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282>\
**Category:** Questions\
**Tags:** engine, rendering, scene\
**Created:** [January 11, 2023, 2:16pm UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282 "2023-01-11T14:16:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ehtesham\_Ahmad\_Nadim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ehtesham_ahmad_nadim/32/51458_2.png) [@Ehtesham\_Ahmad\_Nadim](https://forum.babylonjs.com/u/Ehtesham_Ahmad_Nadim)\
**Post date:** [January 11, 2023, 2:16pm UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282/1 "2023-01-11T14:16:42Z")

</div>

I have a `scene` that is quite static. So basically there is no animation or whatsoever when the the user is not interacting with it. But the `runRenderLoop` is getting executed at 60 FPS when there is no user interaction. I do not want the same scene to be rendered again and again, which I think reduces the battery usage of the device. I want to prevent the `scene` from rendering when the previously rendered `scene` and the current `scene` are the same.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 11, 2023, 4:14pm UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282/2 "2023-01-11T16:14:45Z")

</div>

This should help [On-demand rendering solution broken since 5.29 - #6 by PolygonalSun](https://forum.babylonjs.com/t/on-demand-rendering-solution-broken-since-5-29/36379/6)

---

<div class="post-metadata">

**Author:** ![Ehtesham\_Ahmad\_Nadim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ehtesham_ahmad_nadim/32/51458_2.png) [@Ehtesham\_Ahmad\_Nadim](https://forum.babylonjs.com/u/Ehtesham_Ahmad_Nadim)\
**Post date:** [January 12, 2023, 2:56pm UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282/3 "2023-01-12T14:56:55Z")

</div>

Well, tbh I only need the scene to render when the user moves the camera and does some interaction with the mouse (e.g clicks on the mesh). I think this solution also will not work for the `UniversalCamera` situation

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [January 13, 2023, 9:12am UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282/4 "2023-01-13T09:12:17Z")

</div>

Hi, you can try this

```auto
camera.onViewMatrixChangedObservable.add(() => {
        scene.render();
});

```

long version…  
Create a boolean and make it true inside pointer functions and insinde above function, and in renderLoop check if this variable is true, and only then call scene.render()

---

<div class="post-metadata">

**Author:** ![Ehtesham\_Ahmad\_Nadim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ehtesham_ahmad_nadim/32/51458_2.png) [@Ehtesham\_Ahmad\_Nadim](https://forum.babylonjs.com/u/Ehtesham_Ahmad_Nadim)\
**Post date:** [January 30, 2023, 6:57pm UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282/5 "2023-01-30T18:57:22Z")

</div>

Is there any way to compare the previous scene and the new scene and then prevent the scene to render if the two scenes have same attributes

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [January 31, 2023, 7:10am UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282/6 "2023-01-31T07:10:00Z")

</div>

You can [serialize](https://doc.babylonjs.com/features/featuresDeepDive/Exporters/Save_Babylon) the scene and compare the json, but again this is not the solution. You may want to do this on save to avoid ‘excesive’ save request, and even there is not to good to serialize the entire scene, instead you can create a json only with the atributes you want to store.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [January 31, 2023, 7:29am UTC](https://forum.babylonjs.com/t/how-to-prevent-runrenderloop-to-render-scene-when-user-does-not-interact-in-the-scene-and-the-scene-is-static/37282/7 "2023-01-31T07:29:45Z")

</div>

I made a pg, check the console

> **[Babylon.js Playground](https://playground.babylonjs.com/#7ZAIM7%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes
