Konstantin P
Konstantin P

Reputation: 25

Chrome on android: touchevent not work on a-entity click

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

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

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/ (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.

Here code excerpt

 <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");
});```  

Upvotes: 0

Views: 713

Answers (1)

Diego Marcos
Diego Marcos

Reputation: 4585

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/

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

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

Upvotes: 1

Related Questions