I have a weird issue that I’m not getting a position update on the camera movement.
The scenario is that I want to create a mesh, when a controller button clicks, in front of the camera.
But when I move in the VR world and click the controller button, I get the same [camera.position] values from the original starting location every time and hence create a mesh only in the original starting location.
Tried different Camera types and did R&D with the examples and documentation, same behavior.
Same issue occurs in the browser WebXR simulator and in the Oculus Quest as well.
Am I missing something or this is an Issue?
Hi @lior3790 and welcome to the forum! Pinging @RaananW, who is behind the implementation of WebXR in Babylon.js. Could you please share a repro via a playground URL so we can take a look at the code?
At least you should make sure that you working with correct camera. In XR mode babylon create new camera that can be got by scene.getCameraByName('webxr')
If you take the position of default camera before entering xr mode, so you getting wrong position.
Thanks @Dok11 , That solve the enigma.
Now I get the position correctly.
But in what scenario Babylon needs to create an additional discreet camera?
It is SO confusing. @RaananW, Can it be avoided or at least is it a future improvement consideration?
Hi Lior,
The WebXR implementation follows Babylon concepts and therefore requires a new (rig) camera to work as expected. Might be confusing at first, but once you understand the concept of a camera in Babylon it’s much clearer.
Having said that - at any given time you can get the current active camera in scene.activeCamera
If you want a direct reference to the WebXR camera you can also get it from the basic experience helper which creates it for you