spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.16k stars 380 forks source link

Raycast lines? #6

Closed mrspeaker closed 8 years ago

mrspeaker commented 8 years ago

Is it possible to get intersection information from MeshLines? It's possible I have something setup incorrectly, but it seems like I don't get results from intersectObjects on MeshLines, (I do with other meshes).

spite commented 8 years ago

Unfortunately, no. While the geometry is a set of points in the right position, the triangles have no area because they're expanded on the vertex shader. Three.js raycaster tests with geometries before they're processed by the GPU.

There's a solution for picking meshes that are processed in vertex shaders (skinned meshes, animated geometries, mesh lines, etc.) and is using a color buffer to check the object ID. Check this example out: http://threejs.org/examples/#webgl_interactive_cubes_gpu, I hope it helps.

mrspeaker commented 8 years ago

Ok great! I guess this is really "by design" then - I'll close this issue off.

makc commented 8 years ago

Ok, but you are not entirely honest here. Normal 3js lines do not have triangles too, yet you can raycast them.

spite commented 8 years ago

@makc "not entirely honest"? wow, thanks! I might be wrong, or technically not correct, but definitely not dishonest.

Three.js lines do the intersection test by creating segments that can be tested by the raycaster (https://github.com/mrdoob/three.js/blob/317d6f66542ab63323c5dab6c7a4e9d08c07ca05/src/objects/Line.js#L26).

Something like that could be done for THREE.MeshLine, if someone had the inclination and time to do so.

spite commented 8 years ago

I've opened issue https://github.com/spite/THREE.MeshLine/issues/8, for the adventurous that are not afraid of challenges.

makc commented 8 years ago

which ever term you prefer, man, no hard feelings, please

spite commented 8 years ago

I like constructive terms, with proactive solutions, if possible