Idenity segments in Linesegment2 raycast

I am able to raycast to lineSegment2. How to identify which segment is raycasted as segment has numerous points.

You should be able to use faceIndex to get that:

I was able to utilize faceIndex for my usecase.
However in my use case e.g.
positions = [node0,node1,node0,node2,node0,node3];
faceIndex values are coming out as a multiple of 2. Is that expected behaivour?

Looking at the code that doesn’t sound right – can you make a jsfiddle to show what’s happening?


Please have a look.
FaceIndices are console listed.


You have to use LineSegmentsGeometry rather than LineGeometry otherwise it will create lines connecting every point.

1 Like

@gkjohnson Thank You. It works .