hi. i have many scenes which are rendered to many canvases. the problem: i have to switch between them but keep what is rendered. how to stop rendering completely but hold last frame? i’m handling it with snapshots like:
you’re right. engine canvas (which goes to constructor) keeps last rendered frame but registered canvases are not on engine.stopRenderLoop(). i took your website demo views: Babylon.js - Multi views demo and modified it with timeout and stop render loop:
<script>
// Create a working document
var canvas = document.createElement("canvas");
var engine = new BABYLON.Engine(canvas, true);
// Set the default canvas to use for events
engine.inputElement = document.getElementById("renderCanvas0");
var scene = createScene();
engine.runRenderLoop(function () {
if (scene.activeCamera) {
scene.render();
}
});
setTimeout(() => {
engine.stopRenderLoop();
}, 3_000);
</script>
Workaround:
You can take a screenshot of the view(s) before ending the render loop and create img html elements with a z-index higher than the canvases. Position and size these imgs over the canvases. Display the screenshotted content in the imgs. Remove the imgs when engine loop/loops is/are resumes. Maybe you will need to wrap the imgs in a div.