Hi all,
I made a simple line in ThreeJS that has 2 segments and I would like a sphere (or any indicator) to show exactly at the mid-distance of the segment.
When I build my line at the start, the Raycaster and the whole code works fine. However, when I build my line after the scene is rendered by clicking on the button that generates the line, the Raycaster doesn’t seem to work.
Could you please help with this.
here is my jsfiddle : You need to push Esc to get out of Orbit and to enable Raycasting
https://jsfiddle.net/d34xL9ue/3/
When changing geometry data, it’s important to recompute the bounding volumes. In your case, recomputing the bounding sphere is sufficient: https://jsfiddle.net/13pvyk87/
BTW: Rendering objects with an empty geometry should be avoided. It unnecessarily improves processing overhead in the renderer which can easily avoided at app level code. So add the line object during the import, not before. https://jsfiddle.net/uz8a1sk4/3/
3 Likes
Thank soo much,
Contributors such as yourself and others in this forum add so much value to our society.
I really mean that.
Thanks again
3 Likes
thank you million times!
I was scared due to the behavior of my raycast not intersecting modified bufferGeometries. It’ now fixed!