@kineviz/gl 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84849,9 +84849,23 @@ void main() {
84849
84849
  sz += posArray[gidx * 3 + 2];
84850
84850
  }
84851
84851
  const n = neighbors.length;
84852
- posArray[idx * 3] = sx / n + (Math.random() - 0.5) * 2 * jitter;
84853
- posArray[idx * 3 + 1] = sy / n + (Math.random() - 0.5) * 2 * jitter;
84854
- posArray[idx * 3 + 2] = isPlanar ? 0 : sz / n + (Math.random() - 0.5) * 2 * jitter;
84852
+ let cx = sx / n, cy = sy / n, cz = sz / n;
84853
+ if (!isPlanar) {
84854
+ const len = Math.hypot(cx, cy, cz);
84855
+ if (len > 1e-6) {
84856
+ const s = radius / len;
84857
+ cx *= s;
84858
+ cy *= s;
84859
+ cz *= s;
84860
+ } else {
84861
+ cx = 0;
84862
+ cy = 0;
84863
+ cz = radius;
84864
+ }
84865
+ }
84866
+ posArray[idx * 3] = cx + (Math.random() - 0.5) * 2 * jitter;
84867
+ posArray[idx * 3 + 1] = cy + (Math.random() - 0.5) * 2 * jitter;
84868
+ posArray[idx * 3 + 2] = isPlanar ? 0 : cz + (Math.random() - 0.5) * 2 * jitter;
84855
84869
  } else if (isPlanar) {
84856
84870
  posArray[idx * 3 + 2] = 0;
84857
84871
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kineviz/gl",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Complete 3D graph visualization engine",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",