@adatechnology/game-items-three 0.8.1 → 0.8.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.
@@ -15220,7 +15220,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15220
15220
  ricochetDeg: 10,
15221
15221
  hitDebris: "chips",
15222
15222
  breakDebris: "dust",
15223
- visual: { innerColor: 12085567 },
15223
+ visual: { innerColor: 12085567, unitColor: 11031866 },
15224
15224
  thermal: {
15225
15225
  conductivity: 0.15,
15226
15226
  heatCapacity: 2.5
@@ -16163,6 +16163,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16163
16163
  var MEMBER_CRATER_CALIBRES = 3.4;
16164
16164
  var MEMBER_BARED_MAX = 24;
16165
16165
  var MEMBER_CUT_LOSS = 0.9;
16166
+ var MEMBER_UNIT_LOSS = 0.25;
16166
16167
  var BLAST_EDGE_WEAR = 0.6;
16167
16168
  var RESIDUAL_CAPACITY = 0.15;
16168
16169
  var SEVER_BAND = 0.1;
@@ -16175,6 +16176,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16175
16176
  var BREACH_GRID_CAP = 4096;
16176
16177
  var MASONRY_CRUMBLE_SPEED = 0.6;
16177
16178
  var TILE_CLUMPS = 160;
16179
+ var TILE_THICKNESS = 0.018;
16178
16180
  var PANEL_EDGE_PILLAR = 2;
16179
16181
  var PANEL_EDGE_BASE = 4;
16180
16182
  var PANEL_EDGE_BEAM = 3;
@@ -17287,10 +17289,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17287
17289
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
17288
17290
  const cells = grid.filter((cell, i) => worn[i] !== -1 && !(op && p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius));
17289
17291
  const { c } = partXf(o, p);
17290
- const fragments = cells.length > 0 ? [
17291
- ...cellFragments(o, p, clumpUnits(cells, p.thin, unitSpan(p), isTiledCover(p) ? TILE_CLUMPS : unitClumps), vec.add(c, [0, 1, 0]), null, MASONRY_CRUMBLE_SPEED, p.st.mass, "m_", true),
17292
- ...plasterFlakes(o, p, cells, vec.add(c, [0, 1, 0]), MASONRY_CRUMBLE_SPEED, "mp_")
17293
- ] : [];
17292
+ const tiles = isTiledCover(p);
17293
+ const pieces = cellFragments(o, p, clumpUnits(cells, p.thin, unitSpan(p), tiles ? TILE_CLUMPS : unitClumps), vec.add(c, [0, 1, 0]), null, MASONRY_CRUMBLE_SPEED, p.st.mass, "m_", true);
17294
+ const fragments = cells.length === 0 ? [] : tiles ? pieces.map((f) => ({ ...f, shape: "shard", size: f.size.map((x, k) => k === p.thin ? Math.min(x, TILE_THICKNESS) : x) })) : [...pieces, ...plasterFlakes(o, p, cells, vec.add(c, [0, 1, 0]), MASONRY_CRUMBLE_SPEED, "mp_")];
17294
17295
  p.st.status = "broken";
17295
17296
  p.st.hp = 0;
17296
17297
  p.st.mass = 0;
@@ -18164,6 +18165,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18164
18165
  const faceArea = (cell) => cell.size[u] * cell.size[v];
18165
18166
  const total = cells.reduce((sum, cell) => sum + faceArea(cell), 0) || 1;
18166
18167
  const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
18168
+ const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
18167
18169
  return cells.map((cell, i) => {
18168
18170
  const cw = toWorld(c, q, cell.center);
18169
18171
  const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
@@ -18182,7 +18184,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18182
18184
  angularVelocity: [(rnd() - 0.5) * 8, (rnd() - 0.5) * 8, (rnd() - 0.5) * 8],
18183
18185
  mass: mass * faceArea(cell) / total,
18184
18186
  ...marks.length > 0 ? { marks } : {},
18185
- ...inner ? { inner } : {}
18187
+ ...inner && laid ? { unit: true } : inner ? { inner } : {}
18186
18188
  };
18187
18189
  });
18188
18190
  };
@@ -18258,10 +18260,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18258
18260
  if (!cells?.length) return false;
18259
18261
  const [u, v] = planeAxes(p.thin);
18260
18262
  const lp = toLocal(p.pos, p.q, objectPoint);
18263
+ if (p.spec.reinforcement && isMember(p.dims) && !p.st.stripped) {
18264
+ const along = p.dims.indexOf(Math.max(...p.dims));
18265
+ const bands = Math.max(1, Math.round(p.dims[along] / MEMBER_BAND));
18266
+ const band = clamp2(Math.floor((lp[along] + p.dims[along] / 2) / p.dims[along] * bands), 0, bands - 1);
18267
+ if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
18268
+ }
18261
18269
  return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
18262
18270
  };
18263
18271
  const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
18264
- var _a, _b;
18272
+ var _a, _b, _c, _d;
18265
18273
  if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
18266
18274
  const along = p.dims.indexOf(Math.max(...p.dims));
18267
18275
  const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
@@ -18293,19 +18301,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18293
18301
  exposeRebar(o, p, src);
18294
18302
  }
18295
18303
  }
18296
- if (before >= MEMBER_CUT_LOSS || after < MEMBER_CUT_LOSS) return true;
18297
- const axisUp = rotateVec(p.q, [0, 0, 0].map((_, k) => k === along ? 1 : 0));
18298
- const standing = Math.abs(axisUp[1]) > 0.7;
18299
- const upward = axisUp[1] >= 0 ? 1 : -1;
18300
18304
  const grid = gridOf(p);
18301
- const gone = p.rt.chips ?? {};
18305
+ const gone = (_c = p.rt).chips ?? (_c.chips = {});
18306
+ if (before >= MEMBER_CUT_LOSS || after < MEMBER_CUT_LOSS) {
18307
+ if (h <= REBAR_COVER) return true;
18308
+ const [u, v] = planeAxes(p.thin);
18309
+ const hit = grid.findIndex((cell2, i) => gone[i] !== -1 && Math.abs(lp[u] - cell2.center[u]) <= cell2.size[u] / 2 && Math.abs(lp[v] - cell2.center[v]) <= cell2.size[v] / 2);
18310
+ if (hit < 0) return true;
18311
+ const wear = (_d = p.rt).cellWear ?? (_d.cellWear = {});
18312
+ const cell = grid[hit];
18313
+ wear[hit] = (wear[hit] ?? 0) + volume;
18314
+ if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
18315
+ return true;
18316
+ }
18302
18317
  const out = [];
18303
18318
  for (let i = 0; i < grid.length; i++) {
18304
18319
  if (gone[i] === -1) continue;
18305
- const at2 = grid[i].center[along];
18306
- const inBand = Math.abs(at2 - bandCenter) <= height / 2 + 1e-6;
18307
- const above = standing && (at2 - bandCenter) * upward > height / 2;
18308
- if (inBand || above) out.push(i);
18320
+ if (Math.abs(grid[i].center[along] - bandCenter) <= height / 2 + 1e-6) out.push(i);
18309
18321
  }
18310
18322
  if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
18311
18323
  giveAtCut(o, p, src);
@@ -18780,6 +18792,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18780
18792
  return;
18781
18793
  }
18782
18794
  if (!force && giveAtCut(o, p, src)) return;
18795
+ if (!force && isTiledCover(p)) {
18796
+ crumbleMasonry(o, p, src);
18797
+ return;
18798
+ }
18783
18799
  const ex = p.spec.explodes;
18784
18800
  const style = force ?? (p.snap ? "snap" : p.mat.fracture === "none" ? "snap" : p.mat.fracture);
18785
18801
  const { c, q } = partXf(o, p);
@@ -20801,6 +20817,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20801
20817
  return loads;
20802
20818
  }
20803
20819
  var isBearing = (part) => part.role === "column" || part.role === "wall";
20820
+ function isRoofFrame2(part) {
20821
+ return part.role === "roof" || part.id.startsWith("rafter");
20822
+ }
20804
20823
  function sizeCapacities(parts, supports, options) {
20805
20824
  const loads = loadsAtRest(parts, supports);
20806
20825
  const worst = /* @__PURE__ */ new Map();
@@ -20814,7 +20833,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20814
20833
  for (const part of parts) {
20815
20834
  const load = loads.get(part.id);
20816
20835
  if (load === void 0 || part.role === "none") continue;
20817
- const factor = isBearing(part) ? Math.max(1 / options.safety, (worst.get(part.id) ?? 1) / options.redundancy) : 1 / options.safetyOthers;
20836
+ const afterLoss = (worst.get(part.id) ?? 1) / options.redundancy;
20837
+ const factor = isBearing(part) ? Math.max(1 / options.safety, afterLoss) : isRoofFrame2(part) ? Math.max(1 / options.safetyOthers, afterLoss) : 1 / options.safetyOthers;
20818
20838
  capacities.set(part.id, Math.max(1, load * factor));
20819
20839
  }
20820
20840
  return capacities;
@@ -23524,7 +23544,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23524
23544
  }
23525
23545
  var residentialTower = residentialTowerTemplate();
23526
23546
 
23527
- // ../game-floorplan-three/dist/chunk-EWU252NT.js
23547
+ // ../game-floorplan-three/dist/chunk-HDRFS5H2.js
23528
23548
  var __defProp3 = Object.defineProperty;
23529
23549
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
23530
23550
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -24595,7 +24615,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24595
24615
  }
24596
24616
  const wref = R.walls.find((w) => w.floor === f && w.axis === j.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS3), th = wref ? wref.thickness || 0.15 : 0.15, t = 0.05, tt = th + 0.02;
24597
24617
  const bar2 = (u0, y_0, u1, y_1, mat, color2, tw = tt) => alongU ? bx(mat, u0, y0 + y_0, L - tw / 2, u1, y0 + y_1, L + tw / 2, color2) : bx(mat, L - tw / 2, y0 + y_0, u0, L + tw / 2, y0 + y_1, u1, color2);
24598
- cursor.pc = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f });
24618
+ const frame2 = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f });
24619
+ cursor.pc = frame2;
24599
24620
  bar2(a, ya, a + t, yb, "metal", fr);
24600
24621
  bar2(b - t, ya, b, yb, "metal", fr);
24601
24622
  bar2(a, ya, b, ya + t, "metal", fr);
@@ -24608,6 +24629,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24608
24629
  const am = (sd) => roomAt(f, alongU ? j.at : L + sd * 0.4, alongU ? L + sd * 0.4 : j.at);
24609
24630
  const outside = !am(1) ? 1 : !am(-1) ? -1 : 0;
24610
24631
  if (outside) {
24632
+ cursor.pc = frame2;
24611
24633
  const off = outside * (th / 2 + 0.03);
24612
24634
  if (alongU) bx("plaster", a - 0.05, y0 + ya - 0.04, L + (outside > 0 ? th / 2 : -th / 2 - 0.08), b + 0.05, y0 + ya, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), pe_);
24613
24635
  else bx("plaster", L + (outside > 0 ? th / 2 : -th / 2 - 0.08), y0 + ya - 0.04, a - 0.05, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), y0 + ya, b + 0.05, pe_);
@@ -24623,6 +24645,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24623
24645
  else bx("metal", L + go - 0.012, y0 + y, a, L + go + 0.012, y0 + y + 0.025, b, g);
24624
24646
  }
24625
24647
  }
24648
+ cursor.pc = null;
24626
24649
  }
24627
24650
  if (j.boards && !boardItems.has(j.id) && !cut) {
24628
24651
  const inside2 = -(outside || -1), off = inside2 * (th / 2 + 0.04), n = Math.max(3, Math.round((yb - ya) / 0.16));
@@ -25555,7 +25578,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25555
25578
  const { UV_SCALE, _Y, _h2, _q, accFor, cursor, put, rgbOf, structurePiece } = K;
25556
25579
  const sh = (...a) => K.sh(...a);
25557
25580
  const R_STYLE = () => shared2.ctx.r && shared2.ctx.r.style || "budget";
25558
- function tileRelief(mat, pts, color2, type) {
25581
+ function tileRelief(mat, pts, color2, type, origin) {
25559
25582
  const n = pts.length;
25560
25583
  if (n < 3) return;
25561
25584
  const [a, b, c] = pts;
@@ -25589,7 +25612,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25589
25612
  ex /= el;
25590
25613
  ey /= el;
25591
25614
  ez /= el;
25592
- const o = pts[0], S = [], T2 = [];
25615
+ const o = origin ?? pts[0], S = [], T2 = [];
25593
25616
  for (const p of pts) {
25594
25617
  const rx = p[0] - o[0], ry = p[1] - o[1], rz = p[2] - o[2];
25595
25618
  S.push(rx * ex + ry * ey + rz * ez);
@@ -25654,6 +25677,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25654
25677
  AC.nv += m * 2;
25655
25678
  }
25656
25679
  function ridge(a, b, type, roofColor) {
25680
+ const cuts = K.cfg.destruction ? baysAlong(a, b) : [];
25681
+ if (cuts.length) {
25682
+ let from = a;
25683
+ for (const f of [...cuts, 1]) {
25684
+ const to = [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f];
25685
+ ridgeCap(from, to, type, roofColor);
25686
+ from = to;
25687
+ }
25688
+ return;
25689
+ }
25690
+ ridgeCap(a, b, type, roofColor);
25691
+ }
25692
+ function ridgeCap(a, b, type, roofColor) {
25657
25693
  cursor.pc = pieceOfPane((a[0] + b[0]) / 2, (a[2] + b[2]) / 2);
25658
25694
  const dx = b[0] - a[0], dy = b[1] - a[1], dz = b[2] - a[2], Ln = Math.hypot(dx, dy, dz);
25659
25695
  if (Ln < 0.05) return;
@@ -25680,7 +25716,81 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25680
25716
  }
25681
25717
  return m ? structurePiece(m.id) : null;
25682
25718
  }
25683
- const defined = { R_STYLE, tileRelief, ridge, pieceOfPane };
25719
+ function paneTiles(mat, pts, color2, type) {
25720
+ const panes = panesUnder(pts), whole = centroidPiece(pts);
25721
+ if (panes.length < 2 || !whole || !K.cfg.destruction) {
25722
+ cursor.pc = whole;
25723
+ tileRelief(mat, pts, color2, type);
25724
+ return;
25725
+ }
25726
+ for (const r of panes) {
25727
+ const part = clipToRect(pts, r);
25728
+ if (part.length < 3 || planArea(part) < 1e-4) continue;
25729
+ cursor.pc = centroidPiece(part);
25730
+ tileRelief(mat, part, color2, type, pts[0]);
25731
+ }
25732
+ }
25733
+ function centroidPiece(pts) {
25734
+ let cx = 0, cz = 0;
25735
+ for (const p of pts) {
25736
+ cx += p[0];
25737
+ cz += p[2];
25738
+ }
25739
+ return pieceOfPane(cx / pts.length, cz / pts.length);
25740
+ }
25741
+ function panesUnder(pts) {
25742
+ if (shared2.ctx.noPiece || !shared2.ctx.panes.length) return [];
25743
+ let x0 = Infinity, z0 = Infinity, x1 = -Infinity, z1 = -Infinity;
25744
+ for (const p of pts) {
25745
+ x0 = Math.min(x0, p[0]);
25746
+ x1 = Math.max(x1, p[0]);
25747
+ z0 = Math.min(z0, p[2]);
25748
+ z1 = Math.max(z1, p[2]);
25749
+ }
25750
+ const boxes = shared2.ctx.panes.map((a) => a.aabb).filter((b) => !!b && b[0] < x1 - 1e-4 && b[2] > x0 + 1e-4 && b[1] < z1 - 1e-4 && b[3] > z0 + 1e-4);
25751
+ if (boxes.length < 2) return boxes;
25752
+ const lo = [Math.min(...boxes.map((b) => b[0])), Math.min(...boxes.map((b) => b[1]))], hi = [Math.max(...boxes.map((b) => b[2])), Math.max(...boxes.map((b) => b[3]))];
25753
+ return boxes.map((b) => [b[0] <= lo[0] + 1e-6 ? -Infinity : b[0], b[1] <= lo[1] + 1e-6 ? -Infinity : b[1], b[2] >= hi[0] - 1e-6 ? Infinity : b[2], b[3] >= hi[1] - 1e-6 ? Infinity : b[3]]);
25754
+ }
25755
+ function baysAlong(a, b) {
25756
+ const rects = panesUnder([a, b, [b[0] + 1e-3, b[1], b[2] + 1e-3], [a[0] - 1e-3, a[1], a[2] - 1e-3]]);
25757
+ const alongX = Math.abs(b[0] - a[0]) >= Math.abs(b[2] - a[2]), i = alongX ? 0 : 2, k = alongX ? 0 : 1, span = b[i] - a[i];
25758
+ if (Math.abs(span) < 1e-6) return [];
25759
+ const cuts = /* @__PURE__ */ new Set();
25760
+ for (const r of rects) for (const v of [r[k], r[k + 2]]) {
25761
+ const f = (v - a[i]) / span;
25762
+ if (Number.isFinite(f) && f > 0.01 && f < 0.99) cuts.add(+f.toFixed(4));
25763
+ }
25764
+ return [...cuts].sort((p, q) => p - q);
25765
+ }
25766
+ function clipToRect(pts, r) {
25767
+ let poly = pts.map((p) => [p[0], p[1], p[2]]);
25768
+ const edges = [[0, r[0], 1], [0, r[2], -1], [2, r[1], 1], [2, r[3], -1]];
25769
+ for (const [axis, at2, sign2] of edges) {
25770
+ if (!Number.isFinite(at2)) continue;
25771
+ const out = [];
25772
+ for (let i = 0; i < poly.length; i++) {
25773
+ const p = poly[i], q = poly[(i + 1) % poly.length], dp = (p[axis] - at2) * sign2, dq = (q[axis] - at2) * sign2;
25774
+ if (dp >= 0) out.push(p);
25775
+ if (dp >= 0 !== dq >= 0) {
25776
+ const t = dp / (dp - dq);
25777
+ out.push([p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t, p[2] + (q[2] - p[2]) * t]);
25778
+ }
25779
+ }
25780
+ poly = out;
25781
+ if (poly.length < 3) return [];
25782
+ }
25783
+ return poly;
25784
+ }
25785
+ function planArea(pts) {
25786
+ let a = 0;
25787
+ for (let i = 0; i < pts.length; i++) {
25788
+ const p = pts[i], q = pts[(i + 1) % pts.length];
25789
+ a += p[0] * q[2] - q[0] * p[2];
25790
+ }
25791
+ return Math.abs(a) / 2;
25792
+ }
25793
+ const defined = { R_STYLE, tileRelief, paneTiles, ridge, pieceOfPane };
25684
25794
  Object.assign(K, defined);
25685
25795
  }
25686
25796
  function installRoofRect(K, shared2) {
@@ -25689,15 +25799,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25689
25799
  function roofRect(type, X0, Z0, X1, Z1, yb, roofColor, gable, F, touchesU = [0, 0, 0, 0]) {
25690
25800
  const C = shared2.ctx.colors, o = type === "fiber_cement" ? 0.3 : 0.45, x0 = X0 - (touchesU[0] ? 0 : o), x1 = X1 + (touchesU[2] ? 0 : o), z0 = Z0 - (touchesU[1] ? 0 : o), z1 = Z1 + (touchesU[3] ? 0 : o), dx = x1 - x0, dz = z1 - z0, xm = (x0 + x1) / 2, zm = (z0 + z1) / 2;
25691
25801
  const mat = type === "fiber_cement" ? "fiber_cement" : "tile", tp = type === "fiber_cement" ? 0.2 : 0.5, alongX = dx >= dz, up = [0, 1, 0];
25692
- const Q = (pts) => {
25693
- let cx = 0, cz = 0;
25694
- for (const p of pts) {
25695
- cx += p[0];
25696
- cz += p[2];
25697
- }
25698
- cursor.pc = pieceOfPane(cx / pts.length, cz / pts.length);
25699
- return tileRelief(mat, pts, roofColor, type);
25700
- };
25802
+ const Q = (pts) => K.paneTiles(mat, pts, roofColor, type);
25701
25803
  cursor.pc = pieceOfPane(xm, zm);
25702
25804
  {
25703
25805
  const wt = 0.075, yc = yb - 0.2, cf = C.facade != null ? C.facade : 14209216, fas = R_STYLE() === "budget" ? 7228980 : sh(roofColor, 0.55), sof = 15131352, tz = 0.035;
@@ -29981,6 +30083,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29981
30083
  var SPALL_MIN = 0.025;
29982
30084
  var SPALL_RAGGED = 0.045;
29983
30085
  var COVER2 = 0.015;
30086
+ var LUMP_BAR_INSET = 0.035;
30087
+ var LUMPS_PER_BAR = 2;
30088
+ var LUMP_CHANCE = 0.6;
30089
+ var LUMP_MIN = 0.025;
30090
+ var LUMP_MAX = 0.05;
30091
+ var EDGE_LUMPS = 3;
30092
+ var EDGE_LUMP_MIN = 0.04;
30093
+ var EDGE_LUMP_MAX = 0.08;
29984
30094
  var MAX_FLAKES = 64;
29985
30095
  function clipToBox(unit, box4) {
29986
30096
  const lo = [Math.max(unit.x - unit.sx / 2, box4[0]), Math.max(unit.y - unit.sy / 2, box4[1]), Math.max(unit.z - unit.sz / 2, box4[2])];
@@ -30026,6 +30136,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30026
30136
  const dropped = [];
30027
30137
  let lod = 0;
30028
30138
  const unitGeometry = new THREE.BoxGeometry(1, 1, 1);
30139
+ let lumpShape = null;
30140
+ const lumpGeometry = () => {
30141
+ if (lumpShape) return lumpShape;
30142
+ const g = new THREE.IcosahedronGeometry(0.62, 0).toNonIndexed();
30143
+ const at2 = g.getAttribute("position");
30144
+ const moved = /* @__PURE__ */ new Map();
30145
+ for (let i = 0; i < at2.count; i++) {
30146
+ const key2 = `${at2.getX(i).toFixed(3)},${at2.getY(i).toFixed(3)},${at2.getZ(i).toFixed(3)}`;
30147
+ let k = moved.get(key2);
30148
+ if (k === void 0) {
30149
+ const x = Math.sin(moved.size * 12.9898 + 4.1) * 43758.5453;
30150
+ k = 0.7 + 0.45 * (x - Math.floor(x));
30151
+ moved.set(key2, k);
30152
+ }
30153
+ at2.setXYZ(i, at2.getX(i) * k, at2.getY(i) * k * 0.85, at2.getZ(i) * k);
30154
+ }
30155
+ g.computeVertexNormals();
30156
+ lumpShape = g;
30157
+ return g;
30158
+ };
30029
30159
  const tmp = { m: new THREE.Matrix4(), q: new THREE.Quaternion(), p: new THREE.Vector3(), s: new THREE.Vector3(), c: new THREE.Color() };
30030
30160
  const local = (p) => {
30031
30161
  house.updateMatrixWorld(true);
@@ -30201,6 +30331,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30201
30331
  const discs = [];
30202
30332
  const flakes = [];
30203
30333
  const shown = [];
30334
+ const castGone = [];
30204
30335
  const pillars = pillarSpans(view);
30205
30336
  for (const id of view.parts) {
30206
30337
  const part = structure.byId.get(id), units2 = specOf(id).units, chips = view.chips.get(id), opening = view.openings.get(id), spalls = view.spalls.get(id);
@@ -30208,6 +30339,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30208
30339
  const all = id === view.host ? own.flatMap((c) => besidePillars(c, pillars)) : own;
30209
30340
  if (view.fallen.has(id)) {
30210
30341
  holes.push(...all);
30342
+ view.kept.set(id, []);
30211
30343
  continue;
30212
30344
  }
30213
30345
  const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
@@ -30225,6 +30357,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30225
30357
  const open = (c) => gone(c) || opening !== void 0 && Math.hypot((c.a + c.b) / 2 - along(opening.center), (c.y0 + c.y1) / 2 - opening.center[1]) < opening.radius;
30226
30358
  const kept = [];
30227
30359
  for (const c of all) (open(c) ? holes : kept).push(c);
30360
+ view.kept.set(id, kept);
30361
+ if (units2.mortar === part.material) {
30362
+ for (const c of all) if (!kept.includes(c)) castGone.push({ c, part, thick, mid });
30363
+ }
30228
30364
  for (const c of kept) shown.push({ c, part, units: units2, thick, mid });
30229
30365
  for (const box4 of boxes) {
30230
30366
  if (holes.some((h) => box4.s0 >= h.a - 1e-4 && box4.s1 <= h.b + 1e-4 && box4.y0 >= h.y0 - 1e-4 && box4.y1 <= h.y1 + 1e-4)) continue;
@@ -30285,10 +30421,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30285
30421
  at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
30286
30422
  }
30287
30423
  }
30288
- if (view.units) {
30289
- view.units.removeFromParent();
30290
- view.units.dispose();
30291
- }
30424
+ const lumps = stuckLumps(castGone, mask, view.bounds);
30425
+ if (view.units) dropUnits(view.units);
30292
30426
  const units = new THREE.InstancedMesh(unitGeometry, view.unitMaterial, Math.max(1, list2.length));
30293
30427
  units.name = "breach:" + view.host;
30294
30428
  list2.forEach((u, i) => {
@@ -30302,6 +30436,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30302
30436
  units.castShadow = true;
30303
30437
  units.receiveShadow = true;
30304
30438
  units.visible = lod === 0;
30439
+ if (lumps.length > 0) units.add(lumpMesh(lumps, view.unitMaterial));
30305
30440
  house.add(units);
30306
30441
  view.units = units;
30307
30442
  view.gone = holes.length;
@@ -30341,9 +30476,70 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30341
30476
  spalls: new Map(parts.map((id) => [id, []])),
30342
30477
  openings: /* @__PURE__ */ new Map(),
30343
30478
  flakes: 0,
30344
- fallen: /* @__PURE__ */ new Set()
30479
+ fallen: /* @__PURE__ */ new Set(),
30480
+ kept: /* @__PURE__ */ new Map()
30345
30481
  };
30346
30482
  }
30483
+ function stuckLumps(gone, mask, bounds2) {
30484
+ const out = [];
30485
+ const grey = fragmentMaterial("concrete").color.getHex();
30486
+ for (const { c, part, thick, mid } of gone) {
30487
+ const p0 = (mask.alongU ? part.aabb[0] : part.aabb[1]) - mask.start, p1 = (mask.alongU ? part.aabb[2] : part.aabb[3]) - mask.start;
30488
+ for (const [edge, k0] of [[c.y0, 0], [c.y1, 4]]) {
30489
+ for (let k = k0; k < k0 + EDGE_LUMPS; k++) {
30490
+ const r = (n) => {
30491
+ const x = Math.sin(c.a * 63.1 + edge * 29.7 + mid * 17.3 + k * 5.3 + n * 2.9) * 43758.5453;
30492
+ return x - Math.floor(x);
30493
+ };
30494
+ const size = EDGE_LUMP_MIN + (EDGE_LUMP_MAX - EDGE_LUMP_MIN) * r(1);
30495
+ const centre = mask.start + c.a + (0.1 + 0.8 * r(2)) * (c.b - c.a), d = mid + (r(3) - 0.5) * (thick - 2 * LUMP_BAR_INSET);
30496
+ const unit = clipToBox({ x: mask.alongU ? centre : d, y: edge, z: mask.alongU ? d : centre, sx: size, sy: size * (0.6 + 0.5 * r(4)), sz: size, colour: tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(5)).getHex() }, bounds2);
30497
+ if (unit) out.push(unit);
30498
+ }
30499
+ }
30500
+ const bars = [p0 + LUMP_BAR_INSET, p1 - LUMP_BAR_INSET].filter((s) => s >= c.a - 1e-6 && s <= c.b + 1e-6);
30501
+ for (const s of bars) {
30502
+ for (const side of [-1, 1]) {
30503
+ const d = mid + side * (thick / 2 - LUMP_BAR_INSET);
30504
+ for (let k = 0; k < LUMPS_PER_BAR; k++) {
30505
+ const r = (n) => {
30506
+ const x = Math.sin(s * 91.7 + d * 47.3 + c.y0 * 113.1 + k * 7.9 + n * 3.3) * 43758.5453;
30507
+ return x - Math.floor(x);
30508
+ };
30509
+ if (r(1) > LUMP_CHANCE) continue;
30510
+ const y = c.y0 + (0.15 + 0.7 * r(2)) * (c.y1 - c.y0);
30511
+ const sa = LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(3), sy = LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(4), sd = LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(5);
30512
+ const centre = mask.start + s + (r(6) - 0.5) * 0.02;
30513
+ const unit = clipToBox({ x: mask.alongU ? centre : d, y, z: mask.alongU ? d : centre, sx: mask.alongU ? sa : sd, sy, sz: mask.alongU ? sd : sa, colour: tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex() }, bounds2);
30514
+ if (unit) out.push(unit);
30515
+ }
30516
+ }
30517
+ }
30518
+ }
30519
+ return out;
30520
+ }
30521
+ function dropUnits(units) {
30522
+ for (const child of [...units.children]) if (child instanceof THREE.InstancedMesh) child.dispose();
30523
+ units.removeFromParent();
30524
+ units.dispose();
30525
+ }
30526
+ function lumpMesh(lumps, material) {
30527
+ const mesh2 = new THREE.InstancedMesh(lumpGeometry(), material, lumps.length);
30528
+ mesh2.name = "breach-lumps";
30529
+ lumps.forEach((u, i) => {
30530
+ const r = (n) => {
30531
+ const x = Math.sin(u.x * 71.3 + u.y * 37.9 + u.z * 53.1 + n * 9.7) * 43758.5453;
30532
+ return x - Math.floor(x);
30533
+ };
30534
+ tmp.q.setFromEuler(new THREE.Euler(r(1) * Math.PI, r(2) * Math.PI, r(3) * Math.PI));
30535
+ tmp.m.compose(tmp.p.set(u.x, u.y, u.z), tmp.q, tmp.s.set(u.sx, u.sy, u.sz));
30536
+ mesh2.setMatrixAt(i, tmp.m);
30537
+ mesh2.setColorAt(i, tmp.c.setHex(u.colour));
30538
+ });
30539
+ mesh2.castShadow = true;
30540
+ mesh2.receiveShadow = true;
30541
+ return mesh2;
30542
+ }
30347
30543
  function cut(view) {
30348
30544
  if (view.saved) return;
30349
30545
  view.shells = view.items.map((it) => shell(it, view.mask));
@@ -30428,10 +30624,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30428
30624
  paintQueues.add(queue);
30429
30625
  function dispose(view) {
30430
30626
  dirty.delete(view);
30431
- if (view.units) {
30432
- view.units.removeFromParent();
30433
- view.units.dispose();
30434
- }
30627
+ if (view.units) dropUnits(view.units);
30435
30628
  view.unitMaterial.dispose();
30436
30629
  for (const m of view.shells) {
30437
30630
  m.removeFromParent();
@@ -30442,6 +30635,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30442
30635
  view.core.texture.dispose();
30443
30636
  }
30444
30637
  return {
30638
+ /**
30639
+ * What still stands of the units of `partId` once its wall is cut, as drawn: spans along the wall from `start` (in the house's space, along u when
30640
+ * `alongU`) and up. Null while the wall is whole (all of the part stands).
30641
+ */
30642
+ standing(partId) {
30643
+ const hostId = hostOf(partId), view = hostId ? views.get(hostId) : void 0;
30644
+ const spans = view?.saved ? view.kept.get(partId) : void 0;
30645
+ return view && spans ? { spans, alongU: view.mask.alongU, start: view.mask.start } : null;
30646
+ },
30445
30647
  /** Handles a `stage` event of the house's object. Returns true when the wall was cut. */
30446
30648
  stage(event) {
30447
30649
  return event.stage === 2 && !!event.opening ? draw(event.part, { opening: event.opening }) : false;
@@ -30836,13 +31038,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30836
31038
  breach.flush(Infinity);
30837
31039
  }, FOLLOW_FLUSH_FALLBACK_MS);
30838
31040
  });
31041
+ const holders = /* @__PURE__ */ new Map();
31042
+ const holderOf = (pid) => {
31043
+ const known = holders.get(pid) ?? id;
31044
+ if (world.part(known, pid)) return known;
31045
+ for (const other of world.ids()) if (world.part(other, pid)) {
31046
+ holders.set(pid, other);
31047
+ return other;
31048
+ }
31049
+ return null;
31050
+ };
31051
+ const at2 = new THREE.Vector3(), turn = new THREE.Quaternion();
31052
+ const inSpec = (objectId, x, y, z) => {
31053
+ const o = world.state(objectId);
31054
+ if (!o) return null;
31055
+ const r = o.rotation;
31056
+ return at2.set(x - o.position[0], y - o.position[1], z - o.position[2]).applyQuaternion(turn.set(r[0], r[1], r[2], r[3]).invert());
31057
+ };
31058
+ const blocks = (x, z, radius, y0, y1) => {
31059
+ for (const part of structure.parts) {
31060
+ const holder = holderOf(part.id), state = holder ? world.part(holder, part.id) : null;
31061
+ if (!holder || !state || state.status !== "intact" && state.status !== "damaged" && state.status !== "collapsed") continue;
31062
+ const low = inSpec(holder, x, y0, z);
31063
+ if (!low) continue;
31064
+ const ly0 = low.y, high = inSpec(holder, x, y1, z), ly1 = high.y, lx = high.x, lz = high.z;
31065
+ if (part.y1 <= Math.min(ly0, ly1) || part.y0 >= Math.max(ly0, ly1)) continue;
31066
+ const [u0, v0, u1, v1] = part.aabb, du = Math.max(u0 - lx, 0, lx - u1), dv = Math.max(v0 - lz, 0, lz - v1);
31067
+ if (du * du + dv * dv >= radius * radius) continue;
31068
+ const left = breach.standing(part.id);
31069
+ if (!left) return true;
31070
+ const s0 = (left.alongU ? lx : lz) - left.start;
31071
+ if (left.spans.some((c) => c.b > s0 - radius && c.a < s0 + radius && c.y1 > Math.min(ly0, ly1) && c.y0 < Math.max(ly0, ly1))) return true;
31072
+ }
31073
+ return false;
31074
+ };
31075
+ const owns = (objectId) => objectId === id || [...holders.values()].includes(objectId);
30839
31076
  return { restore: () => breach.restore(), dispose: () => {
30840
31077
  offFollow();
30841
31078
  breach.restore();
30842
31079
  breach.release();
30843
31080
  }, update: () => {
30844
31081
  breach.flush();
30845
- } };
31082
+ }, blocks, owns };
30846
31083
  };
30847
31084
  D.piece = (id) => D.active ? D.world.part(D.id, id) : null;
30848
31085
  D.state = () => D.active ? D.world.state(D.id) : null;