How to change FOV of VR Camera?

Hi everyone,

i’m just wondering if there is a way to change the fov of the VR Camera using the default vrExperienceHelper like: “var vrHelper = scene.createDefaultVRExperience();” .

When trying to change the fov of the camera like scene.activeCamera.fov or vrHelper.currentVRCamera.fov (even in onAfterEnteringVRObservable) has no effect on the VR Camera at all. It’s working with the non VR view, but not in VR. Any help appreciated.


1 Like
for(const subC of myCam.rigCameras) {
    subC.fov = xxx;

I should note VR is being made obsolete by XR. In XR, the device is responsible for sending the projection matrices of each of the cameras every frame. This is no longer your responsiblity in XR, and this would probably be ignored there.

Pinging @RaananW

I’m running into the same issue, trying the same things.
Edit: Also had no luck trying to change the fov manually with the inspector in the sandbox.

Here’s a basic example of trying to change the fov onAfterEnteringVRObservable:

I finally got things to actually change the output. fov is not used for VR, I think. Setting it on the rig cameras works, but did not do anything. _cameraRigParams.vrMetrics is what is used. It has an aspectRatioFov. Changing it does change the display, but not sure the way fov changes a single camera.

The more natural way to change rig params is when the camera is being setup. Not clue for hoe on the vr helper thing.

vrHelper.onAfterEnteringVRObservable.add(() => {
    vrHelper.currentVRCamera.rigCameras[0]._cameraRigParams.vrMetrics.aspectRatioFov = 0.265103; // 120mm focal length

Also, both rigs share the same rigParams object, so only the first need changing.

I will amend before. aspectRatioFov is actually defined as getter of a ratio.

  * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
 public get aspectRatioFov(): number {
     return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));

You probably want to change one of the inputs. From the comment, eyeToScreenDistance looks like the fov, which seems to make sense.

I would say - careful when changing the fov for VR/XR.

Just like @JCPalmer said, WebVR and WebXR provide the information needed to display the scene correctly. Amending it might cause the user to… not feel well when seeing you scene.

I would recommend not to do that. fov is being ignored, since we are using the projection matrix directly. If you want to do it , you will need to calculate the projection matrix yourself.

1 Like

Okay thanks for your answers. I think i’ll keep it the way it is then. But thanks for your effort anyways.