Current position of VR HMD

How can you find/read the current 3D position of a VR HMD as it is being used (ie. moved around)?

I’m working with a MS mixed reality HMD and have a 10’x10’ area to move around. When I use getPosition() it only returns the starting position of the Camera Offset (testing using the VR starter kit). If I manually move the Camera Offset entity with the editor or with setPosition() it will update to the new position and i can log the new xyz but it does not update when i physically move the HMD.

What I’m trying to do is use gaze targets for a simple teleport function. ex. place gaze targets around a 3D room space and when triggered teleport the user to a predetermined location with setPosition(x,y,z).

I have the gaze targets working and reading attributes for each targets xyz but the setPosition() code is not taking user movement into account when calculating the teleport…so if the user moves from the starting xyz position and then activates a gaze target it seems to use the original xyz position and moves the user from there which causes incorrect teleport locations.

Hope that makes sense… here is a graphic i made to try and show what happens.
Fullscreen capture 5302018 111455 AM|640x499.

thanks,Chris

Fullscreen capture 5302018 111455 AM

Which entity do you call getPosition() on? Could you show the surrounding code or even better, a link to the project/link to a project with this problem?

this.activeCamera = this.app.root.findByName(‘Camera Offset’);

and i have tested/checked it at in various functions (update, hover, onSelect) with:

console.log("after move position: " + this.activeCamera.getPosition());

I’m making a forked version so i can remove a clients private models.

Thanks for taking a look.

And here is project link:
https://playcanvas.com/editor/scene/615660

I removed the private stuff and left the rooms and props. The teleport targets are the squares on the walls and center of the floor.

That’s not the camera :stuck_out_tongue:

That’s the anchor point of the camera. The HMD gives a position in it’s local space and the Camera Offset entity is the ‘root’ of the camera where the HMD applies the offset from.

The camera is a child entity of the Camera Offset (named ‘Camera’).

image

To do the teleport, you do need to move the Camera Offset entity but you have to take the HMD offset into consideration. The WebVR Labs sample does this: https://developer.playcanvas.com/en/tutorials/webvr-lab/

Line 26 in LookCamera: https://playcanvas.com/editor/code/446331?tabs=6078040

yes… i did look over the webvr-lab code but the scene itself does not work very well with my MS Mixed Reality HMD (Lenovo Explorer). It loads but the teleport controls do not work or the pointer wand freezes in space. If i re-load a bunch it might work a couple of jumps then freezes.

I also get that the Camera Offset it not the camera and have tried getting the positions on the camera itself but never got it return anything but the starting position.

i will take another look and see if i can get the positions like the Line 26 LookCamera code.

thanks

ok… tried a couple of tests and all I get from getLocalPosition(); on the actual camera is 0,0,0.

Not sure if this a Lenovo HMD issue or if it is my code… most likely my code:(

From box.js in my linked sample

this.activeCamera2 = this.app.root.findByName(‘Camera1’);

this.getCurrentPos = this.activeCamera2.getLocalPosition();

console.log(“hover :” + this.getCurrentPos);

Do you get any error messages in console.

Unfortunately, I don’t have a a mixed reality HMD to test with.

When you physically move around the room, does it move the camera in the virtual room?

yes.,… other than the offset in the camera when teleporting everything works great .

I will see what the console shows with the labvr. It works visually with the HMD and tracks local movements … just the no controls… not a problem for me on this project as i dont want to use the controllers and want the simple gaze control.

before the error above i was able to teleport once… controller vanished and all i can do is look around.

Interesting, it’s almost as though the game controller disconnects or lost during use of the app. Are there any connected controllers?

You should be able to get around that by disabling or removing the component script for games in the project.

Thanks, Only controllers are the 2 VR motion units and they work fine in other apps/games. I will give disabling the script a shot.

But the controllers are not really an issue for this project and I still need to figure out the teleport offset and how to read the current position. I understand what i need to do to fix the offset but can’t get anything from the camera getLocalPosition other than 0,0,0.

If you are managing to move the virtual camera by moving the HMD, its REALLY odd that the camera position doesn’t move. It should be impossible otherwise it just doesn’t work.

It’s a shame I don’t have a HMD to test with as it’s really bugging me.

i know the feeling… I’ve got to have something missing/wrong. i will take another look this afternoon.

Note the MS HMD are pretty cheap on Amazon now … you can finds deals for $230-250 w the controllers… still need a good PC setup tho