如何使用Oculus Go触控板在AFrame中移动

jgb*_*rah 6 html5 oculus aframe oculusgo

我正在使用Oculus Go测试一些AFrame页面,但是无法使触控板在场景中移动。我使用的是AFrame的主版本,显然支持Oculus Go控制器。实际上,此代码例如:

<!DOCTYPE html>
<html>
<head>
  <script src="https://rawgit.com/aframevr/aframe/cf15c15/dist/aframe-master.min.js"></script>
</head>
<body>
  <a-scene anti-alias>
    <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
    <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E" shadow></a-sphere>
    <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D" shadow></a-cylinder>
    <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" shadow></a-plane>
    <a-sky color="#ECECEC"></a-sky>

    <a-entity laser-controls="hand: right"></a-entity>
    <a-entity oculus-go-controls x-button-listener></a-entity>
    <a-entity camera look-controls wasd-controls position="0 1.6 0"></a-entity>
  </a-scene>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在图像中显示了控制器,但显然并没有像我在台式机版本中使用wasd那样对使用的触控板产生影响(相对于遍历场景而言,效果很好)。

因此,总而言之,我如何在AFrame场景中使用Oculus Go触控板在其中移动,就像在桌面使用wasd键一样?(或者,也许AFrame仍不支持此功能?)

[我知道这类似于AFrame Oculus Go Controller文档吗?,但我对移动方式更感兴趣。]

Die*_*cos 5

A-Frame不提供开箱即用的基于轨迹板的运动。您可以研究aframe-extras,尤其是运动控件,以此作为派生自己的Oculus Go运动组件的起点


jgb*_*rah 5

感谢@ diego-marcos回答,我可以编写一些对我有用的简单HTML:

<!DOCTYPE html>
<html>
<head>
  <script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
  <script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v4.1.2/dist/aframe-extras.min.js"></script>
</head>
<body>
  <a-scene anti-alias>
    <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
    <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E" shadow></a-sphere>
    <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D" shadow></a-cylinder>
    <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" shadow></a-plane>
    <a-sky color="#ECECEC"></a-sky>

    <a-entity movement-controls="fly: true" position="0 0 0">
      <a-entity camera position="0 1.6 0"></a-entity>
    </a-entity>
  </a-scene>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

使用AFrameAFrame Extras的当前稳定版本,可以立即使用摄像机进行移动

在Oculus Go的浏览器中启动场景并进入VR时,只需将拇指轻轻放在触控板上即可控制相机的移动。相机会沿着您的拇指方向,水平面和视线方向移动。也就是说,如果您向前移动,但是将拇指放在触控板的前面并向上看,则相机将朝着注视的方向向前和向上移动。请记住,摄像头是在移动,而不是场景在移动,这意味着如果将拇指放在左侧,则摄像头将向左移动,并且场景似乎向右移动。

如果不需要垂直移动(例如,因为您正在模拟在水平面上移动),则可以fly: truemovement-controls属性中删除。

有关其他属性,movement-controls请检查其文档