Change camera direction

I have a and array of cameras streaming videos.
i need half of them to use useRightHandedSystem, and the other half to use useLeftHandedSystem.
But when oI do Scene.useRightHandedSystem = false, it changes the whole thing.
Can i make this conditionally, based on camera name?

// Makes 6 small canvas, and inserts camera with streaming for each canvas
multipleCanvasCreation(scene) {
for (const cameraInformation of this.cameraInformations) {
const canvas = document.getElementById(${cameraInformationrmation.name}_myCanvas);

    // Set handedness for the camera
    if (
      cameraInformation.name === "cam1" ||
      cameraInformation.name === "cam3" ||
      cameraInformation.name === "cam5"
    ) {
      const camera = new BABYLON.ArcRotateCamera(
        `${cameraInformation.name}_eachcamera`,
        0,
        0,
        0,
        cameraInformation._p.add(cameraInformation._dir.scale(this.deltaTarget)),
        scene
      );

      camera.fov = (this.lastfov * Math.PI) / 180;
      camera.maxZ = this.far;
      camera.minZ = this.near;
      this.engine.registerView(canvas, camera);
      cameraInformation._eachCamera = camera;
    } else if (
      cameraInformation.name === "cam2" ||
      cameraInformation.name === "cam4" ||
      cameraInformation.name === "cam6"
    ) {
      const camera = new BABYLON.ArcRotateCamera(
        `${cameraInformation.name}_eachcamera`,
        0,
        0,
        1,
        cameraInformation._p.add(cameraInformation._dir.scale(this.deltaTarget)),
        scene
      );

      camera.fov = (this.lastfov * Math.PI) / 180;
      camera.maxZ = this.far;
      camera.minZ = this.near;

      camera.setPosition(cameraInformation._p.clone());

      this.engine.registerView(canvas, camera);

      cameraInformation._eachCamera = camera;
    }
  }
}

The above is currently working fine, but i just want to change the handedSystem based on camera name, not globally.
useRightHandedSystem is set to false in initialization.

no, that’s not quite possible. I am also not quite sure why you need that, but that’s a different topic and I am sure you have a good use case for that :slight_smile:

RHS changes the way all Babylon components are working. The way the camera matrices are computed, the way the models are loaded, everything. It is not camera dependent.

It is possible only at the scene level, docs here - Babylon.js docs

is it possible to make two instances of scene, in the same canvas, and then assign different RHS for both?

Yes, you can create two scenes, and render them one after another in the same canvas like so :

engine.runRenderLoop(function () {
    scene1.render();
    scene2.render();
});

Make sure to set scene2.autoClear = false so that the second render won’t erase the first one.
Here is a Playground example

I assume it would work since it’s two different scenes, but I have never tested. I let you give it a try :stuck_out_tongue:

++
Tricotou

1 Like

Thanks man!! Will give it a try and let you know!

1 Like