aframevr / aframevr/aframe

Nested raycasters cause false intersections on parent raycasters due to event bubbling

Open
#5,075 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
17.6k
Forks
4.4k
PR merge metrics
No merged PRs in 30d

Description

Description:

  • A-Frame Version: 1.3
  • Platform / Device: NA
  • Reproducible Code Snippet or URL:
<a-scene cursor="mouse" raycaster>
  <a-entity cursor></a-entity>
</a-scene>

When the cursor on the entity hits an object it does an intersection and events are fired
It then bubbles up the DOM tree and reaches the a-scene which sees an intersection event assumes that it is it's own and fires off it's own intersection events so anything listening for intersection events now thinks the a-scene cursor intersected it when it did not.

The fix is to check for event.currentTarget === event.target in onIntersection in cursor.js

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in cursor.js at onIntersection and reproduce the nested cursor and raycaster setup from the issue. Verify that the parent scene does not treat bubbled child intersections as its own, while direct intersections still produce the expected events.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.