Render view woes - Continuous + on-demand render

Is there an intended way to render a view (on a separate canvas) manually (eg not via render loop) while a 2nd view (canvas) is rendered continuously?

I got something up and running, but it’s quite hacky and involves stopping and starting the render loop, calling _renderViews() and registering and unregistering the views for every rendered frame. I’m hoping there is a simpler (maybe more obvious?) way to to this.

To show what I mean I created this playground

The interesting part happens in renderFrame:

    const renderFrame = (frame) => {
        // Why is play & pause needed for goToFrame to work properly?????
        animGroup.play();
        animGroup.pause();

        animGroup.goToFrame(frame)
		
        engine.registerView(newCanvas1, camera2);
        engine.registerView(newCanvas2, camera);
        engine.stopRenderLoop();

        engine.runRenderLoop(() => {
            scene.render();
        });

        engine.unRegisterView(canvas);
        engine._renderViews();

        setTimeout(() => {
            engine.unRegisterView(newCanvas1);
            engine.unRegisterView(newCanvas2);
        }, 0);
    }```

Does it need to be this hard? Am I missing something?

i would say that you can set the first view to enabled = false, and simply enabled it when you need it ?

Thank you. That seems to work!

Here’s an updated playground:

1 Like

Here I did something similar but where the views are always rendered. Instead it’s the animations that are playing at different frame rates using onBeforeViewRenderObservable.

Pretty cool if you ask me! :smiley:

2 Likes

Great!!!