@adatechnology/game-vehicles-fleet 11.0.1 → 11.0.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.
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, doorGlassSplits, 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
  }
@@ -5690,8 +5743,9 @@ function installCarsExtra(fx) {
5690
5743
  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
5744
  return h ? h.p.addScaledVector(h.n, 3e-3) : null;
5692
5745
  }).filter(Boolean);
5693
- const t = c.tube(P, 38e-4, MT.dark, { seg: P.length * 8, rs: 4 });
5746
+ const t = c.tube(P, GAP_R, I.gap ?? MT.dark, { seg: P.length * 8, rs: 4 });
5694
5747
  t.castShadow = false;
5748
+ t.userData.gap = true;
5695
5749
  c.deform.push(t);
5696
5750
  return t;
5697
5751
  };
@@ -5717,6 +5771,8 @@ function installCarsExtra(fx) {
5717
5771
  };
5718
5772
  return K;
5719
5773
  }
5774
+ const DIVISION_OVER = 0.012;
5775
+ const COWL_DROP = 0.012;
5720
5776
  const glassDivisions = /* @__PURE__ */ new WeakMap();
5721
5777
  function car(c, s) {
5722
5778
  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 +5810,10 @@ function installCarsExtra(fx) {
5754
5810
  if (gh.polys) polys = gh.polys(polys);
5755
5811
  const divided = splitSidePolys(polys, doorGlassSplits(gh, s.wheels ?? []));
5756
5812
  polys = divided.polys;
5757
- glassDivisions.set(c, divided.used);
5813
+ glassDivisions.set(
5814
+ c,
5815
+ divided.used.map((at) => ({ at, span: divisionSpan(divided.polys, at) }))
5816
+ );
5758
5817
  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
5818
  const gHoles = [];
5760
5819
  if (intr) {
@@ -5775,6 +5834,7 @@ function installCarsExtra(fx) {
5775
5834
  side: THREE.DoubleSide
5776
5835
  }) : null;
5777
5836
  kit.shell(c, { items: ghItems, W: gh.Wg, col: s.col, mat: roofMat, T, holes: gHoles, sub: intr ? 0.12 : 0.2 });
5837
+ const sealEdges = doorEdgesOf(gh, s.wheels ?? []);
5778
5838
  kit.sideWindows(
5779
5839
  c,
5780
5840
  polys,
@@ -5783,7 +5843,14 @@ function installCarsExtra(fx) {
5783
5843
  function(i, n) {
5784
5844
  return i === 0 && n > 2 ? lbl("quarter_glass") : i === n - 1 ? lbl("window_front") : lbl("window_rear");
5785
5845
  },
5786
- { see: !!intr }
5846
+ {
5847
+ see: !!intr,
5848
+ // a fixed pane sits in a thin rubber flush with the body; the window of a door runs in a channel round its frame
5849
+ seal: function(i) {
5850
+ const xs = polys[i].map((q) => q[0]), mid = (Math.min(...xs) + Math.max(...xs)) / 2;
5851
+ return sealEdges && mid > sealEdges.C && mid < sealEdges.doorF ? DOOR_SEAL_R : FIXED_SEAL_R;
5852
+ }
5853
+ }
5787
5854
  );
5788
5855
  kit.glassQuad(c, qf, lbl("windshield"), { see: !!intr });
5789
5856
  kit.glassQuad(c, qr, lbl("rear_window"), { see: !!intr, mat: intr ? MT.tint : MT.glassDark });
@@ -5820,6 +5887,8 @@ function installCarsExtra(fx) {
5820
5887
  rb: gh.rb,
5821
5888
  rt: gh.rt,
5822
5889
  roof: gh.roof + 0.02,
5890
+ roofRear: (gh.roofR || gh.roof) + 0.02,
5891
+ roofCrown: gh.crown || 0,
5823
5892
  belt: gh.belt,
5824
5893
  floor: s.bottomY + 0.02,
5825
5894
  seatH: 0.12,
@@ -5840,7 +5909,7 @@ function installCarsExtra(fx) {
5840
5909
  (s.arches || []).forEach(function(a) {
5841
5910
  fa = Math.max(fa, a[0]);
5842
5911
  });
5843
- const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col });
5912
+ const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col, gap: HOOD_GAP });
5844
5913
  if (hood)
5845
5914
  kit.engineBay(c, {
5846
5915
  x0: hx0 + 0.02,
@@ -5874,6 +5943,7 @@ function installCarsExtra(fx) {
5874
5943
  );
5875
5944
  const Wf = mkWarp(wo);
5876
5945
  const S = mkSurf(lowMesh, W);
5946
+ if (c.hood && hoodO) hoodGap(c, S, hx0, hx1, zH, gapMaterial(s.col));
5877
5947
  details(c, s, Wf, S);
5878
5948
  applyWarp(c, Wf);
5879
5949
  return m;
@@ -5885,7 +5955,7 @@ function installCarsExtra(fx) {
5885
5955
  }, rx = function(y) {
5886
5956
  return profX(it, y, false);
5887
5957
  };
5888
- const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S };
5958
+ const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S, gap: gapMaterial(s.col) };
5889
5959
  I.fxB = S.endX(1, by + 0.2);
5890
5960
  I.rxB = S.endX(-1, by + 0.2);
5891
5961
  const K = mkKit(c, S, I);
@@ -5914,21 +5984,22 @@ function installCarsExtra(fx) {
5914
5984
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
5915
5985
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
5916
5986
  [1, -1].forEach(function(sd) {
5917
- const bar = function(px, width) {
5918
- const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
5919
- c.roundBox(width, hh, 3e-3, 15e-4, GLOSS, px, yc, sd * (halfAt(gh.Wg, T, yc) + 4e-3), { rot: [-sd * tang, 0, 0] }).castShadow = false;
5987
+ const bar = function(px, width, span) {
5988
+ 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;
5989
+ 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] });
5990
+ m2.castShadow = false;
5991
+ return m2;
5920
5992
  };
5921
5993
  (s.blackPillars || []).forEach((px) => bar(px, 0.118));
5922
- (glassDivisions.get(c) ?? []).forEach((px) => bar(px, 2 * DIVISION_HALF - 2e-3));
5994
+ (glassDivisions.get(c) ?? []).forEach(({ at, span }) => {
5995
+ bar(at, 2 * DIVISION_HALF - 2e-3, span).userData.doorChannel = true;
5996
+ });
5923
5997
  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;
5924
5998
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
5925
5999
  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 } });
5926
6000
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
5927
6001
  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));
5928
- (s.seams || []).forEach(function(q) {
5929
- const r = q, x = r.length ? r[0] : q, y0 = r.length ? r[1] : by + 0.09, y1 = r.length ? r[2] : gh.belt - 0.03;
5930
- c.roundBox(8e-3, y1 - y0, 6e-3, 3e-3, MT.dark, x, (y0 + y1) / 2, sd * (hw + 1e-3));
5931
- });
6002
+ if (s.fuelDoor && sd === s.fuelDoor[2]) fuelDoorGap(c, S, sd, s.fuelDoor[0], s.fuelDoor[1], I.gap);
5932
6003
  (s.handles || []).forEach(function(x) {
5933
6004
  c.roundBox(
5934
6005
  0.15,
@@ -5943,7 +6014,8 @@ function installCarsExtra(fx) {
5943
6014
  });
5944
6015
  if (s.arches && s.arches.length > 1) {
5945
6016
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
5946
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
6017
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
6018
+ 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 }));
5947
6019
  if (s.clad)
5948
6020
  s.arches.forEach(function(a) {
5949
6021
  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));
@@ -5955,16 +6027,25 @@ function installCarsExtra(fx) {
5955
6027
  c.roundBox(
5956
6028
  gh.fb - gh.rb - 0.3,
5957
6029
  0.012,
5958
- 8e-3,
6030
+ 0.012,
5959
6031
  4e-3,
5960
6032
  MT.chrome,
5961
6033
  (gh.fb + gh.rb) / 2 - 0.05,
5962
6034
  gh.belt + 0.035,
5963
- sd * (halfAt(gh.Wg, T, gh.belt + 0.035) + 4e-3)
6035
+ sd * (halfAt(gh.Wg, T, gh.belt + 0.035) + 6e-3)
5964
6036
  );
5965
6037
  });
5966
6038
  const cwh = S.hit(new V3(gh.fb + 0.03, 3, 0), new V3(0, -1, 0)), cwy = cwh ? cwh.p.y : gh.belt;
5967
- c.roundBox(0.15, 0.02, gh.Wg - 0.06, 8e-3, PLASTIC, gh.fb + 0.02, cwy + 4e-3, 0).castShadow = false;
6039
+ let cwz = gh.Wg / 2 - 0.03;
6040
+ for (let z = 0.3; z < cwz; z += 0.01) {
6041
+ const h = S.hit(new V3(gh.fb + 0.03, 3, z), new V3(0, -1, 0));
6042
+ if (!h || h.p.y < cwy - COWL_DROP) {
6043
+ cwz = z;
6044
+ break;
6045
+ }
6046
+ }
6047
+ cwz = Math.min(cwz, halfAt(gh.Wg, T, gh.belt + 0.05) - 0.072);
6048
+ c.roundBox(0.15, 0.02, 2 * cwz, 8e-3, PLASTIC, gh.fb + 0.02, cwy + 4e-3, 0).castShadow = false;
5968
6049
  const wd = new V3(gh.ft - gh.fb, gh.roof - gh.belt, 0).normalize(), wn = new V3(wd.y, -wd.x, 0);
5969
6050
  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);
5970
6051
  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;
@@ -6009,6 +6090,21 @@ function installCarsExtra(fx) {
6009
6090
  });
6010
6091
  underbody(c, s, I);
6011
6092
  if (s.extra) s.extra(c, I);
6093
+ c.vehicle.updateMatrixWorld(true);
6094
+ [1, -1].forEach(function(sd) {
6095
+ const side = bodySide(THREE, c, S, sd);
6096
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
6097
+ (s.seams || []).forEach(function(q) {
6098
+ 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;
6099
+ const pts = shutLinePoints(side, x, y0, y1);
6100
+ if (pts.length < 3) return;
6101
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, I.gap ?? MT.dark, { seg: 72, rs: 5 }));
6102
+ seam.castShadow = false;
6103
+ seam.userData.doorSeam = true;
6104
+ seam.userData.gap = true;
6105
+ c.deform.push(seam);
6106
+ });
6107
+ });
6012
6108
  if (!c.parts.some(function(p) {
6013
6109
  return p.kind === "engine";
6014
6110
  }))
@@ -6082,6 +6178,59 @@ function installCarsExtra(fx) {
6082
6178
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
6083
6179
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
6084
6180
  }
6181
+ const GAP_R = 2e-3;
6182
+ const FIXED_SEAL_R = 4e-3;
6183
+ const DOOR_SEAL_R = 6e-3;
6184
+ const GAP_SHADE = 0.45;
6185
+ const gapMaterials = /* @__PURE__ */ new Map();
6186
+ function gapMaterial(col) {
6187
+ const hex = "#" + new THREE.Color(col).multiplyScalar(GAP_SHADE).getHexString();
6188
+ const known = gapMaterials.get(hex);
6189
+ if (known) return known;
6190
+ const made = CM(hex, { roughness: 0.6 }) ?? MT.dark;
6191
+ gapMaterials.set(hex, made);
6192
+ return made;
6193
+ }
6194
+ const HOOD_GAP = 4 * GAP_R;
6195
+ function hoodGap(c, S, x0, x1, zH, mat) {
6196
+ const onTop = (x, z) => {
6197
+ const h = S.hit(new V3(x, 3, z), new V3(0, -1, 0));
6198
+ return h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, 0, z);
6199
+ };
6200
+ const steps = Math.max(4, Math.ceil((x1 - x0) / 0.04));
6201
+ const across = Math.max(4, Math.ceil(2 * zH / 0.04));
6202
+ const line = [];
6203
+ for (let k = 0; k <= steps; k++) line.push(onTop(x0 + (x1 - x0) * k / steps, zH));
6204
+ for (let k = 1; k < across; k++) line.push(onTop(x1, zH - 2 * zH * k / across));
6205
+ for (let k = steps; k >= 0; k--) line.push(onTop(x0 + (x1 - x0) * k / steps, -zH));
6206
+ const t = c.tube(line, GAP_R, mat, { seg: line.length * 2, rs: 4 });
6207
+ t.castShadow = false;
6208
+ t.userData.gap = true;
6209
+ return t;
6210
+ }
6211
+ const FUEL_DOOR_W = 0.13;
6212
+ const FUEL_DOOR_H = 0.11;
6213
+ const FUEL_DOOR_R = 0.02;
6214
+ function fuelDoorGap(c, S, sd, x, y, mat) {
6215
+ const pts = [];
6216
+ const hx = FUEL_DOOR_W / 2 - FUEL_DOOR_R, hy = FUEL_DOOR_H / 2 - FUEL_DOOR_R;
6217
+ const corners = [
6218
+ [hx, hy, 0],
6219
+ [-hx, hy, 0.5 * PI],
6220
+ [-hx, -hy, PI],
6221
+ [hx, -hy, 1.5 * PI]
6222
+ ];
6223
+ corners.forEach(function([cx, cy, a0]) {
6224
+ for (let k = 0; k <= 4; k++) {
6225
+ 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");
6226
+ pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(px, py, sd * S.hw));
6227
+ }
6228
+ });
6229
+ const t = c.tube(pts, GAP_R, mat, { closed: true, seg: pts.length * 2, rs: 4 });
6230
+ t.castShadow = false;
6231
+ t.userData.gap = true;
6232
+ return t;
6233
+ }
6085
6234
  function sm(t) {
6086
6235
  t = clamp(t, 0, 1);
6087
6236
  return t * t * (3 - 2 * t);
@@ -6128,36 +6277,23 @@ function installCarsExtra(fx) {
6128
6277
  });
6129
6278
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
6130
6279
  function yAt(u) {
6131
- const x = x0 + (x1 - x0) * u;
6132
- for (let i = 0; i < pts.length - 1; i++) {
6133
- const a = pts[i], b = pts[i + 1];
6134
- if ((x - a[0]) * (x - b[0]) <= 0) {
6135
- const t = (x - a[0]) / (b[0] - a[0] || 1);
6136
- return a[1] + (b[1] - a[1]) * sm(t);
6137
- }
6138
- }
6139
- return pts[pts.length - 1][1];
6280
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
6140
6281
  }
6141
- I.K.skin(Gd, o.mat || c.paint(o.col), {
6282
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
6142
6283
  yb: function(u) {
6143
6284
  return yAt(u) - h;
6144
6285
  },
6145
6286
  yt: yAt,
6146
- off: o.off || 6e-3,
6147
- thick: 9e-3,
6148
- nv: 2,
6287
+ off: o.off || 2e-3,
6288
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
6289
+ crease: 30,
6290
+ nv: 5,
6149
6291
  u0: o.u0 || 0.01,
6150
6292
  u1: o.u1 || 0.99
6151
6293
  });
6152
- const l = [];
6153
- for (let k = 0; k <= 30; k++) {
6154
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
6155
- l.push([u, yAt(u) - h - 1e-3]);
6156
- }
6157
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
6294
+ markRaised(c, markFinishDetail(fold));
6158
6295
  return Gd;
6159
6296
  }
6160
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
6161
6297
  const CHROMEH = CM("#c9cdd0", { metalness: 0.85, roughness: 0.25 });
6162
6298
  const CHROMEB = CM("#d4d8db", { metalness: 0.5, roughness: 0.24 });
6163
6299
  const VINYL = "#2e2622";
@@ -6492,6 +6628,8 @@ function installCarsExtra(fx) {
6492
6628
  dropRear: true,
6493
6629
  seams: [0.64, -0.5, [-1.27, 0.67, 0.93]],
6494
6630
  handles: [0.12, -0.86],
6631
+ /* fuel door on the right rear fender, between the rear door and the taillight, over the wheel */
6632
+ fuelDoor: [-1.47, 0.71, 1],
6495
6633
  blackPillars: [-0.5],
6496
6634
  frontBumper: { y1: 0.6 },
6497
6635
  rearBumper: { y1: 0.58 },
@@ -6669,7 +6807,8 @@ function installCarsExtra(fx) {
6669
6807
  [1.75, 0.8],
6670
6808
  [0.6, 0.82],
6671
6809
  [-0.6, 0.835],
6672
- [-1.82, 0.85]
6810
+ // it ends where the taillight wraps onto the side, never running into the lamp
6811
+ [-1.6, 0.845]
6673
6812
  ],
6674
6813
  { col: hex, h: 0.024 }
6675
6814
  );
@@ -14045,7 +14184,8 @@ function installMilitary(fx) {
14045
14184
  }
14046
14185
 
14047
14186
  // src/vehicles/motorcycles-cars.ts
14048
- import { DIVISION_HALF as DIVISION_HALF2, doorGlassSplits as doorGlassSplits2, splitSidePolys as splitSidePolys2 } from "@adatechnology/game-vehicles";
14187
+ import { SHUT_LINE_RADIUS as SHUT_LINE_RADIUS2, markFinishDetail as markFinishDetail2, shutLinePoints as shutLinePoints2 } from "@adatechnology/game-vehicles";
14188
+ 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";
14049
14189
  function installMotorcyclesCars(fx) {
14050
14190
  const kit = fx.kit;
14051
14191
  const THREE = kit.THREE;
@@ -14497,7 +14637,8 @@ function installMotorcyclesCars(fx) {
14497
14637
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
14498
14638
  for (let j = 0; j <= nv; j++) {
14499
14639
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
14500
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
14640
+ 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;
14641
+ 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] });
14501
14642
  }
14502
14643
  Q.push(row);
14503
14644
  }
@@ -14790,8 +14931,9 @@ function installMotorcyclesCars(fx) {
14790
14931
  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");
14791
14932
  return h ? h.p.addScaledVector(h.n, 3e-3) : null;
14792
14933
  }).filter(Boolean);
14793
- const t = c.tube(P, 38e-4, MT.dark, { seg: P.length * 8, rs: 4 });
14934
+ const t = c.tube(P, GAP_R, I.gap ?? MT.dark, { seg: P.length * 8, rs: 4 });
14794
14935
  t.castShadow = false;
14936
+ t.userData.gap = true;
14795
14937
  c.deform.push(t);
14796
14938
  return t;
14797
14939
  };
@@ -14817,6 +14959,7 @@ function installMotorcyclesCars(fx) {
14817
14959
  };
14818
14960
  return K;
14819
14961
  }
14962
+ const DIVISION_OVER = 0.012;
14820
14963
  const glassDivisions = /* @__PURE__ */ new WeakMap();
14821
14964
  function car(c, s) {
14822
14965
  const W = s.W, gh = s.gh, bev = 0.05, T = { belt: gh.belt, top: gh.roof + bev, k: gh.k }, m = c.meta;
@@ -14853,7 +14996,10 @@ function installMotorcyclesCars(fx) {
14853
14996
  if (s.dropRear) polys = polys.slice(1);
14854
14997
  const divided = splitSidePolys2(polys, doorGlassSplits2(gh, s.wheels ?? []));
14855
14998
  polys = divided.polys;
14856
- glassDivisions.set(c, divided.used);
14999
+ glassDivisions.set(
15000
+ c,
15001
+ divided.used.map((at) => ({ at, span: divisionSpan2(divided.polys, at) }))
15002
+ );
14857
15003
  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);
14858
15004
  const gHoles = [];
14859
15005
  if (intr) {
@@ -14874,6 +15020,7 @@ function installMotorcyclesCars(fx) {
14874
15020
  side: THREE.DoubleSide
14875
15021
  }) : null;
14876
15022
  kit.shell(c, { items: ghItems, W: gh.Wg, col: s.col, mat: roofMat, T, holes: gHoles, sub: intr ? 0.12 : 0.2 });
15023
+ const sealEdges = doorEdgesOf2(gh, s.wheels ?? []);
14877
15024
  kit.sideWindows(
14878
15025
  c,
14879
15026
  polys,
@@ -14882,7 +15029,14 @@ function installMotorcyclesCars(fx) {
14882
15029
  function(i, n) {
14883
15030
  return i === 0 && n > 2 ? lbl("quarter_glass") : i === n - 1 ? lbl("window_front") : lbl("window_rear");
14884
15031
  },
14885
- { see: !!intr }
15032
+ {
15033
+ see: !!intr,
15034
+ // a fixed pane sits in a thin rubber flush with the body; the window of a door runs in a channel round its frame
15035
+ seal: function(i) {
15036
+ const xs = polys[i].map((q) => q[0]), mid = (Math.min(...xs) + Math.max(...xs)) / 2;
15037
+ return sealEdges && mid > sealEdges.C && mid < sealEdges.doorF ? DOOR_SEAL_R : FIXED_SEAL_R;
15038
+ }
15039
+ }
14886
15040
  );
14887
15041
  kit.glassQuad(c, qf, lbl("windshield"), { see: !!intr });
14888
15042
  kit.glassQuad(c, qr, lbl("rear_window"), { see: !!intr, mat: intr ? REARTINT : MT.glassDark });
@@ -14914,6 +15068,8 @@ function installMotorcyclesCars(fx) {
14914
15068
  rb: gh.rb,
14915
15069
  rt: gh.rt,
14916
15070
  roof: gh.roof + 0.02,
15071
+ roofRear: (gh.roofR || gh.roof) + 0.02,
15072
+ roofCrown: gh.crown || 0,
14917
15073
  belt: gh.belt,
14918
15074
  floor: s.bottomY + 0.02,
14919
15075
  seatH: 0.12,
@@ -14932,7 +15088,7 @@ function installMotorcyclesCars(fx) {
14932
15088
  (s.arches || []).forEach(function(a) {
14933
15089
  fa = Math.max(fa, a[0]);
14934
15090
  });
14935
- const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col });
15091
+ const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col, gap: HOOD_GAP });
14936
15092
  if (hood)
14937
15093
  kit.engineBay(c, {
14938
15094
  x0: hx0 + 0.02,
@@ -14966,6 +15122,7 @@ function installMotorcyclesCars(fx) {
14966
15122
  );
14967
15123
  const Wf = mkWarp(wo);
14968
15124
  const S = mkSurf(lowMesh, W);
15125
+ if (c.hood && hoodO) hoodGap(c, S, hx0, hx1, zH, gapMaterial(s.col));
14969
15126
  details(c, s, Wf, S);
14970
15127
  applyWarp(c, Wf);
14971
15128
  return m;
@@ -14977,7 +15134,7 @@ function installMotorcyclesCars(fx) {
14977
15134
  }, rx = function(y) {
14978
15135
  return profX(it, y, false);
14979
15136
  };
14980
- const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S };
15137
+ const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S, gap: gapMaterial(s.col) };
14981
15138
  I.fxB = S.endX(1, by + 0.2);
14982
15139
  I.rxB = S.endX(-1, by + 0.2);
14983
15140
  const K = mkKit(c, S, I);
@@ -15006,20 +15163,22 @@ function installMotorcyclesCars(fx) {
15006
15163
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
15007
15164
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
15008
15165
  [1, -1].forEach(function(sd) {
15009
- const bar = function(px, width) {
15010
- const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
15011
- c.roundBox(width, hh, 3e-3, 15e-4, GLOSS, px, yc, sd * (halfAt(gh.Wg, T, yc) + 4e-3), { rot: [-sd * tang, 0, 0] }).castShadow = false;
15166
+ const bar = function(px, width, span) {
15167
+ 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;
15168
+ 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] });
15169
+ m2.castShadow = false;
15170
+ return m2;
15012
15171
  };
15013
15172
  (s.blackPillars || []).forEach((px) => bar(px, 0.118));
15014
- (glassDivisions.get(c) ?? []).forEach((px) => bar(px, 2 * DIVISION_HALF2 - 2e-3));
15173
+ (glassDivisions.get(c) ?? []).forEach(({ at, span }) => {
15174
+ bar(at, 2 * DIVISION_HALF2 - 2e-3, span).userData.doorChannel = true;
15175
+ });
15015
15176
  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;
15016
15177
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
15017
15178
  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 } });
15018
15179
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
15019
15180
  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));
15020
- (s.seams || []).forEach(function(x) {
15021
- c.roundBox(8e-3, gh.belt - by - 0.12, 6e-3, 3e-3, MT.dark, x, (gh.belt + by) / 2 + 0.03, sd * (hw + 1e-3));
15022
- });
15181
+ if (s.fuelDoor && sd === s.fuelDoor[2]) fuelDoorGap(c, S, sd, s.fuelDoor[0], s.fuelDoor[1], I.gap);
15023
15182
  (s.handles || []).forEach(function(x) {
15024
15183
  c.roundBox(
15025
15184
  0.15,
@@ -15034,7 +15193,8 @@ function installMotorcyclesCars(fx) {
15034
15193
  });
15035
15194
  if (s.arches && s.arches.length > 1) {
15036
15195
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
15037
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
15196
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
15197
+ 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 }));
15038
15198
  if (s.clad)
15039
15199
  s.arches.forEach(function(a) {
15040
15200
  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));
@@ -15087,6 +15247,20 @@ function installMotorcyclesCars(fx) {
15087
15247
  });
15088
15248
  underbody(c, s, I);
15089
15249
  if (s.extra) s.extra(c, I);
15250
+ c.vehicle.updateMatrixWorld(true);
15251
+ [1, -1].forEach(function(sd) {
15252
+ const side = bodySide(THREE, c, S, sd);
15253
+ const edges = doorEdgesOf2(gh, s.wheels ?? []);
15254
+ (s.seams || []).forEach(function(x) {
15255
+ const pts = shutLinePoints2(side, seamOnDoorEdge2(x, edges), by + 0.11, gh.belt - 0.03);
15256
+ if (pts.length < 3) return;
15257
+ const seam = markFinishDetail2(c.tube(pts, SHUT_LINE_RADIUS2, I.gap ?? MT.dark, { seg: 72, rs: 5 }));
15258
+ seam.castShadow = false;
15259
+ seam.userData.doorSeam = true;
15260
+ seam.userData.gap = true;
15261
+ c.deform.push(seam);
15262
+ });
15263
+ });
15090
15264
  if (!c.parts.some(function(p) {
15091
15265
  return p.kind === "engine";
15092
15266
  }))
@@ -15160,6 +15334,59 @@ function installMotorcyclesCars(fx) {
15160
15334
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
15161
15335
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
15162
15336
  }
15337
+ const GAP_R = 2e-3;
15338
+ const FIXED_SEAL_R = 4e-3;
15339
+ const DOOR_SEAL_R = 6e-3;
15340
+ const GAP_SHADE = 0.45;
15341
+ const gapMaterials = /* @__PURE__ */ new Map();
15342
+ function gapMaterial(col) {
15343
+ const hex = "#" + new THREE.Color(col).multiplyScalar(GAP_SHADE).getHexString();
15344
+ const known = gapMaterials.get(hex);
15345
+ if (known) return known;
15346
+ const made = CM(hex, { roughness: 0.6 }) ?? MT.dark;
15347
+ gapMaterials.set(hex, made);
15348
+ return made;
15349
+ }
15350
+ const HOOD_GAP = 4 * GAP_R;
15351
+ function hoodGap(c, S, x0, x1, zH, mat) {
15352
+ const onTop = (x, z) => {
15353
+ const h = S.hit(new V3(x, 3, z), new V3(0, -1, 0));
15354
+ return h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, 0, z);
15355
+ };
15356
+ const steps = Math.max(4, Math.ceil((x1 - x0) / 0.04));
15357
+ const across = Math.max(4, Math.ceil(2 * zH / 0.04));
15358
+ const line = [];
15359
+ for (let k = 0; k <= steps; k++) line.push(onTop(x0 + (x1 - x0) * k / steps, zH));
15360
+ for (let k = 1; k < across; k++) line.push(onTop(x1, zH - 2 * zH * k / across));
15361
+ for (let k = steps; k >= 0; k--) line.push(onTop(x0 + (x1 - x0) * k / steps, -zH));
15362
+ const t = c.tube(line, GAP_R, mat, { seg: line.length * 2, rs: 4 });
15363
+ t.castShadow = false;
15364
+ t.userData.gap = true;
15365
+ return t;
15366
+ }
15367
+ const FUEL_DOOR_W = 0.13;
15368
+ const FUEL_DOOR_H = 0.11;
15369
+ const FUEL_DOOR_R = 0.02;
15370
+ function fuelDoorGap(c, S, sd, x, y, mat) {
15371
+ const pts = [];
15372
+ const hx = FUEL_DOOR_W / 2 - FUEL_DOOR_R, hy = FUEL_DOOR_H / 2 - FUEL_DOOR_R;
15373
+ const corners = [
15374
+ [hx, hy, 0],
15375
+ [-hx, hy, 0.5 * PI],
15376
+ [-hx, -hy, PI],
15377
+ [hx, -hy, 1.5 * PI]
15378
+ ];
15379
+ corners.forEach(function([cx, cy, a0]) {
15380
+ for (let k = 0; k <= 4; k++) {
15381
+ 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");
15382
+ pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(px, py, sd * S.hw));
15383
+ }
15384
+ });
15385
+ const t = c.tube(pts, GAP_R, mat, { closed: true, seg: pts.length * 2, rs: 4 });
15386
+ t.castShadow = false;
15387
+ t.userData.gap = true;
15388
+ return t;
15389
+ }
15163
15390
  function sm(t) {
15164
15391
  t = clamp(t, 0, 1);
15165
15392
  return t * t * (3 - 2 * t);
@@ -15206,36 +15433,23 @@ function installMotorcyclesCars(fx) {
15206
15433
  });
15207
15434
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
15208
15435
  function yAt(u) {
15209
- const x = x0 + (x1 - x0) * u;
15210
- for (let i = 0; i < pts.length - 1; i++) {
15211
- const a = pts[i], b = pts[i + 1];
15212
- if ((x - a[0]) * (x - b[0]) <= 0) {
15213
- const t = (x - a[0]) / (b[0] - a[0] || 1);
15214
- return a[1] + (b[1] - a[1]) * sm(t);
15215
- }
15216
- }
15217
- return pts[pts.length - 1][1];
15436
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
15218
15437
  }
15219
- I.K.skin(Gd, o.mat || c.paint(o.col), {
15438
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
15220
15439
  yb: function(u) {
15221
15440
  return yAt(u) - h;
15222
15441
  },
15223
15442
  yt: yAt,
15224
- off: o.off || 6e-3,
15225
- thick: 9e-3,
15226
- nv: 2,
15443
+ off: o.off || 2e-3,
15444
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
15445
+ crease: 30,
15446
+ nv: 5,
15227
15447
  u0: o.u0 || 0.01,
15228
15448
  u1: o.u1 || 0.99
15229
15449
  });
15230
- const l = [];
15231
- for (let k = 0; k <= 30; k++) {
15232
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
15233
- l.push([u, yAt(u) - h - 1e-3]);
15234
- }
15235
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
15450
+ markRaised(c, markFinishDetail2(fold));
15236
15451
  return Gd;
15237
15452
  }
15238
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
15239
15453
  function dloChrome(c, I, sd, pts, r) {
15240
15454
  const gh = I.gh, T = I.T, P = pts.map(function(q) {
15241
15455
  return [q[0], q[1], sd * (halfAt(gh.Wg, T, q[1]) + 0.012)];
@@ -16293,12 +16507,10 @@ function installMotorcyclesCars(fx) {
16293
16507
  I,
16294
16508
  sd,
16295
16509
  [
16296
- [1, 0.47],
16297
- [0, 0.5],
16298
- [-0.9, 0.6],
16299
- [-1.2, 0.66]
16510
+ [0.86, 0.52],
16511
+ [-0.98, 0.52]
16300
16512
  ],
16301
- { col: "#8b939a", h: 0.035 }
16513
+ { col: "#8b939a", h: 0.03 }
16302
16514
  );
16303
16515
  });
16304
16516
  }
@@ -24126,6 +24338,7 @@ function installSuvPickupVan(fx) {
24126
24338
  tl: P.tl,
24127
24339
  grille: P.grille,
24128
24340
  seams: P.seams,
24341
+ shell: shellM,
24129
24342
  handles: P.handles,
24130
24343
  wheels: [
24131
24344
  [A.xf, P.wr, 0.24, { rim: P.rim }],