getFrontPosition in VR Mode

Hi,

I am trying to place a plane in front of the camera which is working fine in non-VR mode.
But in VR mode the mesh is placed at the wrong location.

Anyone has an idea on how to use getFrontPosition in VR mode?
Since the currentVRCamera does not have a target, I have to use the leftCamera.

Here is a link to my playground example:
https://www.babylonjs-playground.com/indexStable.html#5HMVD6#5

There plane is (re)placed whenever you press the middle mouse button or the trigger on the VR controller.

I am using Oculus Rift with Firefox.

pinging @trevordev

I think getFrontPosition assumes the camera is not parented.

See this playground: Babylon.js Playground based on the Accessing vr device position and rotation section from Use the WebVR experience helper - Babylon.js Documentation

Thank you very much.
Your solution is working fine.
All I had to do is backport the rotateByQuaternionToRef because I am using the stable version ob Babylon which does not yet contain this.

In order to test this on Cardboard I also replaced the trigger/mouse button with an interval.

https://www.babylonjs-playground.com/indexStable.html#5HMVD6#13

When testing on Cardboard I found out that on some devices it does not work.
Seems like this happens on devices using the fallback camera.

1 Like