4

Just started playing with A-Frame and I can see vive-controls and oculus-touch-controls but nothing for google daydream.

I've looked at the component repo and don't see anything that looks like it'll do the job. The closest thing to now investigate would be the Gamepad API, but I'm amazed I can't find anything.

I've got a Pixel XL & daydream and would like to incorporate the controller rather than just head tracking and gaze based control. Can someone point me in the right direction please.

Thanks

UPDATE - I've got the Daydream controller working for clicks! Running the 360-image-gallery(https://aframe.io/examples/showcase/360-image-gallery/) accepts clicks from the Daydream controller. I guess maybe it had timed out on my previous attempts or I hadn't paired it properly! I'll keep playing!

4

3 回答 3

5

在 Aframe 项目中设置 Daydream 遥控器。目前还没有适用于 Daydream 遥控器的组件,但我希望尽快完成一个 - 听起来他们将在即将发布的 Aframe 版本中提供主线支持。

但是你可以手卷支撑没问题。

首先,您需要做一些准备工作:

  1. 在您的 Pixel 上下载 Chrome Beta 56:https: //www.google.com/chrome/browser/beta.html
  2. 打开 Chrome Beta,导航到chrome://flags并启用 WebVR 和 Gamepad 标志。

现在,您将能够在真正的 WebVR 中启动使用 Aframe v0.4 或更高版本构建的体验。您将收到通常的 Daydream 屏幕提示(将您的手机放在耳机中,然后连接遥控器。)如果您正在连接到本地开发环境,您会看到一个安全连接警告,但这虽然很烦人,但不会t 阻止你工作。

其次,既然您正在运行真正的 WebVR,您需要利用 Gamepad API 从您的 Daydream 遥控器中获取信息。让我们首先记录它已连接。

    window.addEventListener('gamepadconnected', function(evt) {
      console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.",
        e.gamepad.index, e.gamepad.id,
        e.gamepad.buttons.length, e.gamepad.axes.length);
    });

第三,现在您正在记录连接,您需要设置一个更新循环来获取游戏手柄的当前状态。您可以使用requestAnimationFrame. 按照这里的教程:https ://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API

一旦我发布了一个基本的 dayframe-remote 组件,我将在此处发布一个链接。希望这可以帮助您入门!


编辑:看起来下面的建议效果很好。只需将“Daydream Controller”作为跟踪控件的 id 传递:tracked-controls="id: Daydream Controller".


这是一个示例 Daydream 控制器输出。目前,似乎只暴露了触控板按钮——而不是应用程序或主页按钮。

    { 
      axes: [0, 1],
      buttons: [{
        pressed: false,
        touched: false,
        value: 0
      }],
      connected: true,
      displayId: 16,
      hand: "left",
      id: "Daydream Controller",
      index: 0,
      mapping: "",
      pose: {
        angularAcceleration: null,
        angularVelocity: [0, 0, 0],
        hasOrientation: true,
        hasPosition: false,
        linearAcceleration: [0,0,0],
        orientation: [0,0,0,1],
        position: null
      },
      timestamp: 1234567890123
    }
于 2016-12-28T22:13:41.003 回答
1

有什么让你尝试...

当前 A-Frame 0.4.0 支持的tracked-controls工作方式:

如果你指定它应该只匹配一个空字符串的 ID 值,''那么它应该匹配任何带有姿势的游戏手柄......所以你可以尝试类似的东西

<a-entity tracked-controls="id:"></a-entity>

看看是否会发生事件等?

于 2016-12-28T22:34:48.833 回答
0

A-Frame 主分支现在包含一个白日梦控制器组件:https ://aframe.io/docs/master/components/daydream-controls.html

于 2017-05-23T09:17:58.747 回答