Aframe 游标保险丝工作,当它不是预期的

Aframe cursor fuse working, when it not expected

融合光标的奇怪行为。我已经为主场景和 a-cursor 的光标设置 fuse false,但 fuse 仍然出现在悬停时。

在 ios、android 上测试时出现了这个问题。从桌面浏览器工作正常。

<a-camera id="default_angle" camera  position="0 0 0" look-controls  wasd-controls>
<a-cursor>
 <!-- by default click should be not expected on hover object (fuse) -->
</a-cursor>
</a-camera>
...
<a-box id="motor" color="red" position="0 0 -5"></a-box>
<!-- on hover to this object from mobile fuse should not appear -->
...
  var motor = document.querySelector('#motor');
  motor.addEventListener('click', function (evt) {
   alert('clicked');  
  });

请查看此代码笔 https://codepen.io/sevenspring/pen/XWWzNvK

这里可能会想到,当光标悬停在对象上时,触摸(在移动屏幕上点击)产生的点击。

但是你可以用陀螺仪检查这个例子。 https://parent.glitch.me 在虚拟现实模式下,我们可以通过陀螺仪移动将光标悬停在按钮 "play/pause" 上,它仍然会产生点击。 https://glitch.com/edit/#!/join/d1afa869-dea2-47ec-9904-e851e451d832

这里实际上有很多问题。

一个问题是 CodePen 演示使用的是 <a-cursor fuse="false" cursor></a-cursor>。这实际上是两个游标,因为您通过 cursor 添加第二个游标作为组件,但尚未配置。

另一个问题是,如果未明确设置为 cursor="fuse: false;"

cursor 在移动设备上默认会融合

另一个问题是您正在侦听 click 事件,当您将鼠标悬停在实体上后,该事件捕获点击。

我认为 fuse 旨在允许 click 无需点击,但同时也允许用户在有能力的情况下点击。

如果你想测试什么时候完全融合,你可能想尝试监听 fusing 事件而不是 click

<a-cursor fuse="false"><a-cursor>

<a-entity cursor="fuse: false;">
  <!-- you will need to provide your own cursor geometry -->
<a-entity>

然后监听 fusing:

this.el.addEventListener('fusing', function (e) {
 console.log(e);
});

希望对您有所帮助。

Dan S. 的回答是正确的。 当我们使用不带属性的 "cursor" 时,融合事件不会被触发,正如默认情况下所期望的那样