-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Raycast update #33
Merged
Merged
Raycast update #33
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nfinity) to prevent false positive on init
Ready for review! A couple big changes in this PR, so here are some notes: Raycaster componentSee here for an example (source). <Camera>
<!-- if the Raycaster is a child of a camera, use that camera as the ray origin -->
<Raycaster
:onPointerOver="callback that accepts an array of all new intersections, like onMouseEnter"
:onPointerLeave="callback that accepts an array of all newly-ended intersections, like onMouseLeave"
:onPointerOver="callback that accepts array of all current intersections"
:onClick="callback that accepts array of currently intersected objects"
:onBeforeRender="callback that fires every frame - optional, accepts the created raycaster. setting this property assumes the user is implementing all raycaster functionality and nullifies all other props and built-in functionality."
:scene="THREE scene - optional, defaults to current scene"
:camera="camera - optional, defaults to parent camera"
:intersects="array of objects to check for intersections - optional, casts against all scene children by default"
/>
</Camera> Object3D additionsSee here for an example (source). New Object3D props (all optional):
Deprecations and other notes
|
Thanks Sander for your work, really helpful |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Copied from #31:
Raycaster-first
Sometimes I want to raycast against everything in a crowded scene - in this case, I'd rather write a single raycaster's
pointerEnter
andpointerLeave
functions than those of all the objects in the scene. To accomplish this, we could add aRaycaster
component:This would raycast against everything (
raycaster.intersectObjects(scene.children)
) and fire appropriate callbacks when pointer interactions start and end. We could also include an optional proptargetObjects
if the user wants to specify which objects to target if they don't want all of them.Object-first
I'm finding the
<Renderer mouse-over>
and mesh:onHover
prop a little confusing - maybe we could do something like this:pointerEnter
andpointerLeave
props to all MeshespointerEnter
orpointerLeave
are defined, check forthis.three.raycaster
.this.three
to create one (a new method likethis.three.initializeRaycaster()
), then add the mesh to the list of target objects.From there,
three.raycaster
can handle calling events on meshes when the pointer enters or leaves them. This way we don't need anyRenderer
-level awareness of raycasting and thepointerEnter
/pointerLeave
events more closely match the Raycast component above (plus they're more clearly named for handling non-mouse inputs).TODO
mouse_move_element
onPointer...
callbacks only check the object in question, so we may get false positives hovering a mesh that's behind another. Possible fix: pass list of objects to check topointerObjects
prop or similar?Out of scope
Touch events will be out of the scope of this PR - I'll leave in placeholders (
// TODO: touch
) where they'll probably fit in.