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

feat(raycaster): Raycaster doesn't trigger objects when recursive is set to false (refs: v0.4.0) #2329

Closed
maissani opened this issue Jan 30, 2017 · 4 comments · Fixed by #2331

Comments

@maissani
Copy link

maissani commented Jan 30, 2017

Description:

Raycaster doesn't trigger objects when recursive is set to false

Environment:

Expected Behavior and Issue

Raycaster with recursive true currently working properly.
Raycaster with recursive false is not working properly: it doesn't trigger on Objects.
It seems that

intersections = this.raycaster.intersectObjects(this.objects, data.recursive)

Doesn't return any intersection when set to false
This bug is probably related to Three.js or not

A simple workAround tho fix this is to set to true whatever ( and then rollback when it's fixed on three.js), and add a conditional check to get only the parrent object (only if he is the origin of intersection )

@maissani maissani changed the title feat(raycaster): Raycaster doesn't trigger objects when recursive is set to false (refs:87c934aae6c85ac05af48e3c569db584197fb946) feat(raycaster): Raycaster doesn't trigger objects when recursive is set to false (refs: v0.4.0) Jan 30, 2017
@donmccurdy
Copy link
Member

donmccurdy commented Jan 30, 2017

Understand the confusion, but this is how THREE.Raycaster works. Parent THREE.Objects do not have geometry: if recursive:false is set the children are ignored, so there's nothing for the raycaster to hit. Neither A-Frame nor Three.js will be able to change this behavior, in all likelihood.

Your workaround is a good one, though, and perhaps a community component (shallow-raycaster?) should be created to allow it more conveniently.

@donmccurdy
Copy link
Member

donmccurdy commented Jan 30, 2017

Ok, looking at this a bit more, here's a simpler Codepen demo. With no nesting whatsoever, and {recursive:false}, clicks on the box still don't go through because there's a wrapping THREE.Group around the mesh.

So, there is something to be fixed here. Either:

  1. We remove the recursive property from the raycaster, because it should basically always be true.
  2. Or, we try to implement shallow (1-level) raycasting in a way that avoids these wrapping elements.

@machenmusik
Copy link
Contributor

(is the wrapping that is done always only one level deep?)

@donmccurdy
Copy link
Member

(is the wrapping that is done always only one level deep?)

For stock geometries, yes. If there's a collada-model or something involved, there's also a good chance that the model introduces its own wrappers.

ngokevin pushed a commit that referenced this issue May 16, 2017
* change raycaster to be non-recursive

since there appears to be a wrapper around an entity's object3D, use its children instead

* add simple example of non-recursive raycaster and dynamically created box

add geometry so that raycaster actually adds something

wait until next tick to satisfy Firefox; remove extra tick

* changes per discussion on PR

* changes per discussion on PR
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

Successfully merging a pull request may close this issue.

3 participants