I’m trying to use the WebXRCamera. I hadn’t luck in finding a working example of the use of WebXRCamera by searching Playgrounds and on Google. I use the following lines to create the WebXRCamera:
const xrSessionManager = new BABYLON.WebXRSessionManager(scene);
const xrCamera = new BABYLON.WebXRCamera("camera", scene, xrSessionManager);
but the code doesn’t work. I should see a sphere, and instead the scene appears void. But, if I use a FreeCamera instead, the scene renders correctly.
I create a minimum, reproducible example at this Playground:
Where have I messed in the creation of the WebXRCamera?
Unfortunately I encountered and additional issue: the Playground prints the message createEngine function must return an engine, which I was unable to fix. But outside of the Playground this issue disappears.
The XR camera is initialized when you call createDefaultXRExperienceAsync, there is no need to directly create it, unless you want to implement the experience helper yourself (i.e. initialize all needed parts and enter the scene manually). The scene’s initial camera should be a regular non-Vr supported camera (well, any other than the XR camera ). Arc rotate or free camera will do just fine. Afterwards you have direct access to the XR camera inside the experience helper