HTC Vive controllers in playcanvas

Hi,
I have written some code to map the HTC Vive controllers to entities in playcanvas and it’s working fine. i.e. the reflect the position and orientation of the controllers as they move. However the position side is a little bit off and I am having trouble figuring out to position them relative the the camera.
Is there anyone on this forum with HTC vive and controllers working on similar code? Do you know if the camera and controllers use the same origin? It’s my first time working in 3D (and I am 47) so you might have to put it in laymen’s terms

My next approach will be to stick some markers down in the environment so i can see where the positions of everything are and try to visualise whats happening.

Ok I managed to fix the issue with the position and now both position and orientation are correct but there is something weird going on with the playcanvas implementation of WebVR. The ground plane keeps changing position everytime I launch which is very odd.

The origin of the world is set when you call enterVr(). So the position of the ground plane depends on where the headset is when you first call enterVr().

You can call vrCamera.reset() to set the current HMD position to be the new origin.

That doesn’t seem right to me for room scale VR.

If I launch and then put on the headset my position in VR is different than if I already had the headset on and then launched VR. That is very different to how all other VR applications/frameworks work. Normally it wouldn’t make any difference if I had the headset on or off before I started.

I will try out the vrCamera.reset() command and see what kind of effect it has. But for room scale the origin wouldn’t be the the HMD anyway it would be the corner of the room wounldn’t it?

If I have time I will have a play tonight and get back to you.

ps. having loads of fun mucking around with the Vive on PlayCanvas even though it still a bit experimental !

Having thought about it a little , the origin for room scale will most likely be the middle of the room at it’s lowest point (this probably explains why various steamVR textures for the ground have a target like image, I am guessing they used them to calculate if the room scaling was working correctly.

Just as I expected vrCamera.reset() makes it worse rather than better because it simply lifts the ground plane up to HMD level. That probably works ok for seated type experiences but for room scale vr i am pretty confident that the origin needs to be set to the center of the room at ground level. Not sure how to do that though yet.