Check If A Line And A Mesh Intersect In Three.js
I have some cilinders in the scene. When user clicks on some specific points, I´m drawing a line (THREE.Line) between the points. I need to check if the line intersects with any o
Solution 1:
From Three.js documentation:
Ray(origin, direction)
origin -- Vector3 The origin of the Ray.
direction -- Vector3 The direction of the Ray.
So if you have pointA and pointB that are the clicks of the user, you can:
(pseudo code)
origin = pointA
direction = (pointB-pointA).normalize()
myRay = THREE.Ray(origin, direction)
You can do the same with a THREE.Raycaster()
Post a Comment for "Check If A Line And A Mesh Intersect In Three.js"