@adatechnology/game-urban-three 0.5.8 → 0.5.10

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.
@@ -2368,8 +2368,8 @@ var GameUrbanThree = (() => {
2368
2368
 
2369
2369
  // src/text.ts
2370
2370
  var FIT = 0.92;
2371
- function createTextTexture(THREE, document, lines, o) {
2372
- const canvas = document.createElement("canvas");
2371
+ function createTextTexture(THREE, document2, lines, o) {
2372
+ const canvas = document2.createElement("canvas");
2373
2373
  canvas.width = o.width;
2374
2374
  canvas.height = o.height;
2375
2375
  const g = canvas.getContext("2d");
@@ -5145,6 +5145,262 @@ var GameUrbanThree = (() => {
5145
5145
  }
5146
5146
  var engine = defaultFloorplan();
5147
5147
 
5148
+ // ../game-vehicles/dist/index.js
5149
+ var SHUT_LINE_RADIUS = 2e-3;
5150
+ var SHUT_LINE_LIFT = 8e-4;
5151
+ var SHUT_LINE_STEPS = 36;
5152
+ var SHUT_LINE_STRAY = 0.04;
5153
+ function shutLinePoints(hit, x, y0, y1) {
5154
+ const out = [];
5155
+ for (let k = 0; k <= SHUT_LINE_STEPS; k++) {
5156
+ const h = hit(x, y0 + (y1 - y0) * k / SHUT_LINE_STEPS);
5157
+ 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]);
5158
+ }
5159
+ if (out.length < 3) return out;
5160
+ const depths = out.map((q) => q[2]).sort((a, b) => a - b);
5161
+ const median = depths[Math.floor(depths.length / 2)];
5162
+ return out.filter((q) => Math.abs(q[2] - median) < SHUT_LINE_STRAY);
5163
+ }
5164
+ var FINISH_DETAIL = "finishDetail";
5165
+ function markFinishDetail(object2) {
5166
+ object2.userData[FINISH_DETAIL] = true;
5167
+ return object2;
5168
+ }
5169
+ var DIVISION_HALF = 0.02;
5170
+ var GLASS_IN_FROM_EDGE = 0.03;
5171
+ var CUT_EPS = 1e-6;
5172
+ var PAST_EDGE_MIN = 0.01;
5173
+ var PANE_MIN_AREA = 8e-3;
5174
+ var PANE_MIN_WIDTH = 0.12;
5175
+ function carDoorEdges(fb, rb, pillars, xr, rr) {
5176
+ const doorF = fb - 0.03;
5177
+ const pil = pillars.slice().sort((a, b) => b - a);
5178
+ const first = pil[0];
5179
+ const B = first !== void 0 && first < doorF - 0.45 && first > rb + 0.2 ? first : Math.max(rb + 0.1, doorF - 1.1);
5180
+ const rearDoor = first !== void 0 && first < doorF - 0.45 && B - Math.max(rb, xr) > 0.5;
5181
+ const second = pil[1];
5182
+ const C = rearDoor ? Math.max(second !== void 0 && second < B - 0.4 ? second : rb, xr + rr * 0.2) : B;
5183
+ return { doorF, B, C, rearDoor };
5184
+ }
5185
+ function doorEdgesOf(gh, wheels) {
5186
+ let xr = Infinity;
5187
+ let rr = 0.3;
5188
+ for (const w of wheels) {
5189
+ const x = w[0];
5190
+ const r = w[1];
5191
+ if (typeof x === "number" && x < xr) {
5192
+ xr = x;
5193
+ rr = typeof r === "number" ? r : 0.3;
5194
+ }
5195
+ }
5196
+ if (!Number.isFinite(xr)) {
5197
+ if (gh.pillars.length) return null;
5198
+ xr = -Infinity;
5199
+ }
5200
+ return carDoorEdges(gh.fb, gh.rb, gh.pillars, xr, rr);
5201
+ }
5202
+ var SEAM_SNAP = 0.1;
5203
+ var SEAM_INSIDE = 4e-3;
5204
+ function seamOnDoorEdge(x, edges) {
5205
+ if (!edges) return x;
5206
+ let best = x;
5207
+ let gap = SEAM_SNAP;
5208
+ const lines = [edges.doorF - SEAM_INSIDE, edges.B, edges.C === edges.B ? edges.C : edges.C + SEAM_INSIDE];
5209
+ for (let i = 0; i < lines.length; i++) {
5210
+ const d = Math.abs([edges.doorF, edges.B, edges.C][i] - x);
5211
+ if (d <= gap) [best, gap] = [lines[i], d];
5212
+ }
5213
+ return best;
5214
+ }
5215
+ function doorGlassSplits(gh, wheels) {
5216
+ const edges = doorEdgesOf(gh, wheels);
5217
+ if (!edges) return [];
5218
+ return [{ at: edges.C + GLASS_IN_FROM_EDGE - DIVISION_HALF, front: edges.rearDoor ? edges.B : edges.doorF }];
5219
+ }
5220
+ function clipPoly(poly, at, keep) {
5221
+ const out = [];
5222
+ const inside = (p) => keep * ((p[0] ?? 0) - at) >= 0;
5223
+ for (let i = 0; i < poly.length; i++) {
5224
+ const a = poly[i];
5225
+ const b = poly[(i + 1) % poly.length];
5226
+ const ina = inside(a);
5227
+ const inb = inside(b);
5228
+ if (ina) out.push([a[0], a[1]]);
5229
+ if (ina !== inb) {
5230
+ const t = (at - a[0]) / (b[0] - a[0]);
5231
+ out.push([at, a[1] + t * (b[1] - a[1])]);
5232
+ }
5233
+ }
5234
+ return out;
5235
+ }
5236
+ function areaOf2(poly) {
5237
+ let a = 0;
5238
+ for (let i = 0; i < poly.length; i++) {
5239
+ const p = poly[i];
5240
+ const q = poly[(i + 1) % poly.length];
5241
+ a += p[0] * q[1] - q[0] * p[1];
5242
+ }
5243
+ return Math.abs(a) / 2;
5244
+ }
5245
+ function widthOf(poly) {
5246
+ const xs = poly.map((p) => p[0]);
5247
+ return Math.max(...xs) - Math.min(...xs);
5248
+ }
5249
+ function splitSidePolys(polys, splits) {
5250
+ let out = polys.map((p) => p.map((q) => [...q]));
5251
+ const used = [];
5252
+ for (const { at, front: doorFront } of splits) {
5253
+ const next = [];
5254
+ let cut = false;
5255
+ for (const poly of out) {
5256
+ const xs = poly.map((p) => p[0]);
5257
+ const edge = at + DIVISION_HALF - GLASS_IN_FROM_EDGE;
5258
+ const middle = (Math.min(...xs) + Math.max(...xs)) / 2;
5259
+ if (Math.min(...xs) >= edge - PAST_EDGE_MIN || Math.max(...xs) <= edge + CUT_EPS || middle <= edge || middle >= doorFront) {
5260
+ next.push(poly);
5261
+ continue;
5262
+ }
5263
+ cut = true;
5264
+ const rear = clipPoly(poly, at - DIVISION_HALF, -1);
5265
+ const front = clipPoly(poly, at + DIVISION_HALF, 1);
5266
+ if (rear.length >= 3 && areaOf2(rear) >= PANE_MIN_AREA && widthOf(rear) >= PANE_MIN_WIDTH) next.push(rear);
5267
+ if (front.length >= 3) next.push(front);
5268
+ }
5269
+ if (cut) used.push(at);
5270
+ out = next;
5271
+ }
5272
+ return { polys: out, used };
5273
+ }
5274
+ var SmokeCause = { STEAM: "steam", OIL: "oil", FIRE: "fire" };
5275
+ var SMOKE_LOOKS = {
5276
+ [SmokeCause.STEAM]: { color: 14870248, alpha: 0.18 },
5277
+ [SmokeCause.OIL]: { color: 11120306, alpha: 0.2 },
5278
+ [SmokeCause.FIRE]: { color: 2302756, alpha: 0.3 }
5279
+ };
5280
+ var CAUSE_OF_EMITTER = { white: SmokeCause.STEAM, oil: SmokeCause.OIL, black: SmokeCause.FIRE };
5281
+ var LIFT = { [SmokeCause.STEAM]: 0.5, [SmokeCause.OIL]: 0.45, [SmokeCause.FIRE]: 0.6 };
5282
+ var LID_OUTWARD = [-Math.SQRT1_2, Math.SQRT1_2, 0];
5283
+ var cabin_default = {
5284
+ source: "Spec 012 (R6, T0.2) \u2014 SAE J1100 interior packaging & ISO 7250-1 / NASA-STD-3000 adult anthropometry (1.80 m seated height = 0.936 m, buttock-knee = 0.612 m, shoulder = 0.468 m)",
5285
+ entryDuckFactor: 0.44,
5286
+ categories: {
5287
+ passenger_car: {
5288
+ frontHeadroomMetres: 0.95,
5289
+ rearHeadroomMetres: 0.9,
5290
+ frontLegroomMetres: 0.62,
5291
+ widthMetres: 0.52,
5292
+ door: { widthMetres: 0.65, heightMetres: 0.8 }
5293
+ },
5294
+ suv_pickup: {
5295
+ frontHeadroomMetres: 0.98,
5296
+ rearHeadroomMetres: 0.93,
5297
+ frontLegroomMetres: 0.64,
5298
+ widthMetres: 0.54,
5299
+ door: { widthMetres: 0.7, heightMetres: 0.82 }
5300
+ },
5301
+ van: {
5302
+ frontHeadroomMetres: 1.05,
5303
+ rearHeadroomMetres: 1.05,
5304
+ frontLegroomMetres: 0.65,
5305
+ widthMetres: 0.54,
5306
+ door: { widthMetres: 0.75, heightMetres: 0.95 }
5307
+ },
5308
+ truck: {
5309
+ frontHeadroomMetres: 1,
5310
+ rearHeadroomMetres: 1,
5311
+ frontLegroomMetres: 0.62,
5312
+ widthMetres: 0.52,
5313
+ door: { widthMetres: 0.65, heightMetres: 0.85 }
5314
+ },
5315
+ bus: {
5316
+ frontHeadroomMetres: 1.2,
5317
+ rearHeadroomMetres: 1.2,
5318
+ frontLegroomMetres: 0.62,
5319
+ widthMetres: 0.5,
5320
+ door: { widthMetres: 0.7, heightMetres: 1.75 }
5321
+ },
5322
+ agricultural: {
5323
+ frontHeadroomMetres: 1.05,
5324
+ rearHeadroomMetres: null,
5325
+ frontLegroomMetres: 0.62,
5326
+ widthMetres: 0.52,
5327
+ door: { widthMetres: 0.65, heightMetres: 0.9 }
5328
+ },
5329
+ military_light: {
5330
+ frontHeadroomMetres: 0.95,
5331
+ rearHeadroomMetres: 0.92,
5332
+ frontLegroomMetres: 0.62,
5333
+ widthMetres: 0.5,
5334
+ door: { widthMetres: 0.6, heightMetres: 0.8 }
5335
+ },
5336
+ military_armored: {
5337
+ frontHeadroomMetres: 0.88,
5338
+ rearHeadroomMetres: 0.88,
5339
+ frontLegroomMetres: 0.58,
5340
+ widthMetres: 0.46,
5341
+ door: { widthMetres: 0.5, heightMetres: 0.55 }
5342
+ },
5343
+ open_vehicle: {
5344
+ frontHeadroomMetres: null,
5345
+ rearHeadroomMetres: null,
5346
+ frontLegroomMetres: null,
5347
+ widthMetres: null,
5348
+ door: null
5349
+ },
5350
+ boat_cabin: {
5351
+ frontHeadroomMetres: 1.05,
5352
+ rearHeadroomMetres: 1.05,
5353
+ frontLegroomMetres: 0.62,
5354
+ widthMetres: 0.52,
5355
+ door: { widthMetres: 0.6, heightMetres: 0.9 }
5356
+ },
5357
+ aircraft_enclosed: {
5358
+ frontHeadroomMetres: 0.95,
5359
+ rearHeadroomMetres: 0.92,
5360
+ frontLegroomMetres: 0.62,
5361
+ widthMetres: 0.48,
5362
+ door: { widthMetres: 0.55, heightMetres: 0.8 }
5363
+ }
5364
+ }
5365
+ };
5366
+ var CABIN_CATEGORIES = [
5367
+ "passenger_car",
5368
+ "suv_pickup",
5369
+ "van",
5370
+ "truck",
5371
+ "bus",
5372
+ "agricultural",
5373
+ "military_light",
5374
+ "military_armored",
5375
+ "open_vehicle",
5376
+ "boat_cabin",
5377
+ "aircraft_enclosed"
5378
+ ];
5379
+ var toClearance = (value) => value === null ? Number.POSITIVE_INFINITY : value;
5380
+ var toCabinMinimum = (category, raw) => {
5381
+ if (category === "open_vehicle") {
5382
+ return {
5383
+ frontHeadroomMetres: Number.POSITIVE_INFINITY,
5384
+ rearHeadroomMetres: Number.POSITIVE_INFINITY,
5385
+ frontLegroomMetres: Number.POSITIVE_INFINITY,
5386
+ widthMetres: Number.POSITIVE_INFINITY,
5387
+ door: void 0
5388
+ };
5389
+ }
5390
+ return {
5391
+ frontHeadroomMetres: toClearance(raw.frontHeadroomMetres),
5392
+ rearHeadroomMetres: raw.rearHeadroomMetres === null ? void 0 : raw.rearHeadroomMetres,
5393
+ frontLegroomMetres: toClearance(raw.frontLegroomMetres),
5394
+ widthMetres: toClearance(raw.widthMetres),
5395
+ door: raw.door === null ? void 0 : { widthMetres: raw.door.widthMetres, heightMetres: raw.door.heightMetres }
5396
+ };
5397
+ };
5398
+ var CABIN_SOURCE = cabin_default.source;
5399
+ var ENTRY_DUCK_FACTOR = cabin_default.entryDuckFactor;
5400
+ var CABIN_MINIMUMS = Object.fromEntries(
5401
+ CABIN_CATEGORIES.map((category) => [category, toCabinMinimum(category, cabin_default.categories[category])])
5402
+ );
5403
+
5148
5404
  // ../game-vehicles-fleet/dist/index.js
5149
5405
  var cars = [
5150
5406
  "compact_hatch",
@@ -10060,6 +10316,55 @@ var GameUrbanThree = (() => {
10060
10316
  pane2.userData.sunroof = { slide };
10061
10317
  return pane2;
10062
10318
  }
10319
+ var CREASE_FOLD_LIFT = 7e-3;
10320
+ var CREASE_FOLD_AT = 0.4;
10321
+ function creaseHeightAt(pts, x) {
10322
+ const n = pts.length;
10323
+ const slope = (i) => (pts[i + 1][1] - pts[i][1]) / (pts[i + 1][0] - pts[i][0] || 1);
10324
+ const tangent = (i) => {
10325
+ if (i === 0) return slope(0);
10326
+ if (i === n - 1) return slope(n - 2);
10327
+ const a = slope(i - 1), b = slope(i);
10328
+ return a * b <= 0 ? 0 : 2 * a * b / (a + b);
10329
+ };
10330
+ for (let i = 0; i < n - 1; i++) {
10331
+ const a = pts[i], b = pts[i + 1];
10332
+ if ((x - a[0]) * (x - b[0]) > 0) continue;
10333
+ const w = b[0] - a[0] || 1, t = (x - a[0]) / w, t2 = t * t, t3 = t2 * t;
10334
+ 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);
10335
+ }
10336
+ return pts[n - 1][1];
10337
+ }
10338
+ var raised = /* @__PURE__ */ new WeakMap();
10339
+ function raisedOnSide(c) {
10340
+ let list2 = raised.get(c);
10341
+ if (!list2) raised.set(c, list2 = []);
10342
+ return list2;
10343
+ }
10344
+ function markRaised(c, mesh2) {
10345
+ raisedOnSide(c).push(mesh2);
10346
+ }
10347
+ function bodySide(THREE, c, S, sd) {
10348
+ const ray = new THREE.Raycaster();
10349
+ const world = c.vehicle.matrixWorld;
10350
+ const toVehicle = world.clone().invert();
10351
+ return function(x, y) {
10352
+ const origin = new THREE.Vector3(x, y, sd * (S.hw + 1));
10353
+ const best = S.hit(origin, new THREE.Vector3(0, 0, -sd), "M");
10354
+ ray.set(origin.clone().applyMatrix4(world), new THREE.Vector3(0, 0, -sd).transformDirection(world));
10355
+ raisedOnSide(c).forEach(function(m) {
10356
+ const h = ray.intersectObject(m, false)[0];
10357
+ if (!h || !h.face) return;
10358
+ const p = h.point.clone().applyMatrix4(toVehicle);
10359
+ if (!best || Math.abs(p.z) <= Math.abs(best.p.z)) return;
10360
+ const n = h.face.normal.clone().transformDirection(m.matrixWorld).transformDirection(toVehicle);
10361
+ if (n.z * sd < 0) n.negate();
10362
+ best.p = p;
10363
+ best.n = n;
10364
+ });
10365
+ return best;
10366
+ };
10367
+ }
10063
10368
  function installCarsExtra(fx) {
10064
10369
  const kit = fx.kit;
10065
10370
  const THREE = kit.THREE;
@@ -10398,7 +10703,8 @@ var GameUrbanThree = (() => {
10398
10703
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
10399
10704
  for (let j = 0; j <= nv; j++) {
10400
10705
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
10401
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
10706
+ 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;
10707
+ 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] });
10402
10708
  }
10403
10709
  Q.push(row);
10404
10710
  }
@@ -10731,6 +11037,7 @@ var GameUrbanThree = (() => {
10731
11037
  };
10732
11038
  return K;
10733
11039
  }
11040
+ const glassDivisions = /* @__PURE__ */ new WeakMap();
10734
11041
  function car(c, s) {
10735
11042
  const W = s.W, gh = s.gh, bev = 0.05, T = { belt: gh.belt, top: gh.roof + bev, k: gh.k }, m = c.meta;
10736
11043
  m.color = s.col;
@@ -10765,6 +11072,9 @@ var GameUrbanThree = (() => {
10765
11072
  let polys = windows(gh);
10766
11073
  if (s.dropRear) polys = polys.slice(1);
10767
11074
  if (gh.polys) polys = gh.polys(polys);
11075
+ const divided = splitSidePolys(polys, doorGlassSplits(gh, s.wheels ?? []));
11076
+ polys = divided.polys;
11077
+ glassDivisions.set(c, divided.used);
10768
11078
  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 });
10769
11079
  const gHoles = [];
10770
11080
  if (intr) {
@@ -10830,6 +11140,8 @@ var GameUrbanThree = (() => {
10830
11140
  rb: gh.rb,
10831
11141
  rt: gh.rt,
10832
11142
  roof: gh.roof + 0.02,
11143
+ roofRear: (gh.roofR || gh.roof) + 0.02,
11144
+ roofCrown: gh.crown || 0,
10833
11145
  belt: gh.belt,
10834
11146
  floor: s.bottomY + 0.02,
10835
11147
  seatH: 0.12,
@@ -10924,20 +11236,21 @@ var GameUrbanThree = (() => {
10924
11236
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
10925
11237
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
10926
11238
  [1, -1].forEach(function(sd) {
10927
- ;
10928
- (s.blackPillars || []).forEach(function(px) {
11239
+ const bar = function(px, width) {
10929
11240
  const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
10930
- c.roundBox(0.118, hh, 3e-3, 15e-4, GLOSS, px, yc, sd * (halfAt(gh.Wg, T, yc) + 4e-3), { rot: [-sd * tang, 0, 0] }).castShadow = false;
11241
+ 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] });
11242
+ m2.castShadow = false;
11243
+ return m2;
11244
+ };
11245
+ (s.blackPillars || []).forEach((px) => bar(px, 0.118));
11246
+ (glassDivisions.get(c) ?? []).forEach((px) => {
11247
+ bar(px, 2 * DIVISION_HALF - 2e-3).userData.doorChannel = true;
10931
11248
  });
10932
11249
  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;
10933
11250
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
10934
11251
  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 } });
10935
11252
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
10936
11253
  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));
10937
- (s.seams || []).forEach(function(q) {
10938
- 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;
10939
- c.roundBox(8e-3, y1 - y0, 6e-3, 3e-3, MT.dark, x, (y0 + y1) / 2, sd * (hw + 1e-3));
10940
- });
10941
11254
  (s.handles || []).forEach(function(x) {
10942
11255
  c.roundBox(
10943
11256
  0.15,
@@ -10952,7 +11265,8 @@ var GameUrbanThree = (() => {
10952
11265
  });
10953
11266
  if (s.arches && s.arches.length > 1) {
10954
11267
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
10955
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
11268
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
11269
+ 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 }));
10956
11270
  if (s.clad)
10957
11271
  s.arches.forEach(function(a) {
10958
11272
  const a0 = Math.asin(clamp4((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));
@@ -11018,6 +11332,20 @@ var GameUrbanThree = (() => {
11018
11332
  });
11019
11333
  underbody(c, s, I);
11020
11334
  if (s.extra) s.extra(c, I);
11335
+ c.vehicle.updateMatrixWorld(true);
11336
+ [1, -1].forEach(function(sd) {
11337
+ const side = bodySide(THREE, c, S, sd);
11338
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
11339
+ (s.seams || []).forEach(function(q) {
11340
+ 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;
11341
+ const pts = shutLinePoints(side, x, y0, y1);
11342
+ if (pts.length < 3) return;
11343
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, MT.dark, { seg: 72, rs: 5 }));
11344
+ seam.castShadow = false;
11345
+ seam.userData.doorSeam = true;
11346
+ c.deform.push(seam);
11347
+ });
11348
+ });
11021
11349
  if (!c.parts.some(function(p) {
11022
11350
  return p.kind === "engine";
11023
11351
  }))
@@ -11137,36 +11465,23 @@ var GameUrbanThree = (() => {
11137
11465
  });
11138
11466
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
11139
11467
  function yAt(u) {
11140
- const x = x0 + (x1 - x0) * u;
11141
- for (let i = 0; i < pts.length - 1; i++) {
11142
- const a = pts[i], b = pts[i + 1];
11143
- if ((x - a[0]) * (x - b[0]) <= 0) {
11144
- const t = (x - a[0]) / (b[0] - a[0] || 1);
11145
- return a[1] + (b[1] - a[1]) * sm(t);
11146
- }
11147
- }
11148
- return pts[pts.length - 1][1];
11468
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
11149
11469
  }
11150
- I.K.skin(Gd, o.mat || c.paint(o.col), {
11470
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
11151
11471
  yb: function(u) {
11152
11472
  return yAt(u) - h;
11153
11473
  },
11154
11474
  yt: yAt,
11155
- off: o.off || 6e-3,
11156
- thick: 9e-3,
11157
- nv: 2,
11475
+ off: o.off || 2e-3,
11476
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
11477
+ crease: 30,
11478
+ nv: 5,
11158
11479
  u0: o.u0 || 0.01,
11159
11480
  u1: o.u1 || 0.99
11160
11481
  });
11161
- const l = [];
11162
- for (let k = 0; k <= 30; k++) {
11163
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
11164
- l.push([u, yAt(u) - h - 1e-3]);
11165
- }
11166
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
11482
+ markRaised(c, markFinishDetail(fold));
11167
11483
  return Gd;
11168
11484
  }
11169
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
11170
11485
  const CHROMEH = CM("#c9cdd0", { metalness: 0.85, roughness: 0.25 });
11171
11486
  const CHROMEB = CM("#d4d8db", { metalness: 0.5, roughness: 0.24 });
11172
11487
  const VINYL = "#2e2622";
@@ -11678,7 +11993,8 @@ var GameUrbanThree = (() => {
11678
11993
  [1.75, 0.8],
11679
11994
  [0.6, 0.82],
11680
11995
  [-0.6, 0.835],
11681
- [-1.82, 0.85]
11996
+ // it ends where the taillight wraps onto the side, never running into the lamp
11997
+ [-1.6, 0.845]
11682
11998
  ],
11683
11999
  { col: hex, h: 0.024 }
11684
12000
  );
@@ -19497,7 +19813,8 @@ var GameUrbanThree = (() => {
19497
19813
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
19498
19814
  for (let j = 0; j <= nv; j++) {
19499
19815
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
19500
- row.push({ p: s.p.addScaledVector(s.n, of), n: s.n, uv: [i / nu * su, o.tile ? (y - G2.y0) * sv0 : j / nv] });
19816
+ 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;
19817
+ 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] });
19501
19818
  }
19502
19819
  Q.push(row);
19503
19820
  }
@@ -19817,6 +20134,7 @@ var GameUrbanThree = (() => {
19817
20134
  };
19818
20135
  return K;
19819
20136
  }
20137
+ const glassDivisions = /* @__PURE__ */ new WeakMap();
19820
20138
  function car(c, s) {
19821
20139
  const W = s.W, gh = s.gh, bev = 0.05, T = { belt: gh.belt, top: gh.roof + bev, k: gh.k }, m = c.meta;
19822
20140
  m.color = s.col;
@@ -19850,6 +20168,9 @@ var GameUrbanThree = (() => {
19850
20168
  ghItems.push([gh.ft, gh.roof, gh.r2 || 0.2], [gh.fb, gh.belt - 0.1, 0]);
19851
20169
  let polys = windows(gh);
19852
20170
  if (s.dropRear) polys = polys.slice(1);
20171
+ const divided = splitSidePolys(polys, doorGlassSplits(gh, s.wheels ?? []));
20172
+ polys = divided.polys;
20173
+ glassDivisions.set(c, divided.used);
19853
20174
  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);
19854
20175
  const gHoles = [];
19855
20176
  if (intr) {
@@ -19910,6 +20231,8 @@ var GameUrbanThree = (() => {
19910
20231
  rb: gh.rb,
19911
20232
  rt: gh.rt,
19912
20233
  roof: gh.roof + 0.02,
20234
+ roofRear: (gh.roofR || gh.roof) + 0.02,
20235
+ roofCrown: gh.crown || 0,
19913
20236
  belt: gh.belt,
19914
20237
  floor: s.bottomY + 0.02,
19915
20238
  seatH: 0.12,
@@ -20002,19 +20325,21 @@ var GameUrbanThree = (() => {
20002
20325
  K.plate(-1, s.plateR || (bR.y0 + bR.y1) / 2 + 0.03, { off: s.plateROnBumper === false ? 4e-3 : 0.018 });
20003
20326
  const tang = Math.atan(gh.Wg / 2 * gh.k / (T.top - T.belt));
20004
20327
  [1, -1].forEach(function(sd) {
20005
- ;
20006
- (s.blackPillars || []).forEach(function(px) {
20328
+ const bar = function(px, width) {
20007
20329
  const ry = roofAt(gh, px), yc = (gh.belt + ry) / 2 + 5e-3, hh = ry - gh.belt - 0.1;
20008
- c.roundBox(0.118, hh, 3e-3, 15e-4, GLOSS, px, yc, sd * (halfAt(gh.Wg, T, yc) + 4e-3), { rot: [-sd * tang, 0, 0] }).castShadow = false;
20330
+ 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] });
20331
+ m2.castShadow = false;
20332
+ return m2;
20333
+ };
20334
+ (s.blackPillars || []).forEach((px) => bar(px, 0.118));
20335
+ (glassDivisions.get(c) ?? []).forEach((px) => {
20336
+ bar(px, 2 * DIVISION_HALF - 2e-3).userData.doorChannel = true;
20009
20337
  });
20010
20338
  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;
20011
20339
  c.roundBox(0.16, 0.05, 0.08, 0.02, MT.trim, mx + 0.03, my - 0.04, sd * (mz0 + 0.03));
20012
20340
  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 } });
20013
20341
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
20014
20342
  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));
20015
- (s.seams || []).forEach(function(x) {
20016
- 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));
20017
- });
20018
20343
  (s.handles || []).forEach(function(x) {
20019
20344
  c.roundBox(
20020
20345
  0.15,
@@ -20029,7 +20354,8 @@ var GameUrbanThree = (() => {
20029
20354
  });
20030
20355
  if (s.arches && s.arches.length > 1) {
20031
20356
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
20032
- c.roundBox(x1 - x0, 0.08, 0.035, 0.015, MT.trim, (x0 + x1) / 2, by + 0.05, sd * (hw - 8e-3));
20357
+ const mouldingG = sideGrid(S, sd, { x0, x1, y0: by + 5e-3, y1: by + 0.12 });
20358
+ 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 }));
20033
20359
  if (s.clad)
20034
20360
  s.arches.forEach(function(a) {
20035
20361
  const a0 = Math.asin(clamp4((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));
@@ -20082,6 +20408,19 @@ var GameUrbanThree = (() => {
20082
20408
  });
20083
20409
  underbody(c, s, I);
20084
20410
  if (s.extra) s.extra(c, I);
20411
+ c.vehicle.updateMatrixWorld(true);
20412
+ [1, -1].forEach(function(sd) {
20413
+ const side = bodySide(THREE, c, S, sd);
20414
+ const edges = doorEdgesOf(gh, s.wheels ?? []);
20415
+ (s.seams || []).forEach(function(x) {
20416
+ const pts = shutLinePoints(side, seamOnDoorEdge(x, edges), by + 0.11, gh.belt - 0.03);
20417
+ if (pts.length < 3) return;
20418
+ const seam = markFinishDetail(c.tube(pts, SHUT_LINE_RADIUS, MT.dark, { seg: 72, rs: 5 }));
20419
+ seam.castShadow = false;
20420
+ seam.userData.doorSeam = true;
20421
+ c.deform.push(seam);
20422
+ });
20423
+ });
20085
20424
  if (!c.parts.some(function(p) {
20086
20425
  return p.kind === "engine";
20087
20426
  }))
@@ -20201,36 +20540,23 @@ var GameUrbanThree = (() => {
20201
20540
  });
20202
20541
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
20203
20542
  function yAt(u) {
20204
- const x = x0 + (x1 - x0) * u;
20205
- for (let i = 0; i < pts.length - 1; i++) {
20206
- const a = pts[i], b = pts[i + 1];
20207
- if ((x - a[0]) * (x - b[0]) <= 0) {
20208
- const t = (x - a[0]) / (b[0] - a[0] || 1);
20209
- return a[1] + (b[1] - a[1]) * sm(t);
20210
- }
20211
- }
20212
- return pts[pts.length - 1][1];
20543
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
20213
20544
  }
20214
- I.K.skin(Gd, o.mat || c.paint(o.col), {
20545
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
20215
20546
  yb: function(u) {
20216
20547
  return yAt(u) - h;
20217
20548
  },
20218
20549
  yt: yAt,
20219
- off: o.off || 6e-3,
20220
- thick: 9e-3,
20221
- nv: 2,
20550
+ off: o.off || 2e-3,
20551
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
20552
+ crease: 30,
20553
+ nv: 5,
20222
20554
  u0: o.u0 || 0.01,
20223
20555
  u1: o.u1 || 0.99
20224
20556
  });
20225
- const l = [];
20226
- for (let k = 0; k <= 30; k++) {
20227
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
20228
- l.push([u, yAt(u) - h - 1e-3]);
20229
- }
20230
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
20557
+ markRaised(c, markFinishDetail(fold));
20231
20558
  return Gd;
20232
20559
  }
20233
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
20234
20560
  function dloChrome(c, I, sd, pts, r) {
20235
20561
  const gh = I.gh, T = I.T, P = pts.map(function(q) {
20236
20562
  return [q[0], q[1], sd * (halfAt(gh.Wg, T, q[1]) + 0.012)];
@@ -21288,12 +21614,10 @@ var GameUrbanThree = (() => {
21288
21614
  I,
21289
21615
  sd,
21290
21616
  [
21291
- [1, 0.47],
21292
- [0, 0.5],
21293
- [-0.9, 0.6],
21294
- [-1.2, 0.66]
21617
+ [0.86, 0.52],
21618
+ [-0.98, 0.52]
21295
21619
  ],
21296
- { col: "#8b939a", h: 0.035 }
21620
+ { col: "#8b939a", h: 0.03 }
21297
21621
  );
21298
21622
  });
21299
21623
  }
@@ -29115,6 +29439,7 @@ var GameUrbanThree = (() => {
29115
29439
  tl: P.tl,
29116
29440
  grille: P.grille,
29117
29441
  seams: P.seams,
29442
+ shell: shellM,
29118
29443
  handles: P.handles,
29119
29444
  wheels: [
29120
29445
  [A.xf, P.wr, 0.24, { rim: P.rim }],
@@ -42663,8 +42988,8 @@ gl_Position = projectionMatrix * mvPosition;
42663
42988
  const draw = (THREE, build, kit, buildSeed) => {
42664
42989
  const b = kit.builder({ seed: buildSeed });
42665
42990
  build(b, kit);
42666
- const document = options.document ?? globalThis.document;
42667
- const drawn = createUrbanThree(THREE, { ...document ? { document } : {}, resolvers: resolversFor(THREE), ...lightsOption() }).draw(b.scene());
42991
+ const document2 = options.document ?? globalThis.document;
42992
+ const drawn = createUrbanThree(THREE, { ...document2 ? { document: document2 } : {}, resolvers: resolversFor(THREE), ...lightsOption() }).draw(b.scene());
42668
42993
  return { root: drawn.root, drawn };
42669
42994
  };
42670
42995
  const sample = (THREE, key) => {
@@ -42721,8 +43046,8 @@ gl_Position = projectionMatrix * mvPosition;
42721
43046
  if ((settings.providers === "vehicles" || settings.providers === "both") && !options.vehicles) host.log(text2.log.no_vehicles);
42722
43047
  const b = kit.builder({ seed: settings.seed });
42723
43048
  const made = kit.neighbourhoods.get(settings.pattern).compose(b, { x: 0, z: 0 }, { locale, providers: providersOf(settings.providers) });
42724
- const document = options.document ?? globalThis.document;
42725
- const drawn = createUrbanThree(three, { ...document ? { document } : {}, resolvers: resolversFor(three), ...lightsOption() }).draw(b.scene());
43049
+ const document2 = options.document ?? globalThis.document;
43050
+ const drawn = createUrbanThree(three, { ...document2 ? { document: document2 } : {}, resolvers: resolversFor(three), ...lightsOption() }).draw(b.scene());
42726
43051
  drawn.root.position.set(benchOrigin[0], FLOOR_Y, benchOrigin[1]);
42727
43052
  host.scene.add(drawn.root);
42728
43053
  bench = { root: drawn.root, drawn, plan: made };