@adatechnology/game-urban 0.7.5 → 0.7.6

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.
@@ -4544,6 +4544,26 @@ var GameUrban = (() => {
4544
4544
  }
4545
4545
 
4546
4546
  // ../game-vehicles/dist/index.js
4547
+ var SHUT_LINE_RADIUS = 2e-3;
4548
+ var SHUT_LINE_LIFT = 8e-4;
4549
+ var SHUT_LINE_STEPS = 36;
4550
+ var SHUT_LINE_STRAY = 0.04;
4551
+ function shutLinePoints(hit, x, y0, y1) {
4552
+ const out = [];
4553
+ for (let k = 0; k <= SHUT_LINE_STEPS; k++) {
4554
+ const h = hit(x, y0 + (y1 - y0) * k / SHUT_LINE_STEPS);
4555
+ if (h) out.push([h.p.x + h.n.x * SHUT_LINE_LIFT, h.p.y + h.n.y * SHUT_LINE_LIFT, h.p.z + h.n.z * SHUT_LINE_LIFT]);
4556
+ }
4557
+ if (out.length < 3) return out;
4558
+ const depths = out.map((q) => q[2]).sort((a, b) => a - b);
4559
+ const median = depths[Math.floor(depths.length / 2)];
4560
+ return out.filter((q) => Math.abs(q[2] - median) < SHUT_LINE_STRAY);
4561
+ }
4562
+ var FINISH_DETAIL = "finishDetail";
4563
+ function markFinishDetail(object) {
4564
+ object.userData[FINISH_DETAIL] = true;
4565
+ return object;
4566
+ }
4547
4567
  var DIVISION_HALF = 0.02;
4548
4568
  var GLASS_IN_FROM_EDGE = 0.03;
4549
4569
  var CUT_EPS = 1e-6;
@@ -9694,6 +9714,55 @@ var GameUrban = (() => {
9694
9714
  pane2.userData.sunroof = { slide };
9695
9715
  return pane2;
9696
9716
  }
9717
+ var CREASE_FOLD_LIFT = 7e-3;
9718
+ var CREASE_FOLD_AT = 0.4;
9719
+ function creaseHeightAt(pts, x) {
9720
+ const n = pts.length;
9721
+ const slope = (i) => (pts[i + 1][1] - pts[i][1]) / (pts[i + 1][0] - pts[i][0] || 1);
9722
+ const tangent = (i) => {
9723
+ if (i === 0) return slope(0);
9724
+ if (i === n - 1) return slope(n - 2);
9725
+ const a = slope(i - 1), b = slope(i);
9726
+ return a * b <= 0 ? 0 : 2 * a * b / (a + b);
9727
+ };
9728
+ for (let i = 0; i < n - 1; i++) {
9729
+ const a = pts[i], b = pts[i + 1];
9730
+ if ((x - a[0]) * (x - b[0]) > 0) continue;
9731
+ const w = b[0] - a[0] || 1, t = (x - a[0]) / w, t2 = t * t, t3 = t2 * t;
9732
+ return (2 * t3 - 3 * t2 + 1) * a[1] + (t3 - 2 * t2 + t) * w * tangent(i) + (-2 * t3 + 3 * t2) * b[1] + (t3 - t2) * w * tangent(i + 1);
9733
+ }
9734
+ return pts[n - 1][1];
9735
+ }
9736
+ var raised = /* @__PURE__ */ new WeakMap();
9737
+ function raisedOnSide(c) {
9738
+ let list = raised.get(c);
9739
+ if (!list) raised.set(c, list = []);
9740
+ return list;
9741
+ }
9742
+ function markRaised(c, mesh) {
9743
+ raisedOnSide(c).push(mesh);
9744
+ }
9745
+ function bodySide(THREE, c, S, sd) {
9746
+ const ray = new THREE.Raycaster();
9747
+ const world = c.vehicle.matrixWorld;
9748
+ const toVehicle = world.clone().invert();
9749
+ return function(x, y) {
9750
+ const origin = new THREE.Vector3(x, y, sd * (S.hw + 1));
9751
+ const best = S.hit(origin, new THREE.Vector3(0, 0, -sd), "M");
9752
+ ray.set(origin.clone().applyMatrix4(world), new THREE.Vector3(0, 0, -sd).transformDirection(world));
9753
+ raisedOnSide(c).forEach(function(m) {
9754
+ const h = ray.intersectObject(m, false)[0];
9755
+ if (!h || !h.face) return;
9756
+ const p = h.point.clone().applyMatrix4(toVehicle);
9757
+ if (!best || Math.abs(p.z) <= Math.abs(best.p.z)) return;
9758
+ const n = h.face.normal.clone().transformDirection(m.matrixWorld).transformDirection(toVehicle);
9759
+ if (n.z * sd < 0) n.negate();
9760
+ best.p = p;
9761
+ best.n = n;
9762
+ });
9763
+ return best;
9764
+ };
9765
+ }
9697
9766
  function installCarsExtra(fx) {
9698
9767
  const kit = fx.kit;
9699
9768
  const THREE = kit.THREE;
@@ -10032,7 +10101,8 @@ var GameUrban = (() => {
10032
10101
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
10033
10102
  for (let j = 0; j <= nv; j++) {
10034
10103
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
10035
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
10104
+ const lift = o.ridge ? o.ridge.lift * (j / nv < o.ridge.at ? j / nv / o.ridge.at : (1 - j / nv) / (1 - o.ridge.at)) : 0;
10105
+ row.push({ p: s.p.addScaledVector(s.n, of + lift), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
10036
10106
  }
10037
10107
  Q.push(row);
10038
10108
  }
@@ -10579,11 +10649,6 @@ var GameUrban = (() => {
10579
10649
  c.roundBox(0.12, 0.12, 0.2, 0.05, mcol, mx, my + 0.02, sd * (mz0 + 0.14), { taper: { sx: 0.8, shift: -0.01 } });
10580
10650
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
10581
10651
  if (s.mirrorBlink !== false) c.roundBox(0.02, 0.012, 0.12, 5e-3, MT.amber, mx + 0.03, my - 0.025, sd * (mz0 + 0.17));
10582
- const edges = doorEdgesOf(gh, s.wheels ?? []);
10583
- (s.seams || []).forEach(function(q) {
10584
- const r = q, x = seamOnDoorEdge(r.length ? r[0] : q, edges), y0 = r.length ? r[1] : by + 0.09, y1 = r.length ? r[2] : gh.belt - 0.03;
10585
- doorSeam(c, S, sd, x, y0, y1);
10586
- });
10587
10652
  (s.handles || []).forEach(function(x) {
10588
10653
  c.roundBox(
10589
10654
  0.15,
@@ -10598,7 +10663,8 @@ var GameUrban = (() => {
10598
10663
  });
10599
10664
  if (s.arches && s.arches.length > 1) {
10600
10665
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
10601
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
10666
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
10667
+ markRaised(c, K.skin(mouldingG, MT.trim, { yb: by + 0.01, yt: by + 0.09, off: 0.012, thick: 0.03, nv: 2, crease: 30, shadow: true }));
10602
10668
  if (s.clad)
10603
10669
  s.arches.forEach(function(a) {
10604
10670
  const a0 = Math.asin(clamp3((by - a[1]) / a[2], -1, 1)), tor = c.add(new THREE.TorusGeometry(a[2] + 0.02, 0.035, 6, 26, PI - 2 * a0), MT.trim, a[0], a[1], sd * (hw - 0.01));
@@ -10664,6 +10730,20 @@ var GameUrban = (() => {
10664
10730
  });
10665
10731
  underbody(c, s, I);
10666
10732
  if (s.extra) s.extra(c, I);
10733
+ c.vehicle.updateMatrixWorld(true);
10734
+ [1, -1].forEach(function(sd) {
10735
+ const side = bodySide(THREE, c, S, sd);
10736
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
10737
+ (s.seams || []).forEach(function(q) {
10738
+ const r = q, x = seamOnDoorEdge(r.length ? r[0] : q, edges), y0 = r.length ? r[1] : by + 0.11, y1 = r.length ? r[2] : gh.belt - 0.03;
10739
+ const pts = shutLinePoints(side, x, y0, y1);
10740
+ if (pts.length < 3) return;
10741
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, MT.dark, { seg: 72, rs: 5 }));
10742
+ seam.castShadow = false;
10743
+ seam.userData.doorSeam = true;
10744
+ c.deform.push(seam);
10745
+ });
10746
+ });
10667
10747
  if (!c.parts.some(function(p) {
10668
10748
  return p.kind === "engine";
10669
10749
  }))
@@ -10737,18 +10817,6 @@ var GameUrban = (() => {
10737
10817
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
10738
10818
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
10739
10819
  }
10740
- const SEAM_POINTS = 14;
10741
- function doorSeam(c, S, sd, x, y0, y1) {
10742
- const pts = [];
10743
- for (let k = 0; k <= SEAM_POINTS; k++) {
10744
- const y = y0 + (y1 - y0) * k / SEAM_POINTS, h = S.hit(new V3(x, y, sd * (S.hw + 1)), new V3(0, 0, -sd), "M");
10745
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
10746
- }
10747
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
10748
- t.castShadow = false;
10749
- t.userData.doorSeam = true;
10750
- return t;
10751
- }
10752
10820
  function sm(t) {
10753
10821
  t = clamp3(t, 0, 1);
10754
10822
  return t * t * (3 - 2 * t);
@@ -10795,36 +10863,23 @@ var GameUrban = (() => {
10795
10863
  });
10796
10864
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
10797
10865
  function yAt(u) {
10798
- const x = x0 + (x1 - x0) * u;
10799
- for (let i = 0; i < pts.length - 1; i++) {
10800
- const a = pts[i], b = pts[i + 1];
10801
- if ((x - a[0]) * (x - b[0]) <= 0) {
10802
- const t = (x - a[0]) / (b[0] - a[0] || 1);
10803
- return a[1] + (b[1] - a[1]) * sm(t);
10804
- }
10805
- }
10806
- return pts[pts.length - 1][1];
10866
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
10807
10867
  }
10808
- I.K.skin(Gd, o.mat || c.paint(o.col), {
10868
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
10809
10869
  yb: function(u) {
10810
10870
  return yAt(u) - h;
10811
10871
  },
10812
10872
  yt: yAt,
10813
- off: o.off || 6e-3,
10814
- thick: 9e-3,
10815
- nv: 2,
10873
+ off: o.off || 2e-3,
10874
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
10875
+ crease: 30,
10876
+ nv: 5,
10816
10877
  u0: o.u0 || 0.01,
10817
10878
  u1: o.u1 || 0.99
10818
10879
  });
10819
- const l = [];
10820
- for (let k = 0; k <= 30; k++) {
10821
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
10822
- l.push([u, yAt(u) - h - 1e-3]);
10823
- }
10824
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
10880
+ markRaised(c, markFinishDetail(fold));
10825
10881
  return Gd;
10826
10882
  }
10827
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
10828
10883
  const CHROMEH = CM("#c9cdd0", { metalness: 0.85, roughness: 0.25 });
10829
10884
  const CHROMEB = CM("#d4d8db", { metalness: 0.5, roughness: 0.24 });
10830
10885
  const VINYL = "#2e2622";
@@ -19156,7 +19211,8 @@ var GameUrban = (() => {
19156
19211
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
19157
19212
  for (let j = 0; j <= nv; j++) {
19158
19213
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
19159
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
19214
+ const lift = o.ridge ? o.ridge.lift * (j / nv < o.ridge.at ? j / nv / o.ridge.at : (1 - j / nv) / (1 - o.ridge.at)) : 0;
19215
+ row.push({ p: s.p.addScaledVector(s.n, of + lift), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
19160
19216
  }
19161
19217
  Q.push(row);
19162
19218
  }
@@ -19682,11 +19738,6 @@ var GameUrban = (() => {
19682
19738
  c.roundBox(0.12, 0.12, 0.2, 0.05, mcol, mx, my + 0.02, sd * (mz0 + 0.14), { taper: { sx: 0.8, shift: -0.01 } });
19683
19739
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
19684
19740
  if (s.mirrorBlink !== false) c.roundBox(0.02, 0.012, 0.12, 5e-3, MT.amber, mx + 0.03, my - 0.025, sd * (mz0 + 0.17));
19685
- const edges = doorEdgesOf(gh, s.wheels ?? []);
19686
- (s.seams || []).forEach(function(x0) {
19687
- const x = seamOnDoorEdge(x0, edges);
19688
- doorSeam(c, S, sd, x, by + 0.09, gh.belt - 0.03);
19689
- });
19690
19741
  (s.handles || []).forEach(function(x) {
19691
19742
  c.roundBox(
19692
19743
  0.15,
@@ -19701,7 +19752,8 @@ var GameUrban = (() => {
19701
19752
  });
19702
19753
  if (s.arches && s.arches.length > 1) {
19703
19754
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
19704
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
19755
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
19756
+ markRaised(c, K.skin(mouldingG, MT.trim, { yb: by + 0.01, yt: by + 0.09, off: 0.012, thick: 0.03, nv: 2, crease: 30, shadow: true }));
19705
19757
  if (s.clad)
19706
19758
  s.arches.forEach(function(a) {
19707
19759
  const a0 = Math.asin(clamp3((by - a[1]) / a[2], -1, 1)), tor = c.add(new THREE.TorusGeometry(a[2] + 0.02, 0.035, 6, 26, PI - 2 * a0), MT.trim, a[0], a[1], sd * (hw - 0.01));
@@ -19754,6 +19806,19 @@ var GameUrban = (() => {
19754
19806
  });
19755
19807
  underbody(c, s, I);
19756
19808
  if (s.extra) s.extra(c, I);
19809
+ c.vehicle.updateMatrixWorld(true);
19810
+ [1, -1].forEach(function(sd) {
19811
+ const side = bodySide(THREE, c, S, sd);
19812
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
19813
+ (s.seams || []).forEach(function(x) {
19814
+ const pts = shutLinePoints(side, seamOnDoorEdge(x, edges), by + 0.11, gh.belt - 0.03);
19815
+ if (pts.length < 3) return;
19816
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, MT.dark, { seg: 72, rs: 5 }));
19817
+ seam.castShadow = false;
19818
+ seam.userData.doorSeam = true;
19819
+ c.deform.push(seam);
19820
+ });
19821
+ });
19757
19822
  if (!c.parts.some(function(p) {
19758
19823
  return p.kind === "engine";
19759
19824
  }))
@@ -19827,18 +19892,6 @@ var GameUrban = (() => {
19827
19892
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
19828
19893
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
19829
19894
  }
19830
- const SEAM_POINTS = 14;
19831
- function doorSeam(c, S, sd, x, y0, y1) {
19832
- const pts = [];
19833
- for (let k = 0; k <= SEAM_POINTS; k++) {
19834
- const y = y0 + (y1 - y0) * k / SEAM_POINTS, h = S.hit(new V3(x, y, sd * (S.hw + 1)), new V3(0, 0, -sd), "M");
19835
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
19836
- }
19837
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
19838
- t.castShadow = false;
19839
- t.userData.doorSeam = true;
19840
- return t;
19841
- }
19842
19895
  function sm(t) {
19843
19896
  t = clamp3(t, 0, 1);
19844
19897
  return t * t * (3 - 2 * t);
@@ -19885,36 +19938,23 @@ var GameUrban = (() => {
19885
19938
  });
19886
19939
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
19887
19940
  function yAt(u) {
19888
- const x = x0 + (x1 - x0) * u;
19889
- for (let i = 0; i < pts.length - 1; i++) {
19890
- const a = pts[i], b = pts[i + 1];
19891
- if ((x - a[0]) * (x - b[0]) <= 0) {
19892
- const t = (x - a[0]) / (b[0] - a[0] || 1);
19893
- return a[1] + (b[1] - a[1]) * sm(t);
19894
- }
19895
- }
19896
- return pts[pts.length - 1][1];
19941
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
19897
19942
  }
19898
- I.K.skin(Gd, o.mat || c.paint(o.col), {
19943
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
19899
19944
  yb: function(u) {
19900
19945
  return yAt(u) - h;
19901
19946
  },
19902
19947
  yt: yAt,
19903
- off: o.off || 6e-3,
19904
- thick: 9e-3,
19905
- nv: 2,
19948
+ off: o.off || 2e-3,
19949
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
19950
+ crease: 30,
19951
+ nv: 5,
19906
19952
  u0: o.u0 || 0.01,
19907
19953
  u1: o.u1 || 0.99
19908
19954
  });
19909
- const l = [];
19910
- for (let k = 0; k <= 30; k++) {
19911
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
19912
- l.push([u, yAt(u) - h - 1e-3]);
19913
- }
19914
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
19955
+ markRaised(c, markFinishDetail(fold));
19915
19956
  return Gd;
19916
19957
  }
19917
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
19918
19958
  function dloChrome(c, I, sd, pts, r) {
19919
19959
  const gh = I.gh, T = I.T, P = pts.map(function(q) {
19920
19960
  return [q[0], q[1], sd * (halfAt(gh.Wg, T, q[1]) + 0.012)];
@@ -20972,12 +21012,10 @@ var GameUrban = (() => {
20972
21012
  I,
20973
21013
  sd,
20974
21014
  [
20975
- [1, 0.47],
20976
- [0, 0.5],
20977
- [-0.9, 0.6],
20978
- [-1.2, 0.66]
21015
+ [0.86, 0.52],
21016
+ [-0.98, 0.52]
20979
21017
  ],
20980
- { col: "#8b939a", h: 0.035 }
21018
+ { col: "#8b939a", h: 0.03 }
20981
21019
  );
20982
21020
  });
20983
21021
  }
@@ -28799,6 +28837,7 @@ var GameUrban = (() => {
28799
28837
  tl: P.tl,
28800
28838
  grille: P.grille,
28801
28839
  seams: P.seams,
28840
+ shell: shellM,
28802
28841
  handles: P.handles,
28803
28842
  wheels: [
28804
28843
  [A.xf, P.wr, 0.24, { rim: P.rim }],