@adatechnology/game-items-three 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +957 -123
- package/dist/index.global.js.map +1 -1
- package/package.json +8 -8
package/dist/index.global.js
CHANGED
|
@@ -13625,21 +13625,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13625
13625
|
for (const row of rows.values()) for (const i of row) if (!held.has(i)) loose.push(i);
|
|
13626
13626
|
return loose;
|
|
13627
13627
|
};
|
|
13628
|
-
var
|
|
13628
|
+
var clumpUnits = (cells, thin, unit, cap) => {
|
|
13629
13629
|
if (cells.length <= cap) return [...cells];
|
|
13630
13630
|
const [u, v] = planeAxes(thin);
|
|
13631
|
-
let lo0 = Infinity, lo1 = Infinity
|
|
13631
|
+
let lo0 = Infinity, lo1 = Infinity;
|
|
13632
13632
|
for (const cell of cells) {
|
|
13633
13633
|
lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
|
|
13634
|
-
hi0 = Math.max(hi0, cell.center[u] + cell.size[u] / 2);
|
|
13635
13634
|
lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
|
|
13636
|
-
hi1 = Math.max(hi1, cell.center[v] + cell.size[v] / 2);
|
|
13637
13635
|
}
|
|
13638
|
-
let
|
|
13639
|
-
for (; ; ) {
|
|
13636
|
+
let along = 1, up = 1;
|
|
13637
|
+
for (let grow = 0; ; grow++) {
|
|
13640
13638
|
const bins = /* @__PURE__ */ new Map();
|
|
13641
13639
|
for (const cell of cells) {
|
|
13642
|
-
const key2 = `${Math.floor((cell.center[u] - lo0) /
|
|
13640
|
+
const key2 = `${Math.floor((cell.center[u] - lo0) / (along * unit[0]))}:${Math.floor((cell.center[v] - lo1) / (up * unit[1]))}`;
|
|
13643
13641
|
const bin = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
|
|
13644
13642
|
for (let k = 0; k < 3; k++) {
|
|
13645
13643
|
bin.lo[k] = Math.min(bin.lo[k], cell.center[k] - cell.size[k] / 2);
|
|
@@ -13650,7 +13648,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13650
13648
|
if (bins.size <= cap) {
|
|
13651
13649
|
return [...bins.values()].map(({ lo, hi }) => ({ center: [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2], size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]] }));
|
|
13652
13650
|
}
|
|
13653
|
-
|
|
13651
|
+
if (grow % 2 === 0) up++;
|
|
13652
|
+
else along++;
|
|
13654
13653
|
}
|
|
13655
13654
|
};
|
|
13656
13655
|
var MAX_SPALLS = 64;
|
|
@@ -13719,6 +13718,39 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13719
13718
|
for (const x of spread(dims[u], COVER, spacing, MAX_BARS_PER_DIRECTION)) out.push(bar(v, dims[v] / 2 - 0.02, [[u, x], [thin, 0]]));
|
|
13720
13719
|
return out;
|
|
13721
13720
|
};
|
|
13721
|
+
var STIRRUP_SPACING = 0.15;
|
|
13722
|
+
var memberStirrups = (dims, spacing = STIRRUP_SPACING) => {
|
|
13723
|
+
if (!isMember(dims)) return [];
|
|
13724
|
+
const long = dims.indexOf(Math.max(...dims));
|
|
13725
|
+
const [u = 0, v = 0] = [0, 1, 2].filter((i) => i !== long);
|
|
13726
|
+
const hu = dims[u] / 2 - COVER, hv = dims[v] / 2 - COVER;
|
|
13727
|
+
const out = [];
|
|
13728
|
+
for (const s of spread(dims[long], 0.05, spacing, 200)) {
|
|
13729
|
+
const corner = (x, y) => {
|
|
13730
|
+
const c = [0, 0, 0];
|
|
13731
|
+
c[long] = s;
|
|
13732
|
+
c[u] = x;
|
|
13733
|
+
c[v] = y;
|
|
13734
|
+
return c;
|
|
13735
|
+
};
|
|
13736
|
+
out.push([corner(-hu, -hv), corner(hu, -hv)], [corner(hu, -hv), corner(hu, hv)], [corner(hu, hv), corner(-hu, hv)], [corner(-hu, hv), corner(-hu, -hv)]);
|
|
13737
|
+
}
|
|
13738
|
+
return out;
|
|
13739
|
+
};
|
|
13740
|
+
var clipBarsToVolume = (bars, center, size) => {
|
|
13741
|
+
const out = [];
|
|
13742
|
+
for (const [a, b] of bars) {
|
|
13743
|
+
const axis = [0, 1, 2].find((k) => a[k] !== b[k]) ?? 0;
|
|
13744
|
+
if ([0, 1, 2].some((k) => k !== axis && Math.abs(a[k] - center[k]) > size[k] / 2 + 1e-6)) continue;
|
|
13745
|
+
const lo = Math.max(Math.min(a[axis], b[axis]), center[axis] - size[axis] / 2), hi = Math.min(Math.max(a[axis], b[axis]), center[axis] + size[axis] / 2);
|
|
13746
|
+
if (hi - lo < 1e-6) continue;
|
|
13747
|
+
const p = [a[0], a[1], a[2]], q = [b[0], b[1], b[2]];
|
|
13748
|
+
p[axis] = lo;
|
|
13749
|
+
q[axis] = hi;
|
|
13750
|
+
out.push([p, q]);
|
|
13751
|
+
}
|
|
13752
|
+
return out;
|
|
13753
|
+
};
|
|
13722
13754
|
var clipBarsToBox = (bars, u, v, center, size) => {
|
|
13723
13755
|
const out = [];
|
|
13724
13756
|
for (const [a, b] of bars) {
|
|
@@ -14132,6 +14164,120 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14132
14164
|
const stable = converged && cholesky3(ev.Jt, [0, 0, 0]) !== null;
|
|
14133
14165
|
return { s, a, b, stable, yielded: ev.yielded, bearing: capSum > 0 ? weight / capSum : Infinity, edge: ev.edge, residual: [ev.r[0], ev.r[1], ev.r[2]] };
|
|
14134
14166
|
};
|
|
14167
|
+
function voidRuns(flags, step) {
|
|
14168
|
+
const runs = [];
|
|
14169
|
+
let start = -1;
|
|
14170
|
+
for (let i = 0; i <= flags.length; i++) {
|
|
14171
|
+
if (i < flags.length && flags[i]) {
|
|
14172
|
+
if (start < 0) start = i;
|
|
14173
|
+
continue;
|
|
14174
|
+
}
|
|
14175
|
+
if (start >= 0) runs.push({ start: start * step, end: i * step });
|
|
14176
|
+
start = -1;
|
|
14177
|
+
}
|
|
14178
|
+
return runs;
|
|
14179
|
+
}
|
|
14180
|
+
var PILLAR_REACH = 0.15;
|
|
14181
|
+
var pillarNear = (pillars, at2) => pillars.some((p) => Math.abs(p - at2) <= PILLAR_REACH);
|
|
14182
|
+
function splitAtPillars(runs, pillars) {
|
|
14183
|
+
const out = [];
|
|
14184
|
+
for (const run of runs) {
|
|
14185
|
+
const inside2 = pillars.filter((p) => p > run.start + PILLAR_REACH && p < run.end - PILLAR_REACH).sort((a, b) => a - b);
|
|
14186
|
+
let from = run.start;
|
|
14187
|
+
for (const p of inside2) {
|
|
14188
|
+
out.push({ start: from, end: p });
|
|
14189
|
+
from = p;
|
|
14190
|
+
}
|
|
14191
|
+
out.push({ start: from, end: run.end });
|
|
14192
|
+
}
|
|
14193
|
+
return out;
|
|
14194
|
+
}
|
|
14195
|
+
function mergeRuns(runs, check2) {
|
|
14196
|
+
let list2 = [...runs];
|
|
14197
|
+
for (let changed = true; changed; ) {
|
|
14198
|
+
changed = false;
|
|
14199
|
+
for (let k = 0; k <= list2.length && !changed; k++) {
|
|
14200
|
+
const before = list2[k - 1];
|
|
14201
|
+
const after = list2[k];
|
|
14202
|
+
const from = before ? before.end : 0;
|
|
14203
|
+
const to = after ? after.start : check2.length;
|
|
14204
|
+
const soil = to - from;
|
|
14205
|
+
if (soil <= 0 || !before && !after) continue;
|
|
14206
|
+
if (check2.pillars.some((p) => p >= from - PILLAR_REACH && p <= to + PILLAR_REACH)) continue;
|
|
14207
|
+
if (!before && check2.continuous?.[0] || !after && check2.continuous?.[1]) continue;
|
|
14208
|
+
const reaction = (before ? (before.end - before.start) / 2 : 0) + (after ? (after.end - after.start) / 2 : 0);
|
|
14209
|
+
const narrow = soil < check2.depth;
|
|
14210
|
+
const weak = reaction > (check2.soilSafety - 1) * soil;
|
|
14211
|
+
if (!narrow && !weak) continue;
|
|
14212
|
+
const merged2 = { start: before ? before.start : 0, end: after ? after.end : check2.length };
|
|
14213
|
+
list2 = [...list2.slice(0, Math.max(0, k - 1)), merged2, ...list2.slice(after ? k + 1 : k)];
|
|
14214
|
+
changed = true;
|
|
14215
|
+
}
|
|
14216
|
+
}
|
|
14217
|
+
return list2;
|
|
14218
|
+
}
|
|
14219
|
+
function judgeBeam(flags, step, check2) {
|
|
14220
|
+
const merged2 = mergeRuns(voidRuns(flags, step), check2);
|
|
14221
|
+
const runs = splitAtPillars(merged2, check2.pillars);
|
|
14222
|
+
const behind = (run, fromStart) => fromStart ? (merged2.find((m) => m.start >= run.end - 1e-9)?.start ?? check2.length) - run.end : run.start - ([...merged2].reverse().find((m) => m.end <= run.start + 1e-9)?.end ?? 0);
|
|
14223
|
+
const verdicts = [];
|
|
14224
|
+
let tips = false;
|
|
14225
|
+
for (const run of runs) {
|
|
14226
|
+
const span = run.end - run.start;
|
|
14227
|
+
const freeStart = run.start <= 1e-9 && !pillarNear(check2.pillars, 0) && !check2.continuous?.[0];
|
|
14228
|
+
const freeEnd = run.end >= check2.length - 1e-9 && !pillarNear(check2.pillars, check2.length) && !check2.continuous?.[1];
|
|
14229
|
+
if (freeStart && freeEnd) {
|
|
14230
|
+
verdicts.push({ ...run, kind: "cantilever", span, moment: Infinity, holds: false, cracks: true });
|
|
14231
|
+
tips = true;
|
|
14232
|
+
continue;
|
|
14233
|
+
}
|
|
14234
|
+
const cantilever = freeStart || freeEnd;
|
|
14235
|
+
const moment = (cantilever ? check2.load * span * span / 2 : check2.load * span * span / 8) * check2.loadFactor;
|
|
14236
|
+
const reach = cantilever ? check2.spanDepth * check2.depth / 2 : check2.spanDepth * check2.depth;
|
|
14237
|
+
const balanced = !cantilever || span <= behind(run, freeStart);
|
|
14238
|
+
const rooted = cantilever && pillarNear(check2.pillars, freeStart ? run.end : run.start);
|
|
14239
|
+
const held = cantilever && !!check2.continuous?.[freeStart ? 1 : 0];
|
|
14240
|
+
const holds2 = span <= reach && moment <= check2.resists && (balanced || rooted);
|
|
14241
|
+
verdicts.push({ ...run, kind: cantilever ? "cantilever" : "span", span, moment, holds: holds2, cracks: moment > check2.cracking });
|
|
14242
|
+
if (cantilever && !holds2 && !balanced && !rooted && !held) tips = true;
|
|
14243
|
+
}
|
|
14244
|
+
return { runs: verdicts, tips };
|
|
14245
|
+
}
|
|
14246
|
+
function judgePlate(check2) {
|
|
14247
|
+
const a = check2.across;
|
|
14248
|
+
const moment = (check2.load * a * a / 8 + check2.points.reduce((sum, p) => sum + p.weight * a / 4, 0)) * check2.loadFactor;
|
|
14249
|
+
const d = Math.max(0.01, check2.effectiveDepth);
|
|
14250
|
+
const punched = check2.points.some((p) => p.weight * check2.loadFactor / (4 * (p.side + d) * d) > check2.punching);
|
|
14251
|
+
return { holds: moment <= check2.resists && !punched, cracks: moment > check2.cracking, moment, punched };
|
|
14252
|
+
}
|
|
14253
|
+
var cross = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
|
14254
|
+
function convexHull(points) {
|
|
14255
|
+
const sorted = [...points].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
14256
|
+
if (sorted.length < 3) return sorted;
|
|
14257
|
+
const lower = [];
|
|
14258
|
+
for (const p of sorted) {
|
|
14259
|
+
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0) lower.pop();
|
|
14260
|
+
lower.push(p);
|
|
14261
|
+
}
|
|
14262
|
+
const upper = [];
|
|
14263
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
14264
|
+
const p = sorted[i];
|
|
14265
|
+
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], p) <= 0) upper.pop();
|
|
14266
|
+
upper.push(p);
|
|
14267
|
+
}
|
|
14268
|
+
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
|
14269
|
+
}
|
|
14270
|
+
function restsOver(point, contacts, margin) {
|
|
14271
|
+
const hull = convexHull(contacts);
|
|
14272
|
+
if (hull.length < 3) return false;
|
|
14273
|
+
for (let i = 0; i < hull.length; i++) {
|
|
14274
|
+
const a = hull[i];
|
|
14275
|
+
const b = hull[(i + 1) % hull.length];
|
|
14276
|
+
const length = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1;
|
|
14277
|
+
if (cross(a, b, point) / length < margin) return false;
|
|
14278
|
+
}
|
|
14279
|
+
return true;
|
|
14280
|
+
}
|
|
14135
14281
|
var GROUND_LOSS_DEFAULTS = {
|
|
14136
14282
|
footingDepth: 0.5,
|
|
14137
14283
|
spread: 1,
|
|
@@ -14139,6 +14285,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14139
14285
|
maxSettlement: 0.05,
|
|
14140
14286
|
crackDistortion: 1 / 300,
|
|
14141
14287
|
damageDistortion: 1 / 150,
|
|
14288
|
+
bearingCrackDistortion: 1 / 500,
|
|
14289
|
+
bearingDamageDistortion: 1 / 300,
|
|
14142
14290
|
distortionDamage: 0.3,
|
|
14143
14291
|
bridgeSpanDepth: 10,
|
|
14144
14292
|
beamRebarRatio: 4e-3
|
|
@@ -14158,33 +14306,77 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14158
14306
|
const steepest = loss.radius * loss.radius / (2 * loss.depth * spread2);
|
|
14159
14307
|
return Math.max(0, cut(reach), cut(Math.min(reach, steepest)), cut(0));
|
|
14160
14308
|
};
|
|
14161
|
-
var
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
continue;
|
|
14168
|
-
}
|
|
14169
|
-
if (start >= 0 && (!best || i - start > best.end - best.start)) best = { start, end: i };
|
|
14170
|
-
start = -1;
|
|
14171
|
-
}
|
|
14172
|
-
return best;
|
|
14309
|
+
var relativeToChord = (drops) => {
|
|
14310
|
+
const n = drops.length;
|
|
14311
|
+
if (n < 2) return drops.map(() => 0);
|
|
14312
|
+
const first = drops[0];
|
|
14313
|
+
const last = drops[n - 1];
|
|
14314
|
+
return drops.map((v, k) => v - (first + (last - first) * k / (n - 1)));
|
|
14173
14315
|
};
|
|
14174
14316
|
var distortionOf = (drops, step) => {
|
|
14175
14317
|
const span = Math.max(1, Math.round(DISTORTION_BASE / step));
|
|
14176
14318
|
let value = 0;
|
|
14177
14319
|
let at2 = 0;
|
|
14320
|
+
let down = 1;
|
|
14178
14321
|
for (let i = 0; i < drops.length; i++) {
|
|
14179
14322
|
const j = Math.min(drops.length - 1, i + span);
|
|
14180
14323
|
if (j === i) continue;
|
|
14181
|
-
const
|
|
14324
|
+
const change = drops[j] - drops[i];
|
|
14325
|
+
const beta = Math.abs(change) / Math.max((j - i) * step, DISTORTION_BASE);
|
|
14182
14326
|
if (beta > value) {
|
|
14183
14327
|
value = beta;
|
|
14184
14328
|
at2 = (i + j) / 2;
|
|
14329
|
+
down = change >= 0 ? 1 : -1;
|
|
14185
14330
|
}
|
|
14186
14331
|
}
|
|
14187
|
-
return { value, at: at2 };
|
|
14332
|
+
return { value, at: at2, down };
|
|
14333
|
+
};
|
|
14334
|
+
var smoothProfile = (drops, step, window) => {
|
|
14335
|
+
const half = Math.max(0, Math.round(window / step / 2));
|
|
14336
|
+
return drops.map((_, k) => {
|
|
14337
|
+
let sum = 0;
|
|
14338
|
+
let count = 0;
|
|
14339
|
+
for (let i = Math.max(0, k - half); i <= Math.min(drops.length - 1, k + half); i++) {
|
|
14340
|
+
sum += drops[i];
|
|
14341
|
+
count++;
|
|
14342
|
+
}
|
|
14343
|
+
return sum / count;
|
|
14344
|
+
});
|
|
14345
|
+
};
|
|
14346
|
+
var BEAM_SPREAD = 1;
|
|
14347
|
+
var SETTLEMENT_POINTS = 24;
|
|
14348
|
+
var settlementProfile = (drops, step) => {
|
|
14349
|
+
const n = drops.length;
|
|
14350
|
+
if (n === 0) return [0, 0];
|
|
14351
|
+
const length = n * step;
|
|
14352
|
+
const count = Math.max(2, Math.min(SETTLEMENT_POINTS, n + 1));
|
|
14353
|
+
const out = [];
|
|
14354
|
+
for (let k = 0; k < count; k++) {
|
|
14355
|
+
const at2 = clampNumber(k / (count - 1) * length / step - 0.5, 0, n - 1);
|
|
14356
|
+
const i = Math.floor(at2);
|
|
14357
|
+
const j = Math.min(n - 1, i + 1);
|
|
14358
|
+
out.push(drops[i] + (drops[j] - drops[i]) * (at2 - i));
|
|
14359
|
+
}
|
|
14360
|
+
return out;
|
|
14361
|
+
};
|
|
14362
|
+
var clampNumber = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
14363
|
+
var settlementAt = (settlement, point) => {
|
|
14364
|
+
const d = [settlement.to[0] - settlement.from[0], settlement.to[1] - settlement.from[1], settlement.to[2] - settlement.from[2]];
|
|
14365
|
+
const length2 = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
|
|
14366
|
+
const t = length2 > 0 ? clampNumber(((point[0] - settlement.from[0]) * d[0] + (point[1] - settlement.from[1]) * d[1] + (point[2] - settlement.from[2]) * d[2]) / length2, 0, 1) : 0;
|
|
14367
|
+
const drops = settlement.drop;
|
|
14368
|
+
if (drops.length === 0) return 0;
|
|
14369
|
+
const at2 = t * (drops.length - 1);
|
|
14370
|
+
const i = Math.floor(at2);
|
|
14371
|
+
const j = Math.min(drops.length - 1, i + 1);
|
|
14372
|
+
return drops[i] + (drops[j] - drops[i]) * (at2 - i);
|
|
14373
|
+
};
|
|
14374
|
+
var mergeSettlement = (old, next) => {
|
|
14375
|
+
if (!old) return next;
|
|
14376
|
+
const same = old.from.every((v, k) => Math.abs(v - next.from[k]) < 1e-6) && old.to.every((v, k) => Math.abs(v - next.to[k]) < 1e-6);
|
|
14377
|
+
if (same && old.drop.length === next.drop.length) return { from: old.from, to: old.to, drop: old.drop.map((v, k) => Math.max(v, next.drop[k])) };
|
|
14378
|
+
const mean = (line) => line.drop.reduce((sum, v) => sum + v, 0) / Math.max(1, line.drop.length);
|
|
14379
|
+
return mean(old) >= mean(next) ? old : next;
|
|
14188
14380
|
};
|
|
14189
14381
|
var wind_terrain_default = [
|
|
14190
14382
|
{ id: "I", zg: 250, b: { A: 1.1, B: 1.11, C: 1.12 }, p: { A: 0.06, B: 0.065, C: 0.07 }, z0: 5e-3 },
|
|
@@ -15981,6 +16173,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15981
16173
|
var SUPPORT_TOLERANCE = 0.05;
|
|
15982
16174
|
var UNIT_FRAGMENT_FACTOR = 4;
|
|
15983
16175
|
var BREACH_GRID_CAP = 4096;
|
|
16176
|
+
var MASONRY_CRUMBLE_SPEED = 0.6;
|
|
16177
|
+
var TILE_CLUMPS = 160;
|
|
16178
|
+
var TILE_THICKNESS = 0.018;
|
|
16179
|
+
var PANEL_EDGE_PILLAR = 2;
|
|
16180
|
+
var PANEL_EDGE_BASE = 4;
|
|
16181
|
+
var PANEL_EDGE_BEAM = 3;
|
|
16182
|
+
var PLASTER_FLAKE_AREA = 0.25;
|
|
16183
|
+
var MAX_PLASTER_FLAKES = 24;
|
|
15984
16184
|
var CHIP_ENERGY = 200;
|
|
15985
16185
|
var CHIP_SPLASH = 0.5;
|
|
15986
16186
|
var CRATER_SPENT = 0.6;
|
|
@@ -15991,7 +16191,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15991
16191
|
var DISTORTION_GROWTH = 1.2;
|
|
15992
16192
|
var MAX_SETTLEMENT_CRACKS = 4;
|
|
15993
16193
|
var SETTLEMENT_CRACK_LENGTH = 0.3;
|
|
16194
|
+
var SETTLEMENT_CRACK_SPACING = 0.4;
|
|
16195
|
+
var SETTLEMENT_CRACK_OPENING = 0.3;
|
|
16196
|
+
var MIN_CRACK_WIDTH = 5e-4;
|
|
16197
|
+
var MAX_CRACK_WIDTH = 0.02;
|
|
16198
|
+
var BESIDE_CRACK_OFFSET = 0.8;
|
|
16199
|
+
var BRICK_STEP = [0.2, 0.1];
|
|
16200
|
+
var SETTLEMENT_FOLLOW_DEPTH = 2;
|
|
15994
16201
|
var CRACKED_STIFFNESS = 0.4;
|
|
16202
|
+
var PILLAR_SEAT = 0.05;
|
|
16203
|
+
var PUNCHING_SHARE = 0.5;
|
|
16204
|
+
var ARCH_ANGLE = Math.PI / 3;
|
|
15995
16205
|
var CUT_SLICE = 1;
|
|
15996
16206
|
var cutFactorOf = (shape) => clamp2(Math.max(...shapeDims(shape)) / CUT_SLICE, 1, 50);
|
|
15997
16207
|
var clamp2 = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
@@ -16067,6 +16277,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16067
16277
|
for (const m of options.materials ?? []) materials.set(m.id, m);
|
|
16068
16278
|
const ambient = options.ambientC ?? 20;
|
|
16069
16279
|
const maxFragments = options.maxFragments ?? 24;
|
|
16280
|
+
const unitClumps = maxFragments * UNIT_FRAGMENT_FACTOR;
|
|
16281
|
+
const fallenClumps = Math.max(2, Math.round(unitClumps / 4));
|
|
16070
16282
|
const maxDents = options.maxDents ?? 24;
|
|
16071
16283
|
const maxHoles = options.maxHoles ?? 32;
|
|
16072
16284
|
const fireSpread = options.fireSpread ?? 0.6;
|
|
@@ -16377,6 +16589,61 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16377
16589
|
return (above + p.st.mass * share) / load;
|
|
16378
16590
|
};
|
|
16379
16591
|
};
|
|
16592
|
+
const contactsOf = (p, support) => {
|
|
16593
|
+
const box4 = contactBox(p, support);
|
|
16594
|
+
const broken = support.rt.broken;
|
|
16595
|
+
if (!broken?.length) return [box4];
|
|
16596
|
+
let pieces = [box4];
|
|
16597
|
+
for (const [axis, from, to] of broken) {
|
|
16598
|
+
const a = [p.pos[0], p.pos[1], p.pos[2]];
|
|
16599
|
+
const b = [p.pos[0], p.pos[1], p.pos[2]];
|
|
16600
|
+
a[axis] = from;
|
|
16601
|
+
b[axis] = to;
|
|
16602
|
+
const la = toLocal(p.pos, p.q, a);
|
|
16603
|
+
const lb = toLocal(p.pos, p.q, b);
|
|
16604
|
+
const k = [0, 1, 2].reduce((best, c) => Math.abs(lb[c] - la[c]) > Math.abs(lb[best] - la[best]) ? c : best, 0);
|
|
16605
|
+
const lo = Math.min(la[k], lb[k]);
|
|
16606
|
+
const hi = Math.max(la[k], lb[k]);
|
|
16607
|
+
pieces = pieces.flatMap(([min, max]) => {
|
|
16608
|
+
if (hi <= min[k] || lo >= max[k]) return [[min, max]];
|
|
16609
|
+
const out = [];
|
|
16610
|
+
if (lo > min[k]) {
|
|
16611
|
+
const end = [max[0], max[1], max[2]];
|
|
16612
|
+
end[k] = lo;
|
|
16613
|
+
out.push([min, end]);
|
|
16614
|
+
}
|
|
16615
|
+
if (hi < max[k]) {
|
|
16616
|
+
const start = [min[0], min[1], min[2]];
|
|
16617
|
+
start[k] = hi;
|
|
16618
|
+
out.push([start, max]);
|
|
16619
|
+
}
|
|
16620
|
+
return out;
|
|
16621
|
+
});
|
|
16622
|
+
}
|
|
16623
|
+
return pieces;
|
|
16624
|
+
};
|
|
16625
|
+
const fixedJoint = (j) => j.spec.kind === "rebar" || j.spec.kind === "fused" || j.spec.kind === "weld";
|
|
16626
|
+
const standsOver = (o, p, lower) => {
|
|
16627
|
+
const role = p.spec.structure?.role;
|
|
16628
|
+
if (role !== "slab" && role !== "roof" || p.spec.shape.kind !== "box" || lower.length === 0) return true;
|
|
16629
|
+
if (Math.abs(rotateVec(p.q, [0, 0, 0].map((_, k) => k === p.thin ? 1 : 0))[1]) < 0.9) return true;
|
|
16630
|
+
const i = o.idx.get(p.spec.id);
|
|
16631
|
+
for (const j of o.byPart.get(p.spec.id) ?? []) {
|
|
16632
|
+
if (j.st.open) continue;
|
|
16633
|
+
if (fixedJoint(j) && lower.includes(restsOn(o, j, i)) || j.spec.kind === "tie") return true;
|
|
16634
|
+
}
|
|
16635
|
+
const corners = [];
|
|
16636
|
+
for (const k of lower) {
|
|
16637
|
+
for (const [lo, hi] of contactsOf(p, o.parts[k])) {
|
|
16638
|
+
for (let c = 0; c < 4; c++) {
|
|
16639
|
+
const local = [c & 1 ? hi[0] : lo[0], (lo[1] + hi[1]) / 2, c & 2 ? hi[2] : lo[2]];
|
|
16640
|
+
const at2 = toWorld(p.pos, p.q, local);
|
|
16641
|
+
corners.push([at2[0], at2[2]]);
|
|
16642
|
+
}
|
|
16643
|
+
}
|
|
16644
|
+
}
|
|
16645
|
+
return restsOver([p.pos[0], p.pos[2]], corners, 0);
|
|
16646
|
+
};
|
|
16380
16647
|
const borneOn = (p, supports) => {
|
|
16381
16648
|
if (supports.length === 0) return void 0;
|
|
16382
16649
|
const boxes = supports.map((support) => contactBox(p, support));
|
|
@@ -16432,7 +16699,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16432
16699
|
const key2 = lower.join(",");
|
|
16433
16700
|
if (key2 !== p.spanKey) {
|
|
16434
16701
|
p.spanKey = key2;
|
|
16435
|
-
p.span = spanOf(g, lower.
|
|
16702
|
+
p.span = spanOf(g, lower.flatMap((k) => contactsOf(p, o.parts[k])));
|
|
16436
16703
|
}
|
|
16437
16704
|
p.restMoment = 0;
|
|
16438
16705
|
if (g.gravity < 0 || p.span <= 0) return 0;
|
|
@@ -16498,9 +16765,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16498
16765
|
};
|
|
16499
16766
|
const freeSpan = (p, supports) => {
|
|
16500
16767
|
if (supports.length === 0) return Infinity;
|
|
16768
|
+
if (p.spec.shape.kind === "box") {
|
|
16769
|
+
const g = bendGeometry(p.spec);
|
|
16770
|
+
if (!g.member) return spanOf(g, supports.flatMap((k) => contactsOf(p, k)));
|
|
16771
|
+
}
|
|
16501
16772
|
const d = p.dims;
|
|
16502
16773
|
const L = [0, 1, 2].sort((a, b) => d[b] - d[a])[0];
|
|
16503
|
-
const spans = supports.
|
|
16774
|
+
const spans = supports.flatMap((k) => contactsOf(p, k)).map(([lo, hi]) => [lo[L], hi[L]]);
|
|
16504
16775
|
let far = 0;
|
|
16505
16776
|
for (let i = 0; i <= 16; i++) {
|
|
16506
16777
|
const x = (i / 16 - 0.5) * d[L];
|
|
@@ -16550,7 +16821,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16550
16821
|
}
|
|
16551
16822
|
lowerOf.set(i, lower);
|
|
16552
16823
|
const max = parts[i].spec.structure?.maxSpan;
|
|
16553
|
-
|
|
16824
|
+
const tooLong = max !== void 0 && freeSpan(parts[i], lower.map((k) => parts[k])) > max;
|
|
16825
|
+
const standing = parts[i].heldAsDesigned || standsOver(o, parts[i], lower);
|
|
16826
|
+
if (o.seeding && !standing) parts[i].heldAsDesigned = true;
|
|
16827
|
+
if (!parts[i].anchored && (tooLong || !(standing || parts[i].heldAsDesigned))) {
|
|
16554
16828
|
out.add(i);
|
|
16555
16829
|
dropped = true;
|
|
16556
16830
|
}
|
|
@@ -17004,20 +17278,45 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17004
17278
|
if (!o.hasStructure || !o.parts.some((p) => p.anchored)) return;
|
|
17005
17279
|
if (!pendingCollapse.has(o)) pendingCollapse.set(o, src);
|
|
17006
17280
|
};
|
|
17281
|
+
const isLaidMasonry = (p) => !!p.spec.units && p.spec.units.mortar !== p.spec.material && !p.spec.reinforcement && !p.st.stripped;
|
|
17282
|
+
const isTiledCover = (p) => p.spec.structure?.role === "roof" && p.mat.fracture === "shatter" && !p.spec.reinforcement && !p.spec.units;
|
|
17283
|
+
const crumbleMasonry = (o, p, src) => {
|
|
17284
|
+
if (isLost(p)) return;
|
|
17285
|
+
const [u, v] = planeAxes(p.thin);
|
|
17286
|
+
const grid = gridOf(p);
|
|
17287
|
+
const worn = p.rt.chips ?? {};
|
|
17288
|
+
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
17289
|
+
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));
|
|
17290
|
+
const { c } = partXf(o, p);
|
|
17291
|
+
const tiles = isTiledCover(p);
|
|
17292
|
+
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);
|
|
17293
|
+
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
|
+
p.st.status = "broken";
|
|
17295
|
+
p.st.hp = 0;
|
|
17296
|
+
p.st.mass = 0;
|
|
17297
|
+
emit({ ...base(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
|
|
17298
|
+
debris(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
|
|
17299
|
+
setStage(o, p, 3, {}, src);
|
|
17300
|
+
partLost(o, p, src);
|
|
17301
|
+
};
|
|
17007
17302
|
const flushCollapse = () => {
|
|
17008
17303
|
for (const [o, src] of [...pendingCollapse]) {
|
|
17009
17304
|
pendingCollapse.delete(o);
|
|
17010
17305
|
if (!objects.has(o.id) || objects.get(o.id) !== o) continue;
|
|
17011
|
-
|
|
17306
|
+
const crumbling = [];
|
|
17307
|
+
for (const g of [...o.st.groups]) {
|
|
17012
17308
|
const ps = g.map((id) => o.byId.get(id)).filter((p) => !isLost(p) && !o.collapsed.has(p.spec.id));
|
|
17013
17309
|
if (ps.length === 0 || g.some((id) => o.byId.get(id).anchored) || !ps.some((p) => p.structural)) continue;
|
|
17014
|
-
|
|
17310
|
+
const whole2 = ps.filter((p) => !isLaidMasonry(p) && !isTiledCover(p));
|
|
17311
|
+
crumbling.push(...ps.filter((p) => isLaidMasonry(p) || isTiledCover(p)));
|
|
17312
|
+
for (const p of whole2) {
|
|
17015
17313
|
o.collapsed.add(p.spec.id);
|
|
17016
17314
|
p.st.status = "collapsed";
|
|
17017
17315
|
setStage(o, p, 3, {}, src);
|
|
17018
17316
|
}
|
|
17019
|
-
emit({ ...base(o, src), type: "collapse", parts:
|
|
17317
|
+
if (whole2.length > 0) emit({ ...base(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum, p) => sum + p.st.mass, 0) });
|
|
17020
17318
|
}
|
|
17319
|
+
for (const p of crumbling) crumbleMasonry(o, p, src);
|
|
17021
17320
|
}
|
|
17022
17321
|
};
|
|
17023
17322
|
const groundCfg = resolveGroundLoss(options.groundLoss);
|
|
@@ -17058,17 +17357,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17058
17357
|
let sum = 0;
|
|
17059
17358
|
let worst = -1;
|
|
17060
17359
|
let deepest = toWorld(o.st.position, o.st.rotation, [(box4.min[0] + box4.max[0]) / 2, box4.min[1], (box4.min[2] + box4.max[2]) / 2]);
|
|
17360
|
+
let voidBox = null;
|
|
17061
17361
|
for (let k = 0; k < n; k++) {
|
|
17062
17362
|
let open = 0;
|
|
17063
17363
|
let drop = 0;
|
|
17364
|
+
let cutSum = 0;
|
|
17064
17365
|
for (let c = 0; c < m; c++) {
|
|
17065
17366
|
const local = [0, box4.min[1], 0];
|
|
17066
17367
|
local[long] = box4.min[long] + (k + 0.5) * step;
|
|
17067
17368
|
local[across2] = box4.min[across2] + (c + 0.5) * (box4.max[across2] - box4.min[across2]) / m;
|
|
17068
17369
|
const world2 = toWorld(o.st.position, o.st.rotation, local);
|
|
17069
17370
|
const cut = undercutAt(loss, Math.hypot(world2[0] - loss.x, world2[2] - loss.z), b.embed, groundCfg.spread);
|
|
17070
|
-
if (cut >= groundCfg.voidDepth)
|
|
17371
|
+
if (cut >= groundCfg.voidDepth) {
|
|
17372
|
+
open++;
|
|
17373
|
+
const along = local[long] - box4.min[long];
|
|
17374
|
+
const side = local[across2] - box4.min[across2];
|
|
17375
|
+
voidBox ?? (voidBox = { long: [along, along], across: [side, side] });
|
|
17376
|
+
voidBox.long = [Math.min(voidBox.long[0], along - step / 2), Math.max(voidBox.long[1], along + step / 2)];
|
|
17377
|
+
voidBox.across = [Math.min(voidBox.across[0], side), Math.max(voidBox.across[1], side)];
|
|
17378
|
+
}
|
|
17071
17379
|
drop += Math.min(cut, groundCfg.maxSettlement);
|
|
17380
|
+
cutSum += cut;
|
|
17072
17381
|
if (cut > worst) {
|
|
17073
17382
|
worst = cut;
|
|
17074
17383
|
deepest = world2;
|
|
@@ -17076,56 +17385,326 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17076
17385
|
}
|
|
17077
17386
|
voids += open;
|
|
17078
17387
|
sum += drop;
|
|
17079
|
-
slices.push({ void: open * 2 > m, drop: drop / m });
|
|
17388
|
+
slices.push({ void: open * 2 > m, drop: drop / m, cut: cutSum / m });
|
|
17080
17389
|
}
|
|
17081
|
-
return { long, step, slices, share: voids / (n * m), drop: sum / (n * m), deepest };
|
|
17390
|
+
return { long, step, slices, voidBox, share: voids / (n * m), drop: sum / (n * m), deepest };
|
|
17082
17391
|
};
|
|
17083
|
-
const
|
|
17084
|
-
const p = b.p;
|
|
17392
|
+
const sectionOfBearer = (p) => {
|
|
17085
17393
|
if (p.spec.shape.kind !== "box" || !p.mat.strength?.tensileMPa) return null;
|
|
17086
17394
|
const g = bendGeometry(p.spec);
|
|
17087
17395
|
if (g.gravity < 0) return null;
|
|
17088
17396
|
const footing = p.spec.structure?.role === "foundation" && g.member && !isReinforced(p.spec);
|
|
17089
17397
|
const spec = footing ? { ...p.spec, structure: { ...p.spec.structure, rebar: { ratio: groundCfg.beamRebarRatio } } } : p.spec;
|
|
17090
17398
|
const section = { b: sectionWidth(g, g.gravity), h: g.dims[g.gravity] };
|
|
17091
|
-
const
|
|
17092
|
-
const
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
const
|
|
17097
|
-
const
|
|
17098
|
-
const
|
|
17099
|
-
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
|
|
17399
|
+
const steel = tensionSteel(spec, g.dims, section, flexure);
|
|
17400
|
+
const m = sectionMoments(p.mat, section, steel, flexure);
|
|
17401
|
+
return { g, section, steel, m, resists: p.st.cracked ? m.steel : m.ultimate };
|
|
17402
|
+
};
|
|
17403
|
+
const pillarsUnder = (o, b, fp, standing) => {
|
|
17404
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17405
|
+
const across2 = fp.long === 0 ? 2 : 0;
|
|
17406
|
+
const out = [];
|
|
17407
|
+
for (const i of standing) {
|
|
17408
|
+
const q = o.parts[i];
|
|
17409
|
+
if (q.spec.structure?.role !== "column") continue;
|
|
17410
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17411
|
+
const overlaps = c.max[across2] > box4.min[across2] && c.min[across2] < box4.max[across2] && c.max[fp.long] > box4.min[fp.long] && c.min[fp.long] < box4.max[fp.long];
|
|
17412
|
+
if (overlaps && Math.abs(c.min[1] - box4.max[1]) < PILLAR_SEAT) out.push((c.min[fp.long] + c.max[fp.long]) / 2 - box4.min[fp.long]);
|
|
17413
|
+
}
|
|
17414
|
+
return out;
|
|
17415
|
+
};
|
|
17416
|
+
const continuationOf = (o, b, fp, standing) => {
|
|
17417
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17418
|
+
const across2 = fp.long === 0 ? 2 : 0;
|
|
17419
|
+
const ends = [false, false];
|
|
17420
|
+
for (const i of standing) {
|
|
17421
|
+
const q = o.parts[i];
|
|
17422
|
+
if (i === b.i || q.spec.structure?.role !== "foundation" || isTerrain(q)) continue;
|
|
17423
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17424
|
+
const inLine = Math.abs((c.min[across2] + c.max[across2]) / 2 - (box4.min[across2] + box4.max[across2]) / 2) < PILLAR_SEAT && c.max[1] > box4.min[1] && c.min[1] < box4.max[1];
|
|
17425
|
+
if (!inLine) continue;
|
|
17426
|
+
if (Math.abs(c.max[fp.long] - box4.min[fp.long]) < PILLAR_SEAT) ends[0] = true;
|
|
17427
|
+
if (Math.abs(c.min[fp.long] - box4.max[fp.long]) < PILLAR_SEAT) ends[1] = true;
|
|
17428
|
+
}
|
|
17429
|
+
return ends;
|
|
17430
|
+
};
|
|
17431
|
+
const bearBeam = (o, b, fp, standing, sec) => {
|
|
17432
|
+
const length = fp.slices.length * fp.step;
|
|
17433
|
+
const load = lineLoad(sec.g, b.p.st.load ?? b.p.st.mass);
|
|
17434
|
+
const verdict = judgeBeam(fp.slices.map((slice) => slice.void), fp.step, {
|
|
17435
|
+
length,
|
|
17436
|
+
depth: sec.section.h,
|
|
17437
|
+
load,
|
|
17438
|
+
resists: sec.resists,
|
|
17439
|
+
cracking: sec.m.cracking,
|
|
17440
|
+
spanDepth: groundCfg.bridgeSpanDepth,
|
|
17441
|
+
soilSafety: soilCfg.safety,
|
|
17442
|
+
pillars: pillarsUnder(o, b, fp, standing),
|
|
17443
|
+
loadFactor: structureSafety,
|
|
17444
|
+
continuous: continuationOf(o, b, fp, standing)
|
|
17445
|
+
});
|
|
17446
|
+
if (verdict.runs.length === 0) return { status: fp.share <= 1 - 1 / soilCfg.safety ? "settled" : "unsupported", failed: [], cracks: [] };
|
|
17447
|
+
if (verdict.tips) return { status: "unsupported", failed: [], cracks: [] };
|
|
17448
|
+
const cracks = [];
|
|
17449
|
+
const failed = [];
|
|
17450
|
+
const EI = (b.p.mat.strength.elasticGPa ?? 0) * 1e9 * sec.section.b * sec.section.h ** 3 / 12;
|
|
17451
|
+
for (const run2 of verdict.runs) {
|
|
17452
|
+
const k0 = Math.round(run2.start / fp.step);
|
|
17453
|
+
const k1 = Math.round(run2.end / fp.step);
|
|
17454
|
+
if (!run2.holds) {
|
|
17455
|
+
const free = run2.kind !== "cantilever" ? void 0 : run2.start <= 1e-9 ? "start" : "end";
|
|
17456
|
+
failed.push({ start: run2.start, end: run2.end, ...free ? { free } : {} });
|
|
17457
|
+
if (free !== "start") cracks.push({ at: run2.start, top: true });
|
|
17458
|
+
if (free !== "end") cracks.push({ at: run2.end, top: true });
|
|
17459
|
+
for (let k = k0; k < k1; k++) fp.slices[k].drop = Math.min(fp.slices[k].cut, run2.span / 2);
|
|
17460
|
+
continue;
|
|
17461
|
+
}
|
|
17462
|
+
if (run2.cracks) cracks.push(run2.kind === "cantilever" ? { at: run2.start <= 1e-9 ? run2.end : run2.start, top: true } : { at: (run2.start + run2.end) / 2, top: false });
|
|
17463
|
+
const stiffness = EI * (run2.cracks || b.p.st.cracked ? CRACKED_STIFFNESS : 1);
|
|
17464
|
+
const sag = stiffness > 0 ? load * run2.span ** 4 / (run2.kind === "cantilever" ? 8 * stiffness : 384 / 5 * stiffness) : groundCfg.maxSettlement;
|
|
17465
|
+
for (let k = k0; k < k1; k++) fp.slices[k].drop = Math.min(fp.slices[k].drop, sag);
|
|
17466
|
+
}
|
|
17467
|
+
return { status: failed.length ? "opened" : "bridged", failed, cracks };
|
|
17468
|
+
};
|
|
17469
|
+
const standingOver = (o, b, fp) => {
|
|
17470
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17471
|
+
const vb = fp.voidBox;
|
|
17472
|
+
if (!vb) return [];
|
|
17473
|
+
const across2 = fp.long === 0 ? 2 : 0;
|
|
17474
|
+
const out = [];
|
|
17475
|
+
for (const j of o.byPart.get(b.p.spec.id) ?? []) {
|
|
17476
|
+
const k = j.ia === b.i ? j.ib : j.ia;
|
|
17477
|
+
if (j.st.open || restsOn(o, j, k) !== b.i) continue;
|
|
17478
|
+
const q = o.parts[k];
|
|
17479
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17480
|
+
const along = (c.min[fp.long] + c.max[fp.long]) / 2 - box4.min[fp.long];
|
|
17481
|
+
const side = (c.min[across2] + c.max[across2]) / 2 - box4.min[across2];
|
|
17482
|
+
if (along >= vb.long[0] && along <= vb.long[1] && side >= vb.across[0] && side <= vb.across[1]) out.push({ q, j });
|
|
17483
|
+
}
|
|
17484
|
+
return out;
|
|
17485
|
+
};
|
|
17486
|
+
const bearPlate = (o, b, fp, sec) => {
|
|
17487
|
+
const vb = fp.voidBox;
|
|
17488
|
+
if (!vb) return { status: "settled", failed: [], cracks: [] };
|
|
17489
|
+
const across2 = Math.max(vb.long[1] - vb.long[0], vb.across[1] - vb.across[0]);
|
|
17490
|
+
const over = standingOver(o, b, fp);
|
|
17491
|
+
const verdict = judgePlate({
|
|
17492
|
+
across: across2,
|
|
17493
|
+
load: lineLoad(sec.g, b.p.st.mass),
|
|
17494
|
+
resists: sec.resists,
|
|
17495
|
+
cracking: sec.m.cracking,
|
|
17496
|
+
effectiveDepth: sec.steel.d,
|
|
17497
|
+
punching: PUNCHING_SHARE * (b.p.mat.strength.tensileMPa ?? 0) * 1e6,
|
|
17498
|
+
loadFactor: structureSafety,
|
|
17499
|
+
points: over.map(({ q }) => {
|
|
17500
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17501
|
+
return { weight: (q.st.load ?? q.st.mass) * GRAVITY, side: Math.min(c.max[0] - c.min[0], c.max[2] - c.min[2]) };
|
|
17502
|
+
})
|
|
17503
|
+
});
|
|
17504
|
+
if (fp.share > 1 - 1 / soilCfg.safety) return { status: "unsupported", failed: [], cracks: [] };
|
|
17505
|
+
const cracks = verdict.cracks || !verdict.holds ? [{ at: vb.long[0], top: true }, { at: vb.long[1], top: true }] : [];
|
|
17506
|
+
if (verdict.holds) return { status: "bridged", failed: [], cracks };
|
|
17507
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17508
|
+
const crossing = fp.long === 0 ? 2 : 0;
|
|
17509
|
+
const center = [(box4.min[0] + box4.max[0]) / 2, (box4.min[1] + box4.max[1]) / 2, (box4.min[2] + box4.max[2]) / 2];
|
|
17510
|
+
center[fp.long] = box4.min[fp.long] + (vb.long[0] + vb.long[1]) / 2;
|
|
17511
|
+
center[crossing] = box4.min[crossing] + (vb.across[0] + vb.across[1]) / 2;
|
|
17512
|
+
const radius = Math.max(vb.long[1] - vb.long[0], vb.across[1] - vb.across[0]) / 2;
|
|
17513
|
+
if (2 * radius >= Math.min(box4.max[0] - box4.min[0], box4.max[2] - box4.min[2])) return { status: "unsupported", failed: [], cracks: [] };
|
|
17514
|
+
return { status: "opened", failed: [{ start: vb.long[0], end: vb.long[1] }], cracks, hole: { center, radius } };
|
|
17515
|
+
};
|
|
17516
|
+
const bearLoss = (o, b, fp, standing) => {
|
|
17517
|
+
const sec = sectionOfBearer(b.p);
|
|
17518
|
+
if (sec?.g.member) return bearBeam(o, b, fp, standing, sec);
|
|
17519
|
+
if (sec && fp.voidBox) return bearPlate(o, b, fp, sec);
|
|
17520
|
+
return { status: fp.share <= 1 - 1 / soilCfg.safety ? "settled" : "unsupported", failed: [], cracks: [] };
|
|
17521
|
+
};
|
|
17522
|
+
const crackBearer = (o, b, fp, bearing, src) => {
|
|
17523
|
+
if (bearing.cracks.length === 0) return;
|
|
17105
17524
|
b.p.st.cracked = true;
|
|
17106
17525
|
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
|
|
17526
|
+
for (const crack of bearing.cracks) {
|
|
17527
|
+
const local = [(box4.min[0] + box4.max[0]) / 2, crack.top ? box4.max[1] : box4.min[1], (box4.min[2] + box4.max[2]) / 2];
|
|
17528
|
+
local[fp.long] = box4.min[fp.long] + crack.at;
|
|
17529
|
+
addCrack(o, b.p, toWorld(o.st.position, o.st.rotation, local), rotateVec(o.st.rotation, [0, crack.top ? 1 : -1, 0]), box4.max[1] - box4.min[1], src);
|
|
17530
|
+
}
|
|
17111
17531
|
};
|
|
17112
|
-
const
|
|
17532
|
+
const openOver = (o, b, fp, failed, opened, src) => {
|
|
17533
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17534
|
+
let lost = false;
|
|
17535
|
+
for (const j of o.byPart.get(b.p.spec.id) ?? []) {
|
|
17536
|
+
const k = j.ia === b.i ? j.ib : j.ia;
|
|
17537
|
+
if (j.st.open || restsOn(o, j, k) !== b.i) continue;
|
|
17538
|
+
const q = o.parts[k];
|
|
17539
|
+
if (isLost(q)) continue;
|
|
17540
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17541
|
+
const from = c.min[fp.long] - box4.min[fp.long];
|
|
17542
|
+
const to = c.max[fp.long] - box4.min[fp.long];
|
|
17543
|
+
const run2 = failed.find((r) => to > r.start && from < r.end);
|
|
17544
|
+
if (!run2) continue;
|
|
17545
|
+
if (from >= run2.start - fp.step && to <= run2.end + fp.step) {
|
|
17546
|
+
j.st.open = true;
|
|
17547
|
+
j.st.hp = 0;
|
|
17548
|
+
j.st.openedBy = "break";
|
|
17549
|
+
opened.push(j);
|
|
17550
|
+
lost = true;
|
|
17551
|
+
continue;
|
|
17552
|
+
}
|
|
17553
|
+
if (isSlender(q.spec, q.mat) && archOver(o, q, fp.long, [box4.min[fp.long] + run2.start, box4.min[fp.long] + run2.end], run2.free, opened, src)) lost = true;
|
|
17554
|
+
}
|
|
17555
|
+
return lost;
|
|
17556
|
+
};
|
|
17557
|
+
const archOver = (o, q, axis, span, free, opened, src) => {
|
|
17558
|
+
var _a;
|
|
17559
|
+
const grid = gridOf(q);
|
|
17560
|
+
const worn = (_a = q.rt).chips ?? (_a.chips = {});
|
|
17561
|
+
const bottom = aabbOf(q.spec.shape, q.pos, q.q).min[1];
|
|
17562
|
+
const half = (span[1] - span[0]) / 2;
|
|
17563
|
+
const middle = (span[0] + span[1]) / 2;
|
|
17564
|
+
const out = [];
|
|
17565
|
+
grid.forEach((cell, i) => {
|
|
17566
|
+
if (worn[i] === -1) return;
|
|
17567
|
+
const at2 = toWorld(q.pos, q.q, cell.center);
|
|
17568
|
+
const height2 = at2[1] - bottom;
|
|
17569
|
+
const reach = height2 / Math.tan(ARCH_ANGLE);
|
|
17570
|
+
const under = free === "start" ? at2[axis] <= span[1] - reach : free === "end" ? at2[axis] >= span[0] + reach : Math.abs(at2[axis] - middle) <= half - reach;
|
|
17571
|
+
if (under) out.push(i);
|
|
17572
|
+
});
|
|
17573
|
+
if (out.length === 0) return false;
|
|
17574
|
+
const centre = [0, bottom, 0];
|
|
17575
|
+
centre[axis] = middle;
|
|
17576
|
+
const other = axis === 0 ? 2 : 0;
|
|
17577
|
+
centre[other] = q.pos[other];
|
|
17578
|
+
knockOutUnits(o, q, toWorld(o.st.position, o.st.rotation, centre), 0, out, src);
|
|
17579
|
+
const height = aabbOf(q.spec.shape, q.pos, q.q).max[1] - bottom;
|
|
17580
|
+
const corbel = height / Math.tan(ARCH_ANGLE);
|
|
17581
|
+
const opening = free === "start" ? [span[0], span[1] - corbel] : free === "end" ? [span[0] + corbel, span[1]] : [span[0] + corbel, span[1] - corbel];
|
|
17582
|
+
return opening[1] > opening[0] && spanOpening(o, q, axis, opening, !!free, opened, src);
|
|
17583
|
+
};
|
|
17584
|
+
const spanOpening = (o, q, axis, opening, overhang, opened, src) => {
|
|
17585
|
+
const qi = o.idx.get(q.spec.id);
|
|
17586
|
+
const length = opening[1] - opening[0];
|
|
17587
|
+
let lost = false;
|
|
17588
|
+
for (const j of [...o.byPart.get(q.spec.id) ?? []]) {
|
|
17589
|
+
const ri = j.ia === qi ? j.ib : j.ia;
|
|
17590
|
+
const r = o.parts[ri];
|
|
17591
|
+
if (j.st.open || isLost(r) || restsOn(o, j, ri) !== qi || !r.structural) continue;
|
|
17592
|
+
const sec = sectionOfBearer(r);
|
|
17593
|
+
if (sec && !sec.g.member && !restsOnlyOn(o, ri, qi)) continue;
|
|
17594
|
+
const load = sec ? lineLoad(sec.g, r.st.load ?? r.st.mass) : 0;
|
|
17595
|
+
const moment = load * length * length / (overhang ? 2 : 8) * structureSafety;
|
|
17596
|
+
const reach = (overhang ? 0.5 : 1) * groundCfg.bridgeSpanDepth * (sec?.section.h ?? 0);
|
|
17597
|
+
if (sec && length <= reach && moment <= sec.resists) {
|
|
17598
|
+
if (moment > sec.m.cracking && !r.st.cracked) {
|
|
17599
|
+
r.st.cracked = true;
|
|
17600
|
+
addCrack(o, r, partXf(o, r).c, rotateVec(o.st.rotation, [0, -1, 0]), sec.section.h, src);
|
|
17601
|
+
}
|
|
17602
|
+
continue;
|
|
17603
|
+
}
|
|
17604
|
+
if (sec?.g.member) {
|
|
17605
|
+
if (breakOver(o, r, axis, opening, opened, src)) lost = true;
|
|
17606
|
+
continue;
|
|
17607
|
+
}
|
|
17608
|
+
hingeDrop(o, r, src);
|
|
17609
|
+
lost = true;
|
|
17610
|
+
}
|
|
17611
|
+
return lost;
|
|
17612
|
+
};
|
|
17613
|
+
const breakOver = (o, r, axis, stretch, opened, src) => {
|
|
17614
|
+
var _a;
|
|
17615
|
+
const ri = o.idx.get(r.spec.id);
|
|
17616
|
+
((_a = r.rt).broken ?? (_a.broken = [])).push([axis, stretch[0], stretch[1]]);
|
|
17617
|
+
r.st.cracked = true;
|
|
17618
|
+
const box4 = aabbOf(r.spec.shape, r.pos, r.q);
|
|
17619
|
+
for (const edge of stretch) {
|
|
17620
|
+
const at2 = [(box4.min[0] + box4.max[0]) / 2, box4.max[1], (box4.min[2] + box4.max[2]) / 2];
|
|
17621
|
+
at2[axis] = edge;
|
|
17622
|
+
addCrack(o, r, toWorld(o.st.position, o.st.rotation, at2), rotateVec(o.st.rotation, [0, 1, 0]), box4.max[1] - box4.min[1], src);
|
|
17623
|
+
}
|
|
17624
|
+
const from = [(box4.min[0] + box4.max[0]) / 2, box4.min[1], (box4.min[2] + box4.max[2]) / 2];
|
|
17625
|
+
const to = [from[0], from[1], from[2]];
|
|
17626
|
+
from[axis] = box4.min[axis];
|
|
17627
|
+
to[axis] = box4.max[axis];
|
|
17628
|
+
const count = SETTLEMENT_POINTS;
|
|
17629
|
+
const drop = Array.from({ length: count }, (_, k) => {
|
|
17630
|
+
const x = box4.min[axis] + (box4.max[axis] - box4.min[axis]) * k / (count - 1);
|
|
17631
|
+
return x <= stretch[0] || x >= stretch[1] ? 0 : Math.min(x - stretch[0], stretch[1] - x, Math.max(0, box4.min[1]));
|
|
17632
|
+
});
|
|
17633
|
+
r.st.settlement = mergeSettlement(r.st.settlement, { from, to, drop });
|
|
17634
|
+
r.st.subsidence = Math.max(r.st.subsidence ?? 0, drop.reduce((sum, v) => sum + v, 0) / count);
|
|
17635
|
+
const middle = [from[0], from[1], from[2]];
|
|
17636
|
+
middle[axis] = (stretch[0] + stretch[1]) / 2;
|
|
17637
|
+
emit({ ...base(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box4.max[axis] - box4.min[axis]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
|
|
17638
|
+
let lost = false;
|
|
17639
|
+
for (const j of [...o.byPart.get(r.spec.id) ?? []]) {
|
|
17640
|
+
const ki = j.ia === ri ? j.ib : j.ia;
|
|
17641
|
+
const k = o.parts[ki];
|
|
17642
|
+
if (j.st.open || isLost(k) || restsOn(o, j, ki) !== ri) continue;
|
|
17643
|
+
const c = aabbOf(k.spec.shape, k.pos, k.q);
|
|
17644
|
+
const within = c.min[axis] >= stretch[0] - SUPPORT_TOLERANCE && c.max[axis] <= stretch[1] + SUPPORT_TOLERANCE;
|
|
17645
|
+
const sec = within ? null : sectionOfBearer(k);
|
|
17646
|
+
const plate = sec && !sec.g.member;
|
|
17647
|
+
const length = stretch[1] - stretch[0];
|
|
17648
|
+
const spans = plate && lineLoad(sec.g, k.st.load ?? k.st.mass) * length * length / 8 * structureSafety <= sec.resists;
|
|
17649
|
+
if (!within && (!plate || spans)) continue;
|
|
17650
|
+
j.st.open = true;
|
|
17651
|
+
j.st.hp = 0;
|
|
17652
|
+
j.st.openedBy = "break";
|
|
17653
|
+
opened.push(j);
|
|
17654
|
+
lost = true;
|
|
17655
|
+
}
|
|
17656
|
+
return lost;
|
|
17657
|
+
};
|
|
17658
|
+
const breakOut = (o, p, hole, src) => {
|
|
17659
|
+
if (p.st.opening) return;
|
|
17660
|
+
const lc = toLocal(p.pos, p.q, hole.center);
|
|
17661
|
+
lc[p.thin] = 0;
|
|
17662
|
+
const worldCenter = toWorld(o.st.position, o.st.rotation, toWorld(p.pos, p.q, lc));
|
|
17663
|
+
const [u, v] = planeAxes(p.thin);
|
|
17664
|
+
const worn = p.rt.chips;
|
|
17665
|
+
const cells = cellsWithin(gridOf(p).filter((_, i) => worn?.[i] !== -1), p.thin, lc, hole.radius);
|
|
17666
|
+
const removed = Math.min(p.st.mass, p.st.mass * Math.PI * hole.radius * hole.radius / (p.dims[u] * p.dims[v]));
|
|
17667
|
+
const fragments = cellFragments(o, p, cells, worldCenter, [0, -1, 0], 0.5, removed, "g");
|
|
17668
|
+
p.st.mass = Math.max(0, p.st.mass - removed);
|
|
17669
|
+
p.rt.removed = (p.rt.removed ?? 0) + removed;
|
|
17670
|
+
p.st.opening = { center: objLocal(o, worldCenter), radius: hole.radius };
|
|
17671
|
+
markDamaged(p);
|
|
17672
|
+
if (p.staged) {
|
|
17673
|
+
setStage(o, p, 1, {}, src);
|
|
17674
|
+
setStage(o, p, 2, { opening: { center: worldCenter, radius: hole.radius }, fragments }, src);
|
|
17675
|
+
} else emit({ ...base(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
|
|
17676
|
+
debris(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
|
|
17677
|
+
if (p.spec.reinforcement) exposeRebar(o, p, src);
|
|
17678
|
+
};
|
|
17679
|
+
const distort = (o, q, beta, at2, toward, src) => {
|
|
17113
17680
|
const prior = q.rt.distortion ?? 0;
|
|
17114
|
-
|
|
17681
|
+
const bearing = q.spec.structure?.role === "wall";
|
|
17682
|
+
const crackAt = bearing ? groundCfg.bearingCrackDistortion : groundCfg.crackDistortion;
|
|
17683
|
+
const damageAt = bearing ? groundCfg.bearingDamageDistortion : groundCfg.damageDistortion;
|
|
17684
|
+
if (beta < crackAt || beta <= prior * DISTORTION_GROWTH) return;
|
|
17115
17685
|
q.rt.distortion = beta;
|
|
17116
17686
|
const box4 = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17117
17687
|
const height = box4.max[1] - box4.min[1];
|
|
17118
|
-
const cracks = (d) => d <
|
|
17688
|
+
const cracks = (d) => d < crackAt ? 0 : Math.min(MAX_SETTLEMENT_CRACKS, 1 + Math.floor(Math.log2(d / crackAt)));
|
|
17119
17689
|
const count = Math.max(1, cracks(beta) - cracks(prior));
|
|
17120
17690
|
const axis = [0, 0, 0];
|
|
17121
17691
|
axis[q.thin] = 1;
|
|
17122
17692
|
const normal = rotateVec(quat.mul(o.st.rotation, q.q), axis);
|
|
17123
|
-
const length = Math.min(height * 0.6, SETTLEMENT_CRACK_LENGTH * Math.sqrt(beta /
|
|
17693
|
+
const length = Math.min(height * 0.6, SETTLEMENT_CRACK_LENGTH * Math.sqrt(beta / crackAt));
|
|
17694
|
+
const units = q.spec.units?.size;
|
|
17695
|
+
const step = units ? [Math.max(units[0], units[2]), units[1]] : [BRICK_STEP[0], BRICK_STEP[1]];
|
|
17696
|
+
const reach = Math.hypot(toward[0], toward[2]) || 1;
|
|
17697
|
+
const along = vec.normalize([toward[0] / reach, 1, toward[2] / reach]);
|
|
17698
|
+
const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
|
|
17699
|
+
const through = q.dims[q.thin];
|
|
17124
17700
|
for (let c = 0; c < count; c++) {
|
|
17125
|
-
const
|
|
17126
|
-
|
|
17701
|
+
const back = c * SETTLEMENT_CRACK_SPACING;
|
|
17702
|
+
const local = [clamp2(at2[0] - toward[0] / reach * back, box4.min[0], box4.max[0]), box4.min[1] + height * (0.2 + 0.12 * c), clamp2(at2[2] - toward[2] / reach * back, box4.min[2], box4.max[2])];
|
|
17703
|
+
const face = toLocal(q.pos, q.q, local);
|
|
17704
|
+
face[q.thin] = through / 2;
|
|
17705
|
+
addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length, src, { along, step, width, through });
|
|
17127
17706
|
}
|
|
17128
|
-
if (beta >=
|
|
17707
|
+
if (beta >= damageAt && prior < damageAt) {
|
|
17129
17708
|
q.st.hp = Math.max(1, q.st.hp - q.st.maxHp * groundCfg.distortionDamage);
|
|
17130
17709
|
markDamaged(q);
|
|
17131
17710
|
}
|
|
@@ -17139,18 +17718,53 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17139
17718
|
const q = o.parts[qi];
|
|
17140
17719
|
if (isLost(q) || isTerrain(q) || o.collapsed.has(q.spec.id) || !isSlender(q.spec, q.mat)) continue;
|
|
17141
17720
|
if (restsOn(o, j, qi) !== b.i) {
|
|
17142
|
-
|
|
17721
|
+
const side = [j.pos[0] - q.pos[0], 0, j.pos[2] - q.pos[2]];
|
|
17722
|
+
const own = q.st.settlement ? settlementAt(q.st.settlement, j.pos) : 0;
|
|
17723
|
+
const reach = Math.hypot(side[0], side[2]) || 1;
|
|
17724
|
+
const from = [j.pos[0] - side[0] / reach * BESIDE_CRACK_OFFSET, j.pos[1], j.pos[2] - side[2] / reach * BESIDE_CRACK_OFFSET];
|
|
17725
|
+
distort(o, q, Math.abs((b.p.st.subsidence ?? 0) - own) / DISTORTION_BASE, from, side, src);
|
|
17143
17726
|
continue;
|
|
17144
17727
|
}
|
|
17145
17728
|
const over = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17146
17729
|
const k0 = clamp2(Math.floor((over.min[fp.long] - box4.min[fp.long]) / fp.step), 0, drops.length - 1);
|
|
17147
17730
|
const k1 = clamp2(Math.ceil((over.max[fp.long] - box4.min[fp.long]) / fp.step), k0 + 1, drops.length);
|
|
17148
|
-
const { value, at: at2 } = distortionOf(drops.slice(k0, k1), fp.step);
|
|
17731
|
+
const { value, at: at2, down } = distortionOf(relativeToChord(drops.slice(k0, k1)), fp.step);
|
|
17149
17732
|
const point = [(over.min[0] + over.max[0]) / 2, over.min[1], (over.min[2] + over.max[2]) / 2];
|
|
17150
17733
|
point[fp.long] = box4.min[fp.long] + (k0 + at2 + 0.5) * fp.step;
|
|
17151
|
-
|
|
17734
|
+
const toward = [0, 0, 0];
|
|
17735
|
+
toward[fp.long] = down;
|
|
17736
|
+
distort(o, q, value, point, toward, src);
|
|
17737
|
+
}
|
|
17738
|
+
};
|
|
17739
|
+
const settle = (o, b, fp) => {
|
|
17740
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17741
|
+
const from = [(box4.min[0] + box4.max[0]) / 2, box4.min[1], (box4.min[2] + box4.max[2]) / 2];
|
|
17742
|
+
const to = [from[0], from[1], from[2]];
|
|
17743
|
+
from[fp.long] = box4.min[fp.long];
|
|
17744
|
+
to[fp.long] = box4.max[fp.long];
|
|
17745
|
+
const line = { from, to, drop: settlementProfile(fp.slices.map((slice) => slice.drop), fp.step) };
|
|
17746
|
+
const follows = { from, to, drop: line.drop.map((v) => Math.min(v, groundCfg.maxSettlement)) };
|
|
17747
|
+
const moved = /* @__PURE__ */ new Set([b.i]);
|
|
17748
|
+
let ring2 = [b.i];
|
|
17749
|
+
for (let depth = 0; depth <= SETTLEMENT_FOLLOW_DEPTH && ring2.length; depth++) {
|
|
17750
|
+
const next = [];
|
|
17751
|
+
for (const i of ring2) {
|
|
17752
|
+
const p = o.parts[i];
|
|
17753
|
+
p.st.settlement = mergeSettlement(p.st.settlement, i === b.i ? line : follows);
|
|
17754
|
+
if (i !== b.i) p.st.subsidence = Math.max(p.st.subsidence ?? 0, settlementAt(p.st.settlement, p.pos));
|
|
17755
|
+
for (const j of o.byPart.get(p.spec.id) ?? []) {
|
|
17756
|
+
const k = j.ia === i ? j.ib : j.ia;
|
|
17757
|
+
const q = o.parts[k];
|
|
17758
|
+
if (j.st.open || moved.has(k) || isLost(q) || isTerrain(q) || q.anchored) continue;
|
|
17759
|
+
if (q.structural && (i !== b.i || restsOn(o, j, k) !== i || !restsOnlyOn(o, k, i))) continue;
|
|
17760
|
+
moved.add(k);
|
|
17761
|
+
next.push(k);
|
|
17762
|
+
}
|
|
17763
|
+
}
|
|
17764
|
+
ring2 = next;
|
|
17152
17765
|
}
|
|
17153
17766
|
};
|
|
17767
|
+
const restsOnlyOn = (o, k, i) => (o.byPart.get(o.parts[k].spec.id) ?? []).every((j) => j.st.open || restsOn(o, j, k) < 0 || restsOn(o, j, k) === i);
|
|
17154
17768
|
const loseGround = (o, b, opened) => {
|
|
17155
17769
|
if (b.p.anchored) {
|
|
17156
17770
|
b.p.anchored = false;
|
|
@@ -17164,38 +17778,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17164
17778
|
opened.push(j);
|
|
17165
17779
|
}
|
|
17166
17780
|
};
|
|
17167
|
-
const bearLoss = (o, b, fp, src) => {
|
|
17168
|
-
const voids = longestRun(fp.slices.map((slice) => slice.void));
|
|
17169
|
-
const bridge = voids ? bridgeOf(b, fp, voids) : null;
|
|
17170
|
-
if (voids && bridge && bridge.span >= bridge.depth) {
|
|
17171
|
-
if (!bridge.holds) return "unsupported";
|
|
17172
|
-
if (bridge.cracks) crackBridge(o, b, fp, voids, bridge, src);
|
|
17173
|
-
for (let k = voids.start; k < voids.end; k++) fp.slices[k].drop = Math.min(fp.slices[k].drop, bridge.sag);
|
|
17174
|
-
fp.drop = fp.slices.reduce((sum, slice) => sum + slice.drop, 0) / fp.slices.length;
|
|
17175
|
-
return "bridged";
|
|
17176
|
-
}
|
|
17177
|
-
return fp.share <= 1 - 1 / soilCfg.safety ? "settled" : "unsupported";
|
|
17178
|
-
};
|
|
17179
17781
|
const undermine = (o, loss) => {
|
|
17180
17782
|
if (!o.hasStructure || !o.anyAnchor || o.st.soil?.status === "toppled") return;
|
|
17181
17783
|
const src = loss.source ?? "ground";
|
|
17182
17784
|
const opened = [];
|
|
17183
17785
|
const settled = [];
|
|
17184
17786
|
let lost = false;
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17787
|
+
const touched = bearersOf(o).filter((b) => nearLoss(o, b.p, loss)).map((b) => ({ b, fp: footprintOf(o, b, loss) })).filter(({ fp }) => fp.share > 0 || fp.drop >= SUBSIDE_MIN);
|
|
17788
|
+
const bearers = bearersOf(o);
|
|
17789
|
+
const pillarFirst = (b) => b.p.spec.structure?.role === "column" ? 0 : 1;
|
|
17790
|
+
const order = [...touched].sort((x, y) => pillarFirst(x.b) - pillarFirst(y.b));
|
|
17791
|
+
const standing = new Set(bearers.map((b) => b.i));
|
|
17792
|
+
for (const { b, fp } of order) {
|
|
17793
|
+
const bearing = bearLoss(o, b, fp, standing);
|
|
17794
|
+
if (bearing.status === "unsupported") standing.delete(b.i);
|
|
17795
|
+
if (bearing.status !== "unsupported" && !bendGeometry(b.p.spec).member) {
|
|
17796
|
+
const kept = fp.slices.filter((slice) => !slice.void);
|
|
17797
|
+
const flat = kept.length ? kept.reduce((sum, slice) => sum + slice.drop, 0) / kept.length : 0;
|
|
17798
|
+
fp.slices.forEach((slice) => slice.drop = flat);
|
|
17799
|
+
fp.drop = flat;
|
|
17800
|
+
}
|
|
17801
|
+
if (bearing.status !== "unsupported" && bendGeometry(b.p.spec).member) {
|
|
17802
|
+
const smooth = smoothProfile(fp.slices.map((slice) => slice.drop), fp.step, BEAM_SPREAD);
|
|
17803
|
+
fp.slices.forEach((slice, k) => slice.drop = bearing.failed.some((r) => (k + 0.5) * fp.step > r.start && (k + 0.5) * fp.step < r.end) ? slice.drop : smooth[k]);
|
|
17804
|
+
fp.drop = fp.slices.reduce((sum, slice) => sum + slice.drop, 0) / Math.max(1, fp.slices.length);
|
|
17805
|
+
}
|
|
17190
17806
|
const before = b.p.st.subsidence ?? 0;
|
|
17191
17807
|
const drop = Math.max(before, fp.drop);
|
|
17192
|
-
|
|
17808
|
+
const peak = () => Math.max(0, ...b.p.st.settlement?.drop ?? []);
|
|
17809
|
+
const peakBefore = peak();
|
|
17810
|
+
if (bearing.status === "unsupported") {
|
|
17193
17811
|
loseGround(o, b, opened);
|
|
17194
17812
|
lost = true;
|
|
17195
|
-
} else
|
|
17196
|
-
|
|
17813
|
+
} else {
|
|
17814
|
+
crackBearer(o, b, fp, bearing, src);
|
|
17815
|
+
if (bearing.failed.length && openOver(o, b, fp, bearing.failed, opened, src)) lost = true;
|
|
17816
|
+
if (bearing.hole) breakOut(o, b.p, bearing.hole, src);
|
|
17817
|
+
settled.push({ b, fp });
|
|
17818
|
+
settle(o, b, fp);
|
|
17819
|
+
}
|
|
17820
|
+
if (bearing.status === "settled" && drop - before < SUBSIDE_MIN && peak() - peakBefore < SUBSIDE_MIN) continue;
|
|
17197
17821
|
b.p.st.subsidence = drop;
|
|
17198
|
-
emit({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status });
|
|
17822
|
+
emit({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing.status });
|
|
17199
17823
|
}
|
|
17200
17824
|
for (const { b, fp } of settled) crackOver(o, b, fp, src);
|
|
17201
17825
|
o.active = true;
|
|
@@ -17240,6 +17864,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17240
17864
|
return r ? { t0: r.t0, t1: r.t1, n: rotateVec(q, r.n0) } : null;
|
|
17241
17865
|
};
|
|
17242
17866
|
const rayPart = (o, p, origin, d) => rayPartRaw(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
17867
|
+
const PART_BOUND_SLACK = 1e-6;
|
|
17243
17868
|
const raySphereMiss = (origin, d, c, r, maxDist) => {
|
|
17244
17869
|
const oc = vec.sub(origin, c);
|
|
17245
17870
|
const b = vec.dot(oc, d);
|
|
@@ -17249,13 +17874,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17249
17874
|
if (disc < 0) return true;
|
|
17250
17875
|
return -b - Math.sqrt(disc) > maxDist;
|
|
17251
17876
|
};
|
|
17877
|
+
const partSphereMiss = (o, d, p, maxDist) => {
|
|
17878
|
+
const x = o[0] - p.pos[0], y = o[1] - p.pos[1], z = o[2] - p.pos[2];
|
|
17879
|
+
const r = p.bound + PART_BOUND_SLACK;
|
|
17880
|
+
const b = x * d[0] + y * d[1] + z * d[2];
|
|
17881
|
+
const cc = x * x + y * y + z * z - r * r;
|
|
17882
|
+
if (cc > 0 && b > 0) return true;
|
|
17883
|
+
const disc = b * b - cc;
|
|
17884
|
+
if (disc < 0) return true;
|
|
17885
|
+
return -b - Math.sqrt(disc) > maxDist;
|
|
17886
|
+
};
|
|
17252
17887
|
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false) => {
|
|
17253
17888
|
const d = vec.normalize(dir);
|
|
17254
17889
|
let best = null;
|
|
17255
17890
|
for (const o of objects.values()) {
|
|
17256
17891
|
if (raySphereMiss(origin, d, toWorld(o.st.position, o.st.rotation, o.bc), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
|
|
17892
|
+
const qi = quat.conjugate(o.st.rotation);
|
|
17893
|
+
const lo = rotateVec(qi, vec.sub(origin, o.st.position));
|
|
17894
|
+
const ld = rotateVec(qi, d);
|
|
17257
17895
|
for (const p of o.parts) {
|
|
17258
17896
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
17897
|
+
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
17259
17898
|
const r = rayPart(o, p, origin, d);
|
|
17260
17899
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
17261
17900
|
if (p.st.opening && insideOpening(o, p, vec.madd(origin, d, r.t0))) continue;
|
|
@@ -17383,8 +18022,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17383
18022
|
setStage(o, p, 1, {}, src);
|
|
17384
18023
|
return hole;
|
|
17385
18024
|
};
|
|
17386
|
-
const addCrack = (o, p, wp, wn, length, src) => {
|
|
17387
|
-
const crack = { point: objLocal(o, wp), normal: objLocalDir(o, wn), length: Math.min(length, Math.max(p.bound, 0.05)), rays: 5 + Math.floor(rnd() * 5) };
|
|
18025
|
+
const addCrack = (o, p, wp, wn, length, src, stair) => {
|
|
18026
|
+
const crack = { point: objLocal(o, wp), normal: objLocalDir(o, wn), length: Math.min(length, Math.max(p.bound, 0.05)), rays: 5 + Math.floor(rnd() * 5), ...stair ? { stair } : {} };
|
|
17388
18027
|
p.st.cracks.push(crack);
|
|
17389
18028
|
if (p.st.cracks.length > 16) p.st.cracks.shift();
|
|
17390
18029
|
markDamaged(p);
|
|
@@ -17511,6 +18150,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17511
18150
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
17512
18151
|
const localHolesOf = (p) => p.st.holes.map((h) => ({ point: toLocal(p.pos, p.q, h.point), normal: rotateVec(quat.conjugate(p.q), h.normal), diameter: h.diameter }));
|
|
17513
18152
|
const unitsOf2 = (p) => p.spec.units ?? { size: [p.mat.fragmentSize?.[1] ?? 0.2, p.mat.fragmentSize?.[1] ?? 0.2, p.thickness], bond: "stack" };
|
|
18153
|
+
const unitSpan = (p) => {
|
|
18154
|
+
const [u, v] = planeAxes(p.thin);
|
|
18155
|
+
const first = gridOf(p)[0];
|
|
18156
|
+
const size = unitsOf2(p).size;
|
|
18157
|
+
return first && first.size[u] > size[0] + 1e-6 ? [first.size[u], first.size[v]] : [Math.min(size[0], p.dims[u]), Math.min(size[1], p.dims[v])];
|
|
18158
|
+
};
|
|
17514
18159
|
const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
|
|
17515
18160
|
const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false) => {
|
|
17516
18161
|
const { c, q } = partXf(o, p);
|
|
@@ -17541,6 +18186,44 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17541
18186
|
};
|
|
17542
18187
|
});
|
|
17543
18188
|
};
|
|
18189
|
+
const plasterFlakes = (o, p, cells, hitW, speed, tag) => {
|
|
18190
|
+
const layer = p.layers.find((l) => l.mat.fracture === "crumble");
|
|
18191
|
+
if (!layer || cells.length === 0) return [];
|
|
18192
|
+
const { c, q } = partXf(o, p);
|
|
18193
|
+
const [u, v] = planeAxes(p.thin);
|
|
18194
|
+
const faces = layer.def.faces === "both" ? [1, -1] : [layer.def.faces === "+" ? 1 : -1];
|
|
18195
|
+
const area3 = cells.reduce((sum, cell) => sum + cell.size[u] * cell.size[v], 0) * faces.length;
|
|
18196
|
+
const count = Math.min(MAX_PLASTER_FLAKES, Math.ceil(area3 / PLASTER_FLAKE_AREA));
|
|
18197
|
+
const out = [];
|
|
18198
|
+
for (let i = 0; i < count; i++) {
|
|
18199
|
+
const cell = cells[Math.floor(rnd() * cells.length)];
|
|
18200
|
+
const face = faces[i % faces.length];
|
|
18201
|
+
const local = [cell.center[0], cell.center[1], cell.center[2]];
|
|
18202
|
+
local[u] += (rnd() - 0.5) * cell.size[u];
|
|
18203
|
+
local[v] += (rnd() - 0.5) * cell.size[v];
|
|
18204
|
+
local[p.thin] = cell.center[p.thin] + face * (cell.size[p.thin] / 2 - layer.def.thickness / 2);
|
|
18205
|
+
const size = [0, 0, 0];
|
|
18206
|
+
size[u] = 0.04 + 0.12 * rnd();
|
|
18207
|
+
size[v] = 0.03 + 0.09 * rnd();
|
|
18208
|
+
size[p.thin] = layer.def.thickness;
|
|
18209
|
+
const cw = toWorld(c, q, local);
|
|
18210
|
+
const out0 = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
18211
|
+
const k = speed * (0.4 + 0.9 * rnd());
|
|
18212
|
+
out.push({
|
|
18213
|
+
id: `${p.spec.id}#${tag}${i}`,
|
|
18214
|
+
part: p.spec.id,
|
|
18215
|
+
material: layer.def.material,
|
|
18216
|
+
shape: "scrap",
|
|
18217
|
+
center: cw,
|
|
18218
|
+
size,
|
|
18219
|
+
rotation: q,
|
|
18220
|
+
velocity: [out0[0] * k, out0[1] * k + 0.5 * rnd(), out0[2] * k],
|
|
18221
|
+
angularVelocity: [(rnd() - 0.5) * 12, (rnd() - 0.5) * 12, (rnd() - 0.5) * 12],
|
|
18222
|
+
mass: layer.mat.density * size[0] * size[1] * size[2]
|
|
18223
|
+
});
|
|
18224
|
+
}
|
|
18225
|
+
return out;
|
|
18226
|
+
};
|
|
17544
18227
|
const worldBars = (o, p, bars) => {
|
|
17545
18228
|
const { c, q } = partXf(o, p);
|
|
17546
18229
|
return bars.map(([a, b]) => [toWorld(c, q, a), toWorld(c, q, b)]);
|
|
@@ -17778,6 +18461,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17778
18461
|
}
|
|
17779
18462
|
const bow = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
|
|
17780
18463
|
if (bow > 0) bars = bars.flatMap((bar2, i) => bendBar(bar2, p.thin, bow * BAR_BOW, i));
|
|
18464
|
+
const stirrups = memberStirrups(p.dims);
|
|
18465
|
+
if (stirrups.length > 0 && bars.length > 0) {
|
|
18466
|
+
if (p.st.stripped) bars = [...bars, ...stirrups];
|
|
18467
|
+
else for (const box4 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box4.center, box4.size));
|
|
18468
|
+
}
|
|
17781
18469
|
emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
|
|
17782
18470
|
};
|
|
17783
18471
|
const openBreach = (o, p, center, total, energy, dir, src) => {
|
|
@@ -17848,6 +18536,33 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17848
18536
|
if (out.length === 0) return false;
|
|
17849
18537
|
return knockOutUnits(o, p, wp, energy, out, src);
|
|
17850
18538
|
};
|
|
18539
|
+
const wedgedUnder = (o, p, loose) => {
|
|
18540
|
+
if (loose.length === 0) return loose;
|
|
18541
|
+
const beam = (o.byPart.get(p.spec.id) ?? []).some((j) => j.bears === "a_on_b" && j.spec.b === p.spec.id && !j.st.open && !!o.byId.get(j.spec.a)?.spec.reinforcement);
|
|
18542
|
+
if (!beam) return loose;
|
|
18543
|
+
const [, v] = planeAxes(p.thin);
|
|
18544
|
+
const grid = gridOf(p);
|
|
18545
|
+
const top = p.dims[v] / 2, course = unitSpan(p)[1];
|
|
18546
|
+
return loose.filter((i) => grid[i].center[v] + grid[i].size[v] / 2 < top - PANEL_EDGE_BEAM * course + 1e-4);
|
|
18547
|
+
};
|
|
18548
|
+
const panelEdge = (p, faces, seed) => {
|
|
18549
|
+
const [u, v] = planeAxes(p.thin);
|
|
18550
|
+
const [unitU, unitV] = unitSpan(p);
|
|
18551
|
+
const bottom = -p.dims[v] / 2, top = p.dims[v] / 2;
|
|
18552
|
+
const depth = (key2, most) => {
|
|
18553
|
+
const r = createRng(seed ^ Math.imul(key2 + 1, 2654435761)).next();
|
|
18554
|
+
return Math.floor(r * r * (most + 1));
|
|
18555
|
+
};
|
|
18556
|
+
return (cell) => {
|
|
18557
|
+
const course = Math.round((cell.center[v] - bottom) / unitV - 0.5);
|
|
18558
|
+
const column = Math.round((cell.center[u] - faces.fromFace) / unitU - 0.5);
|
|
18559
|
+
const keyed = course % 2 === 0 ? 0.5 : 0;
|
|
18560
|
+
const side = Math.min(cell.center[u] - faces.fromFace, faces.toFace - cell.center[u]) / unitU;
|
|
18561
|
+
if (side < depth(course * 2, PANEL_EDGE_PILLAR) + keyed + 0.5) return true;
|
|
18562
|
+
if ((cell.center[v] - bottom) / unitV < depth(1e5 + column, PANEL_EDGE_BASE) + 1) return true;
|
|
18563
|
+
return (top - cell.center[v]) / unitV < Math.floor(createRng(seed ^ Math.imul(200001 + column, 2654435761)).next() * (PANEL_EDGE_BEAM + 1));
|
|
18564
|
+
};
|
|
18565
|
+
};
|
|
17851
18566
|
const blastPanel = (o, p, point, energy, src) => {
|
|
17852
18567
|
var _a;
|
|
17853
18568
|
if (!p.staged || p.st.stripped || isLost(p) || !p.spec.units || p.spec.units.mortar === p.spec.material || p.spec.reinforcement) return false;
|
|
@@ -17859,12 +18574,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17859
18574
|
if (m === p || !m.spec.reinforcement || isLost(m) || m.spec.shape.kind !== "box") continue;
|
|
17860
18575
|
const mp = toLocal(p.pos, p.q, m.pos);
|
|
17861
18576
|
if (Math.abs(mp[p.thin]) > p.dims[p.thin] + 0.15 || Math.abs(mp[u]) > half + 0.15 || m.dims[v] < p.dims[v] * 0.5) continue;
|
|
17862
|
-
posts.push(mp[u]);
|
|
18577
|
+
posts.push({ x: mp[u], half: m.dims[u] / 2 });
|
|
17863
18578
|
}
|
|
17864
|
-
let from = -half, to = half;
|
|
17865
|
-
for (const x of posts) {
|
|
17866
|
-
if (x <= lp[u] && x > from)
|
|
17867
|
-
|
|
18579
|
+
let from = -half, to = half, fromFace = -half, toFace = half;
|
|
18580
|
+
for (const { x, half: w } of posts) {
|
|
18581
|
+
if (x <= lp[u] && x > from) {
|
|
18582
|
+
from = x;
|
|
18583
|
+
fromFace = x + w;
|
|
18584
|
+
}
|
|
18585
|
+
if (x >= lp[u] && x < to) {
|
|
18586
|
+
to = x;
|
|
18587
|
+
toFace = x - w;
|
|
18588
|
+
}
|
|
17868
18589
|
}
|
|
17869
18590
|
if (to - from < 0.2) return false;
|
|
17870
18591
|
const tnt = energy * DEFAULT_BLAST_IMPULSE.tntPerJoule;
|
|
@@ -17886,10 +18607,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17886
18607
|
const grid = gridOf(p);
|
|
17887
18608
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
17888
18609
|
const out = [];
|
|
18610
|
+
const edge = panelEdge(p, { fromFace, toFace }, seedOf2(...Array.from(`${o.id}|${p.spec.id}`, (char) => char.charCodeAt(0) / 1e3), from));
|
|
17889
18611
|
for (let i = 0; i < grid.length; i++) {
|
|
17890
18612
|
const cell = grid[i];
|
|
17891
18613
|
if (worn[i] === -1) continue;
|
|
17892
|
-
if (cell.center[u] - cell.size[u] / 2 >= from - 1e-6 && cell.center[u] + cell.size[u] / 2 <= to + 1e-6) out.push(i);
|
|
18614
|
+
if (cell.center[u] - cell.size[u] / 2 >= from - 1e-6 && cell.center[u] + cell.size[u] / 2 <= to + 1e-6 && !edge(cell)) out.push(i);
|
|
17893
18615
|
}
|
|
17894
18616
|
if (out.length === 0) return false;
|
|
17895
18617
|
for (const i of out) worn[i] = -1;
|
|
@@ -17902,7 +18624,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17902
18624
|
const grid = gridOf(p);
|
|
17903
18625
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
17904
18626
|
for (const i of out) worn[i] = -1;
|
|
17905
|
-
const
|
|
18627
|
+
const cast = p.spec.units?.mortar === p.spec.material;
|
|
18628
|
+
const loose = cast ? [] : wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !(op && p.st.opening && Math.hypot(grid[i].center[u] - op[u], grid[i].center[v] - op[v]) <= p.st.opening.radius)));
|
|
17906
18629
|
for (const i of loose) worn[i] = -1;
|
|
17907
18630
|
const blown = out.map((i) => grid[i]), fallen = loose.map((i) => grid[i]);
|
|
17908
18631
|
const volume = (cells2) => cells2.reduce((sum, cell) => sum + cell.size[0] * cell.size[1] * cell.size[2], 0);
|
|
@@ -17913,8 +18636,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17913
18636
|
const chipped = (_b = p.st).chipped ?? (_b.chipped = []);
|
|
17914
18637
|
const tag = `x${chipped.length}_`;
|
|
17915
18638
|
const fragments = [
|
|
17916
|
-
...cellFragments(o, p,
|
|
17917
|
-
...fallen.length > 0 ? cellFragments(o, p,
|
|
18639
|
+
...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, null, speed, blownMass, tag, true),
|
|
18640
|
+
...fallen.length > 0 ? cellFragments(o, p, clumpUnits(fallen, p.thin, unitSpan(p), fallenClumps), wp, null, 0.3, fallenMass, `${tag}f`, true) : [],
|
|
18641
|
+
...plasterFlakes(o, p, blown, wp, speed, `${tag}p`)
|
|
17918
18642
|
];
|
|
17919
18643
|
const cells = [...blown, ...fallen];
|
|
17920
18644
|
const holes = localHolesOf(p);
|
|
@@ -17950,7 +18674,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17950
18674
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
17951
18675
|
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
17952
18676
|
const opened = (cell) => !!op && !!p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius;
|
|
17953
|
-
const loose = unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]));
|
|
18677
|
+
const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i])));
|
|
17954
18678
|
if (loose.length === 0) return 0;
|
|
17955
18679
|
for (const i of loose) worn[i] = -1;
|
|
17956
18680
|
const fallen = loose.map((i) => grid[i]);
|
|
@@ -17965,7 +18689,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17965
18689
|
}
|
|
17966
18690
|
}
|
|
17967
18691
|
const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
|
|
17968
|
-
const fragments = cellFragments(o, p,
|
|
18692
|
+
const fragments = cellFragments(o, p, clumpUnits(fallen, p.thin, unitSpan(p), fallenClumps), vec.add(center, [0, 1, 0]), null, 0.3, mass, `u${chipped.length}_`, true);
|
|
17969
18693
|
const holes = localHolesOf(p);
|
|
17970
18694
|
p.st.holes = p.st.holes.filter((_, k) => !fallen.some((cell) => marksInBox(cell.center, cell.size, void 0, [holes[k]]).length > 0));
|
|
17971
18695
|
for (const cell of fallen) chipped.push({ center: [cell.center[0], cell.center[1], cell.center[2]], size: [cell.size[0], cell.size[1], cell.size[2]] });
|
|
@@ -18056,6 +18780,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18056
18780
|
return;
|
|
18057
18781
|
}
|
|
18058
18782
|
if (!force && giveAtCut(o, p, src)) return;
|
|
18783
|
+
if (!force && isTiledCover(p)) {
|
|
18784
|
+
crumbleMasonry(o, p, src);
|
|
18785
|
+
return;
|
|
18786
|
+
}
|
|
18059
18787
|
const ex = p.spec.explodes;
|
|
18060
18788
|
const style = force ?? (p.snap ? "snap" : p.mat.fracture === "none" ? "snap" : p.mat.fracture);
|
|
18061
18789
|
const { c, q } = partXf(o, p);
|
|
@@ -18385,14 +19113,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18385
19113
|
}
|
|
18386
19114
|
if (Ein > 20 && p.layers.length > 0) spallOuter(o, p, wp, faceOf(o, p, wn), wn, clamp2(0.05 + Math.sqrt(Ein) * 2e-3, 0.05, 0.4), src);
|
|
18387
19115
|
const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
|
|
18388
|
-
const
|
|
18389
|
-
const
|
|
19116
|
+
const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
|
|
19117
|
+
const member = caged2 && (isMember(p.dims) || dist > MEMBER_CUT_REACH * breachReach);
|
|
19118
|
+
const dealt = member ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - p.st.maxHp * FAR_MEMBER_HP_FLOOR)), "explosive", null, null, Ein * 0.3, 40, src) : applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
|
|
18390
19119
|
res.damage += dealt;
|
|
18391
19120
|
if (p.bend && flexure.enabled) bendByBlast(o, p, point, energy, radius, reach, src);
|
|
18392
19121
|
if (p.spec.units && p.spec.units.mortar !== p.spec.material) {
|
|
18393
19122
|
blastPanel(o, p, point, energy, src);
|
|
18394
19123
|
if (!isLost(p)) blastUnits(o, p, wp, energy, dist, src);
|
|
18395
|
-
} else if (
|
|
19124
|
+
} else if (member) blastUnits(o, p, wp, energy, dist, src);
|
|
18396
19125
|
else if (dist <= breachReach) addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
|
|
18397
19126
|
return reach;
|
|
18398
19127
|
};
|
|
@@ -20076,6 +20805,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20076
20805
|
return loads;
|
|
20077
20806
|
}
|
|
20078
20807
|
var isBearing = (part) => part.role === "column" || part.role === "wall";
|
|
20808
|
+
function isRoofFrame2(part) {
|
|
20809
|
+
return part.role === "roof" || part.id.startsWith("rafter");
|
|
20810
|
+
}
|
|
20079
20811
|
function sizeCapacities(parts, supports, options) {
|
|
20080
20812
|
const loads = loadsAtRest(parts, supports);
|
|
20081
20813
|
const worst = /* @__PURE__ */ new Map();
|
|
@@ -20089,7 +20821,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20089
20821
|
for (const part of parts) {
|
|
20090
20822
|
const load = loads.get(part.id);
|
|
20091
20823
|
if (load === void 0 || part.role === "none") continue;
|
|
20092
|
-
const
|
|
20824
|
+
const afterLoss = (worst.get(part.id) ?? 1) / options.redundancy;
|
|
20825
|
+
const factor = isBearing(part) ? Math.max(1 / options.safety, afterLoss) : isRoofFrame2(part) ? Math.max(1 / options.safetyOthers, afterLoss) : 1 / options.safetyOthers;
|
|
20093
20826
|
capacities.set(part.id, Math.max(1, load * factor));
|
|
20094
20827
|
}
|
|
20095
20828
|
return capacities;
|
|
@@ -20656,7 +21389,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20656
21389
|
const alongU = wall.aabb[2] - wall.aabb[0] >= wall.aabb[3] - wall.aabb[1];
|
|
20657
21390
|
const from = alongU ? wall.aabb[0] : wall.aabb[1];
|
|
20658
21391
|
const to = alongU ? wall.aabb[2] : wall.aabb[3];
|
|
20659
|
-
const
|
|
21392
|
+
const cross2 = alongU ? [wall.aabb[1], wall.aabb[3]] : [wall.aabb[0], wall.aabb[2]];
|
|
20660
21393
|
const rows = Math.max(1, Math.round((wall.y1 - wall.y0) / spec.rowHeight));
|
|
20661
21394
|
const rowHeight = (wall.y1 - wall.y0) / rows;
|
|
20662
21395
|
const cells = [];
|
|
@@ -20666,7 +21399,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20666
21399
|
for (const [a, b] of cutAt(from, to, openings.filter((o) => o.wall === wall.id), y0, y1)) for (const [x0, x1] of unitsOf(a, b, row, spec)) cells.push({ from: x0, to: x1, row, y0, y1 });
|
|
20667
21400
|
}
|
|
20668
21401
|
const total = cells.reduce((sum, cell) => sum + (cell.to - cell.from) * (cell.y1 - cell.y0), 0);
|
|
20669
|
-
const box22 = (cell) => alongU ? [cell.from,
|
|
21402
|
+
const box22 = (cell) => alongU ? [cell.from, cross2[0], cell.to, cross2[1]] : [cross2[0], cell.from, cross2[1], cell.to];
|
|
20670
21403
|
const pieces = cells.map((cell, index) => ({
|
|
20671
21404
|
id: `${wall.id}_${spec.unitLength ? "u" : "log"}${cell.row}_${index}`,
|
|
20672
21405
|
role: wall.role,
|
|
@@ -20864,7 +21597,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20864
21597
|
}
|
|
20865
21598
|
return spec;
|
|
20866
21599
|
};
|
|
20867
|
-
var MEMBER_CAGE = { spacing: 0.1, diameter:
|
|
21600
|
+
var MEMBER_CAGE = { spacing: 0.1, diameter: 0.01, unit: 0.1 };
|
|
20868
21601
|
var CAGED_ROLES = /* @__PURE__ */ new Set(["beam", "column"]);
|
|
20869
21602
|
var CAGE_COVER = 0.03;
|
|
20870
21603
|
var CAGE_BUCKLING_SHARE = 0.5;
|
|
@@ -22799,7 +23532,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22799
23532
|
}
|
|
22800
23533
|
var residentialTower = residentialTowerTemplate();
|
|
22801
23534
|
|
|
22802
|
-
// ../game-floorplan-three/dist/chunk-
|
|
23535
|
+
// ../game-floorplan-three/dist/chunk-J3D4FCFR.js
|
|
22803
23536
|
var __defProp3 = Object.defineProperty;
|
|
22804
23537
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
22805
23538
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -23870,7 +24603,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23870
24603
|
}
|
|
23871
24604
|
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;
|
|
23872
24605
|
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);
|
|
23873
|
-
|
|
24606
|
+
const frame2 = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f });
|
|
24607
|
+
cursor.pc = frame2;
|
|
23874
24608
|
bar2(a, ya, a + t, yb, "metal", fr);
|
|
23875
24609
|
bar2(b - t, ya, b, yb, "metal", fr);
|
|
23876
24610
|
bar2(a, ya, b, ya + t, "metal", fr);
|
|
@@ -23883,6 +24617,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23883
24617
|
const am = (sd) => roomAt(f, alongU ? j.at : L + sd * 0.4, alongU ? L + sd * 0.4 : j.at);
|
|
23884
24618
|
const outside = !am(1) ? 1 : !am(-1) ? -1 : 0;
|
|
23885
24619
|
if (outside) {
|
|
24620
|
+
cursor.pc = frame2;
|
|
23886
24621
|
const off = outside * (th / 2 + 0.03);
|
|
23887
24622
|
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_);
|
|
23888
24623
|
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_);
|
|
@@ -23898,6 +24633,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23898
24633
|
else bx("metal", L + go - 0.012, y0 + y, a, L + go + 0.012, y0 + y + 0.025, b, g);
|
|
23899
24634
|
}
|
|
23900
24635
|
}
|
|
24636
|
+
cursor.pc = null;
|
|
23901
24637
|
}
|
|
23902
24638
|
if (j.boards && !boardItems.has(j.id) && !cut) {
|
|
23903
24639
|
const inside2 = -(outside || -1), off = inside2 * (th / 2 + 0.04), n = Math.max(3, Math.round((yb - ya) / 0.16));
|
|
@@ -24830,7 +25566,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24830
25566
|
const { UV_SCALE, _Y, _h2, _q, accFor, cursor, put, rgbOf, structurePiece } = K;
|
|
24831
25567
|
const sh = (...a) => K.sh(...a);
|
|
24832
25568
|
const R_STYLE = () => shared2.ctx.r && shared2.ctx.r.style || "budget";
|
|
24833
|
-
function tileRelief(mat, pts, color2, type) {
|
|
25569
|
+
function tileRelief(mat, pts, color2, type, origin) {
|
|
24834
25570
|
const n = pts.length;
|
|
24835
25571
|
if (n < 3) return;
|
|
24836
25572
|
const [a, b, c] = pts;
|
|
@@ -24864,7 +25600,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24864
25600
|
ex /= el;
|
|
24865
25601
|
ey /= el;
|
|
24866
25602
|
ez /= el;
|
|
24867
|
-
const o = pts[0], S = [], T2 = [];
|
|
25603
|
+
const o = origin ?? pts[0], S = [], T2 = [];
|
|
24868
25604
|
for (const p of pts) {
|
|
24869
25605
|
const rx = p[0] - o[0], ry = p[1] - o[1], rz = p[2] - o[2];
|
|
24870
25606
|
S.push(rx * ex + ry * ey + rz * ez);
|
|
@@ -24929,6 +25665,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24929
25665
|
AC.nv += m * 2;
|
|
24930
25666
|
}
|
|
24931
25667
|
function ridge(a, b, type, roofColor) {
|
|
25668
|
+
const cuts = K.cfg.destruction ? baysAlong(a, b) : [];
|
|
25669
|
+
if (cuts.length) {
|
|
25670
|
+
let from = a;
|
|
25671
|
+
for (const f of [...cuts, 1]) {
|
|
25672
|
+
const to = [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f];
|
|
25673
|
+
ridgeCap(from, to, type, roofColor);
|
|
25674
|
+
from = to;
|
|
25675
|
+
}
|
|
25676
|
+
return;
|
|
25677
|
+
}
|
|
25678
|
+
ridgeCap(a, b, type, roofColor);
|
|
25679
|
+
}
|
|
25680
|
+
function ridgeCap(a, b, type, roofColor) {
|
|
24932
25681
|
cursor.pc = pieceOfPane((a[0] + b[0]) / 2, (a[2] + b[2]) / 2);
|
|
24933
25682
|
const dx = b[0] - a[0], dy = b[1] - a[1], dz = b[2] - a[2], Ln = Math.hypot(dx, dy, dz);
|
|
24934
25683
|
if (Ln < 0.05) return;
|
|
@@ -24955,7 +25704,81 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24955
25704
|
}
|
|
24956
25705
|
return m ? structurePiece(m.id) : null;
|
|
24957
25706
|
}
|
|
24958
|
-
|
|
25707
|
+
function paneTiles(mat, pts, color2, type) {
|
|
25708
|
+
const panes = panesUnder(pts), whole = centroidPiece(pts);
|
|
25709
|
+
if (panes.length < 2 || !whole || !K.cfg.destruction) {
|
|
25710
|
+
cursor.pc = whole;
|
|
25711
|
+
tileRelief(mat, pts, color2, type);
|
|
25712
|
+
return;
|
|
25713
|
+
}
|
|
25714
|
+
for (const r of panes) {
|
|
25715
|
+
const part = clipToRect(pts, r);
|
|
25716
|
+
if (part.length < 3 || planArea(part) < 1e-4) continue;
|
|
25717
|
+
cursor.pc = centroidPiece(part);
|
|
25718
|
+
tileRelief(mat, part, color2, type, pts[0]);
|
|
25719
|
+
}
|
|
25720
|
+
}
|
|
25721
|
+
function centroidPiece(pts) {
|
|
25722
|
+
let cx = 0, cz = 0;
|
|
25723
|
+
for (const p of pts) {
|
|
25724
|
+
cx += p[0];
|
|
25725
|
+
cz += p[2];
|
|
25726
|
+
}
|
|
25727
|
+
return pieceOfPane(cx / pts.length, cz / pts.length);
|
|
25728
|
+
}
|
|
25729
|
+
function panesUnder(pts) {
|
|
25730
|
+
if (shared2.ctx.noPiece || !shared2.ctx.panes.length) return [];
|
|
25731
|
+
let x0 = Infinity, z0 = Infinity, x1 = -Infinity, z1 = -Infinity;
|
|
25732
|
+
for (const p of pts) {
|
|
25733
|
+
x0 = Math.min(x0, p[0]);
|
|
25734
|
+
x1 = Math.max(x1, p[0]);
|
|
25735
|
+
z0 = Math.min(z0, p[2]);
|
|
25736
|
+
z1 = Math.max(z1, p[2]);
|
|
25737
|
+
}
|
|
25738
|
+
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);
|
|
25739
|
+
if (boxes.length < 2) return boxes;
|
|
25740
|
+
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]))];
|
|
25741
|
+
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]]);
|
|
25742
|
+
}
|
|
25743
|
+
function baysAlong(a, b) {
|
|
25744
|
+
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]]);
|
|
25745
|
+
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];
|
|
25746
|
+
if (Math.abs(span) < 1e-6) return [];
|
|
25747
|
+
const cuts = /* @__PURE__ */ new Set();
|
|
25748
|
+
for (const r of rects) for (const v of [r[k], r[k + 2]]) {
|
|
25749
|
+
const f = (v - a[i]) / span;
|
|
25750
|
+
if (Number.isFinite(f) && f > 0.01 && f < 0.99) cuts.add(+f.toFixed(4));
|
|
25751
|
+
}
|
|
25752
|
+
return [...cuts].sort((p, q) => p - q);
|
|
25753
|
+
}
|
|
25754
|
+
function clipToRect(pts, r) {
|
|
25755
|
+
let poly = pts.map((p) => [p[0], p[1], p[2]]);
|
|
25756
|
+
const edges = [[0, r[0], 1], [0, r[2], -1], [2, r[1], 1], [2, r[3], -1]];
|
|
25757
|
+
for (const [axis, at2, sign2] of edges) {
|
|
25758
|
+
if (!Number.isFinite(at2)) continue;
|
|
25759
|
+
const out = [];
|
|
25760
|
+
for (let i = 0; i < poly.length; i++) {
|
|
25761
|
+
const p = poly[i], q = poly[(i + 1) % poly.length], dp = (p[axis] - at2) * sign2, dq = (q[axis] - at2) * sign2;
|
|
25762
|
+
if (dp >= 0) out.push(p);
|
|
25763
|
+
if (dp >= 0 !== dq >= 0) {
|
|
25764
|
+
const t = dp / (dp - dq);
|
|
25765
|
+
out.push([p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t, p[2] + (q[2] - p[2]) * t]);
|
|
25766
|
+
}
|
|
25767
|
+
}
|
|
25768
|
+
poly = out;
|
|
25769
|
+
if (poly.length < 3) return [];
|
|
25770
|
+
}
|
|
25771
|
+
return poly;
|
|
25772
|
+
}
|
|
25773
|
+
function planArea(pts) {
|
|
25774
|
+
let a = 0;
|
|
25775
|
+
for (let i = 0; i < pts.length; i++) {
|
|
25776
|
+
const p = pts[i], q = pts[(i + 1) % pts.length];
|
|
25777
|
+
a += p[0] * q[2] - q[0] * p[2];
|
|
25778
|
+
}
|
|
25779
|
+
return Math.abs(a) / 2;
|
|
25780
|
+
}
|
|
25781
|
+
const defined = { R_STYLE, tileRelief, paneTiles, ridge, pieceOfPane };
|
|
24959
25782
|
Object.assign(K, defined);
|
|
24960
25783
|
}
|
|
24961
25784
|
function installRoofRect(K, shared2) {
|
|
@@ -24964,15 +25787,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24964
25787
|
function roofRect(type, X0, Z0, X1, Z1, yb, roofColor, gable, F, touchesU = [0, 0, 0, 0]) {
|
|
24965
25788
|
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;
|
|
24966
25789
|
const mat = type === "fiber_cement" ? "fiber_cement" : "tile", tp = type === "fiber_cement" ? 0.2 : 0.5, alongX = dx >= dz, up = [0, 1, 0];
|
|
24967
|
-
const Q = (pts) =>
|
|
24968
|
-
let cx = 0, cz = 0;
|
|
24969
|
-
for (const p of pts) {
|
|
24970
|
-
cx += p[0];
|
|
24971
|
-
cz += p[2];
|
|
24972
|
-
}
|
|
24973
|
-
cursor.pc = pieceOfPane(cx / pts.length, cz / pts.length);
|
|
24974
|
-
return tileRelief(mat, pts, roofColor, type);
|
|
24975
|
-
};
|
|
25790
|
+
const Q = (pts) => K.paneTiles(mat, pts, roofColor, type);
|
|
24976
25791
|
cursor.pc = pieceOfPane(xm, zm);
|
|
24977
25792
|
{
|
|
24978
25793
|
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;
|
|
@@ -29195,7 +30010,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29195
30010
|
if (!pc || pc.unit) return sp;
|
|
29196
30011
|
if (pc.role !== "wall" && pc.role !== "partition") {
|
|
29197
30012
|
const def = getAssembly(pc.assembly || (pc.material === "concrete" && ["slab", "beam", "column", "stair"].includes(pc.role) ? "reinforced_concrete" : ""));
|
|
29198
|
-
const
|
|
30013
|
+
const bars = def && def.reinforcement ? pc.role === "column" || pc.role === "beam" ? { ...def.reinforcement, diameter: Math.max(def.reinforcement.diameter, MEMBER_CAGE.diameter) } : def.reinforcement : null;
|
|
30014
|
+
const cage = bars ? pc.role === "column" && sp.shape.kind === "box" ? { ...bars, residualCapacity: cageResidualCapacity(sp.shape.size, bars, sp.structure?.capacity) } : { ...bars } : null;
|
|
29199
30015
|
const out = cage && !sp.reinforcement ? { ...sp, reinforcement: cage } : sp;
|
|
29200
30016
|
if (out.reinforcement && !out.units && pc.material === "concrete" && (pc.role === "beam" || pc.role === "column") && sp.shape.kind === "box") {
|
|
29201
30017
|
return { ...out, units: { size: [MEMBER_CAGE.unit, MEMBER_CAGE.unit, Math.min(...sp.shape.size)], bond: "stack", mortar: "concrete" } };
|
|
@@ -29401,6 +30217,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29401
30217
|
toHouse.value.copy(house.matrixWorld).invert().multiply(mesh2.matrixWorld);
|
|
29402
30218
|
return mesh2;
|
|
29403
30219
|
}
|
|
30220
|
+
const withMask = (material, mask) => {
|
|
30221
|
+
material.userData.breachMask = mask;
|
|
30222
|
+
return material;
|
|
30223
|
+
};
|
|
29404
30224
|
function unitsMaterial(core) {
|
|
29405
30225
|
const material = new THREE.MeshLambertMaterial({ color: 16777215, side: THREE.DoubleSide });
|
|
29406
30226
|
material.onBeforeCompile = (sh) => {
|
|
@@ -29485,13 +30305,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29485
30305
|
if (opening) discs.push({ s: along(opening.center), y: opening.center[1], r: opening.radius });
|
|
29486
30306
|
for (const k of spalls) flakes.push({ s: along(k.center), y: k.center[1], r: k.radius });
|
|
29487
30307
|
const boxes = chips.map((k) => ({ s0: along(k.center) - k.along, s1: along(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
|
|
29488
|
-
const gone = (c) =>
|
|
30308
|
+
const gone = (c) => {
|
|
30309
|
+
const over = boxes.filter((k) => k.s1 > c.a && k.s0 < c.b && k.y1 > c.y0 && k.y0 < c.y1);
|
|
30310
|
+
const share = covered(c, over);
|
|
30311
|
+
if (share >= 0.9) return true;
|
|
30312
|
+
const s = (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2;
|
|
30313
|
+
return share >= 0.5 && over.some((k) => s >= k.s0 && s <= k.s1 && y >= k.y0 && y <= k.y1);
|
|
30314
|
+
};
|
|
30315
|
+
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;
|
|
29489
30316
|
const kept = [];
|
|
29490
|
-
for (const c of all) (
|
|
30317
|
+
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
29491
30318
|
for (const c of kept) shown.push({ c, part, units: units2, thick, mid });
|
|
29492
|
-
for (const
|
|
29493
|
-
if (holes.some((h) =>
|
|
29494
|
-
|
|
30319
|
+
for (const box4 of boxes) {
|
|
30320
|
+
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;
|
|
30321
|
+
const k = id === view.host ? besidePillars({ a: box4.s0, b: box4.s1, y0: box4.y0, y1: box4.y1 }, pillars)[0] : { a: box4.s0, b: box4.s1, y0: box4.y0, y1: box4.y1 };
|
|
30322
|
+
if (!k) continue;
|
|
30323
|
+
pits.push({ s: (k.a + k.b) / 2, y: (k.y0 + k.y1) / 2, rs: (k.b - k.a) / 2, ry: (k.y1 - k.y0) / 2 });
|
|
29495
30324
|
}
|
|
29496
30325
|
}
|
|
29497
30326
|
const reach = SPALL_MIN + SPALL_RAGGED;
|
|
@@ -29520,6 +30349,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29520
30349
|
stamp(mask, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) => plaster(Math.max(0, ellipseDistance(s, y, p.s, p.y, p.rs, p.ry)), s, y));
|
|
29521
30350
|
stamp(core, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) => ellipseDistance(s, y, p.s, p.y, p.rs, p.ry) <= -0.35 * Math.min(p.rs, p.ry) * noise2(s * 1.7, y * 1.3, 0.012));
|
|
29522
30351
|
}
|
|
30352
|
+
for (const q of pillars) {
|
|
30353
|
+
const i0 = Math.max(0, Math.floor((q.a + 5e-3) / mask.len * mask.w)), i1 = Math.min(mask.w - 1, Math.floor((q.b - 5e-3) / mask.len * mask.w));
|
|
30354
|
+
const j0 = Math.max(0, Math.floor((q.y0 - mask.y0) / mask.height * mask.h)), j1 = Math.min(mask.h - 1, Math.floor((q.y1 - mask.y0) / mask.height * mask.h));
|
|
30355
|
+
for (let j = j0; j <= j1; j++) if (mask.data[j * mask.w + i0] && mask.data[j * mask.w + i1]) mask.data.fill(255, j * mask.w + i0, j * mask.w + i1 + 1);
|
|
30356
|
+
}
|
|
29523
30357
|
mask.texture.needsUpdate = true;
|
|
29524
30358
|
core.texture.needsUpdate = true;
|
|
29525
30359
|
const near = (c) => holes.some((h) => boxDistance((c.a + c.b) / 2, (c.y0 + c.y1) / 2, h.a - (c.b - c.a) / 2, h.b + (c.b - c.a) / 2, h.y0 - (c.y1 - c.y0) / 2, h.y1 + (c.y1 - c.y0) / 2) <= reach) || discs.some((d) => boxDistance(d.s, d.y, c.a, c.b, c.y0, c.y1) <= d.r + reach) || pits.some((p) => boxDistance(p.s, p.y, c.a, c.b, c.y0, c.y1) <= Math.max(p.rs, p.ry) + reach) || flakes.some((f) => boxDistance(f.s, f.y, c.a, c.b, c.y0, c.y1) <= 2 * f.r);
|
|
@@ -29586,7 +30420,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29586
30420
|
items,
|
|
29587
30421
|
mask,
|
|
29588
30422
|
core,
|
|
29589
|
-
unitMaterial: unitsMaterial(core),
|
|
30423
|
+
unitMaterial: withMask(unitsMaterial(core), mask),
|
|
29590
30424
|
shells: [],
|
|
29591
30425
|
saved: null,
|
|
29592
30426
|
units: null,
|