@adatechnology/game-interactables-three 0.6.1 → 0.6.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.
@@ -3029,28 +3029,29 @@ void main() {
3029
3029
  // ../game-shapes-three/dist/index.js
3030
3030
  function catenary(a, b, sag, n = 12) {
3031
3031
  const count = Math.max(2, Math.floor(n));
3032
- const span = Math.hypot(b[0] - a[0], b[2] - a[2]) || Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
3033
- const depth = Math.max(0, sag);
3032
+ const { span, c } = catenaryOf(a[0], a[1], a[2], b[0], b[1], b[2], sag);
3034
3033
  const out = [];
3035
- let shape = () => 0;
3036
- if (depth > 1e-6 && span > 1e-6) {
3037
- let lo = 1e-4;
3038
- let hi = span * 1e3;
3039
- for (let i = 0; i < 80; i++) {
3040
- const c2 = (lo + hi) / 2;
3041
- const d = c2 * (Math.cosh(span / (2 * c2)) - 1);
3042
- if (d > depth) lo = c2;
3043
- else hi = c2;
3044
- }
3045
- const c = (lo + hi) / 2;
3046
- shape = (s) => c * (Math.cosh((s - 0.5) * span / c) - Math.cosh(span / (2 * c)));
3047
- }
3048
3034
  for (let i = 0; i < count; i++) {
3049
3035
  const s = i / (count - 1);
3050
- out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + shape(s), a[2] + (b[2] - a[2]) * s]);
3036
+ out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + catenaryDrop(span, c, s), a[2] + (b[2] - a[2]) * s]);
3051
3037
  }
3052
3038
  return out;
3053
3039
  }
3040
+ var catenaryOf = (ax, ay, az, bx, by, bz, sag) => {
3041
+ const span = Math.hypot(bx - ax, bz - az) || Math.hypot(bx - ax, by - ay, bz - az);
3042
+ const depth = Math.max(0, sag);
3043
+ if (depth <= 1e-6 || span <= 1e-6) return { span, c: 0 };
3044
+ let lo = 1e-4;
3045
+ let hi = span * 1e3;
3046
+ for (let i = 0; i < 80; i++) {
3047
+ const c = (lo + hi) / 2;
3048
+ const d = c * (Math.cosh(span / (2 * c)) - 1);
3049
+ if (d > depth) lo = c;
3050
+ else hi = c;
3051
+ }
3052
+ return { span, c: (lo + hi) / 2 };
3053
+ };
3054
+ var catenaryDrop = (span, c, s) => c > 0 ? c * (Math.cosh((s - 0.5) * span / c) - Math.cosh(span / (2 * c))) : 0;
3054
3055
  function createCord(THREE, points, radius, material, radialSegments = 5) {
3055
3056
  if (points.length < 2) throw new Error("createCord needs at least two points");
3056
3057
  const curve = new THREE.CatmullRomCurve3(points.map((p) => new THREE.Vector3(p[0], p[1], p[2])), false, "centripetal");