Quick question on rendering multiple scenes on multiple canvases


I’ve been messing with multi scene, multi canvas approaches both with react-babylonjs and babylonjs.

I am trying out very basic just to test if it works. Currently, I made a component that receives ref to canvas, engine, and a color. This component creates a scene, adds camera, meshes, light to the scene. After that it registers view to the canvas with the camera created within the scene.

I made two scenes, one with white cube, the other scene with red cube. However, in the both canvas I see red cube. I expect to see white cube on the first canvas and red cube on the second canvas. Most likely i’m doing something wrong here and it be great to get little bit of advice.

Here is the repro : testing multiple scene - CodeSandbox

You should check which is the current active view and render the right scene accordingly (see this section in the doc).

Here’s a corrected code:


Thank you so much @Evgeni_Popov
I’m grateful of the fact that Babylon has such a great community :+1: