How to stop/freeze the engine

For an application I’m working on I need to stop/freeze the engine so it doesn’t consume computer resources. Do you know how to do this?

In BabylonJS I use:

engine.stopRenderLoop()

If you know how to do it in PlayCanvas that would be awesome as this is a key element to choose our 3D Framework to use.

Setting this.app.autoRender = false; will stop the application from rendering every frame.

To render set this.app.renderNextFrame = true; each time you wish to render a frame.

@dave will this stop the physics simulation as well?

No, this just prevents the frame from being rendered. Everything else (scripts, physics, etc) updates as usual.

This is ideal for situations where the camera view doesn’t change unless there is user input. For example, a configurator

Understood, thanks! To pause a game using physics how can we do that? As the physics update function is called automatically.

Do you want to stop the physics for performance reasons or just to make everything freeze?

Hi @vaios for start just to make everything freeze, for pausing.

But it would be good to have control over the physics loop and control its update frequency, separately from the render loop.

Thanks!

If you just want to pause stuff or slow them down you could use app.timeScale. If you set it to 0 then it’s gonna pause the physics I think. Although timeScale affects all systems not just physics.

1 Like

Thanks, this is useful. Will check the source code for what it affects in addition.

Thank you very much, I’ll test it right away. We have customers that will use Terminal Server so we need to use resources only when interacting with the 3d model and not the Webpage. I’ll post the outcomes.

I use Cannon.js to pause the physics, this helps me suspend gameplay until garbage collection or other operations the game has to make to free up memory/resource…

I am trying to use the Playcanvas’ physics engine now because I like it’s Mesh RigidBody system…unfortunately Playcanvas’ physics engine makes the sporadic frame rate changes on my low-end devices, while Cannon.js keeps the frame-rate consistent even though lower than the highest fram-rate Playcanvas’ physics engine has.

Well if Playcanvas can create a function specifically to suspend physics engine, that would be ideal…