Render on demand with Babylon Lite

I am working on a scientific application with BabylonJS that is already WebGPU only so I want to port as soon as possible to Babylon Lite. Since I see that await startEngine(engine); is the equivalent to engine.startRenderLoop I was wondering how to not run a render loop but to render on demand, i.e. either wenn my data model or my camera change.

Thank you!

renderFrame is your choice Babylon.js docs

startEngine() is the automatic loop. For manual rendering, skip it and call renderFrame() yourself.

Simple loop:

let lastTime = performance.now();

function loop(now: number) {
const deltaMs = now - lastTime;
lastTime = now;

resizeEngine(engine);
renderFrame(engine, deltaMs);

// continue loop
requestAnimationFrame(loop);
}

// start loop
requestAnimationFrame(loop);