Some clarification on Multicanvas filtering

So I worked up a React website that can make multiple BJS scenes at once with a single engine using the multicanvas engine. The rendering system is independent from the react components that display them so that way as the components scene does not have to build more then once. I noticed that as I started doing multiple scenes I was not sure how to “filter” which one displayed to which.

The documentation says to do

engine.activeView.target === view1

But HTMLCanvasElement and BABYLON.EngineView have no overlap so Im not sure how this is a comparable.

I tried to do
image
Context is actually the scene.

But when I did this and had multiple scenes rendering it seemed to only render the first scene in both elements.

Ill upload the react project to github here soon so others can see how that’s done, but I need to figure out how to accurately filter which scene is being rendered to which element.

You must test the view, not the canvas.

If you have created the view like this:

let view1 = engine.registerView(canvas1, camera1);

The test should be:

if (this.engine.activeView?.target === view1) {
...
}

Ts dropes an error on that saying they have no overlap. Which is why I was wondering whats up.

Ok, it’s simply:

if (this.engine.activeView === view1) {
...
}
1 Like

I’ll give that a shot.