@adatechnology/game-interactables 0.9.0 → 0.10.0

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
@@ -2402,6 +2402,38 @@ function hangTail(params) {
2402
2402
  });
2403
2403
  }
2404
2404
 
2405
+ // src/wire-runs.ts
2406
+ var lerp = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
2407
+ function along(points, step) {
2408
+ const out = points.length ? [[...points[0]]] : [];
2409
+ for (let i = 1; i < points.length; i++) {
2410
+ const a = points[i - 1];
2411
+ const b = points[i];
2412
+ const steps = Math.max(1, Math.ceil(Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]) / step));
2413
+ for (let k = 1; k <= steps; k++) out.push(lerp(a, b, k / steps));
2414
+ }
2415
+ return out;
2416
+ }
2417
+ function wireRuns(params) {
2418
+ const points = along(params.points, Math.max(1e-3, params.step));
2419
+ if (points.length < 2) return [];
2420
+ const holders = points.map((p) => params.holderOf(p));
2421
+ const runs = [];
2422
+ let current = { holder: holders[0], points: [points[0]] };
2423
+ for (let i = 1; i < points.length; i++) {
2424
+ if (holders[i] === current.holder) {
2425
+ current.points.push(points[i]);
2426
+ continue;
2427
+ }
2428
+ const seam = lerp(points[i - 1], points[i], 0.5);
2429
+ current.points.push(seam);
2430
+ runs.push(current);
2431
+ current = { holder: holders[i], points: [[...seam], points[i]] };
2432
+ }
2433
+ runs.push(current);
2434
+ return runs;
2435
+ }
2436
+
2405
2437
  // src/fits-volume.ts
2406
2438
  function fitsInVolume(size, half) {
2407
2439
  const thing = [...size].sort((a, b) => b - a);
@@ -2661,6 +2693,7 @@ export {
2661
2693
  rotateAxis,
2662
2694
  solveSpan,
2663
2695
  spanStrength,
2696
+ wireRuns,
2664
2697
  worldToLocal
2665
2698
  };
2666
2699
  //# sourceMappingURL=index.js.map