@adatechnology/game-vehicles-fleet 11.0.2 → 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.
@@ -5095,6 +5095,26 @@ var GameVehiclesFleet = (() => {
5095
5095
  }
5096
5096
 
5097
5097
  // ../game-vehicles/dist/index.js
5098
+ var SHUT_LINE_RADIUS = 2e-3;
5099
+ var SHUT_LINE_LIFT = 8e-4;
5100
+ var SHUT_LINE_STEPS = 36;
5101
+ var SHUT_LINE_STRAY = 0.04;
5102
+ function shutLinePoints(hit, x, y0, y1) {
5103
+ const out = [];
5104
+ for (let k = 0; k <= SHUT_LINE_STEPS; k++) {
5105
+ const h = hit(x, y0 + (y1 - y0) * k / SHUT_LINE_STEPS);
5106
+ 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]);
5107
+ }
5108
+ if (out.length < 3) return out;
5109
+ const depths = out.map((q) => q[2]).sort((a, b) => a - b);
5110
+ const median = depths[Math.floor(depths.length / 2)];
5111
+ return out.filter((q) => Math.abs(q[2] - median) < SHUT_LINE_STRAY);
5112
+ }
5113
+ var FINISH_DETAIL = "finishDetail";
5114
+ function markFinishDetail(object) {
5115
+ object.userData[FINISH_DETAIL] = true;
5116
+ return object;
5117
+ }
5098
5118
  var DIVISION_HALF = 0.02;
5099
5119
  var GLASS_IN_FROM_EDGE = 0.03;
5100
5120
  var CUT_EPS = 1e-6;
@@ -5200,6 +5220,28 @@ var GameVehiclesFleet = (() => {
5200
5220
  }
5201
5221
  return { polys: out, used };
5202
5222
  }
5223
+ function crossingAt(polys, x) {
5224
+ let lo = Infinity;
5225
+ let hi = -Infinity;
5226
+ for (const poly of polys) {
5227
+ for (let i = 0; i < poly.length; i++) {
5228
+ const a = poly[i];
5229
+ const b = poly[(i + 1) % poly.length];
5230
+ if ((a[0] - x) * (b[0] - x) > 0 || a[0] === b[0]) continue;
5231
+ const y = a[1] + (x - a[0]) / (b[0] - a[0]) * (b[1] - a[1]);
5232
+ lo = Math.min(lo, y);
5233
+ hi = Math.max(hi, y);
5234
+ }
5235
+ }
5236
+ return hi >= lo ? [lo, hi] : null;
5237
+ }
5238
+ function divisionSpan(polys, at) {
5239
+ const rear = crossingAt(polys, at - DIVISION_HALF);
5240
+ const front = crossingAt(polys, at + DIVISION_HALF);
5241
+ if (!rear) return front;
5242
+ if (!front) return rear;
5243
+ return [Math.min(rear[0], front[0]), Math.max(rear[1], front[1])];
5244
+ }
5203
5245
  var SmokeCause = { STEAM: "steam", OIL: "oil", FIRE: "fire" };
5204
5246
  var SMOKE_LOOKS = {
5205
5247
  [SmokeCause.STEAM]: { color: 14870248, alpha: 0.18 },
@@ -5344,6 +5386,57 @@ var GameVehiclesFleet = (() => {
5344
5386
  return pane;
5345
5387
  }
5346
5388
 
5389
+ // src/vehicles/side-design.ts
5390
+ var CREASE_FOLD_LIFT = 7e-3;
5391
+ var CREASE_FOLD_AT = 0.4;
5392
+ function creaseHeightAt(pts, x) {
5393
+ const n = pts.length;
5394
+ const slope = (i) => (pts[i + 1][1] - pts[i][1]) / (pts[i + 1][0] - pts[i][0] || 1);
5395
+ const tangent = (i) => {
5396
+ if (i === 0) return slope(0);
5397
+ if (i === n - 1) return slope(n - 2);
5398
+ const a = slope(i - 1), b = slope(i);
5399
+ return a * b <= 0 ? 0 : 2 * a * b / (a + b);
5400
+ };
5401
+ for (let i = 0; i < n - 1; i++) {
5402
+ const a = pts[i], b = pts[i + 1];
5403
+ if ((x - a[0]) * (x - b[0]) > 0) continue;
5404
+ const w = b[0] - a[0] || 1, t = (x - a[0]) / w, t2 = t * t, t3 = t2 * t;
5405
+ 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);
5406
+ }
5407
+ return pts[n - 1][1];
5408
+ }
5409
+ var raised = /* @__PURE__ */ new WeakMap();
5410
+ function raisedOnSide(c) {
5411
+ let list = raised.get(c);
5412
+ if (!list) raised.set(c, list = []);
5413
+ return list;
5414
+ }
5415
+ function markRaised(c, mesh) {
5416
+ raisedOnSide(c).push(mesh);
5417
+ }
5418
+ function bodySide(THREE, c, S, sd) {
5419
+ const ray = new THREE.Raycaster();
5420
+ const world = c.vehicle.matrixWorld;
5421
+ const toVehicle = world.clone().invert();
5422
+ return function(x, y) {
5423
+ const origin = new THREE.Vector3(x, y, sd * (S.hw + 1));
5424
+ const best = S.hit(origin, new THREE.Vector3(0, 0, -sd), "M");
5425
+ ray.set(origin.clone().applyMatrix4(world), new THREE.Vector3(0, 0, -sd).transformDirection(world));
5426
+ raisedOnSide(c).forEach(function(m) {
5427
+ const h = ray.intersectObject(m, false)[0];
5428
+ if (!h || !h.face) return;
5429
+ const p = h.point.clone().applyMatrix4(toVehicle);
5430
+ if (!best || Math.abs(p.z) <= Math.abs(best.p.z)) return;
5431
+ const n = h.face.normal.clone().transformDirection(m.matrixWorld).transformDirection(toVehicle);
5432
+ if (n.z * sd < 0) n.negate();
5433
+ best.p = p;
5434
+ best.n = n;
5435
+ });
5436
+ return best;
5437
+ };
5438
+ }
5439
+
5347
5440
  // src/vehicles/cars-extra.ts
5348
5441
  function installCarsExtra(fx) {
5349
5442
  const kit = fx.kit;
@@ -5683,7 +5776,8 @@ var GameVehiclesFleet = (() => {
5683
5776
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
5684
5777
  for (let j = 0; j <= nv; j++) {
5685
5778
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
5686
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
5779
+ 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;
5780
+ 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] });
5687
5781
  }
5688
5782
  Q.push(row);
5689
5783
  }
@@ -5989,8 +6083,9 @@ var GameVehiclesFleet = (() => {
5989
6083
  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");
5990
6084
  return h ? h.p.addScaledVector(h.n, 3e-3) : null;
5991
6085
  }).filter(Boolean);
5992
- const t = c.tube(P, 38e-4, MT.dark, { seg: P.length * 8, rs: 4 });
6086
+ const t = c.tube(P, GAP_R, I.gap ?? MT.dark, { seg: P.length * 8, rs: 4 });
5993
6087
  t.castShadow = false;
6088
+ t.userData.gap = true;
5994
6089
  c.deform.push(t);
5995
6090
  return t;
5996
6091
  };
@@ -6016,6 +6111,8 @@ var GameVehiclesFleet = (() => {
6016
6111
  };
6017
6112
  return K;
6018
6113
  }
6114
+ const DIVISION_OVER = 0.012;
6115
+ const COWL_DROP = 0.012;
6019
6116
  const glassDivisions = /* @__PURE__ */ new WeakMap();
6020
6117
  function car(c, s) {
6021
6118
  const W = s.W, gh = s.gh, bev = 0.05, T = { belt: gh.belt, top: gh.roof + bev, k: gh.k }, m = c.meta;
@@ -6053,7 +6150,10 @@ var GameVehiclesFleet = (() => {
6053
6150
  if (gh.polys) polys = gh.polys(polys);
6054
6151
  const divided = splitSidePolys(polys, doorGlassSplits(gh, s.wheels ?? []));
6055
6152
  polys = divided.polys;
6056
- glassDivisions.set(c, divided.used);
6153
+ glassDivisions.set(
6154
+ c,
6155
+ divided.used.map((at) => ({ at, span: divisionSpan(divided.polys, at) }))
6156
+ );
6057
6157
  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 });
6058
6158
  const gHoles = [];
6059
6159
  if (intr) {
@@ -6074,6 +6174,7 @@ var GameVehiclesFleet = (() => {
6074
6174
  side: THREE.DoubleSide
6075
6175
  }) : null;
6076
6176
  kit.shell(c, { items: ghItems, W: gh.Wg, col: s.col, mat: roofMat, T, holes: gHoles, sub: intr ? 0.12 : 0.2 });
6177
+ const sealEdges = doorEdgesOf(gh, s.wheels ?? []);
6077
6178
  kit.sideWindows(
6078
6179
  c,
6079
6180
  polys,
@@ -6082,7 +6183,14 @@ var GameVehiclesFleet = (() => {
6082
6183
  function(i, n) {
6083
6184
  return i === 0 && n > 2 ? lbl("quarter_glass") : i === n - 1 ? lbl("window_front") : lbl("window_rear");
6084
6185
  },
6085
- { see: !!intr }
6186
+ {
6187
+ see: !!intr,
6188
+ // a fixed pane sits in a thin rubber flush with the body; the window of a door runs in a channel round its frame
6189
+ seal: function(i) {
6190
+ const xs = polys[i].map((q) => q[0]), mid = (Math.min(...xs) + Math.max(...xs)) / 2;
6191
+ return sealEdges && mid > sealEdges.C && mid < sealEdges.doorF ? DOOR_SEAL_R : FIXED_SEAL_R;
6192
+ }
6193
+ }
6086
6194
  );
6087
6195
  kit.glassQuad(c, qf, lbl("windshield"), { see: !!intr });
6088
6196
  kit.glassQuad(c, qr, lbl("rear_window"), { see: !!intr, mat: intr ? MT.tint : MT.glassDark });
@@ -6141,7 +6249,7 @@ var GameVehiclesFleet = (() => {
6141
6249
  (s.arches || []).forEach(function(a) {
6142
6250
  fa = Math.max(fa, a[0]);
6143
6251
  });
6144
- const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col });
6252
+ const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col, gap: HOOD_GAP });
6145
6253
  if (hood)
6146
6254
  kit.engineBay(c, {
6147
6255
  x0: hx0 + 0.02,
@@ -6175,6 +6283,7 @@ var GameVehiclesFleet = (() => {
6175
6283
  );
6176
6284
  const Wf = mkWarp(wo);
6177
6285
  const S = mkSurf(lowMesh, W);
6286
+ if (c.hood && hoodO) hoodGap(c, S, hx0, hx1, zH, gapMaterial(s.col));
6178
6287
  details(c, s, Wf, S);
6179
6288
  applyWarp(c, Wf);
6180
6289
  return m;
@@ -6186,7 +6295,7 @@ var GameVehiclesFleet = (() => {
6186
6295
  }, rx = function(y) {
6187
6296
  return profX(it, y, false);
6188
6297
  };
6189
- const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S };
6298
+ const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S, gap: gapMaterial(s.col) };
6190
6299
  I.fxB = S.endX(1, by + 0.2);
6191
6300
  I.rxB = S.endX(-1, by + 0.2);
6192
6301
  const K = mkKit(c, S, I);
@@ -6215,26 +6324,22 @@ var GameVehiclesFleet = (() => {
6215
6324
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
6216
6325
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
6217
6326
  [1, -1].forEach(function(sd) {
6218
- const bar = function(px, width) {
6219
- const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
6327
+ const bar = function(px, width, span) {
6328
+ 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;
6220
6329
  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] });
6221
6330
  m2.castShadow = false;
6222
6331
  return m2;
6223
6332
  };
6224
6333
  (s.blackPillars || []).forEach((px) => bar(px, 0.118));
6225
- (glassDivisions.get(c) ?? []).forEach((px) => {
6226
- bar(px, 2 * DIVISION_HALF - 2e-3).userData.doorChannel = true;
6334
+ (glassDivisions.get(c) ?? []).forEach(({ at, span }) => {
6335
+ bar(at, 2 * DIVISION_HALF - 2e-3, span).userData.doorChannel = true;
6227
6336
  });
6228
6337
  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;
6229
6338
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
6230
6339
  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 } });
6231
6340
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
6232
6341
  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));
6233
- const edges = doorEdgesOf(gh, s.wheels ?? []);
6234
- (s.seams || []).forEach(function(q) {
6235
- 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;
6236
- doorSeam(c, S, sd, x, y0, y1);
6237
- });
6342
+ if (s.fuelDoor && sd === s.fuelDoor[2]) fuelDoorGap(c, S, sd, s.fuelDoor[0], s.fuelDoor[1], I.gap);
6238
6343
  (s.handles || []).forEach(function(x) {
6239
6344
  c.roundBox(
6240
6345
  0.15,
@@ -6249,7 +6354,8 @@ var GameVehiclesFleet = (() => {
6249
6354
  });
6250
6355
  if (s.arches && s.arches.length > 1) {
6251
6356
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
6252
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
6357
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
6358
+ 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 }));
6253
6359
  if (s.clad)
6254
6360
  s.arches.forEach(function(a) {
6255
6361
  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));
@@ -6261,16 +6367,25 @@ var GameVehiclesFleet = (() => {
6261
6367
  c.roundBox(
6262
6368
  gh.fb - gh.rb - 0.3,
6263
6369
  0.012,
6264
- 8e-3,
6370
+ 0.012,
6265
6371
  4e-3,
6266
6372
  MT.chrome,
6267
6373
  (gh.fb + gh.rb) / 2 - 0.05,
6268
6374
  gh.belt + 0.035,
6269
- sd * (halfAt(gh.Wg, T, gh.belt + 0.035) + 4e-3)
6375
+ sd * (halfAt(gh.Wg, T, gh.belt + 0.035) + 6e-3)
6270
6376
  );
6271
6377
  });
6272
6378
  const cwh = S.hit(new V3(gh.fb + 0.03, 3, 0), new V3(0, -1, 0)), cwy = cwh ? cwh.p.y : gh.belt;
6273
- c.roundBox(0.15, 0.02, gh.Wg - 0.06, 8e-3, PLASTIC, gh.fb + 0.02, cwy + 4e-3, 0).castShadow = false;
6379
+ let cwz = gh.Wg / 2 - 0.03;
6380
+ for (let z = 0.3; z < cwz; z += 0.01) {
6381
+ const h = S.hit(new V3(gh.fb + 0.03, 3, z), new V3(0, -1, 0));
6382
+ if (!h || h.p.y < cwy - COWL_DROP) {
6383
+ cwz = z;
6384
+ break;
6385
+ }
6386
+ }
6387
+ cwz = Math.min(cwz, halfAt(gh.Wg, T, gh.belt + 0.05) - 0.072);
6388
+ c.roundBox(0.15, 0.02, 2 * cwz, 8e-3, PLASTIC, gh.fb + 0.02, cwy + 4e-3, 0).castShadow = false;
6274
6389
  const wd = new V3(gh.ft - gh.fb, gh.roof - gh.belt, 0).normalize(), wn = new V3(wd.y, -wd.x, 0);
6275
6390
  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);
6276
6391
  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;
@@ -6315,6 +6430,21 @@ var GameVehiclesFleet = (() => {
6315
6430
  });
6316
6431
  underbody(c, s, I);
6317
6432
  if (s.extra) s.extra(c, I);
6433
+ c.vehicle.updateMatrixWorld(true);
6434
+ [1, -1].forEach(function(sd) {
6435
+ const side = bodySide(THREE, c, S, sd);
6436
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
6437
+ (s.seams || []).forEach(function(q) {
6438
+ 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;
6439
+ const pts = shutLinePoints(side, x, y0, y1);
6440
+ if (pts.length < 3) return;
6441
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, I.gap ?? MT.dark, { seg: 72, rs: 5 }));
6442
+ seam.castShadow = false;
6443
+ seam.userData.doorSeam = true;
6444
+ seam.userData.gap = true;
6445
+ c.deform.push(seam);
6446
+ });
6447
+ });
6318
6448
  if (!c.parts.some(function(p) {
6319
6449
  return p.kind === "engine";
6320
6450
  }))
@@ -6388,16 +6518,57 @@ var GameVehiclesFleet = (() => {
6388
6518
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
6389
6519
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
6390
6520
  }
6391
- const SEAM_POINTS = 14;
6392
- function doorSeam(c, S, sd, x, y0, y1) {
6521
+ const GAP_R = 2e-3;
6522
+ const FIXED_SEAL_R = 4e-3;
6523
+ const DOOR_SEAL_R = 6e-3;
6524
+ const GAP_SHADE = 0.45;
6525
+ const gapMaterials = /* @__PURE__ */ new Map();
6526
+ function gapMaterial(col) {
6527
+ const hex = "#" + new THREE.Color(col).multiplyScalar(GAP_SHADE).getHexString();
6528
+ const known = gapMaterials.get(hex);
6529
+ if (known) return known;
6530
+ const made = CM(hex, { roughness: 0.6 }) ?? MT.dark;
6531
+ gapMaterials.set(hex, made);
6532
+ return made;
6533
+ }
6534
+ const HOOD_GAP = 4 * GAP_R;
6535
+ function hoodGap(c, S, x0, x1, zH, mat) {
6536
+ const onTop = (x, z) => {
6537
+ const h = S.hit(new V3(x, 3, z), new V3(0, -1, 0));
6538
+ return h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, 0, z);
6539
+ };
6540
+ const steps = Math.max(4, Math.ceil((x1 - x0) / 0.04));
6541
+ const across = Math.max(4, Math.ceil(2 * zH / 0.04));
6542
+ const line = [];
6543
+ for (let k = 0; k <= steps; k++) line.push(onTop(x0 + (x1 - x0) * k / steps, zH));
6544
+ for (let k = 1; k < across; k++) line.push(onTop(x1, zH - 2 * zH * k / across));
6545
+ for (let k = steps; k >= 0; k--) line.push(onTop(x0 + (x1 - x0) * k / steps, -zH));
6546
+ const t = c.tube(line, GAP_R, mat, { seg: line.length * 2, rs: 4 });
6547
+ t.castShadow = false;
6548
+ t.userData.gap = true;
6549
+ return t;
6550
+ }
6551
+ const FUEL_DOOR_W = 0.13;
6552
+ const FUEL_DOOR_H = 0.11;
6553
+ const FUEL_DOOR_R = 0.02;
6554
+ function fuelDoorGap(c, S, sd, x, y, mat) {
6393
6555
  const pts = [];
6394
- for (let k = 0; k <= SEAM_POINTS; k++) {
6395
- 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");
6396
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
6397
- }
6398
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
6556
+ const hx = FUEL_DOOR_W / 2 - FUEL_DOOR_R, hy = FUEL_DOOR_H / 2 - FUEL_DOOR_R;
6557
+ const corners = [
6558
+ [hx, hy, 0],
6559
+ [-hx, hy, 0.5 * PI],
6560
+ [-hx, -hy, PI],
6561
+ [hx, -hy, 1.5 * PI]
6562
+ ];
6563
+ corners.forEach(function([cx, cy, a0]) {
6564
+ for (let k = 0; k <= 4; k++) {
6565
+ 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");
6566
+ pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(px, py, sd * S.hw));
6567
+ }
6568
+ });
6569
+ const t = c.tube(pts, GAP_R, mat, { closed: true, seg: pts.length * 2, rs: 4 });
6399
6570
  t.castShadow = false;
6400
- t.userData.doorSeam = true;
6571
+ t.userData.gap = true;
6401
6572
  return t;
6402
6573
  }
6403
6574
  function sm(t) {
@@ -6446,36 +6617,23 @@ var GameVehiclesFleet = (() => {
6446
6617
  });
6447
6618
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
6448
6619
  function yAt(u) {
6449
- const x = x0 + (x1 - x0) * u;
6450
- for (let i = 0; i < pts.length - 1; i++) {
6451
- const a = pts[i], b = pts[i + 1];
6452
- if ((x - a[0]) * (x - b[0]) <= 0) {
6453
- const t = (x - a[0]) / (b[0] - a[0] || 1);
6454
- return a[1] + (b[1] - a[1]) * sm(t);
6455
- }
6456
- }
6457
- return pts[pts.length - 1][1];
6620
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
6458
6621
  }
6459
- I.K.skin(Gd, o.mat || c.paint(o.col), {
6622
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
6460
6623
  yb: function(u) {
6461
6624
  return yAt(u) - h;
6462
6625
  },
6463
6626
  yt: yAt,
6464
- off: o.off || 6e-3,
6465
- thick: 9e-3,
6466
- nv: 2,
6627
+ off: o.off || 2e-3,
6628
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
6629
+ crease: 30,
6630
+ nv: 5,
6467
6631
  u0: o.u0 || 0.01,
6468
6632
  u1: o.u1 || 0.99
6469
6633
  });
6470
- const l = [];
6471
- for (let k = 0; k <= 30; k++) {
6472
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
6473
- l.push([u, yAt(u) - h - 1e-3]);
6474
- }
6475
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
6634
+ markRaised(c, markFinishDetail(fold));
6476
6635
  return Gd;
6477
6636
  }
6478
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
6479
6637
  const CHROMEH = CM("#c9cdd0", { metalness: 0.85, roughness: 0.25 });
6480
6638
  const CHROMEB = CM("#d4d8db", { metalness: 0.5, roughness: 0.24 });
6481
6639
  const VINYL = "#2e2622";
@@ -6810,6 +6968,8 @@ var GameVehiclesFleet = (() => {
6810
6968
  dropRear: true,
6811
6969
  seams: [0.64, -0.5, [-1.27, 0.67, 0.93]],
6812
6970
  handles: [0.12, -0.86],
6971
+ /* fuel door on the right rear fender, between the rear door and the taillight, over the wheel */
6972
+ fuelDoor: [-1.47, 0.71, 1],
6813
6973
  blackPillars: [-0.5],
6814
6974
  frontBumper: { y1: 0.6 },
6815
6975
  rearBumper: { y1: 0.58 },
@@ -14815,7 +14975,8 @@ var GameVehiclesFleet = (() => {
14815
14975
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
14816
14976
  for (let j = 0; j <= nv; j++) {
14817
14977
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
14818
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
14978
+ 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;
14979
+ 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] });
14819
14980
  }
14820
14981
  Q.push(row);
14821
14982
  }
@@ -15108,8 +15269,9 @@ var GameVehiclesFleet = (() => {
15108
15269
  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");
15109
15270
  return h ? h.p.addScaledVector(h.n, 3e-3) : null;
15110
15271
  }).filter(Boolean);
15111
- const t = c.tube(P, 38e-4, MT.dark, { seg: P.length * 8, rs: 4 });
15272
+ const t = c.tube(P, GAP_R, I.gap ?? MT.dark, { seg: P.length * 8, rs: 4 });
15112
15273
  t.castShadow = false;
15274
+ t.userData.gap = true;
15113
15275
  c.deform.push(t);
15114
15276
  return t;
15115
15277
  };
@@ -15135,6 +15297,7 @@ var GameVehiclesFleet = (() => {
15135
15297
  };
15136
15298
  return K;
15137
15299
  }
15300
+ const DIVISION_OVER = 0.012;
15138
15301
  const glassDivisions = /* @__PURE__ */ new WeakMap();
15139
15302
  function car(c, s) {
15140
15303
  const W = s.W, gh = s.gh, bev = 0.05, T = { belt: gh.belt, top: gh.roof + bev, k: gh.k }, m = c.meta;
@@ -15171,7 +15334,10 @@ var GameVehiclesFleet = (() => {
15171
15334
  if (s.dropRear) polys = polys.slice(1);
15172
15335
  const divided = splitSidePolys(polys, doorGlassSplits(gh, s.wheels ?? []));
15173
15336
  polys = divided.polys;
15174
- glassDivisions.set(c, divided.used);
15337
+ glassDivisions.set(
15338
+ c,
15339
+ divided.used.map((at) => ({ at, span: divisionSpan(divided.polys, at) }))
15340
+ );
15175
15341
  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);
15176
15342
  const gHoles = [];
15177
15343
  if (intr) {
@@ -15192,6 +15358,7 @@ var GameVehiclesFleet = (() => {
15192
15358
  side: THREE.DoubleSide
15193
15359
  }) : null;
15194
15360
  kit.shell(c, { items: ghItems, W: gh.Wg, col: s.col, mat: roofMat, T, holes: gHoles, sub: intr ? 0.12 : 0.2 });
15361
+ const sealEdges = doorEdgesOf(gh, s.wheels ?? []);
15195
15362
  kit.sideWindows(
15196
15363
  c,
15197
15364
  polys,
@@ -15200,7 +15367,14 @@ var GameVehiclesFleet = (() => {
15200
15367
  function(i, n) {
15201
15368
  return i === 0 && n > 2 ? lbl("quarter_glass") : i === n - 1 ? lbl("window_front") : lbl("window_rear");
15202
15369
  },
15203
- { see: !!intr }
15370
+ {
15371
+ see: !!intr,
15372
+ // a fixed pane sits in a thin rubber flush with the body; the window of a door runs in a channel round its frame
15373
+ seal: function(i) {
15374
+ const xs = polys[i].map((q) => q[0]), mid = (Math.min(...xs) + Math.max(...xs)) / 2;
15375
+ return sealEdges && mid > sealEdges.C && mid < sealEdges.doorF ? DOOR_SEAL_R : FIXED_SEAL_R;
15376
+ }
15377
+ }
15204
15378
  );
15205
15379
  kit.glassQuad(c, qf, lbl("windshield"), { see: !!intr });
15206
15380
  kit.glassQuad(c, qr, lbl("rear_window"), { see: !!intr, mat: intr ? REARTINT : MT.glassDark });
@@ -15252,7 +15426,7 @@ var GameVehiclesFleet = (() => {
15252
15426
  (s.arches || []).forEach(function(a) {
15253
15427
  fa = Math.max(fa, a[0]);
15254
15428
  });
15255
- const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col });
15429
+ const hood = kit.makeHood(c, lowMesh.userData.cut.hood, { x0: hx0, col: s.col, gap: HOOD_GAP });
15256
15430
  if (hood)
15257
15431
  kit.engineBay(c, {
15258
15432
  x0: hx0 + 0.02,
@@ -15286,6 +15460,7 @@ var GameVehiclesFleet = (() => {
15286
15460
  );
15287
15461
  const Wf = mkWarp(wo);
15288
15462
  const S = mkSurf(lowMesh, W);
15463
+ if (c.hood && hoodO) hoodGap(c, S, hx0, hx1, zH, gapMaterial(s.col));
15289
15464
  details(c, s, Wf, S);
15290
15465
  applyWarp(c, Wf);
15291
15466
  return m;
@@ -15297,7 +15472,7 @@ var GameVehiclesFleet = (() => {
15297
15472
  }, rx = function(y) {
15298
15473
  return profX(it, y, false);
15299
15474
  };
15300
- const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S };
15475
+ const I = { fx: fx2, rx, W, hw, by, gh, T, Wf, S, gap: gapMaterial(s.col) };
15301
15476
  I.fxB = S.endX(1, by + 0.2);
15302
15477
  I.rxB = S.endX(-1, by + 0.2);
15303
15478
  const K = mkKit(c, S, I);
@@ -15326,26 +15501,22 @@ var GameVehiclesFleet = (() => {
15326
15501
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
15327
15502
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
15328
15503
  [1, -1].forEach(function(sd) {
15329
- const bar = function(px, width) {
15330
- const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
15504
+ const bar = function(px, width, span) {
15505
+ 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;
15331
15506
  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] });
15332
15507
  m2.castShadow = false;
15333
15508
  return m2;
15334
15509
  };
15335
15510
  (s.blackPillars || []).forEach((px) => bar(px, 0.118));
15336
- (glassDivisions.get(c) ?? []).forEach((px) => {
15337
- bar(px, 2 * DIVISION_HALF - 2e-3).userData.doorChannel = true;
15511
+ (glassDivisions.get(c) ?? []).forEach(({ at, span }) => {
15512
+ bar(at, 2 * DIVISION_HALF - 2e-3, span).userData.doorChannel = true;
15338
15513
  });
15339
15514
  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;
15340
15515
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
15341
15516
  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 } });
15342
15517
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
15343
15518
  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));
15344
- const edges = doorEdgesOf(gh, s.wheels ?? []);
15345
- (s.seams || []).forEach(function(x0) {
15346
- const x = seamOnDoorEdge(x0, edges);
15347
- doorSeam(c, S, sd, x, by + 0.09, gh.belt - 0.03);
15348
- });
15519
+ if (s.fuelDoor && sd === s.fuelDoor[2]) fuelDoorGap(c, S, sd, s.fuelDoor[0], s.fuelDoor[1], I.gap);
15349
15520
  (s.handles || []).forEach(function(x) {
15350
15521
  c.roundBox(
15351
15522
  0.15,
@@ -15360,7 +15531,8 @@ var GameVehiclesFleet = (() => {
15360
15531
  });
15361
15532
  if (s.arches && s.arches.length > 1) {
15362
15533
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
15363
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
15534
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
15535
+ 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 }));
15364
15536
  if (s.clad)
15365
15537
  s.arches.forEach(function(a) {
15366
15538
  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));
@@ -15413,6 +15585,20 @@ var GameVehiclesFleet = (() => {
15413
15585
  });
15414
15586
  underbody(c, s, I);
15415
15587
  if (s.extra) s.extra(c, I);
15588
+ c.vehicle.updateMatrixWorld(true);
15589
+ [1, -1].forEach(function(sd) {
15590
+ const side = bodySide(THREE, c, S, sd);
15591
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
15592
+ (s.seams || []).forEach(function(x) {
15593
+ const pts = shutLinePoints(side, seamOnDoorEdge(x, edges), by + 0.11, gh.belt - 0.03);
15594
+ if (pts.length < 3) return;
15595
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, I.gap ?? MT.dark, { seg: 72, rs: 5 }));
15596
+ seam.castShadow = false;
15597
+ seam.userData.doorSeam = true;
15598
+ seam.userData.gap = true;
15599
+ c.deform.push(seam);
15600
+ });
15601
+ });
15416
15602
  if (!c.parts.some(function(p) {
15417
15603
  return p.kind === "engine";
15418
15604
  }))
@@ -15486,16 +15672,57 @@ var GameVehiclesFleet = (() => {
15486
15672
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
15487
15673
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
15488
15674
  }
15489
- const SEAM_POINTS = 14;
15490
- function doorSeam(c, S, sd, x, y0, y1) {
15675
+ const GAP_R = 2e-3;
15676
+ const FIXED_SEAL_R = 4e-3;
15677
+ const DOOR_SEAL_R = 6e-3;
15678
+ const GAP_SHADE = 0.45;
15679
+ const gapMaterials = /* @__PURE__ */ new Map();
15680
+ function gapMaterial(col) {
15681
+ const hex = "#" + new THREE.Color(col).multiplyScalar(GAP_SHADE).getHexString();
15682
+ const known = gapMaterials.get(hex);
15683
+ if (known) return known;
15684
+ const made = CM(hex, { roughness: 0.6 }) ?? MT.dark;
15685
+ gapMaterials.set(hex, made);
15686
+ return made;
15687
+ }
15688
+ const HOOD_GAP = 4 * GAP_R;
15689
+ function hoodGap(c, S, x0, x1, zH, mat) {
15690
+ const onTop = (x, z) => {
15691
+ const h = S.hit(new V3(x, 3, z), new V3(0, -1, 0));
15692
+ return h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, 0, z);
15693
+ };
15694
+ const steps = Math.max(4, Math.ceil((x1 - x0) / 0.04));
15695
+ const across = Math.max(4, Math.ceil(2 * zH / 0.04));
15696
+ const line = [];
15697
+ for (let k = 0; k <= steps; k++) line.push(onTop(x0 + (x1 - x0) * k / steps, zH));
15698
+ for (let k = 1; k < across; k++) line.push(onTop(x1, zH - 2 * zH * k / across));
15699
+ for (let k = steps; k >= 0; k--) line.push(onTop(x0 + (x1 - x0) * k / steps, -zH));
15700
+ const t = c.tube(line, GAP_R, mat, { seg: line.length * 2, rs: 4 });
15701
+ t.castShadow = false;
15702
+ t.userData.gap = true;
15703
+ return t;
15704
+ }
15705
+ const FUEL_DOOR_W = 0.13;
15706
+ const FUEL_DOOR_H = 0.11;
15707
+ const FUEL_DOOR_R = 0.02;
15708
+ function fuelDoorGap(c, S, sd, x, y, mat) {
15491
15709
  const pts = [];
15492
- for (let k = 0; k <= SEAM_POINTS; k++) {
15493
- 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");
15494
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
15495
- }
15496
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
15710
+ const hx = FUEL_DOOR_W / 2 - FUEL_DOOR_R, hy = FUEL_DOOR_H / 2 - FUEL_DOOR_R;
15711
+ const corners = [
15712
+ [hx, hy, 0],
15713
+ [-hx, hy, 0.5 * PI],
15714
+ [-hx, -hy, PI],
15715
+ [hx, -hy, 1.5 * PI]
15716
+ ];
15717
+ corners.forEach(function([cx, cy, a0]) {
15718
+ for (let k = 0; k <= 4; k++) {
15719
+ 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");
15720
+ pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(px, py, sd * S.hw));
15721
+ }
15722
+ });
15723
+ const t = c.tube(pts, GAP_R, mat, { closed: true, seg: pts.length * 2, rs: 4 });
15497
15724
  t.castShadow = false;
15498
- t.userData.doorSeam = true;
15725
+ t.userData.gap = true;
15499
15726
  return t;
15500
15727
  }
15501
15728
  function sm(t) {
@@ -15544,36 +15771,23 @@ var GameVehiclesFleet = (() => {
15544
15771
  });
15545
15772
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
15546
15773
  function yAt(u) {
15547
- const x = x0 + (x1 - x0) * u;
15548
- for (let i = 0; i < pts.length - 1; i++) {
15549
- const a = pts[i], b = pts[i + 1];
15550
- if ((x - a[0]) * (x - b[0]) <= 0) {
15551
- const t = (x - a[0]) / (b[0] - a[0] || 1);
15552
- return a[1] + (b[1] - a[1]) * sm(t);
15553
- }
15554
- }
15555
- return pts[pts.length - 1][1];
15774
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
15556
15775
  }
15557
- I.K.skin(Gd, o.mat || c.paint(o.col), {
15776
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
15558
15777
  yb: function(u) {
15559
15778
  return yAt(u) - h;
15560
15779
  },
15561
15780
  yt: yAt,
15562
- off: o.off || 6e-3,
15563
- thick: 9e-3,
15564
- nv: 2,
15781
+ off: o.off || 2e-3,
15782
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
15783
+ crease: 30,
15784
+ nv: 5,
15565
15785
  u0: o.u0 || 0.01,
15566
15786
  u1: o.u1 || 0.99
15567
15787
  });
15568
- const l = [];
15569
- for (let k = 0; k <= 30; k++) {
15570
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
15571
- l.push([u, yAt(u) - h - 1e-3]);
15572
- }
15573
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
15788
+ markRaised(c, markFinishDetail(fold));
15574
15789
  return Gd;
15575
15790
  }
15576
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
15577
15791
  function dloChrome(c, I, sd, pts, r) {
15578
15792
  const gh = I.gh, T = I.T, P = pts.map(function(q) {
15579
15793
  return [q[0], q[1], sd * (halfAt(gh.Wg, T, q[1]) + 0.012)];
@@ -16631,12 +16845,10 @@ var GameVehiclesFleet = (() => {
16631
16845
  I,
16632
16846
  sd,
16633
16847
  [
16634
- [1, 0.47],
16635
- [0, 0.5],
16636
- [-0.9, 0.6],
16637
- [-1.2, 0.66]
16848
+ [0.86, 0.52],
16849
+ [-0.98, 0.52]
16638
16850
  ],
16639
- { col: "#8b939a", h: 0.035 }
16851
+ { col: "#8b939a", h: 0.03 }
16640
16852
  );
16641
16853
  });
16642
16854
  }
@@ -24464,6 +24676,7 @@ var GameVehiclesFleet = (() => {
24464
24676
  tl: P.tl,
24465
24677
  grille: P.grille,
24466
24678
  seams: P.seams,
24679
+ shell: shellM,
24467
24680
  handles: P.handles,
24468
24681
  wheels: [
24469
24682
  [A.xf, P.wr, 0.24, { rim: P.rim }],