本文介绍了Android上的Chrome:触摸事件不适用于实体点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是:通过VR模式在移动设备上通过触摸点击事件在Android Chrome 79+上无法正常工作.在VR模式下,实体上不会触发其他单词touchstart事件.Google Vr服务已安装并启用.

The problem of question is: click event via touch click on mobile from VR modenot work from android Chrome 79+.Otherwords touchstart event does not fired on entity from VR mode.Google Vr services are installed and enabled.

目标最新实体应在Chrome最新的79+版本中可点击用户点击(VR模式下,点击移动设备上的点击)

The goal a-entity should be clickable in Chrome latest 79+on user click (VR mode touch click from mobile)

链接到整个代码:这里2配置简单的应用程序: https://4dkly.csb.app/(配置:融合3.6秒;但是单击实体不会chrome vr的作品) https://codesandbox.io/s/aframe-example-4dkly?fontsize = 14&hidenavigation = 1& theme = white

Links to whole code:here 2 config simple app:https://4dkly.csb.app/ (config: fuse 3.6sec; but click on entity does Not work from chrome vr)https://codesandbox.io/s/aframe-example-4dkly?fontsize=14&hidenavigation=1&theme=white

https://12k87.csb.app/(光标颜色为红色;保险丝已关闭,光标仍然不起作用)
https://codesandbox.io/s/aframe-example-12k87?fontsize = 14&hidenavigation = 1& theme = dark 您能否看一下本示例中的任何一个,并告诉该怎么做,以使chrome最新,vr模式下触摸点击.任何新的好方法新的api都可以.

https://12k87.csb.app/ (cursor color red; fuse turned off , cursor still does not work)
https://codesandbox.io/s/aframe-example-12k87?fontsize=14&hidenavigation=1&theme=dark Could you please take a look for any of this example, and tell what to do, to make chrome latest, vr mode touch click.Any new good approach new api is also ok.

此处代码摘录

 <script src="https://aframe.io/releases/1.0.1/aframe.min.js"></script>

    <a-scene main>
      <a-sphere position="0 2 -5" radius="1.25" color="#EF2D5E"> </a-sphere>
 <!-- ... -->

      <a-camera id="camera" camera rotation>
        <a-entity
          id="cursor"
          cursor="fuse:false"
          position="0 0 -1"
          material="color: #111;"

        >
        </a-entity>
      </a-camera>
//simple event on click
 document.querySelector("a-box").addEventListener("click", () => {
   alert("box");
});```

推荐答案

您所描述的行为是预期的.当通过WebXR进入沉浸式模式时,浏览器会禁用触摸事件,Chrome 79+就是这种情况,并且内容通过 https 提供.在工作中有新的API可以在AR中呈现时实现交互性.您可以在此博客文章中找到其他详细信息: https://aframe.io/blog/webxr-ar-module/

The behavior you described is expected. Touch events are disabled by the browser when entering immersive mode via WebXR as it's the case for Chrome 79+ and content served over https. There are new APIs in the works to enable interactivity while presenting in AR. You can find additional details in this blog post: https://aframe.io/blog/webxr-ar-module/

在没有本机WebXR实现的设备上,VR模式依赖于全屏API,并且可以使用touchevents.

On devices that don't have a native WebXR implementation VR mode relies on the full screen API and touchevents are available.

我不建议在VR中依赖屏幕输入,而是使用基于保险丝的光标

I don't recommend relying on screen input while in VR and use a fuse based cursor

这篇关于Android上的Chrome:触摸事件不适用于实体点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 09:24
查看更多