I recently inquired about connecting nearby particles in ThreeJS and managed to create lines between them. However, due to the logic of the particle system, the lines are drawn twice. This behavior is similar to how the original 2D particle system functions: Link
This redundancy occurs because a line is drawn for each pair of particles connected. This could impact performance negatively. How can I ensure that each line is drawn only once for every pair of connecting points?
For reference, here is the desired effect I aim to achieve but struggle with the underlying code logic: Link
I have shared my progress via this jsfiddle.
// JavaScript code present
// Omitted for brevity
Although I am close to achieving the desired result, I'm concerned about optimization issues. There seems to be flickering lines and instances where a line remains stationary. My current approach involves updating line geometry vertices to match relevant particle points.
Regarding line management, I assign a unique ID by using the indexes of the two points, such as '8-2' for instance.