Jump to content

Reliable way to get webvr device id


1glayfan
 Share

Recommended Posts

Current this is what I need to do to get the device id, using webvr api directly.

 this.vrHelper.onEnteringVR.add(() => {
                
                navigator.getVRDisplays().then((displays) => {
                    for (let display of displays) {
                        console.log(`**** Device: id=${display.displayId}, name=${display.displayName}`);
                    }
                });

The displayId prop is not reliable as it always returns 1 regardless which actual hmd I am using (vive or winmr or other)

The displayName prop is also not consistent among browsers. For ex: when I am using vive hmd, firefox returns 'OpenVR HMD' while chrome returns 'HTC Vive MV.'

I wonder if bjs has api to do this. Ideally returning some kind of enum which we can use it reliably.

Link to comment
Share on other sites

If your app forces the user to use the controller from the beginning then you can call BABYLON.WebVRController.controllerType to get the enum which is defined like the following:

 enum PoseEnabledControllerType {
        /**
         * HTC Vive
         */
        VIVE = 0,
        /**
         * Oculus Rift
         */
        OCULUS = 1,
        /**
         * Windows mixed reality
         */
        WINDOWS = 2,
        /**
         * Samsung gear VR
         */
        GEAR_VR = 3,
        /**
         * Google Daydream
         */
        DAYDREAM = 4,
        /**
         * Generic
         */
        GENERIC = 5,
    }

But again this will work only if your app always uses the controller. 

Link to comment
Share on other sites

Babylon can only expose what the browser makes available and to my knowledge the webVR spec does not provide any way to do this, I believe by design(spec). 

If you are trying to figure out the capabilities of the device currently connected you could use display.capabilities otherwise if you are trying to show a different ui for a device type HoloLites solution seems like the best option at this time.

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...