How to setting the mesh’s parent to be the Vrcamera


1.I use this code,In PC Browser,plane’s content will move and rotation by vrcamera in vr mode,but in HTC VIVE Mozilla Mixed Reality Browser is unuseful,plane’s content never move,i think vrhelper.currentVRCamera is not Mozilla’s vrCamera?
2.I find an other way to resolve this problem,setting the mesh’s parent to be the Vrcamera,but i try it fail,can you give me a demo?I want to make plane’s content always stay in the top left corner of the VRcamera

Did you try mesh.setParent() ?

This should normally work.

I try it ,and i can’t find my plane in the screen

ping @RaananW and @trevordev as I am pretty sure we already did some similar stuff ?

Could you try to attach it to camera.leftCamera after entering in VR ???

https://www.babylonjs-playground.com/#SQ5UC1#41
I try it fail

Do I understand it correctly that it doesnt work ONLY on the MR headset?

Edit - managed to reproduce this using a webvr camera. The plane is positioned correctly, but doesn’t update its position when moving. Got it, checking :slight_smile:

How is this solution?
https://www.babylonjs-playground.com/#SQ5UC1#43

2 Likes

Thank you very much!!VrCamera is so many that i don’t know which one could i use to setparent,your demo solve my problem!

Awesome! Happy it helps.

Based on these codes,I want to set this image in the top left corner of screen,can you give me some suggest?

You need to set the appropriate value at line 23 - I’m afraid I haven’t worked out to calculate in VR. (You’d need to use BABYLON.Vector3.Unproject, but I can’t find the correct view and projection matrices.)

pinging @RaananW

Was trying to play with unproject a bit and got to this -
https://www.babylonjs-playground.com/#SQ5UC1#58

It is a very naive approach that should be slowly perfected, but it does work.