I found it interesting that while THREE.Ray class has methods to detect collisions against Triangle, Plane, Box, and Sphere, doesn’t have a method for Line, such as like intersectsLine3(). Must I write my own or is there a way around it. My goal is to get an intersection on a line, from a ray cast.
So I want to ray cast against a 2D linear line who has a start and end point.
Currently, i’m thinking to get around it without having to write my own, I can create a THREE.Line mesh out of a Line3, and then use the THREE.Raycaster instead to do intersectObjects(myLine).
This step is not necessary. You can directly use Ray.distanceSqToSegment. When performing a ray/line segment intersection test, you actually calculate the distance between both entities. There is an intersection if the distance is smaller than a defined value.
Hi @Mugen87, I thought I had it in my head when i read your instructions. I tried to some attempts but couldn’t get to the logic you described implemented.
here is a jsfiddle https://jsfiddle.net/blackstrings/2xq4meaf/
see if you can connect the dots for me, on how I can get to knowing if an intersection occurred and where the intersection occured. You will be interested in the createScene() method.