Search code examples
javascriptaframe

aframe - cursor component - click event fires on last occured intersection instead of the first one


assume we have an <a-scene> with a cursor component and manually configure the raycaster component later and set the .interactable objects.

Let's say we have two or more of these objects behind each other and let the raycaster fire through them. What we want is to fire the click event on the first element respectively the element in the foreground. But what we noticed is that aframe fires the click event on the last intersected object respectively the one in the background (it's the last entry of raycaster.intersections).

Does someone know how we could avoid this? I hope this question isn't a duplicate, I did not found a similiar one. Else feel free to remove this question. Thank you for your help


Solution

  • For anyone who noticed the same problem:

    It's the A-Frame version. We still used version 0.8.0. But they improved the behaviour of the raycaster component in 0.8.2 / 0.9 for reference: https://github.com/aframevr/aframe/issues/3485 and https://github.com/aframevr/aframe/pull/3475

    Thanks to the A-Frame Team!