如何使用Oculus Go触控板在AFrame中移动
How to use Oculus Go trackpad to move in AFrame
我正在使用 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>
在图像中显示了控制器,但显然不会影响正在使用的触控板,因为我会在桌面版本中使用 wasd(在场景中移动方面效果很好)。
因此,总而言之,如何在 AFrame 场景中使用 Oculus Go 触控板在其中移动,就像在桌面上使用 wasd 键一样? (或者,也许 AFrame 还不支持这个?)
[我知道这类似于 AFrame Oculus Go Controller Documentation?,但我对如何移动更感兴趣。]
A-Frame 不提供开箱即用的基于触控板的运动。您可以查看 aframe-extras,特别是 movement-controls 作为派生您自己的 Oculus Go 运动组件的起点
感谢 我可以写一些简单的 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>
这提供了摄像机的运动,开箱即用,使用当前稳定版本 AFrame, and of AFrame Extras。
当您在 Oculus Go 的浏览器中启动场景并进入 VR 时,只需将拇指轻轻放在触控板上即可控制相机的移动。相机在您放置拇指的方向、水平面和您的注视方向移动。也就是说,如果您向前移动,但将拇指放在触控板前面并向上看,摄像头将朝您注视的方向向前和向上移动。请记住,移动的是相机,而不是场景,这意味着如果您将拇指放在左侧,相机将向左移动,而场景似乎会向右移动。
如果不需要垂直移动(例如,因为您正在模拟在水平面上移动),您可以从 movement-controls
属性中删除 fly: true
。
对于 movement-controls
的其他属性,请检查 its documentation。
我正在使用 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>
在图像中显示了控制器,但显然不会影响正在使用的触控板,因为我会在桌面版本中使用 wasd(在场景中移动方面效果很好)。
因此,总而言之,如何在 AFrame 场景中使用 Oculus Go 触控板在其中移动,就像在桌面上使用 wasd 键一样? (或者,也许 AFrame 还不支持这个?)
[我知道这类似于 AFrame Oculus Go Controller Documentation?,但我对如何移动更感兴趣。]
A-Frame 不提供开箱即用的基于触控板的运动。您可以查看 aframe-extras,特别是 movement-controls 作为派生您自己的 Oculus Go 运动组件的起点
感谢
<!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>
这提供了摄像机的运动,开箱即用,使用当前稳定版本 AFrame, and of AFrame Extras。
当您在 Oculus Go 的浏览器中启动场景并进入 VR 时,只需将拇指轻轻放在触控板上即可控制相机的移动。相机在您放置拇指的方向、水平面和您的注视方向移动。也就是说,如果您向前移动,但将拇指放在触控板前面并向上看,摄像头将朝您注视的方向向前和向上移动。请记住,移动的是相机,而不是场景,这意味着如果您将拇指放在左侧,相机将向左移动,而场景似乎会向右移动。
如果不需要垂直移动(例如,因为您正在模拟在水平面上移动),您可以从 movement-controls
属性中删除 fly: true
。
对于 movement-controls
的其他属性,请检查 its documentation。