【问题标题】:Click event not recognized on mobile browser Aframe-AR.js移动浏览器 Aframe-AR.js 无法识别点击事件
【发布时间】:2019-03-29 17:21:24
【问题描述】:

我正在使用 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 解决方案,它使它变得更好,只是不够准确,在对象外部单击时会检测到单击。 有什么办法可以解决这个问题吗?
谢谢。

【问题讨论】:

    标签: mobile click augmented-reality aframe ar.js


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-01
      • 2013-07-20
      • 1970-01-01
      • 1970-01-01
      • 2015-02-28
      相关资源
      最近更新 更多