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

与世无争的帅哥 提交于 2019-11-30 09:14:55

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!