vasturiano / d3-force-cluster-3d

A clustering force type for the d3-force-3d simulation engine
MIT License
12 stars 3 forks source link

Unstable z values #5

Closed christiandewit closed 1 year ago

christiandewit commented 1 year ago

When using the library I often have the z dimension reaching unexpected high values (and not recovering from it). I had a peek at the source and changing line 19 in cluster.js seems to fix it.

Original:

l = Math.sqrt(x * x + y * y);

Updated:

l = Math.sqrt(x * x + y * y + z * z);
vasturiano commented 1 year ago

Good catch @christiandewit. The z dimension is not being included in the distance calculation. Would you like to open a PR with the fix?