Can I use my own ticker or timer for the render loop when using a physics engine and how?

Hello, i’ve recently started fiddling with babylon as a side project and was wondering if I can just plug the render function into whatever ticker/interval I want? My end goal with it would be to just stick the whole thing in in a while loop to find the end result of a simulation (almost) instantly.

The problem is that when using enablePhysics, neither the render function nor the ticker it’s assigned to are transparent in any way.

1 Like

explain please, as far as I know in other frameworks you can just use a interval function.
Its been a while since babylon js but there are hundreds of ways to code, you just need to specify more details what it is suppose to do for you…

Take this demo that I changed slightly:

I want to do something like
while(physicsRoot.position.y > 0) { renderScene(); }

I want to basically run the animation super fast (near instant) until a set end point.

You control the renderloop so yes :slight_smile:

Instead of calling engine.runRenderLoop() with your function you can manually call scene.render() when you want.

This is not visible in the PG as we have a central render loop but it is ok to call .engine.stopRenderLoop() to take the control over it

Thanks, I managed to stop, skip and resume the animation at will.

1 Like