【问题标题】:A-Frame: rayOrigin cursor and mouse at same timeA-Frame:rayOrigin光标和鼠标同时
【发布时间】:2018-05-13 22:11:07
【问题描述】:

我已经实现了这个例子中的事件: https://aframe-event-set-component.glitch.me/

这些事件现在可以听我的光标或鼠标了。 如何在一个应用程序中结合这两种方法,以便可以通过鼠标和光标触发事件?就像这里:
https://github.com/mayognaise/aframe-mouse-cursor-component(最新的A-Frame不再支持)

我可以写cursor="rayOrigin: mouse && cursor"之类的东西吗?

最好的问候!

【问题讨论】:

    标签: cursor mouse aframe


    【解决方案1】:

    至于click 事件:它似乎与两个cursor 组件一起工作:一个在a-scene 中,一个在相机中:

    <a-scene cursor="rayOrigin: mouse">
      <a-camera position="0 1.6 0">
        <a-entity cursor="fuse: true; fuseTimeout: 500" position="0 0 -1" geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.03" material="color: black; shader: flat">
        </a-entity>
      </a-camera>
    </a-scene>
    

    在此fiddle 中查看。


    另一方面,a-scenes 光标似乎弄乱了另一个events。 你可以提交一个issue,或者创建一个组件,当enter-vr 事件被触发时,它会移除鼠标cursor
    ...
    this.el.sceneEl.addEventListener("enter-vr", function() {
      this.el.removeAttribute("cursor")
    })
    this.el.sceneEl.addEventListener("exit-vr", function() {
      this.el.setAttrubute("cursor", "rayOrigin", "mouse")
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-12
      • 1970-01-01
      • 2011-02-28
      • 2018-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      相关资源
      最近更新 更多