Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected hit on raycaster #5268

Closed
Utopiah opened this issue Apr 3, 2023 · 2 comments
Closed

unexpected hit on raycaster #5268

Utopiah opened this issue Apr 3, 2023 · 2 comments

Comments

@Utopiah
Copy link
Contributor

Utopiah commented Apr 3, 2023

Description: copy/pasting the example from the documentation https://aframe.io/docs/1.4.0/components/raycaster.html#example the console does display a hit.

The event is :

raycaster-intersection { target: a-entity#player, isTrusted: false, detail: {…}, srcElement: a-entity#player, eventPhase: 0, bubbles: true, cancelable: false, returnValue: true, defaultPrevented: false, composed: false, … }
bubbles: true
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
detail: Object { els: (4) […], intersections: (4) […] }
eventPhase: 0
explicitOriginalTarget: <a-entity id="player" collider-check="" raycaster="">
isTrusted: false
originalTarget: <a-entity id="player" collider-check="" raycaster="">
returnValue: true
srcElement: <a-entity id="player" collider-check="" raycaster="">
target: <a-entity id="player" collider-check="" raycaster="">
timeStamp: 698
type: "raycaster-intersection"
<get isTrusted()>: function isTrusted()
<prototype>: CustomEventPrototype { initCustomEvent: initCustomEvent(), detail: Getter, … }

Which seems to return itself as a target.

Changing objects to a non present selector e.g .abcdef gives the same result.

  • A-Frame Version: A-Frame Version: 1.4.1 (Date 2023-01-04, Commit #5183a179) index.js:95:8
  • Platform / Device: desktop running Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0
  • Reproducible Code Snippet or URL: https://aframecaster.glitch.me/

The inspector shows that the line and the cube do not intersect.

image

@dmarcos dmarcos closed this as completed in 1e6a391 Apr 3, 2023
@dmarcos
Copy link
Member

dmarcos commented Apr 3, 2023

Example was wrong / outdated. collider-check has to be on the entity with the raycaster or otherwise the component dependency will add another raycaster to the player entity that it's the one that produces the undesired hits (has no objects filter selector)

Just updated the docs. A glitch with the corrected code:

https://glitch.com/edit/#!/auspicious-weak-dream?path=index.html%3A11%3A91

@Utopiah
Copy link
Contributor Author

Utopiah commented Apr 3, 2023

Super, thanks a lot for the clarification and this super fast fix of the doc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants