a-scene 光标破坏 raycaster

a-scene cursor breaks raycaster

我正在尝试设置具有触发悬停动画的保险丝,同时仍然能够 click/tap 环境中的项目。

<a-cursor position="0 0 -0.25"></a-cursor> 添加为我的相机的子项会在屏幕上显示环形光标,并允许悬停 mouseenter/mouseleave eventListeners 按预期触发。

然后我将 cursor="rayOrigin:mouse;" 添加到场景中,这样我就可以点击场景中的对象,但这会破坏悬停动画。

对于悬停动画,我有一个不可见但位于具有 mouseenter/mouseleave eventListeners 的动画对象前面的平面。但是,当光标在光线投射中同时具有平面和对象时,将调用 mouseleave。如果省略 cursor="rayOrigin:mouse;",则不会发生这种情况。

这里有问题 --> https://glitch.com/edit/#!/join/49af29f1-557a-4976-bc2b-f89fce5e3ad6

<a-cursor>干扰场景的光标

<a-scene cursor="...">
  <a-camera>
    <a-cursor>
    </a-cursor>

因为 <a-cursor> 创建的 raycaster 发出事件(在交集和清除时),这些事件冒泡并被 <a-scene>s 光标捕获。正是 these two listeners.

为了不让他们干涉,可以去掉两者的父子关系:

<a-camera>
  <a-cursor>
  </a-cursor>
</a-camera>
<a-entity cursor="rayOrigin: mouse"></a-entity>

this fiddle

中查看

另一种方法是动态添加/删除其中一个游标,这样一次只有 'intended' 个在工作。