3D Button always in front of camera in AR

Hi

I’m using webxr in “immersive-ar” mode. I want to draw a 3d button always in front of the camera at a specified distance, but having problems making it work.

Have found options to do this:

  • Using the function camera.getFrontPosition
  • Associate the rotation of the camera with the rotation of the button.
  • Using the mode BILLBOARDMODE_ALL, so the button can always face the camera.

If I use the function getFrontPosition I can see the button at the correct distance, but when rotating, the button stops facing the camera.

If I associate the rotation from the camera to the rotation of the button, I can see the button always facing the camera when rotating, but If I move the camera going forward/backwards, left/right I lose the button because the distance is not maintained.

If I use both methods at the same time, the effect seems to sum up, and the object moves a lot faster on camera.
** (cant add more links) same URI but ending in => #1036

Finally, I also test using BILLBOARDMODE_ALL, but it seems to have the same effect that to associate the rotation of the object and the camera.
** (cant add more links) same URI but ending in => #1037

So, the question. How can I keep a 3d button always facing the camera at a specified distance, not matter If I rotate or move around in augmented reality?

Thanks!

Welcome aboard!

You can parent the button mesh to the camera instead:

I can’t check if it works in WebXR, but the regular version does work:

1 Like

Much easier that I thought. Thanks! (it also works well on webxr).