google-chrome - android上的Chrome:touchevent不适用于实体点击
问题描述
问题的问题是:从 VR 模式通过触摸点击移动设备的点击事件不适用于 Android Chrome 79+。换句话说,在 VR 模式下的实体上不会触发 touchstart 事件。已安装并启用 Google VR 服务。
目标 a-entity 应该可以在 Chrome 最新 79+ 中点击用户点击(VR 模式触摸点击来自移动设备)
整个代码的链接:这里 2 配置简单的应用程序: https ://4dkly.csb.app/(配置:fuse 3.6sec;但单击实体在 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也可以。
这里代码摘录
<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/
在没有原生 WebXR 实现的设备上,VR 模式依赖于全屏 API,并且可以使用触摸事件。
我不建议在 VR 中依赖屏幕输入并使用基于保险丝的光标
推荐阅读
- python - 实施“。”的原因。作为当前工作目录的表示
- r - 有没有办法根据两列删除重复项,但在第三列中保留数字最高的列?
- reactjs - 在 Jest 中注入多个模拟上下文
- python - 如何在 python numpy 中引发 nan 值的错误
- firebase - 在 Flutter 中使用 GetX 使用 Image Picker 和 Cropper 后如何显示图像?
- python - Pandas groupby.agg 在传递额外参数时无法处理返回的元组
- .net - 通过 TCP/IP 在 vxWorks 应用程序和 .net 桌面应用程序之间进行进程间通信的最佳方式
- ssis - 使用正确函数时使用大小写的 SSIS 子字符串错误
- php - 莱佛士的 PHP 竞赛条件
- c - C socket Client 在不知道 IP 地址的情况下与 LAN 外的 Server 通信