How to judge and prevent the intersection of lines

What does your code look like?
It seems you have wrong coordinates for the vertices.

Take a look at these simple examples from the Collection of examples from discourse.threejs.org .

BufferGeometryNonIndexed
BufferGeometryIndexed

NumberingHelperExamples