Is it possible to make BJS render for Cardboard VR?

As I suppose, to make this I need to use two cameras on the scene at time with different camera angle?
But how to render a scene from two different cameras in BJS?

You dont need to manually create stereoscopic effect. WebXR will do that for your scene including adding the button to switch to vr splitted screen. You need to run on a device that can handle it like most of the phones WebXR Demos and Examples | Babylon.js Documentation
Not sure how configurable it is if you have some custom display device (adjusting IPD and so on) but it will do for a cardboard I think.

1 Like

Is there a way to manually control the camera when the scene in the VR mode? Like it controls through the Immersive WebXR Emulator.
It will be helpful when creating some cut scenes when you need to set specified camera rotation.

you can control the camera just like you control any other camera - change its position, rotation and so on. this is useful when the camera can’t move on its own, like in the case of cardboard. otherwise, i would recommend to stick to the XR transformations

I thought that it works like this, but it’s not. I’ve tried to control the camera like this:

    scene.registerBeforeRender(function () {
        camera.rotation.y += 0.1;
    } );

it moves the camera successfully but when I enter in VR mode it immediately stops. So it seems the XR takes control of the camera.

that is because you are referencing the wrong camera. you need to use the XR camera that is created for you in the base experience.
I would recommend you to read the webxr documentation and provide code examples / playground so that we can understand the issue better next time.

1 Like