I’m currently testing THREE.Raycaster() with linear objects and have found one weird issue.
Pls check my example: https://jsfiddle.net/k1ygqz2c/
For instance I have a linear square object. As you can see the intersection is detected even when the cursor is not over the object.
What I’m doing wrong?
Raycaster has a property called linePrecision which is in some sense a tolerance value for the ray/line intersection test. The default value is
1. If you decrease the value, it’s possible to mitigate the mentioned effect, see https://jsfiddle.net/k1ygqz2c/2/.
It’s in general hard to provide an “exact” ray/line intersection test since lines do not have a width from a mathematical point of view. The result of the intersection test is more an approximation.
Thank you. Unfortunately the result is not perfect. I think the best way to solve this issue is to draw a transparent square plane for intersections detection and then highlight the linear square. Because I need to highlight it when the cursor is inside it bounds.
Yep, that’s of course a valid solution