gkjohnson / three-mesh-bvh

A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/raycast.html
MIT License
2.56k stars 268 forks source link

Raycaster.firstHitOnly is missing a closest raycast #269

Closed gkjohnson closed 3 years ago

gkjohnson commented 3 years ago

When testing the "coffeemat" model there's a section where the closest hit is not retrieved when raycast.firstHitOnly === true:

Specifically on this handle thing:

image

These are the distance differences when using firstHitOnly = false vs true:

image

TODO

NOTES

gkjohnson commented 3 years ago

The issue is that this point being used to determine whether to run the next sibling is in world space rather than local space like the bounds:

https://github.com/gkjohnson/three-mesh-bvh/blob/9a412aa54dd9c9333b3ebad4f3a2b3159371cbdd/src/castFunctions.template.js#L132