Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect Desktop vs. Mobile vs. GearVR vs. Oculus Rift vs. Vive in A-Frame?

Tags:

aframe

In A-Frame, I want to detect if the user has a VR headset connected and to tell which device they are using. How can I do this?

  • Desktop (no VR display)
  • Mobile (e.g., webvr-polyfilled Google Cardboard, iPhone, Android)
  • Samsung GearVR
  • Oculus Rift
  • HTC Vive
like image 606
ngokevin Avatar asked Aug 16 '16 21:08

ngokevin


People also ask

Is Oculus Rift or Vive better?

Both headsets are a few hundred dollars less expensive than they were when they launched. The Rift is $399, down from $599, while the Vive is $499, down from $799. Since both now feature motion controls and whole-room VR in the box, the Oculus Rift is the better value.

What is the difference between Oculus and vive?

The HTC Vive Pro has a much faster refresh rate than the Oculus to go along with a display of 2880×1600. The Vive doesn't just make games look better. The high-resolution-certified headphones have integrated 3D spatial sound.

How do I watch VR on my browser?

Opera is one of the first browsers to support the support 360-degree videos in virtual reality headsets including HTC Vive and Oculus Rift. Moreover, Opera has direct VR playback built into the browser. So, you will be able to watch virtual reality videos instantly through your VR headset.


1 Answers

There are several utility functions in A-Frame we can use to detect compatibility: https://aframe.io/docs/master/core/utils.html

The mobile-related utils look at navigator.userAgent. The VR-related utils check to see if the pose data returned from the headset/polyfill is not 0,0,0.

Given the current API:

  • Desktop: !AFRAME.utils.checkHeadsetConnected()
  • Mobile: AFRAME.utils.isMobile()
  • GearVR: AFRAME.utils.isGearVR()
  • Oculus Rift: !AFRAME.utils.isMobile() && AFRAME.utils.checkHeadsetConnected()
  • HTC Vive: !AFRAME.utils.isMobile() && AFRAME.utils.checkHeadsetConnected()

To differentiate Rift vs. Vive, try using WebVR API Stage Parameters https://w3c.github.io/webvr/#interface-vrstageparameters

like image 177
ngokevin Avatar answered Oct 19 '22 07:10

ngokevin