1

我正在使用 Aframe 和 AR.js 处理增强现实场景。当检测到标记时,我目前正在渲染 obj 模型。我的要求是能够在渲染时单击单个模型以及静态对象(按钮)。由于某种原因,当我在移动设备上测试它时,aframe 实体上的点击事件没有正确触发,它很少检测到触摸,但当我使用网络摄像头在桌面上测试它时它工作正常。这是我的方法 -

AFRAME.registerComponent('cursor-listener', {
init: function () {
this.el.addEventListener('click', function (evt) {

  console.log('I was clicked at: ', evt.detail.intersection.point);
 });
}
});
</script>
</head>  
<body>
<a-scene embedded arjs='trackingMethod: best; debugUIEnabled: false;'>      

   <a-marker id="marker" preset='hiro' cursor="rayOrigin: mouse">      
    <a-entity  material=" src: url(box.png) " class="collidable" cursor-listener position="0 -1 0"></a-entity>  
   </a-marker>

    <a-camera-static>
      //button a child of the camera.
     <a-entity id="red" material="color: red" class="collidable" geometry="primitive: box" cursor-listener position="0 0 -4" scale="0.3 0.3 0.3"></a-entity>  
    </a-camera-static>

  </a-scene>
  </body>
  </html>

我已经尝试过这个https://github.com/jeromeetienne/AR.js/issues/416#issuecomment-425078800 解决方案,它使它变得更好,只是不够准确,在对象外单击时会检测到单击。有什么办法可以解决这个问题吗?
谢谢。

4

1 回答 1

0

您可能正在寻找的是放弃使用类似凝视的光标处理点击的想法,而是像这里解释的那样进行普通的鼠标/触摸点击

于 2018-11-17T22:31:12.750 回答