Hi gang, possibly-not-that-quick question.
I’m running Babylon in a React project. I’ve had one scene showing for months, and am trying to add a second. The second scene is displayed in a modal, a window that sits in the centre of the screen, over the top of the first. The first scene uses a different skybox to the first, otherwise I’d just use a second camera positioned elsewhere in the first scene and use ViewPorts. The second screen is the same size as the first (per the recommendation in the documentation), but trimmed down using CSS clip-path. As this is still in the “how do I make this work” stage, the path is currently just a circle, and the second canvas is offset by 80px.
I’ve followed every piece of instruction I can find, I’ve scoured the documentation, I’ve spent several days just blindly guessing, but I can’t get it to work correctly.
The nature of the game I’m building makes it a little hard to see, so I’ve highlighted the edge of the “modal” in the screenshot below. The view is identical to the one exterior, albeit clipped and 80px down the page, when it should be showing the second scene
What am I missing?
useEffect(() => {
if (!done && engine && canvasOne.current && canvasTwo.current && multiverseScene && planetViewScene) {
engine.runRenderLoop(() => {
multiverseScene?.render()
planetViewScene?.render()
});
const multiverseCamera = new UniversalCamera("multiverseCamera", new Vector3(0, 0, 0), multiverseScene)
const planetViewCamera = new ArcRotateCamera("planetViewCamera", 90, 90, 40, new Vector3(0, 10, 0), planetViewScene)
setMultiverseEngineView(engine.registerView(canvasOne.current, multiverseCamera))
setPlanetViewEngineView(engine.registerView(canvasTwo.current, planetViewCamera))
multiverseCamera.attachControl(canvasOne.current as HTMLCanvasElement, true);
planetViewScene.autoClear = false
const resize = () => {
multiverseScene.getEngine().resize();
planetViewScene.getEngine().resize();
};
if (window) {
window.addEventListener("resize", resize);
}
if (multiverseScene.isReady()) {
onMultiverseSceneReady(multiverseScene, myPlayerID);
} else {
multiverseScene.onReadyObservable.addOnce((scene) => onMultiverseSceneReady(scene, myPlayerID));
}
if (planetViewScene.isReady()) {
onPlanetViewSceneReady(planetViewScene);
} else {
planetViewScene.onReadyObservable.addOnce((scene) => onPlanetViewSceneReady(scene));
}
setDone(true)
}
}, [done, onRender, onMultiverseSceneReady, onPlanetViewSceneReady, myPlayerID, engine, planetViewScene, multiverseScene, flags.ui.view]);