Ok, I think using the lastest Babylon screenshot tools, combined with the engine.endFrame()
has this working.
The code is now basically like this:
const engine: any = scene.getEngine() as Engine;
const camera = scene.activeCamera as Camera;
const obs = scene.onBeforeRenderObservable.add(async () => {
scene.onBeforeRenderObservable.remove(obs);
const screenshot = await ScreenshotTools.CreateScreenshotUsingRenderTargetAsync(
engine,
camera,
screenshotSize,
mimeType,
4,
true,
);
resolve(screenshot);
});
scene.render();
engine.endFrame();
Using this, the render loop can be paused and the frame buffer always appears flushed. You were right, and this seems only slightly slower. I have no idea what I did wrong before.
I’ll confirm this is fixed once we run through some more builds