Is it possible to run fast simulations using NullEngene?

I am trying to create an application that uses NullEngine to simulate physics and replay the results on the client (browser).

By using NullEngine and Physics, I was able to perform physics simulations (free fall and collision).

I have confirmed that using runRenderLoop to advance the physics phenomena will give me sequential calculations at about 60 (30?) fps.
Trying to do a 10-second physics simulation would require 10 seconds.

engine.runRenderLoop(() => {
  console.log(ballMesh.position.y, ballMesh.position.z);
  scene.render();
});

I would like to know how to process this faster.

In the following example, it processes at high speed without worrying about fps, but time does not advance.

for (let i = 0; i < 200; i++) {
  console.log(ballMesh.position.y, ballMesh.position.z);
  scene.render();
}

Is it possible to run scene.render() without using runRenderLoop as described above, but speed up the process and pretend that time has advanced, and then do a physics simulation?
What would be the best way to do this?

Have you tried the following settings?

//scene.getPhysicsEngine().setTimeStep(1/60);
scene.getPhysicsEngine().setTimeStep(1/6);

scene.getPhysicsEngine().setTimeStep(1/6);

Thank you very much.

I tried it, but the processing time did not change and there was no difference in the processing interval.

For example when taking 200 step coordinates,
If I use “runRenderLoop”, it takes about 4 seconds, regardless of whether I use “setTimeStep” or not.

A simple “for” process would take about 100ms.
On top of that, we have confirmed that the coordinates hardly advance at all.

const plugin = new BABYLON.HavokPlugin(false, havok); // <= I had set true

After this setting, each time “scene.render()” is executed, a certain amount of time elapses, allowing for fast simulation.

On top of this, “setTimeStep” seems to be set, but I could not see any significant difference from the case where I did not set it.

Once the target high speed simulation was achieved.

3 Likes