Raycasting with LineSegment2 objects

My two questions are how to make LineSegment2 objects detectable by RayCaster and how to handle a large number of line segments in a scene.

I need to attach properties to the mesh such as the name and id; this requires me to create a new mesh/material/geometry for each line segment. I have to create about 50k line segments which make rendering slow.

I understand that I could use a single geometry, mesh, and material to draw the line segments but I would lose the name and id information that I need about each line segment. What techniques exist for handling a large number of objects in a scene?

When I click on the Line2Segment objects, Raycaster never detects an intersection. I have played with the RayCaster line precision property trying both large and small numbers but nothing works. How can I make this work?

1 Like

AFAIK, Line2 and LineSegments2 do not support raycasting so far ( see https://github.com/mrdoob/three.js/pull/11349#issuecomment-375815331)

I suggest you do feature request at github if you actually need it.

BTW: Please do not ask two questions in the same topic. In this one, it’s better to focus on raycasting.

Thanks. I will do a feature request.

Line 2 has been out for a while now, but this seems to still be an issue, does anyone know if this will ever be implemented?

does anyone know if this will ever be implemented?

Unfortunately, the way open source work, only a sage with a crystal ball would know an answer to this question. It’s up for grabs, the original author may implement this, someone else may implement it, it may have to wait for you to implement it, or it may never get implemented. All are viable options.

The one good thing is, lines2 are just an example, that can be modified, it’s not embedded in the core.

A contributor created a PR for this a month ago:

Unfortunately, the OP did not implemented the project’s feedback so far. Anyway, you can still try to use the respective code if you need the feature urgently.


Great thanks for the info!