@adatechnology/game-vehicles-fleet 11.0.2 → 12.0.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
@@ -5029,7 +5029,8 @@ function installBoatsExtra(fx) {
5029
5029
  }
5030
5030
 
5031
5031
  // src/vehicles/cars-extra.ts
5032
- import { DIVISION_HALF, doorEdgesOf, doorGlassSplits, seamOnDoorEdge, splitSidePolys } from "@adatechnology/game-vehicles";
5032
+ import { DIVISION_HALF, divisionSpan, doorEdgesOf, doorGlassSplits, seamOnDoorEdge, splitSidePolys } from "@adatechnology/game-vehicles";
5033
+ import { SHUT_LINE_RADIUS, markFinishDetail, shutLinePoints } from "@adatechnology/game-vehicles";
5033
5034
 
5034
5035
  // src/vehicles/moving-parts.ts
5035
5036
  var WIPER_SWEEP = 1.5;
@@ -5045,6 +5046,57 @@ function markSunroof(pane, slide) {
5045
5046
  return pane;
5046
5047
  }
5047
5048
 
5049
+ // src/vehicles/side-design.ts
5050
+ var CREASE_FOLD_LIFT = 7e-3;
5051
+ var CREASE_FOLD_AT = 0.4;
5052
+ function creaseHeightAt(pts, x) {
5053
+ const n = pts.length;
5054
+ const slope = (i) => (pts[i + 1][1] - pts[i][1]) / (pts[i + 1][0] - pts[i][0] || 1);
5055
+ const tangent = (i) => {
5056
+ if (i === 0) return slope(0);
5057
+ if (i === n - 1) return slope(n - 2);
5058
+ const a = slope(i - 1), b = slope(i);
5059
+ return a * b <= 0 ? 0 : 2 * a * b / (a + b);
5060
+ };
5061
+ for (let i = 0; i < n - 1; i++) {
5062
+ const a = pts[i], b = pts[i + 1];
5063
+ if ((x - a[0]) * (x - b[0]) > 0) continue;
5064
+ const w = b[0] - a[0] || 1, t = (x - a[0]) / w, t2 = t * t, t3 = t2 * t;
5065
+ 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);
5066
+ }
5067
+ return pts[n - 1][1];
5068
+ }
5069
+ var raised = /* @__PURE__ */ new WeakMap();
5070
+ function raisedOnSide(c) {
5071
+ let list = raised.get(c);
5072
+ if (!list) raised.set(c, list = []);
5073
+ return list;
5074
+ }
5075
+ function markRaised(c, mesh) {
5076
+ raisedOnSide(c).push(mesh);
5077
+ }
5078
+ function bodySide(THREE, c, S, sd) {
5079
+ const ray = new THREE.Raycaster();
5080
+ const world = c.vehicle.matrixWorld;
5081
+ const toVehicle = world.clone().invert();
5082
+ return function(x, y) {
5083
+ const origin = new THREE.Vector3(x, y, sd * (S.hw + 1));
5084
+ const best = S.hit(origin, new THREE.Vector3(0, 0, -sd), "M");
5085
+ ray.set(origin.clone().applyMatrix4(world), new THREE.Vector3(0, 0, -sd).transformDirection(world));
5086
+ raisedOnSide(c).forEach(function(m) {
5087
+ const h = ray.intersectObject(m, false)[0];
5088
+ if (!h || !h.face) return;
5089
+ const p = h.point.clone().applyMatrix4(toVehicle);
5090
+ if (!best || Math.abs(p.z) <= Math.abs(best.p.z)) return;
5091
+ const n = h.face.normal.clone().transformDirection(m.matrixWorld).transformDirection(toVehicle);
5092
+ if (n.z * sd < 0) n.negate();
5093
+ best.p = p;
5094
+ best.n = n;
5095
+ });
5096
+ return best;
5097
+ };
5098
+ }
5099
+
5048
5100
  // src/vehicles/cars-extra.ts
5049
5101
  function installCarsExtra(fx) {
5050
5102
  const kit = fx.kit;
@@ -5384,7 +5436,8 @@ function installCarsExtra(fx) {
5384
5436
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
5385
5437
  for (let j = 0; j <= nv; j++) {
5386
5438
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
5387
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
5439
+ 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;
5440
+ 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] });
5388
5441
  }
5389
5442
  Q.push(row);
5390
5443
  }
@@ -5673,6 +5726,7 @@ function installCarsExtra(fx) {
5673
5726
  return pl;
5674
5727
  };
5675
5728
  K.lid = function(pts0) {
5729
+ c.meta.lidSeam = pts0;
5676
5730
  const pts = [];
5677
5731
  pts0.forEach(function(q, i) {
5678
5732
  const n = pts0[i + 1];
@@ -5690,8 +5744,9 @@ function installCarsExtra(fx) {
5690
5744
  const h = q.top ? S.hit(new V3(q.x, 3, q.z), new V3(0, -1, 0), "R") : S.hit(new V3(S.endX(-1, q.y) - 1, q.y, q.z), new V3(1, 0, 0), "R");
5691
5745
  return h ? h.p.addScaledVector(h.n, 3e-3) : null;
5692
5746
  }).filter(Boolean);
5693
- const t = c.tube(P, 38e-4, MT.dark, { seg: P.length * 8, rs: 4 });
5747
+ const t = c.tube(P, GAP_R, I.gap ?? MT.dark, { seg: P.length * 8, rs: 4 });
5694
5748
  t.castShadow = false;
5749
+ t.userData.gap = true;
5695
5750
  c.deform.push(t);
5696
5751
  return t;
5697
5752
  };
@@ -5717,6 +5772,8 @@ function installCarsExtra(fx) {
5717
5772
  };
5718
5773
  return K;
5719
5774
  }
5775
+ const DIVISION_OVER = 0.012;
5776
+ const COWL_DROP = 0.012;
5720
5777
  const glassDivisions = /* @__PURE__ */ new WeakMap();
5721
5778
  function car(c, s) {
5722
5779
  const W = s.W, gh = s.gh, bev = 0.05, T = { belt: gh.belt, top: gh.roof + bev, k: gh.k }, m = c.meta;
@@ -5754,7 +5811,10 @@ function installCarsExtra(fx) {
5754
5811
  if (gh.polys) polys = gh.polys(polys);
5755
5812
  const divided = splitSidePolys(polys, doorGlassSplits(gh, s.wheels ?? []));
5756
5813
  polys = divided.polys;
5757
- glassDivisions.set(c, divided.used);
5814
+ glassDivisions.set(
5815
+ c,
5816
+ divided.used.map((at) => ({ at, span: divisionSpan(divided.polys, at) }))
5817
+ );
5758
5818
  const qf = kit.quadDef([gh.fb, gh.belt], [gh.ft, gh.roof], gh.Wg, T, "front", bev, { side: gh.qfSide }), qr = kit.quadDef([gh.rb, gh.belt], [gh.rt, roofR], gh.Wg, T, "rear", bev, { side: gh.qrSide });
5759
5819
  const gHoles = [];
5760
5820
  if (intr) {
@@ -5775,6 +5835,7 @@ function installCarsExtra(fx) {
5775
5835
  side: THREE.DoubleSide
5776
5836
  }) : null;
5777
5837
  kit.shell(c, { items: ghItems, W: gh.Wg, col: s.col, mat: roofMat, T, holes: gHoles, sub: intr ? 0.12 : 0.2 });
5838
+ const sealEdges = doorEdgesOf(gh, s.wheels ?? []);
5778
5839
  kit.sideWindows(
5779
5840
  c,
5780
5841
  polys,
@@ -5783,7 +5844,14 @@ function installCarsExtra(fx) {
5783
5844
  function(i, n) {
5784
5845
  return i === 0 && n > 2 ? lbl("quarter_glass") : i === n - 1 ? lbl("window_front") : lbl("window_rear");
5785
5846
  },
5786
- { see: !!intr }
5847
+ {
5848
+ see: !!intr,
5849
+ // a fixed pane sits in a thin rubber flush with the body; the window of a door runs in a channel round its frame
5850
+ seal: function(i) {
5851
+ const xs = polys[i].map((q) => q[0]), mid = (Math.min(...xs) + Math.max(...xs)) / 2;
5852
+ return sealEdges && mid > sealEdges.C && mid < sealEdges.doorF ? DOOR_SEAL_R : FIXED_SEAL_R;
5853
+ }
5854
+ }
5787
5855
  );
5788
5856
  kit.glassQuad(c, qf, lbl("windshield"), { see: !!intr });
5789
5857
  kit.glassQuad(c, qr, lbl("rear_window"), { see: !!intr, mat: intr ? MT.tint : MT.glassDark });
@@ -5842,7 +5910,7 @@ function installCarsExtra(fx) {
5842
5910
  (s.arches || []).forEach(function(a) {
5843
5911
  fa = Math.max(fa, a[0]);
5844
5912
  });
5845
- const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col });
5913
+ const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col, gap: HOOD_GAP });
5846
5914
  if (hood)
5847
5915
  kit.engineBay(c, {
5848
5916
  x0: hx0 + 0.02,
@@ -5876,6 +5944,7 @@ function installCarsExtra(fx) {
5876
5944
  );
5877
5945
  const Wf = mkWarp(wo);
5878
5946
  const S = mkSurf(lowMesh, W);
5947
+ if (c.hood && hoodO) hoodGap(c, S, hx0, hx1, zH, gapMaterial(s.col));
5879
5948
  details(c, s, Wf, S);
5880
5949
  applyWarp(c, Wf);
5881
5950
  return m;
@@ -5887,7 +5956,7 @@ function installCarsExtra(fx) {
5887
5956
  }, rx = function(y) {
5888
5957
  return profX(it, y, false);
5889
5958
  };
5890
- const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S };
5959
+ const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S, gap: gapMaterial(s.col) };
5891
5960
  I.fxB = S.endX(1, by + 0.2);
5892
5961
  I.rxB = S.endX(-1, by + 0.2);
5893
5962
  const K = mkKit(c, S, I);
@@ -5916,26 +5985,22 @@ function installCarsExtra(fx) {
5916
5985
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
5917
5986
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
5918
5987
  [1, -1].forEach(function(sd) {
5919
- const bar = function(px, width) {
5920
- const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
5988
+ const bar = function(px, width, span) {
5989
+ const ry = roofAt(gh, px), yc = span ? (span[0] + span[1]) / 2 : (gh.belt + ry) / 2 + 5e-3, hh = span ? span[1] - span[0] + 2 * DIVISION_OVER : ry - gh.belt - 0.1;
5921
5990
  const m2 = c.roundBox(width, hh, 3e-3, 15e-4, GLOSS, px, yc, sd * (halfAt(gh.Wg, T, yc) + 4e-3), { rot: [-sd * tang, 0, 0] });
5922
5991
  m2.castShadow = false;
5923
5992
  return m2;
5924
5993
  };
5925
5994
  (s.blackPillars || []).forEach((px) => bar(px, 0.118));
5926
- (glassDivisions.get(c) ?? []).forEach((px) => {
5927
- bar(px, 2 * DIVISION_HALF - 2e-3).userData.doorChannel = true;
5995
+ (glassDivisions.get(c) ?? []).forEach(({ at, span }) => {
5996
+ bar(at, 2 * DIVISION_HALF - 2e-3, span).userData.doorChannel = true;
5928
5997
  });
5929
5998
  const mx = gh.fb - 0.22, my = gh.belt + 0.09, mz0 = halfAt(gh.Wg, T, my), mcol = s.mirrorCol ? CM(s.mirrorCol, { roughness: 0.4, metalness: 0.3 }) : paint;
5930
5999
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
5931
6000
  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 } });
5932
6001
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
5933
6002
  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));
5934
- const edges = doorEdgesOf(gh, s.wheels ?? []);
5935
- (s.seams || []).forEach(function(q) {
5936
- 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;
5937
- doorSeam(c, S, sd, x, y0, y1);
5938
- });
6003
+ if (s.fuelDoor && sd === s.fuelDoor[2]) fuelDoorGap(c, S, sd, s.fuelDoor[0], s.fuelDoor[1], I.gap);
5939
6004
  (s.handles || []).forEach(function(x) {
5940
6005
  c.roundBox(
5941
6006
  0.15,
@@ -5950,7 +6015,8 @@ function installCarsExtra(fx) {
5950
6015
  });
5951
6016
  if (s.arches && s.arches.length > 1) {
5952
6017
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
5953
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
6018
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
6019
+ 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 }));
5954
6020
  if (s.clad)
5955
6021
  s.arches.forEach(function(a) {
5956
6022
  const a0 = Math.asin(clamp((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));
@@ -5962,16 +6028,25 @@ function installCarsExtra(fx) {
5962
6028
  c.roundBox(
5963
6029
  gh.fb - gh.rb - 0.3,
5964
6030
  0.012,
5965
- 8e-3,
6031
+ 0.012,
5966
6032
  4e-3,
5967
6033
  MT.chrome,
5968
6034
  (gh.fb + gh.rb) / 2 - 0.05,
5969
6035
  gh.belt + 0.035,
5970
- sd * (halfAt(gh.Wg, T, gh.belt + 0.035) + 4e-3)
6036
+ sd * (halfAt(gh.Wg, T, gh.belt + 0.035) + 6e-3)
5971
6037
  );
5972
6038
  });
5973
6039
  const cwh = S.hit(new V3(gh.fb + 0.03, 3, 0), new V3(0, -1, 0)), cwy = cwh ? cwh.p.y : gh.belt;
5974
- c.roundBox(0.15, 0.02, gh.Wg - 0.06, 8e-3, PLASTIC, gh.fb + 0.02, cwy + 4e-3, 0).castShadow = false;
6040
+ let cwz = gh.Wg / 2 - 0.03;
6041
+ for (let z = 0.3; z < cwz; z += 0.01) {
6042
+ const h = S.hit(new V3(gh.fb + 0.03, 3, z), new V3(0, -1, 0));
6043
+ if (!h || h.p.y < cwy - COWL_DROP) {
6044
+ cwz = z;
6045
+ break;
6046
+ }
6047
+ }
6048
+ cwz = Math.min(cwz, halfAt(gh.Wg, T, gh.belt + 0.05) - 0.072);
6049
+ c.roundBox(0.15, 0.02, 2 * cwz, 8e-3, PLASTIC, gh.fb + 0.02, cwy + 4e-3, 0).castShadow = false;
5975
6050
  const wd = new V3(gh.ft - gh.fb, gh.roof - gh.belt, 0).normalize(), wn = new V3(wd.y, -wd.x, 0);
5976
6051
  const fr = new V3(gh.fb, gh.belt, 0).addScaledVector(wd, 0.065).addScaledVector(wn, 0.047), frw = 2 * (halfAt(gh.Wg, T, gh.belt + 0.05) - 0.07);
5977
6052
  c.roundBox(0.14, 6e-3, frw, 3e-3, PLASTIC, fr.x, fr.y, 0, { rot: [0, 0, Math.atan2(wd.y, wd.x)] }).castShadow = false;
@@ -6016,6 +6091,21 @@ function installCarsExtra(fx) {
6016
6091
  });
6017
6092
  underbody(c, s, I);
6018
6093
  if (s.extra) s.extra(c, I);
6094
+ c.vehicle.updateMatrixWorld(true);
6095
+ [1, -1].forEach(function(sd) {
6096
+ const side = bodySide(THREE, c, S, sd);
6097
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
6098
+ (s.seams || []).forEach(function(q) {
6099
+ 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;
6100
+ const pts = shutLinePoints(side, x, y0, y1);
6101
+ if (pts.length < 3) return;
6102
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, I.gap ?? MT.dark, { seg: 72, rs: 5 }));
6103
+ seam.castShadow = false;
6104
+ seam.userData.doorSeam = true;
6105
+ seam.userData.gap = true;
6106
+ c.deform.push(seam);
6107
+ });
6108
+ });
6019
6109
  if (!c.parts.some(function(p) {
6020
6110
  return p.kind === "engine";
6021
6111
  }))
@@ -6089,16 +6179,57 @@ function installCarsExtra(fx) {
6089
6179
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
6090
6180
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
6091
6181
  }
6092
- const SEAM_POINTS = 14;
6093
- function doorSeam(c, S, sd, x, y0, y1) {
6182
+ const GAP_R = 2e-3;
6183
+ const FIXED_SEAL_R = 4e-3;
6184
+ const DOOR_SEAL_R = 6e-3;
6185
+ const GAP_SHADE = 0.45;
6186
+ const gapMaterials = /* @__PURE__ */ new Map();
6187
+ function gapMaterial(col) {
6188
+ const hex = "#" + new THREE.Color(col).multiplyScalar(GAP_SHADE).getHexString();
6189
+ const known = gapMaterials.get(hex);
6190
+ if (known) return known;
6191
+ const made = CM(hex, { roughness: 0.6 }) ?? MT.dark;
6192
+ gapMaterials.set(hex, made);
6193
+ return made;
6194
+ }
6195
+ const HOOD_GAP = 4 * GAP_R;
6196
+ function hoodGap(c, S, x0, x1, zH, mat) {
6197
+ const onTop = (x, z) => {
6198
+ const h = S.hit(new V3(x, 3, z), new V3(0, -1, 0));
6199
+ return h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, 0, z);
6200
+ };
6201
+ const steps = Math.max(4, Math.ceil((x1 - x0) / 0.04));
6202
+ const across = Math.max(4, Math.ceil(2 * zH / 0.04));
6203
+ const line = [];
6204
+ for (let k = 0; k <= steps; k++) line.push(onTop(x0 + (x1 - x0) * k / steps, zH));
6205
+ for (let k = 1; k < across; k++) line.push(onTop(x1, zH - 2 * zH * k / across));
6206
+ for (let k = steps; k >= 0; k--) line.push(onTop(x0 + (x1 - x0) * k / steps, -zH));
6207
+ const t = c.tube(line, GAP_R, mat, { seg: line.length * 2, rs: 4 });
6208
+ t.castShadow = false;
6209
+ t.userData.gap = true;
6210
+ return t;
6211
+ }
6212
+ const FUEL_DOOR_W = 0.13;
6213
+ const FUEL_DOOR_H = 0.11;
6214
+ const FUEL_DOOR_R = 0.02;
6215
+ function fuelDoorGap(c, S, sd, x, y, mat) {
6094
6216
  const pts = [];
6095
- for (let k = 0; k <= SEAM_POINTS; k++) {
6096
- 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");
6097
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
6098
- }
6099
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
6217
+ const hx = FUEL_DOOR_W / 2 - FUEL_DOOR_R, hy = FUEL_DOOR_H / 2 - FUEL_DOOR_R;
6218
+ const corners = [
6219
+ [hx, hy, 0],
6220
+ [-hx, hy, 0.5 * PI],
6221
+ [-hx, -hy, PI],
6222
+ [hx, -hy, 1.5 * PI]
6223
+ ];
6224
+ corners.forEach(function([cx, cy, a0]) {
6225
+ for (let k = 0; k <= 4; k++) {
6226
+ const a = a0 + k / 4 * 0.5 * PI, px = x + cx + FUEL_DOOR_R * Math.cos(a), py = y + cy + FUEL_DOOR_R * Math.sin(a), h = S.hit(new V3(px, py, sd * (S.hw + 1)), new V3(0, 0, -sd), "M");
6227
+ pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(px, py, sd * S.hw));
6228
+ }
6229
+ });
6230
+ const t = c.tube(pts, GAP_R, mat, { closed: true, seg: pts.length * 2, rs: 4 });
6100
6231
  t.castShadow = false;
6101
- t.userData.doorSeam = true;
6232
+ t.userData.gap = true;
6102
6233
  return t;
6103
6234
  }
6104
6235
  function sm(t) {
@@ -6147,36 +6278,23 @@ function installCarsExtra(fx) {
6147
6278
  });
6148
6279
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
6149
6280
  function yAt(u) {
6150
- const x = x0 + (x1 - x0) * u;
6151
- for (let i = 0; i < pts.length - 1; i++) {
6152
- const a = pts[i], b = pts[i + 1];
6153
- if ((x - a[0]) * (x - b[0]) <= 0) {
6154
- const t = (x - a[0]) / (b[0] - a[0] || 1);
6155
- return a[1] + (b[1] - a[1]) * sm(t);
6156
- }
6157
- }
6158
- return pts[pts.length - 1][1];
6281
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
6159
6282
  }
6160
- I.K.skin(Gd, o.mat || c.paint(o.col), {
6283
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
6161
6284
  yb: function(u) {
6162
6285
  return yAt(u) - h;
6163
6286
  },
6164
6287
  yt: yAt,
6165
- off: o.off || 6e-3,
6166
- thick: 9e-3,
6167
- nv: 2,
6288
+ off: o.off || 2e-3,
6289
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
6290
+ crease: 30,
6291
+ nv: 5,
6168
6292
  u0: o.u0 || 0.01,
6169
6293
  u1: o.u1 || 0.99
6170
6294
  });
6171
- const l = [];
6172
- for (let k = 0; k <= 30; k++) {
6173
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
6174
- l.push([u, yAt(u) - h - 1e-3]);
6175
- }
6176
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
6295
+ markRaised(c, markFinishDetail(fold));
6177
6296
  return Gd;
6178
6297
  }
6179
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
6180
6298
  const CHROMEH = CM("#c9cdd0", { metalness: 0.85, roughness: 0.25 });
6181
6299
  const CHROMEB = CM("#d4d8db", { metalness: 0.5, roughness: 0.24 });
6182
6300
  const VINYL = "#2e2622";
@@ -6511,6 +6629,8 @@ function installCarsExtra(fx) {
6511
6629
  dropRear: true,
6512
6630
  seams: [0.64, -0.5, [-1.27, 0.67, 0.93]],
6513
6631
  handles: [0.12, -0.86],
6632
+ /* fuel door on the right rear fender, between the rear door and the taillight, over the wheel */
6633
+ fuelDoor: [-1.47, 0.71, 1],
6514
6634
  blackPillars: [-0.5],
6515
6635
  frontBumper: { y1: 0.6 },
6516
6636
  rearBumper: { y1: 0.58 },
@@ -14065,7 +14185,8 @@ function installMilitary(fx) {
14065
14185
  }
14066
14186
 
14067
14187
  // src/vehicles/motorcycles-cars.ts
14068
- import { DIVISION_HALF as DIVISION_HALF2, doorEdgesOf as doorEdgesOf2, doorGlassSplits as doorGlassSplits2, seamOnDoorEdge as seamOnDoorEdge2, splitSidePolys as splitSidePolys2 } from "@adatechnology/game-vehicles";
14188
+ import { SHUT_LINE_RADIUS as SHUT_LINE_RADIUS2, markFinishDetail as markFinishDetail2, shutLinePoints as shutLinePoints2 } from "@adatechnology/game-vehicles";
14189
+ import { DIVISION_HALF as DIVISION_HALF2, divisionSpan as divisionSpan2, doorEdgesOf as doorEdgesOf2, doorGlassSplits as doorGlassSplits2, seamOnDoorEdge as seamOnDoorEdge2, splitSidePolys as splitSidePolys2 } from "@adatechnology/game-vehicles";
14069
14190
  function installMotorcyclesCars(fx) {
14070
14191
  const kit = fx.kit;
14071
14192
  const THREE = kit.THREE;
@@ -14517,7 +14638,8 @@ function installMotorcyclesCars(fx) {
14517
14638
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
14518
14639
  for (let j = 0; j <= nv; j++) {
14519
14640
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
14520
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
14641
+ 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;
14642
+ 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] });
14521
14643
  }
14522
14644
  Q.push(row);
14523
14645
  }
@@ -14806,12 +14928,14 @@ function installMotorcyclesCars(fx) {
14806
14928
  return pl;
14807
14929
  };
14808
14930
  K.lid = function(pts) {
14931
+ c.meta.lidSeam = pts;
14809
14932
  const P = pts.map(function(q) {
14810
14933
  const h = q.top ? S.hit(new V3(q.x, 3, q.z), new V3(0, -1, 0), "R") : S.hit(new V3(S.endX(-1, q.y) - 1, q.y, q.z), new V3(1, 0, 0), "R");
14811
14934
  return h ? h.p.addScaledVector(h.n, 3e-3) : null;
14812
14935
  }).filter(Boolean);
14813
- const t = c.tube(P, 38e-4, MT.dark, { seg: P.length * 8, rs: 4 });
14936
+ const t = c.tube(P, GAP_R, I.gap ?? MT.dark, { seg: P.length * 8, rs: 4 });
14814
14937
  t.castShadow = false;
14938
+ t.userData.gap = true;
14815
14939
  c.deform.push(t);
14816
14940
  return t;
14817
14941
  };
@@ -14837,6 +14961,7 @@ function installMotorcyclesCars(fx) {
14837
14961
  };
14838
14962
  return K;
14839
14963
  }
14964
+ const DIVISION_OVER = 0.012;
14840
14965
  const glassDivisions = /* @__PURE__ */ new WeakMap();
14841
14966
  function car(c, s) {
14842
14967
  const W = s.W, gh = s.gh, bev = 0.05, T = { belt: gh.belt, top: gh.roof + bev, k: gh.k }, m = c.meta;
@@ -14873,7 +14998,10 @@ function installMotorcyclesCars(fx) {
14873
14998
  if (s.dropRear) polys = polys.slice(1);
14874
14999
  const divided = splitSidePolys2(polys, doorGlassSplits2(gh, s.wheels ?? []));
14875
15000
  polys = divided.polys;
14876
- glassDivisions.set(c, divided.used);
15001
+ glassDivisions.set(
15002
+ c,
15003
+ divided.used.map((at) => ({ at, span: divisionSpan2(divided.polys, at) }))
15004
+ );
14877
15005
  const qf = kit.quadDef([gh.fb, gh.belt], [gh.ft, gh.roof], gh.Wg, T, "front", bev), qr = kit.quadDef([gh.rb, gh.belt], [gh.rt, roofR], gh.Wg, T, "rear", bev);
14878
15006
  const gHoles = [];
14879
15007
  if (intr) {
@@ -14894,6 +15022,7 @@ function installMotorcyclesCars(fx) {
14894
15022
  side: THREE.DoubleSide
14895
15023
  }) : null;
14896
15024
  kit.shell(c, { items: ghItems, W: gh.Wg, col: s.col, mat: roofMat, T, holes: gHoles, sub: intr ? 0.12 : 0.2 });
15025
+ const sealEdges = doorEdgesOf2(gh, s.wheels ?? []);
14897
15026
  kit.sideWindows(
14898
15027
  c,
14899
15028
  polys,
@@ -14902,7 +15031,14 @@ function installMotorcyclesCars(fx) {
14902
15031
  function(i, n) {
14903
15032
  return i === 0 && n > 2 ? lbl("quarter_glass") : i === n - 1 ? lbl("window_front") : lbl("window_rear");
14904
15033
  },
14905
- { see: !!intr }
15034
+ {
15035
+ see: !!intr,
15036
+ // a fixed pane sits in a thin rubber flush with the body; the window of a door runs in a channel round its frame
15037
+ seal: function(i) {
15038
+ const xs = polys[i].map((q) => q[0]), mid = (Math.min(...xs) + Math.max(...xs)) / 2;
15039
+ return sealEdges && mid > sealEdges.C && mid < sealEdges.doorF ? DOOR_SEAL_R : FIXED_SEAL_R;
15040
+ }
15041
+ }
14906
15042
  );
14907
15043
  kit.glassQuad(c, qf, lbl("windshield"), { see: !!intr });
14908
15044
  kit.glassQuad(c, qr, lbl("rear_window"), { see: !!intr, mat: intr ? REARTINT : MT.glassDark });
@@ -14954,7 +15090,7 @@ function installMotorcyclesCars(fx) {
14954
15090
  (s.arches || []).forEach(function(a) {
14955
15091
  fa = Math.max(fa, a[0]);
14956
15092
  });
14957
- const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col });
15093
+ const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col, gap: HOOD_GAP });
14958
15094
  if (hood)
14959
15095
  kit.engineBay(c, {
14960
15096
  x0: hx0 + 0.02,
@@ -14988,6 +15124,7 @@ function installMotorcyclesCars(fx) {
14988
15124
  );
14989
15125
  const Wf = mkWarp(wo);
14990
15126
  const S = mkSurf(lowMesh, W);
15127
+ if (c.hood && hoodO) hoodGap(c, S, hx0, hx1, zH, gapMaterial(s.col));
14991
15128
  details(c, s, Wf, S);
14992
15129
  applyWarp(c, Wf);
14993
15130
  return m;
@@ -14999,7 +15136,7 @@ function installMotorcyclesCars(fx) {
14999
15136
  }, rx = function(y) {
15000
15137
  return profX(it, y, false);
15001
15138
  };
15002
- const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S };
15139
+ const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S, gap: gapMaterial(s.col) };
15003
15140
  I.fxB = S.endX(1, by + 0.2);
15004
15141
  I.rxB = S.endX(-1, by + 0.2);
15005
15142
  const K = mkKit(c, S, I);
@@ -15028,26 +15165,22 @@ function installMotorcyclesCars(fx) {
15028
15165
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
15029
15166
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
15030
15167
  [1, -1].forEach(function(sd) {
15031
- const bar = function(px, width) {
15032
- const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
15168
+ const bar = function(px, width, span) {
15169
+ const ry = roofAt(gh, px), yc = span ? (span[0] + span[1]) / 2 : (gh.belt + ry) / 2 + 5e-3, hh = span ? span[1] - span[0] + 2 * DIVISION_OVER : ry - gh.belt - 0.1;
15033
15170
  const m2 = c.roundBox(width, hh, 3e-3, 15e-4, GLOSS, px, yc, sd * (halfAt(gh.Wg, T, yc) + 4e-3), { rot: [-sd * tang, 0, 0] });
15034
15171
  m2.castShadow = false;
15035
15172
  return m2;
15036
15173
  };
15037
15174
  (s.blackPillars || []).forEach((px) => bar(px, 0.118));
15038
- (glassDivisions.get(c) ?? []).forEach((px) => {
15039
- bar(px, 2 * DIVISION_HALF2 - 2e-3).userData.doorChannel = true;
15175
+ (glassDivisions.get(c) ?? []).forEach(({ at, span }) => {
15176
+ bar(at, 2 * DIVISION_HALF2 - 2e-3, span).userData.doorChannel = true;
15040
15177
  });
15041
15178
  const mx = gh.fb - 0.22, my = gh.belt + 0.09, mz0 = halfAt(gh.Wg, T, my), mcol = s.mirrorCol ? CM(s.mirrorCol, { roughness: 0.4, metalness: 0.3 }) : paint;
15042
15179
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
15043
15180
  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 } });
15044
15181
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
15045
15182
  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));
15046
- const edges = doorEdgesOf2(gh, s.wheels ?? []);
15047
- (s.seams || []).forEach(function(x0) {
15048
- const x = seamOnDoorEdge2(x0, edges);
15049
- doorSeam(c, S, sd, x, by + 0.09, gh.belt - 0.03);
15050
- });
15183
+ if (s.fuelDoor && sd === s.fuelDoor[2]) fuelDoorGap(c, S, sd, s.fuelDoor[0], s.fuelDoor[1], I.gap);
15051
15184
  (s.handles || []).forEach(function(x) {
15052
15185
  c.roundBox(
15053
15186
  0.15,
@@ -15062,7 +15195,8 @@ function installMotorcyclesCars(fx) {
15062
15195
  });
15063
15196
  if (s.arches && s.arches.length > 1) {
15064
15197
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
15065
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
15198
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
15199
+ 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 }));
15066
15200
  if (s.clad)
15067
15201
  s.arches.forEach(function(a) {
15068
15202
  const a0 = Math.asin(clamp((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));
@@ -15115,6 +15249,20 @@ function installMotorcyclesCars(fx) {
15115
15249
  });
15116
15250
  underbody(c, s, I);
15117
15251
  if (s.extra) s.extra(c, I);
15252
+ c.vehicle.updateMatrixWorld(true);
15253
+ [1, -1].forEach(function(sd) {
15254
+ const side = bodySide(THREE, c, S, sd);
15255
+ const edges = doorEdgesOf2(gh, s.wheels ?? []);
15256
+ (s.seams || []).forEach(function(x) {
15257
+ const pts = shutLinePoints2(side, seamOnDoorEdge2(x, edges), by + 0.11, gh.belt - 0.03);
15258
+ if (pts.length < 3) return;
15259
+ const seam = markFinishDetail2(c.tube(pts, SHUT_LINE_RADIUS2, I.gap ?? MT.dark, { seg: 72, rs: 5 }));
15260
+ seam.castShadow = false;
15261
+ seam.userData.doorSeam = true;
15262
+ seam.userData.gap = true;
15263
+ c.deform.push(seam);
15264
+ });
15265
+ });
15118
15266
  if (!c.parts.some(function(p) {
15119
15267
  return p.kind === "engine";
15120
15268
  }))
@@ -15188,16 +15336,57 @@ function installMotorcyclesCars(fx) {
15188
15336
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
15189
15337
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
15190
15338
  }
15191
- const SEAM_POINTS = 14;
15192
- function doorSeam(c, S, sd, x, y0, y1) {
15339
+ const GAP_R = 2e-3;
15340
+ const FIXED_SEAL_R = 4e-3;
15341
+ const DOOR_SEAL_R = 6e-3;
15342
+ const GAP_SHADE = 0.45;
15343
+ const gapMaterials = /* @__PURE__ */ new Map();
15344
+ function gapMaterial(col) {
15345
+ const hex = "#" + new THREE.Color(col).multiplyScalar(GAP_SHADE).getHexString();
15346
+ const known = gapMaterials.get(hex);
15347
+ if (known) return known;
15348
+ const made = CM(hex, { roughness: 0.6 }) ?? MT.dark;
15349
+ gapMaterials.set(hex, made);
15350
+ return made;
15351
+ }
15352
+ const HOOD_GAP = 4 * GAP_R;
15353
+ function hoodGap(c, S, x0, x1, zH, mat) {
15354
+ const onTop = (x, z) => {
15355
+ const h = S.hit(new V3(x, 3, z), new V3(0, -1, 0));
15356
+ return h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, 0, z);
15357
+ };
15358
+ const steps = Math.max(4, Math.ceil((x1 - x0) / 0.04));
15359
+ const across = Math.max(4, Math.ceil(2 * zH / 0.04));
15360
+ const line = [];
15361
+ for (let k = 0; k <= steps; k++) line.push(onTop(x0 + (x1 - x0) * k / steps, zH));
15362
+ for (let k = 1; k < across; k++) line.push(onTop(x1, zH - 2 * zH * k / across));
15363
+ for (let k = steps; k >= 0; k--) line.push(onTop(x0 + (x1 - x0) * k / steps, -zH));
15364
+ const t = c.tube(line, GAP_R, mat, { seg: line.length * 2, rs: 4 });
15365
+ t.castShadow = false;
15366
+ t.userData.gap = true;
15367
+ return t;
15368
+ }
15369
+ const FUEL_DOOR_W = 0.13;
15370
+ const FUEL_DOOR_H = 0.11;
15371
+ const FUEL_DOOR_R = 0.02;
15372
+ function fuelDoorGap(c, S, sd, x, y, mat) {
15193
15373
  const pts = [];
15194
- for (let k = 0; k <= SEAM_POINTS; k++) {
15195
- 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");
15196
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
15197
- }
15198
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
15374
+ const hx = FUEL_DOOR_W / 2 - FUEL_DOOR_R, hy = FUEL_DOOR_H / 2 - FUEL_DOOR_R;
15375
+ const corners = [
15376
+ [hx, hy, 0],
15377
+ [-hx, hy, 0.5 * PI],
15378
+ [-hx, -hy, PI],
15379
+ [hx, -hy, 1.5 * PI]
15380
+ ];
15381
+ corners.forEach(function([cx, cy, a0]) {
15382
+ for (let k = 0; k <= 4; k++) {
15383
+ const a = a0 + k / 4 * 0.5 * PI, px = x + cx + FUEL_DOOR_R * Math.cos(a), py = y + cy + FUEL_DOOR_R * Math.sin(a), h = S.hit(new V3(px, py, sd * (S.hw + 1)), new V3(0, 0, -sd), "M");
15384
+ pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(px, py, sd * S.hw));
15385
+ }
15386
+ });
15387
+ const t = c.tube(pts, GAP_R, mat, { closed: true, seg: pts.length * 2, rs: 4 });
15199
15388
  t.castShadow = false;
15200
- t.userData.doorSeam = true;
15389
+ t.userData.gap = true;
15201
15390
  return t;
15202
15391
  }
15203
15392
  function sm(t) {
@@ -15246,36 +15435,23 @@ function installMotorcyclesCars(fx) {
15246
15435
  });
15247
15436
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
15248
15437
  function yAt(u) {
15249
- const x = x0 + (x1 - x0) * u;
15250
- for (let i = 0; i < pts.length - 1; i++) {
15251
- const a = pts[i], b = pts[i + 1];
15252
- if ((x - a[0]) * (x - b[0]) <= 0) {
15253
- const t = (x - a[0]) / (b[0] - a[0] || 1);
15254
- return a[1] + (b[1] - a[1]) * sm(t);
15255
- }
15256
- }
15257
- return pts[pts.length - 1][1];
15438
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
15258
15439
  }
15259
- I.K.skin(Gd, o.mat || c.paint(o.col), {
15440
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
15260
15441
  yb: function(u) {
15261
15442
  return yAt(u) - h;
15262
15443
  },
15263
15444
  yt: yAt,
15264
- off: o.off || 6e-3,
15265
- thick: 9e-3,
15266
- nv: 2,
15445
+ off: o.off || 2e-3,
15446
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
15447
+ crease: 30,
15448
+ nv: 5,
15267
15449
  u0: o.u0 || 0.01,
15268
15450
  u1: o.u1 || 0.99
15269
15451
  });
15270
- const l = [];
15271
- for (let k = 0; k <= 30; k++) {
15272
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
15273
- l.push([u, yAt(u) - h - 1e-3]);
15274
- }
15275
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
15452
+ markRaised(c, markFinishDetail2(fold));
15276
15453
  return Gd;
15277
15454
  }
15278
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
15279
15455
  function dloChrome(c, I, sd, pts, r) {
15280
15456
  const gh = I.gh, T = I.T, P = pts.map(function(q) {
15281
15457
  return [q[0], q[1], sd * (halfAt(gh.Wg, T, q[1]) + 0.012)];
@@ -16333,12 +16509,10 @@ function installMotorcyclesCars(fx) {
16333
16509
  I,
16334
16510
  sd,
16335
16511
  [
16336
- [1, 0.47],
16337
- [0, 0.5],
16338
- [-0.9, 0.6],
16339
- [-1.2, 0.66]
16512
+ [0.86, 0.52],
16513
+ [-0.98, 0.52]
16340
16514
  ],
16341
- { col: "#8b939a", h: 0.035 }
16515
+ { col: "#8b939a", h: 0.03 }
16342
16516
  );
16343
16517
  });
16344
16518
  }
@@ -24166,6 +24340,7 @@ function installSuvPickupVan(fx) {
24166
24340
  tl: P.tl,
24167
24341
  grille: P.grille,
24168
24342
  seams: P.seams,
24343
+ shell: shellM,
24169
24344
  handles: P.handles,
24170
24345
  wheels: [
24171
24346
  [A.xf, P.wr, 0.24, { rim: P.rim }],