Jump to content

HP mixed reality headset position, rotation


SteveS
 Share

Recommended Posts

Is it possible to get the position and rotation of an attached HP mixed reality headset after using the scene.createDefaultVRExperience() call?

I've been unable to get the content using scene.activeCamera.

Also is it possible to use a different webCam - the default is the front looking camera on my laptop.  I'd like to use a USB webcam instead.

Love babylon.js

 

Link to comment
Share on other sites

The device's rotation and position can be retrieved using the current (active) camera:

devicePosition (http://doc.babylonjs.com/classes/3.0/webvrfreecamera#deviceposition-vector3-classes-3-0-vector3-)

deviceRotationQuaternion (http://doc.babylonjs.com/classes/3.0/webvrfreecamera#devicerotationquaternion-any)

About the webcam - you can provide a device ID in the constraints when initializing the video texture - http://doc.babylonjs.com/classes/3.0/videotexture#static-createfromwebcam-scene-onready-constraints-rarr-void

I hope this helps!

Link to comment
Share on other sites

Thanks for the quick response.

Let me elaborate a bit more about the issue.

Before the scene.createDefaultVRExperience() call (which I believe was created in early August) one would use the webvrfreecamera call and a few other calls to setup the VR device connection.

What is nice about the createDefaultVRExperience call is that all the VR configuration setup is done for you by that single call.  It also creates a button in the lower right corner that when pressed immerses you if a compatible headset is attached.  We received our HP mixed reality headset in early August and set about creating a number of apps using babylonjs and they work with that single call - when the button is pressed you immerse in the headset. Now this only works in the Edge browser not released versions of Firefox, Opera and Chrome.

One of the apps we created displays a 360 picture on the inside and outside of a sphere of diameter 6.  The HP headset has inside out tracking and provides continuous position and rotation information with position in  metric units just like the Hololens.  When immersed you can walk around the sphere and even go inside the sphere and look around.  

The app has a text panel displaying the position and rotation of the parameters scene.activeCamera.position and scene.activeCamera.rotation.  scene.activeCamera.position never changes but scene.activeCamera.rotation does change based on mouse movement before immersion but doesn't change while immersed.

I think what is happening is the createDefaultVRExperience call is creating a private scene camera but only partially updating it's public parameters in activeCamera under certain conditions.  I've only briefly looked at the code for that function and not being a javascript expert haven't been able to see what might be missing.   Possibly the author of the function could shine some light on this.

I'll look into the webCam device ID and see if I can change the CAM selection.

Thanks for the help.

 

 

Link to comment
Share on other sites

The createDefaultVRExperience should work flawlessly on chrome or firefox with Oculus or HTC vive. HP device is only supported by Edge (not a limitation of babylon.js per se)

It does not create a private camera but instead replace the scene.activeCamera.

The WebVRCamera does not update its position / rotation but instead keeps the deviceOrientation and devicePosition updated. The camera.position and camera.rotation only specify offsets from the deviceOrientation and devicePosition values.

Link to comment
Share on other sites

Thanks for responding.

The createDefaultVRExperience works beautifully with the HP headset.  My problem is I don't know how to reference the headset orientation and position.

I want to use the deviceOrientation and devicePosition information to control other functions inside the render loop - I just don't know how to get that information.

I've tried scene.activeCamera.devicePosition.x,  scene.devicePosition.x, etc.  Everything I've tried doesn't work.

A code example would be terrific.

 

 

Link to comment
Share on other sites

The enterVR() function of the VRHelper (that is being initialized when calling createDefaultVRExperience()  sets the active camera to be the webvr camera. Are you calling this function? Can you check the name of the camera's class (scene.activeCamera.getClassName() ) ?

The following interface is exposed on the WebVRCamera objcet:

export interface PoseControlled {
        position: Vector3;
        rotationQuaternion: Quaternion;
        devicePosition?: Vector3;
        deviceRotationQuaternion: Quaternion;
        rawPose: DevicePose;
        deviceScaleFactor: number;
    }

rawPose, and both device*** are the variables you can use to get the device'S position. The rest is to set a "world offset" for your scene.

Link to comment
Share on other sites

Some progress.

scene.activeCamera.getClassName()   pre-immersion  returns  DeviceOrientationCamera.

post immersion (after pressing the lower right hand side googles - which I assume executes the enterVR() function)    returns  WebVRFreeCamera.

I added a delay before attempting to access the headset data after immersion but still no success.

I tried  

scene.activeCamera.WebVRFreeCamera.devicePosition.x

scene.WebVRFreeCamera.devicePosition.x  

scene.WebVRFreeCamera.rawPose.position.x  

and a bunch of other permutations.  In all cases the render loop still halts.

Clearly I'm not be using the correct reference syntax.

 

 

 

Link to comment
Share on other sites

I can't use camera._vrDevice as I don't declare a camera object in my code - I use the camera created by the scene.createDefaultVRExperience() call.

From there (courtesy of Deltakosh's post) I reference properties of the camera by using scene.activeCamera.devicePosition

So it's not clear to me how to reference _vrDevice.isPresenting in my code as  "if(camera._vrDevice&&camera._vrDevice.isPresenting)" fails. 

I would prefer to use .isPresenting I just don't how to reference it.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...