We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to draw lines between particles if they are close enough to each other.
My code seems to do that however the frame rate drops to pretty much 0.
How can I make this faster?
Code here: https://codepen.io/jmean/pen/pdwXgO
You only need to check the particles after the current particle for proximity. If a is close to b then b is close to a and you've already joined them together with a line anyway.
I'd also square both sides of your distance method, get rid of the expensive sqrt.
A very similar sketch, but in Java syntax though: :-\"
Thanks a lot guys.
Your tips definitely helped, especially ditching the Math.sqrt.
I was also console logging the distances, causing a lot of slowdown