@adatechnology/game-urban-three 0.5.9 → 0.5.11

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.
@@ -5146,6 +5146,26 @@ var GameUrbanThree = (() => {
5146
5146
  var engine = defaultFloorplan();
5147
5147
 
5148
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
+ }
5149
5169
  var DIVISION_HALF = 0.02;
5150
5170
  var GLASS_IN_FROM_EDGE = 0.03;
5151
5171
  var CUT_EPS = 1e-6;
@@ -10296,6 +10316,55 @@ var GameUrbanThree = (() => {
10296
10316
  pane2.userData.sunroof = { slide };
10297
10317
  return pane2;
10298
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
+ }
10299
10368
  function installCarsExtra(fx) {
10300
10369
  const kit = fx.kit;
10301
10370
  const THREE = kit.THREE;
@@ -10634,7 +10703,8 @@ var GameUrbanThree = (() => {
10634
10703
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
10635
10704
  for (let j = 0; j <= nv; j++) {
10636
10705
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
10637
- 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] });
10638
10708
  }
10639
10709
  Q.push(row);
10640
10710
  }
@@ -11181,11 +11251,6 @@ var GameUrbanThree = (() => {
11181
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 } });
11182
11252
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
11183
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));
11184
- const edges = doorEdgesOf(gh, s.wheels ?? []);
11185
- (s.seams || []).forEach(function(q) {
11186
- 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;
11187
- doorSeam(c, S, sd, x, y0, y1);
11188
- });
11189
11254
  (s.handles || []).forEach(function(x) {
11190
11255
  c.roundBox(
11191
11256
  0.15,
@@ -11200,7 +11265,8 @@ var GameUrbanThree = (() => {
11200
11265
  });
11201
11266
  if (s.arches && s.arches.length > 1) {
11202
11267
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
11203
- 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 }));
11204
11270
  if (s.clad)
11205
11271
  s.arches.forEach(function(a) {
11206
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));
@@ -11266,6 +11332,20 @@ var GameUrbanThree = (() => {
11266
11332
  });
11267
11333
  underbody(c, s, I);
11268
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
+ });
11269
11349
  if (!c.parts.some(function(p) {
11270
11350
  return p.kind === "engine";
11271
11351
  }))
@@ -11339,18 +11419,6 @@ var GameUrbanThree = (() => {
11339
11419
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
11340
11420
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
11341
11421
  }
11342
- const SEAM_POINTS = 14;
11343
- function doorSeam(c, S, sd, x, y0, y1) {
11344
- const pts = [];
11345
- for (let k = 0; k <= SEAM_POINTS; k++) {
11346
- 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");
11347
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
11348
- }
11349
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
11350
- t.castShadow = false;
11351
- t.userData.doorSeam = true;
11352
- return t;
11353
- }
11354
11422
  function sm(t) {
11355
11423
  t = clamp4(t, 0, 1);
11356
11424
  return t * t * (3 - 2 * t);
@@ -11397,36 +11465,23 @@ var GameUrbanThree = (() => {
11397
11465
  });
11398
11466
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
11399
11467
  function yAt(u) {
11400
- const x = x0 + (x1 - x0) * u;
11401
- for (let i = 0; i < pts.length - 1; i++) {
11402
- const a = pts[i], b = pts[i + 1];
11403
- if ((x - a[0]) * (x - b[0]) <= 0) {
11404
- const t = (x - a[0]) / (b[0] - a[0] || 1);
11405
- return a[1] + (b[1] - a[1]) * sm(t);
11406
- }
11407
- }
11408
- return pts[pts.length - 1][1];
11468
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
11409
11469
  }
11410
- I.K.skin(Gd, o.mat || c.paint(o.col), {
11470
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
11411
11471
  yb: function(u) {
11412
11472
  return yAt(u) - h;
11413
11473
  },
11414
11474
  yt: yAt,
11415
- off: o.off || 6e-3,
11416
- thick: 9e-3,
11417
- nv: 2,
11475
+ off: o.off || 2e-3,
11476
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
11477
+ crease: 30,
11478
+ nv: 5,
11418
11479
  u0: o.u0 || 0.01,
11419
11480
  u1: o.u1 || 0.99
11420
11481
  });
11421
- const l = [];
11422
- for (let k = 0; k <= 30; k++) {
11423
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
11424
- l.push([u, yAt(u) - h - 1e-3]);
11425
- }
11426
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
11482
+ markRaised(c, markFinishDetail(fold));
11427
11483
  return Gd;
11428
11484
  }
11429
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
11430
11485
  const CHROMEH = CM("#c9cdd0", { metalness: 0.85, roughness: 0.25 });
11431
11486
  const CHROMEB = CM("#d4d8db", { metalness: 0.5, roughness: 0.24 });
11432
11487
  const VINYL = "#2e2622";
@@ -19758,7 +19813,8 @@ var GameUrbanThree = (() => {
19758
19813
  const u = u0 + (u1 - u0) * i / nu, b = yb(u), t = yt(u), row = [];
19759
19814
  for (let j = 0; j <= nv; j++) {
19760
19815
  const y = b + (t - b) * j / nv, s = G2.at(u, y);
19761
- 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] });
19762
19818
  }
19763
19819
  Q.push(row);
19764
19820
  }
@@ -20284,11 +20340,6 @@ var GameUrbanThree = (() => {
20284
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 } });
20285
20341
  c.roundBox(0.02, 0.09, 0.16, 0.02, MT.chrome, mx - 0.065, my + 0.02, sd * (mz0 + 0.14));
20286
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));
20287
- const edges = doorEdgesOf(gh, s.wheels ?? []);
20288
- (s.seams || []).forEach(function(x0) {
20289
- const x = seamOnDoorEdge(x0, edges);
20290
- doorSeam(c, S, sd, x, by + 0.09, gh.belt - 0.03);
20291
- });
20292
20343
  (s.handles || []).forEach(function(x) {
20293
20344
  c.roundBox(
20294
20345
  0.15,
@@ -20303,7 +20354,8 @@ var GameUrbanThree = (() => {
20303
20354
  });
20304
20355
  if (s.arches && s.arches.length > 1) {
20305
20356
  const x0 = s.arches[1][0] + s.arches[1][2] + 0.02, x1 = s.arches[0][0] - s.arches[0][2] - 0.02;
20306
- 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 }));
20307
20359
  if (s.clad)
20308
20360
  s.arches.forEach(function(a) {
20309
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));
@@ -20356,6 +20408,19 @@ var GameUrbanThree = (() => {
20356
20408
  });
20357
20409
  underbody(c, s, I);
20358
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
+ });
20359
20424
  if (!c.parts.some(function(p) {
20360
20425
  return p.kind === "engine";
20361
20426
  }))
@@ -20429,18 +20494,6 @@ var GameUrbanThree = (() => {
20429
20494
  c.cylinder(0.07, 0.055, 0.1, MT.steel, x, y, z, "x");
20430
20495
  c.cylinder(0.06, 0.06, 0.012, MT.head, x + 0.055, y, z, "x");
20431
20496
  }
20432
- const SEAM_POINTS = 14;
20433
- function doorSeam(c, S, sd, x, y0, y1) {
20434
- const pts = [];
20435
- for (let k = 0; k <= SEAM_POINTS; k++) {
20436
- 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");
20437
- pts.push(h ? h.p.clone().addScaledVector(h.n, 1e-3) : new V3(x, y, sd * (S.hw + 1e-3)));
20438
- }
20439
- const t = c.tube(pts, 3e-3, MT.dark, { seg: SEAM_POINTS, rs: 4 });
20440
- t.castShadow = false;
20441
- t.userData.doorSeam = true;
20442
- return t;
20443
- }
20444
20497
  function sm(t) {
20445
20498
  t = clamp4(t, 0, 1);
20446
20499
  return t * t * (3 - 2 * t);
@@ -20487,36 +20540,23 @@ var GameUrbanThree = (() => {
20487
20540
  });
20488
20541
  const h = o.h || 0.03, Gd = sideGrid(I.S, sd, { x0, x1, y0: lo - h - 0.03, y1: hi + 0.03 });
20489
20542
  function yAt(u) {
20490
- const x = x0 + (x1 - x0) * u;
20491
- for (let i = 0; i < pts.length - 1; i++) {
20492
- const a = pts[i], b = pts[i + 1];
20493
- if ((x - a[0]) * (x - b[0]) <= 0) {
20494
- const t = (x - a[0]) / (b[0] - a[0] || 1);
20495
- return a[1] + (b[1] - a[1]) * sm(t);
20496
- }
20497
- }
20498
- return pts[pts.length - 1][1];
20543
+ return creaseHeightAt(pts, x0 + (x1 - x0) * u);
20499
20544
  }
20500
- I.K.skin(Gd, o.mat || c.paint(o.col), {
20545
+ const fold = I.K.skin(Gd, o.mat || c.paint(o.col), {
20501
20546
  yb: function(u) {
20502
20547
  return yAt(u) - h;
20503
20548
  },
20504
20549
  yt: yAt,
20505
- off: o.off || 6e-3,
20506
- thick: 9e-3,
20507
- nv: 2,
20550
+ off: o.off || 2e-3,
20551
+ ridge: { at: CREASE_FOLD_AT, lift: CREASE_FOLD_LIFT },
20552
+ crease: 30,
20553
+ nv: 5,
20508
20554
  u0: o.u0 || 0.01,
20509
20555
  u1: o.u1 || 0.99
20510
20556
  });
20511
- const l = [];
20512
- for (let k = 0; k <= 30; k++) {
20513
- const u = (o.u0 || 0.01) + k / 30 * ((o.u1 || 0.99) - (o.u0 || 0.01));
20514
- l.push([u, yAt(u) - h - 1e-3]);
20515
- }
20516
- lineOn(c, Gd, l, 3e-3, o.shade || SHADE, 3e-3);
20557
+ markRaised(c, markFinishDetail(fold));
20517
20558
  return Gd;
20518
20559
  }
20519
- const SHADE = CM("#000000", { roughness: 1, transparent: true, opacity: 0.45, depthWrite: false });
20520
20560
  function dloChrome(c, I, sd, pts, r) {
20521
20561
  const gh = I.gh, T = I.T, P = pts.map(function(q) {
20522
20562
  return [q[0], q[1], sd * (halfAt(gh.Wg, T, q[1]) + 0.012)];
@@ -21574,12 +21614,10 @@ var GameUrbanThree = (() => {
21574
21614
  I,
21575
21615
  sd,
21576
21616
  [
21577
- [1, 0.47],
21578
- [0, 0.5],
21579
- [-0.9, 0.6],
21580
- [-1.2, 0.66]
21617
+ [0.86, 0.52],
21618
+ [-0.98, 0.52]
21581
21619
  ],
21582
- { col: "#8b939a", h: 0.035 }
21620
+ { col: "#8b939a", h: 0.03 }
21583
21621
  );
21584
21622
  });
21585
21623
  }
@@ -29401,6 +29439,7 @@ var GameUrbanThree = (() => {
29401
29439
  tl: P.tl,
29402
29440
  grille: P.grille,
29403
29441
  seams: P.seams,
29442
+ shell: shellM,
29404
29443
  handles: P.handles,
29405
29444
  wheels: [
29406
29445
  [A.xf, P.wr, 0.24, { rim: P.rim }],