@kineviz/gl 0.4.0 → 0.4.2

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.
package/dist/index.js CHANGED
@@ -46479,9 +46479,23 @@ var _MapApi = class _MapApi {
46479
46479
  sz += posArray[gidx * 3 + 2];
46480
46480
  }
46481
46481
  const n = neighbors.length;
46482
- posArray[idx * 3] = sx / n + (Math.random() - 0.5) * 2 * jitter;
46483
- posArray[idx * 3 + 1] = sy / n + (Math.random() - 0.5) * 2 * jitter;
46484
- posArray[idx * 3 + 2] = isPlanar ? 0 : sz / n + (Math.random() - 0.5) * 2 * jitter;
46482
+ let cx = sx / n, cy = sy / n, cz = sz / n;
46483
+ if (!isPlanar) {
46484
+ const len = Math.hypot(cx, cy, cz);
46485
+ if (len > 1e-6) {
46486
+ const s = radius / len;
46487
+ cx *= s;
46488
+ cy *= s;
46489
+ cz *= s;
46490
+ } else {
46491
+ cx = 0;
46492
+ cy = 0;
46493
+ cz = radius;
46494
+ }
46495
+ }
46496
+ posArray[idx * 3] = cx + (Math.random() - 0.5) * 2 * jitter;
46497
+ posArray[idx * 3 + 1] = cy + (Math.random() - 0.5) * 2 * jitter;
46498
+ posArray[idx * 3 + 2] = isPlanar ? 0 : cz + (Math.random() - 0.5) * 2 * jitter;
46485
46499
  } else if (isPlanar) {
46486
46500
  posArray[idx * 3 + 2] = 0;
46487
46501
  }