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

Add near and far check in intersectRay #657

Closed
agargaro opened this issue Apr 11, 2024 · 2 comments
Closed

Add near and far check in intersectRay #657

agargaro opened this issue Apr 11, 2024 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@agargaro
Copy link
Contributor

agargaro commented Apr 11, 2024

Adding near and far to the intersectRay function would avoid recursively checking many bvh nodes when raycasting.

It will require a change in the API.

I did a test by setting raycaster.far = 0.1 from raycast example page and of course it is super fast.

It would also be useful to edit the raycast example page by adding near and far in the GUI (which will also change the length of the drawn lines) and to use InstancedMesh so that raycasting can be tested better (too many drawcalls are a bottleneck).

image

@agargaro agargaro added the enhancement New feature or request label Apr 11, 2024
@gkjohnson gkjohnson added this to the v0.7.5 milestone Apr 12, 2024
@gkjohnson
Copy link
Owner

This would be a good change - currently I think the raycast results may even be incorrect if raycaster.near or far are modified.

It will require a change in the API.

I think we can just add near and far arguments to the .raycast and .raycastFirst functions - it shouldn't be breaking.

It would also be useful to edit the raycast example page by adding near and far in the GUI

If we do this lets change the ray lengths to help show the difference in what's happening.

use InstancedMesh so that raycasting can be tested better (too many drawcalls are a bottleneck).

I've been meaning to do this but have never had time. Help would be great! The bvh raycasting demo I added to three.js uses InstancedMesh for the spheres and updates a LineSegments class for all the lines.

@agargaro
Copy link
Contributor Author

I think to be able to make a PR this weekend :)

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

No branches or pull requests

2 participants