A simple example of WebXRCamera position

Hi BJS devs!

I’d like to use non vr camera position to immersive-vr mode camera position.
The document kindly explains to use WebXRCamera.

The WebXR Camera | Babylon.js Documentation (babylonjs.com)

WebXRCamera requires xrSessionManager but there is no simple sample when we use createDefaultXRExperienceAsync.

The following playground provide a simple example. Camera positions are the same as non vr and immersive-vr.

Hope would be useful.

WebXR_player_position_adjustment_v2 | Babylon.js Playground (babylonjs-playground.com)

1 Like

Cool, but to be clear, setTransformationFromNonVRCamera is called automatically by the DefaultWebXRExperience initialization using the currently activeCamera. (See here). Your example might be useful if wishing to initialize the WebXR camera to a non active camera though.

Docs mention this as well:

The basic XR experience helper offers direct access to the following:

  • A configured XR Camera that will have the non-VR camera’s position when entering XR
2 Likes

@kaliatech
Thanks for your reply.
A few month ago I failed to synchronize position between non-VR and VR camera with using DefaultWebXRExperience. Current DefaultWebXRExperience document does not explain camera position. Therefore I made the PG, but I realized the issue had been solved. Sorry for taking your time.

3 Likes