aframevr / aframevr/aframe

Can't stop cursor raycaster intersecting multiple times with the same convex object

Open
#4,723 0 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

I'm using a cursor (raycaster) to select objects in a scene by having them react to the raycaster-intersected event, and I've identified a surprising edge-case.

If the object is convex (eg, a complex object loaded from a .OBJ asset) and the raycaster passes through it multiple times then the cursor's raycaster reports all intersections, counts the intersected object once for each intersection, and as a result the raycaster-intersected event can fire multiple times on the same object for a given tick.

This may be required behaviour in some cases, but in others it may be undesirable (eg, when toggling state in the selected object, or when counting the number of unique objects (rather than intersections) intersecting the raycaster.

It would be useful in these cases to be able to select between these two behaviours with a raycaster property (something like uniqueElements: {default: false}).

I actually already have a quickly hacked-up fix for this in a custom raycaster component in my current project, and will try to work it up into a PR for consideration ASAP if there's agreement it might be useful.

  • A-Frame Version: 1.0.4
  • Platform / Device: Confirmed Windows/Chrome, Android/Chrome, suspected all platforms
  • Reproducible Code Snippet or URL: To be added

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 at the raycaster component and the raycaster-intersected event path; the issue names no source file or test, so first trace how multiple intersections are reported for one object. Done should provide a deliberate choice between reporting every intersection and reporting each intersected object once, while preserving current behavior by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.