@adatechnology/game-weapons-three 0.21.0 → 0.21.1
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 +856 -112
- package/dist/index.global.js.map +1 -1
- package/package.json +8 -8
package/dist/index.global.js
CHANGED
|
@@ -22354,21 +22354,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22354
22354
|
for (const row of rows.values()) for (const i of row) if (!held.has(i)) loose.push(i);
|
|
22355
22355
|
return loose;
|
|
22356
22356
|
};
|
|
22357
|
-
var
|
|
22357
|
+
var clumpUnits = (cells, thin, unit, cap) => {
|
|
22358
22358
|
if (cells.length <= cap) return [...cells];
|
|
22359
22359
|
const [u, v] = planeAxes(thin);
|
|
22360
|
-
let lo0 = Infinity, lo1 = Infinity
|
|
22360
|
+
let lo0 = Infinity, lo1 = Infinity;
|
|
22361
22361
|
for (const cell of cells) {
|
|
22362
22362
|
lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
|
|
22363
|
-
hi0 = Math.max(hi0, cell.center[u] + cell.size[u] / 2);
|
|
22364
22363
|
lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
|
|
22365
|
-
hi1 = Math.max(hi1, cell.center[v] + cell.size[v] / 2);
|
|
22366
22364
|
}
|
|
22367
|
-
let
|
|
22368
|
-
for (; ; ) {
|
|
22365
|
+
let along = 1, up = 1;
|
|
22366
|
+
for (let grow = 0; ; grow++) {
|
|
22369
22367
|
const bins = /* @__PURE__ */ new Map();
|
|
22370
22368
|
for (const cell of cells) {
|
|
22371
|
-
const key2 = `${Math.floor((cell.center[u] - lo0) /
|
|
22369
|
+
const key2 = `${Math.floor((cell.center[u] - lo0) / (along * unit[0]))}:${Math.floor((cell.center[v] - lo1) / (up * unit[1]))}`;
|
|
22372
22370
|
const bin = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
|
|
22373
22371
|
for (let k = 0; k < 3; k++) {
|
|
22374
22372
|
bin.lo[k] = Math.min(bin.lo[k], cell.center[k] - cell.size[k] / 2);
|
|
@@ -22379,7 +22377,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22379
22377
|
if (bins.size <= cap) {
|
|
22380
22378
|
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]] }));
|
|
22381
22379
|
}
|
|
22382
|
-
|
|
22380
|
+
if (grow % 2 === 0) up++;
|
|
22381
|
+
else along++;
|
|
22383
22382
|
}
|
|
22384
22383
|
};
|
|
22385
22384
|
var MAX_SPALLS = 64;
|
|
@@ -22448,6 +22447,39 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22448
22447
|
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]]));
|
|
22449
22448
|
return out;
|
|
22450
22449
|
};
|
|
22450
|
+
var STIRRUP_SPACING = 0.15;
|
|
22451
|
+
var memberStirrups = (dims, spacing = STIRRUP_SPACING) => {
|
|
22452
|
+
if (!isMember(dims)) return [];
|
|
22453
|
+
const long = dims.indexOf(Math.max(...dims));
|
|
22454
|
+
const [u = 0, v = 0] = [0, 1, 2].filter((i) => i !== long);
|
|
22455
|
+
const hu = dims[u] / 2 - COVER, hv = dims[v] / 2 - COVER;
|
|
22456
|
+
const out = [];
|
|
22457
|
+
for (const s of spread(dims[long], 0.05, spacing, 200)) {
|
|
22458
|
+
const corner = (x, y) => {
|
|
22459
|
+
const c = [0, 0, 0];
|
|
22460
|
+
c[long] = s;
|
|
22461
|
+
c[u] = x;
|
|
22462
|
+
c[v] = y;
|
|
22463
|
+
return c;
|
|
22464
|
+
};
|
|
22465
|
+
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)]);
|
|
22466
|
+
}
|
|
22467
|
+
return out;
|
|
22468
|
+
};
|
|
22469
|
+
var clipBarsToVolume = (bars, center, size) => {
|
|
22470
|
+
const out = [];
|
|
22471
|
+
for (const [a, b] of bars) {
|
|
22472
|
+
const axis2 = [0, 1, 2].find((k) => a[k] !== b[k]) ?? 0;
|
|
22473
|
+
if ([0, 1, 2].some((k) => k !== axis2 && Math.abs(a[k] - center[k]) > size[k] / 2 + 1e-6)) continue;
|
|
22474
|
+
const lo = Math.max(Math.min(a[axis2], b[axis2]), center[axis2] - size[axis2] / 2), hi = Math.min(Math.max(a[axis2], b[axis2]), center[axis2] + size[axis2] / 2);
|
|
22475
|
+
if (hi - lo < 1e-6) continue;
|
|
22476
|
+
const p = [a[0], a[1], a[2]], q = [b[0], b[1], b[2]];
|
|
22477
|
+
p[axis2] = lo;
|
|
22478
|
+
q[axis2] = hi;
|
|
22479
|
+
out.push([p, q]);
|
|
22480
|
+
}
|
|
22481
|
+
return out;
|
|
22482
|
+
};
|
|
22451
22483
|
var clipBarsToBox = (bars, u, v, center, size) => {
|
|
22452
22484
|
const out = [];
|
|
22453
22485
|
for (const [a, b] of bars) {
|
|
@@ -22861,6 +22893,120 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22861
22893
|
const stable = converged && cholesky3(ev.Jt, [0, 0, 0]) !== null;
|
|
22862
22894
|
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]] };
|
|
22863
22895
|
};
|
|
22896
|
+
function voidRuns(flags, step) {
|
|
22897
|
+
const runs = [];
|
|
22898
|
+
let start = -1;
|
|
22899
|
+
for (let i = 0; i <= flags.length; i++) {
|
|
22900
|
+
if (i < flags.length && flags[i]) {
|
|
22901
|
+
if (start < 0) start = i;
|
|
22902
|
+
continue;
|
|
22903
|
+
}
|
|
22904
|
+
if (start >= 0) runs.push({ start: start * step, end: i * step });
|
|
22905
|
+
start = -1;
|
|
22906
|
+
}
|
|
22907
|
+
return runs;
|
|
22908
|
+
}
|
|
22909
|
+
var PILLAR_REACH = 0.15;
|
|
22910
|
+
var pillarNear = (pillars, at4) => pillars.some((p) => Math.abs(p - at4) <= PILLAR_REACH);
|
|
22911
|
+
function splitAtPillars(runs, pillars) {
|
|
22912
|
+
const out = [];
|
|
22913
|
+
for (const run of runs) {
|
|
22914
|
+
const inside2 = pillars.filter((p) => p > run.start + PILLAR_REACH && p < run.end - PILLAR_REACH).sort((a, b) => a - b);
|
|
22915
|
+
let from = run.start;
|
|
22916
|
+
for (const p of inside2) {
|
|
22917
|
+
out.push({ start: from, end: p });
|
|
22918
|
+
from = p;
|
|
22919
|
+
}
|
|
22920
|
+
out.push({ start: from, end: run.end });
|
|
22921
|
+
}
|
|
22922
|
+
return out;
|
|
22923
|
+
}
|
|
22924
|
+
function mergeRuns(runs, check2) {
|
|
22925
|
+
let list2 = [...runs];
|
|
22926
|
+
for (let changed = true; changed; ) {
|
|
22927
|
+
changed = false;
|
|
22928
|
+
for (let k = 0; k <= list2.length && !changed; k++) {
|
|
22929
|
+
const before = list2[k - 1];
|
|
22930
|
+
const after2 = list2[k];
|
|
22931
|
+
const from = before ? before.end : 0;
|
|
22932
|
+
const to = after2 ? after2.start : check2.length;
|
|
22933
|
+
const soil = to - from;
|
|
22934
|
+
if (soil <= 0 || !before && !after2) continue;
|
|
22935
|
+
if (check2.pillars.some((p) => p >= from - PILLAR_REACH && p <= to + PILLAR_REACH)) continue;
|
|
22936
|
+
if (!before && check2.continuous?.[0] || !after2 && check2.continuous?.[1]) continue;
|
|
22937
|
+
const reaction = (before ? (before.end - before.start) / 2 : 0) + (after2 ? (after2.end - after2.start) / 2 : 0);
|
|
22938
|
+
const narrow = soil < check2.depth;
|
|
22939
|
+
const weak = reaction > (check2.soilSafety - 1) * soil;
|
|
22940
|
+
if (!narrow && !weak) continue;
|
|
22941
|
+
const merged2 = { start: before ? before.start : 0, end: after2 ? after2.end : check2.length };
|
|
22942
|
+
list2 = [...list2.slice(0, Math.max(0, k - 1)), merged2, ...list2.slice(after2 ? k + 1 : k)];
|
|
22943
|
+
changed = true;
|
|
22944
|
+
}
|
|
22945
|
+
}
|
|
22946
|
+
return list2;
|
|
22947
|
+
}
|
|
22948
|
+
function judgeBeam(flags, step, check2) {
|
|
22949
|
+
const merged2 = mergeRuns(voidRuns(flags, step), check2);
|
|
22950
|
+
const runs = splitAtPillars(merged2, check2.pillars);
|
|
22951
|
+
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);
|
|
22952
|
+
const verdicts = [];
|
|
22953
|
+
let tips = false;
|
|
22954
|
+
for (const run of runs) {
|
|
22955
|
+
const span = run.end - run.start;
|
|
22956
|
+
const freeStart = run.start <= 1e-9 && !pillarNear(check2.pillars, 0) && !check2.continuous?.[0];
|
|
22957
|
+
const freeEnd = run.end >= check2.length - 1e-9 && !pillarNear(check2.pillars, check2.length) && !check2.continuous?.[1];
|
|
22958
|
+
if (freeStart && freeEnd) {
|
|
22959
|
+
verdicts.push({ ...run, kind: "cantilever", span, moment: Infinity, holds: false, cracks: true });
|
|
22960
|
+
tips = true;
|
|
22961
|
+
continue;
|
|
22962
|
+
}
|
|
22963
|
+
const cantilever = freeStart || freeEnd;
|
|
22964
|
+
const moment = (cantilever ? check2.load * span * span / 2 : check2.load * span * span / 8) * check2.loadFactor;
|
|
22965
|
+
const reach = cantilever ? check2.spanDepth * check2.depth / 2 : check2.spanDepth * check2.depth;
|
|
22966
|
+
const balanced = !cantilever || span <= behind(run, freeStart);
|
|
22967
|
+
const rooted = cantilever && pillarNear(check2.pillars, freeStart ? run.end : run.start);
|
|
22968
|
+
const held = cantilever && !!check2.continuous?.[freeStart ? 1 : 0];
|
|
22969
|
+
const holds3 = span <= reach && moment <= check2.resists && (balanced || rooted);
|
|
22970
|
+
verdicts.push({ ...run, kind: cantilever ? "cantilever" : "span", span, moment, holds: holds3, cracks: moment > check2.cracking });
|
|
22971
|
+
if (cantilever && !holds3 && !balanced && !rooted && !held) tips = true;
|
|
22972
|
+
}
|
|
22973
|
+
return { runs: verdicts, tips };
|
|
22974
|
+
}
|
|
22975
|
+
function judgePlate(check2) {
|
|
22976
|
+
const a = check2.across;
|
|
22977
|
+
const moment = (check2.load * a * a / 8 + check2.points.reduce((sum2, p) => sum2 + p.weight * a / 4, 0)) * check2.loadFactor;
|
|
22978
|
+
const d = Math.max(0.01, check2.effectiveDepth);
|
|
22979
|
+
const punched = check2.points.some((p) => p.weight * check2.loadFactor / (4 * (p.side + d) * d) > check2.punching);
|
|
22980
|
+
return { holds: moment <= check2.resists && !punched, cracks: moment > check2.cracking, moment, punched };
|
|
22981
|
+
}
|
|
22982
|
+
var cross2 = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
|
22983
|
+
function convexHull(points) {
|
|
22984
|
+
const sorted = [...points].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
22985
|
+
if (sorted.length < 3) return sorted;
|
|
22986
|
+
const lower = [];
|
|
22987
|
+
for (const p of sorted) {
|
|
22988
|
+
while (lower.length >= 2 && cross2(lower[lower.length - 2], lower[lower.length - 1], p) <= 0) lower.pop();
|
|
22989
|
+
lower.push(p);
|
|
22990
|
+
}
|
|
22991
|
+
const upper = [];
|
|
22992
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
22993
|
+
const p = sorted[i];
|
|
22994
|
+
while (upper.length >= 2 && cross2(upper[upper.length - 2], upper[upper.length - 1], p) <= 0) upper.pop();
|
|
22995
|
+
upper.push(p);
|
|
22996
|
+
}
|
|
22997
|
+
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
|
22998
|
+
}
|
|
22999
|
+
function restsOver(point, contacts, margin) {
|
|
23000
|
+
const hull = convexHull(contacts);
|
|
23001
|
+
if (hull.length < 3) return false;
|
|
23002
|
+
for (let i = 0; i < hull.length; i++) {
|
|
23003
|
+
const a = hull[i];
|
|
23004
|
+
const b = hull[(i + 1) % hull.length];
|
|
23005
|
+
const length2 = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1;
|
|
23006
|
+
if (cross2(a, b, point) / length2 < margin) return false;
|
|
23007
|
+
}
|
|
23008
|
+
return true;
|
|
23009
|
+
}
|
|
22864
23010
|
var GROUND_LOSS_DEFAULTS = {
|
|
22865
23011
|
footingDepth: 0.5,
|
|
22866
23012
|
spread: 1,
|
|
@@ -22868,6 +23014,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22868
23014
|
maxSettlement: 0.05,
|
|
22869
23015
|
crackDistortion: 1 / 300,
|
|
22870
23016
|
damageDistortion: 1 / 150,
|
|
23017
|
+
bearingCrackDistortion: 1 / 500,
|
|
23018
|
+
bearingDamageDistortion: 1 / 300,
|
|
22871
23019
|
distortionDamage: 0.3,
|
|
22872
23020
|
bridgeSpanDepth: 10,
|
|
22873
23021
|
beamRebarRatio: 4e-3
|
|
@@ -22887,33 +23035,77 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22887
23035
|
const steepest = loss.radius * loss.radius / (2 * loss.depth * spread2);
|
|
22888
23036
|
return Math.max(0, cut(reach), cut(Math.min(reach, steepest)), cut(0));
|
|
22889
23037
|
};
|
|
22890
|
-
var
|
|
22891
|
-
|
|
22892
|
-
|
|
22893
|
-
|
|
22894
|
-
|
|
22895
|
-
|
|
22896
|
-
continue;
|
|
22897
|
-
}
|
|
22898
|
-
if (start >= 0 && (!best || i - start > best.end - best.start)) best = { start, end: i };
|
|
22899
|
-
start = -1;
|
|
22900
|
-
}
|
|
22901
|
-
return best;
|
|
23038
|
+
var relativeToChord = (drops) => {
|
|
23039
|
+
const n = drops.length;
|
|
23040
|
+
if (n < 2) return drops.map(() => 0);
|
|
23041
|
+
const first = drops[0];
|
|
23042
|
+
const last = drops[n - 1];
|
|
23043
|
+
return drops.map((v, k) => v - (first + (last - first) * k / (n - 1)));
|
|
22902
23044
|
};
|
|
22903
23045
|
var distortionOf = (drops, step) => {
|
|
22904
23046
|
const span = Math.max(1, Math.round(DISTORTION_BASE / step));
|
|
22905
23047
|
let value = 0;
|
|
22906
23048
|
let at4 = 0;
|
|
23049
|
+
let down = 1;
|
|
22907
23050
|
for (let i = 0; i < drops.length; i++) {
|
|
22908
23051
|
const j = Math.min(drops.length - 1, i + span);
|
|
22909
23052
|
if (j === i) continue;
|
|
22910
|
-
const
|
|
23053
|
+
const change = drops[j] - drops[i];
|
|
23054
|
+
const beta = Math.abs(change) / Math.max((j - i) * step, DISTORTION_BASE);
|
|
22911
23055
|
if (beta > value) {
|
|
22912
23056
|
value = beta;
|
|
22913
23057
|
at4 = (i + j) / 2;
|
|
23058
|
+
down = change >= 0 ? 1 : -1;
|
|
22914
23059
|
}
|
|
22915
23060
|
}
|
|
22916
|
-
return { value, at: at4 };
|
|
23061
|
+
return { value, at: at4, down };
|
|
23062
|
+
};
|
|
23063
|
+
var smoothProfile = (drops, step, window2) => {
|
|
23064
|
+
const half = Math.max(0, Math.round(window2 / step / 2));
|
|
23065
|
+
return drops.map((_, k) => {
|
|
23066
|
+
let sum2 = 0;
|
|
23067
|
+
let count = 0;
|
|
23068
|
+
for (let i = Math.max(0, k - half); i <= Math.min(drops.length - 1, k + half); i++) {
|
|
23069
|
+
sum2 += drops[i];
|
|
23070
|
+
count++;
|
|
23071
|
+
}
|
|
23072
|
+
return sum2 / count;
|
|
23073
|
+
});
|
|
23074
|
+
};
|
|
23075
|
+
var BEAM_SPREAD = 1;
|
|
23076
|
+
var SETTLEMENT_POINTS = 24;
|
|
23077
|
+
var settlementProfile = (drops, step) => {
|
|
23078
|
+
const n = drops.length;
|
|
23079
|
+
if (n === 0) return [0, 0];
|
|
23080
|
+
const length2 = n * step;
|
|
23081
|
+
const count = Math.max(2, Math.min(SETTLEMENT_POINTS, n + 1));
|
|
23082
|
+
const out = [];
|
|
23083
|
+
for (let k = 0; k < count; k++) {
|
|
23084
|
+
const at4 = clampNumber(k / (count - 1) * length2 / step - 0.5, 0, n - 1);
|
|
23085
|
+
const i = Math.floor(at4);
|
|
23086
|
+
const j = Math.min(n - 1, i + 1);
|
|
23087
|
+
out.push(drops[i] + (drops[j] - drops[i]) * (at4 - i));
|
|
23088
|
+
}
|
|
23089
|
+
return out;
|
|
23090
|
+
};
|
|
23091
|
+
var clampNumber = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
23092
|
+
var settlementAt = (settlement, point) => {
|
|
23093
|
+
const d = [settlement.to[0] - settlement.from[0], settlement.to[1] - settlement.from[1], settlement.to[2] - settlement.from[2]];
|
|
23094
|
+
const length2 = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
|
|
23095
|
+
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;
|
|
23096
|
+
const drops = settlement.drop;
|
|
23097
|
+
if (drops.length === 0) return 0;
|
|
23098
|
+
const at4 = t * (drops.length - 1);
|
|
23099
|
+
const i = Math.floor(at4);
|
|
23100
|
+
const j = Math.min(drops.length - 1, i + 1);
|
|
23101
|
+
return drops[i] + (drops[j] - drops[i]) * (at4 - i);
|
|
23102
|
+
};
|
|
23103
|
+
var mergeSettlement = (old, next) => {
|
|
23104
|
+
if (!old) return next;
|
|
23105
|
+
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);
|
|
23106
|
+
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])) };
|
|
23107
|
+
const mean = (line) => line.drop.reduce((sum2, v) => sum2 + v, 0) / Math.max(1, line.drop.length);
|
|
23108
|
+
return mean(old) >= mean(next) ? old : next;
|
|
22917
23109
|
};
|
|
22918
23110
|
var wind_terrain_default = [
|
|
22919
23111
|
{ 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 },
|
|
@@ -24710,6 +24902,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24710
24902
|
var SUPPORT_TOLERANCE = 0.05;
|
|
24711
24903
|
var UNIT_FRAGMENT_FACTOR = 4;
|
|
24712
24904
|
var BREACH_GRID_CAP = 4096;
|
|
24905
|
+
var MASONRY_CRUMBLE_SPEED = 0.6;
|
|
24906
|
+
var TILE_CLUMPS = 160;
|
|
24907
|
+
var PANEL_EDGE_PILLAR = 2;
|
|
24908
|
+
var PANEL_EDGE_BASE = 4;
|
|
24909
|
+
var PANEL_EDGE_BEAM = 3;
|
|
24910
|
+
var PLASTER_FLAKE_AREA = 0.25;
|
|
24911
|
+
var MAX_PLASTER_FLAKES = 24;
|
|
24713
24912
|
var CHIP_ENERGY = 200;
|
|
24714
24913
|
var CHIP_SPLASH = 0.5;
|
|
24715
24914
|
var CRATER_SPENT = 0.6;
|
|
@@ -24720,7 +24919,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24720
24919
|
var DISTORTION_GROWTH = 1.2;
|
|
24721
24920
|
var MAX_SETTLEMENT_CRACKS = 4;
|
|
24722
24921
|
var SETTLEMENT_CRACK_LENGTH = 0.3;
|
|
24922
|
+
var SETTLEMENT_CRACK_SPACING = 0.4;
|
|
24923
|
+
var SETTLEMENT_CRACK_OPENING = 0.3;
|
|
24924
|
+
var MIN_CRACK_WIDTH = 5e-4;
|
|
24925
|
+
var MAX_CRACK_WIDTH = 0.02;
|
|
24926
|
+
var BESIDE_CRACK_OFFSET = 0.8;
|
|
24927
|
+
var BRICK_STEP = [0.2, 0.1];
|
|
24928
|
+
var SETTLEMENT_FOLLOW_DEPTH = 2;
|
|
24723
24929
|
var CRACKED_STIFFNESS = 0.4;
|
|
24930
|
+
var PILLAR_SEAT = 0.05;
|
|
24931
|
+
var PUNCHING_SHARE = 0.5;
|
|
24932
|
+
var ARCH_ANGLE = Math.PI / 3;
|
|
24724
24933
|
var CUT_SLICE = 1;
|
|
24725
24934
|
var cutFactorOf = (shape) => clamp2(Math.max(...shapeDims(shape)) / CUT_SLICE, 1, 50);
|
|
24726
24935
|
var clamp2 = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
@@ -24796,6 +25005,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24796
25005
|
for (const m of options.materials ?? []) materials.set(m.id, m);
|
|
24797
25006
|
const ambient = options.ambientC ?? 20;
|
|
24798
25007
|
const maxFragments = options.maxFragments ?? 24;
|
|
25008
|
+
const unitClumps = maxFragments * UNIT_FRAGMENT_FACTOR;
|
|
25009
|
+
const fallenClumps = Math.max(2, Math.round(unitClumps / 4));
|
|
24799
25010
|
const maxDents = options.maxDents ?? 24;
|
|
24800
25011
|
const maxHoles = options.maxHoles ?? 32;
|
|
24801
25012
|
const fireSpread = options.fireSpread ?? 0.6;
|
|
@@ -25106,6 +25317,61 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25106
25317
|
return (above2 + p.st.mass * share) / load;
|
|
25107
25318
|
};
|
|
25108
25319
|
};
|
|
25320
|
+
const contactsOf = (p, support) => {
|
|
25321
|
+
const box5 = contactBox(p, support);
|
|
25322
|
+
const broken = support.rt.broken;
|
|
25323
|
+
if (!broken?.length) return [box5];
|
|
25324
|
+
let pieces = [box5];
|
|
25325
|
+
for (const [axis2, from, to] of broken) {
|
|
25326
|
+
const a = [p.pos[0], p.pos[1], p.pos[2]];
|
|
25327
|
+
const b = [p.pos[0], p.pos[1], p.pos[2]];
|
|
25328
|
+
a[axis2] = from;
|
|
25329
|
+
b[axis2] = to;
|
|
25330
|
+
const la = toLocal(p.pos, p.q, a);
|
|
25331
|
+
const lb = toLocal(p.pos, p.q, b);
|
|
25332
|
+
const k = [0, 1, 2].reduce((best, c) => Math.abs(lb[c] - la[c]) > Math.abs(lb[best] - la[best]) ? c : best, 0);
|
|
25333
|
+
const lo = Math.min(la[k], lb[k]);
|
|
25334
|
+
const hi = Math.max(la[k], lb[k]);
|
|
25335
|
+
pieces = pieces.flatMap(([min2, max2]) => {
|
|
25336
|
+
if (hi <= min2[k] || lo >= max2[k]) return [[min2, max2]];
|
|
25337
|
+
const out = [];
|
|
25338
|
+
if (lo > min2[k]) {
|
|
25339
|
+
const end3 = [max2[0], max2[1], max2[2]];
|
|
25340
|
+
end3[k] = lo;
|
|
25341
|
+
out.push([min2, end3]);
|
|
25342
|
+
}
|
|
25343
|
+
if (hi < max2[k]) {
|
|
25344
|
+
const start = [min2[0], min2[1], min2[2]];
|
|
25345
|
+
start[k] = hi;
|
|
25346
|
+
out.push([start, max2]);
|
|
25347
|
+
}
|
|
25348
|
+
return out;
|
|
25349
|
+
});
|
|
25350
|
+
}
|
|
25351
|
+
return pieces;
|
|
25352
|
+
};
|
|
25353
|
+
const fixedJoint = (j) => j.spec.kind === "rebar" || j.spec.kind === "fused" || j.spec.kind === "weld";
|
|
25354
|
+
const standsOver = (o, p, lower) => {
|
|
25355
|
+
const role = p.spec.structure?.role;
|
|
25356
|
+
if (role !== "slab" && role !== "roof" || p.spec.shape.kind !== "box" || lower.length === 0) return true;
|
|
25357
|
+
if (Math.abs(rotateVec(p.q, [0, 0, 0].map((_, k) => k === p.thin ? 1 : 0))[1]) < 0.9) return true;
|
|
25358
|
+
const i = o.idx.get(p.spec.id);
|
|
25359
|
+
for (const j of o.byPart.get(p.spec.id) ?? []) {
|
|
25360
|
+
if (j.st.open) continue;
|
|
25361
|
+
if (fixedJoint(j) && lower.includes(restsOn(o, j, i)) || j.spec.kind === "tie") return true;
|
|
25362
|
+
}
|
|
25363
|
+
const corners = [];
|
|
25364
|
+
for (const k of lower) {
|
|
25365
|
+
for (const [lo, hi] of contactsOf(p, o.parts[k])) {
|
|
25366
|
+
for (let c = 0; c < 4; c++) {
|
|
25367
|
+
const local2 = [c & 1 ? hi[0] : lo[0], (lo[1] + hi[1]) / 2, c & 2 ? hi[2] : lo[2]];
|
|
25368
|
+
const at4 = toWorld(p.pos, p.q, local2);
|
|
25369
|
+
corners.push([at4[0], at4[2]]);
|
|
25370
|
+
}
|
|
25371
|
+
}
|
|
25372
|
+
}
|
|
25373
|
+
return restsOver([p.pos[0], p.pos[2]], corners, 0);
|
|
25374
|
+
};
|
|
25109
25375
|
const borneOn = (p, supports) => {
|
|
25110
25376
|
if (supports.length === 0) return void 0;
|
|
25111
25377
|
const boxes = supports.map((support) => contactBox(p, support));
|
|
@@ -25161,7 +25427,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25161
25427
|
const key2 = lower.join(",");
|
|
25162
25428
|
if (key2 !== p.spanKey) {
|
|
25163
25429
|
p.spanKey = key2;
|
|
25164
|
-
p.span = spanOf(g, lower.
|
|
25430
|
+
p.span = spanOf(g, lower.flatMap((k) => contactsOf(p, o.parts[k])));
|
|
25165
25431
|
}
|
|
25166
25432
|
p.restMoment = 0;
|
|
25167
25433
|
if (g.gravity < 0 || p.span <= 0) return 0;
|
|
@@ -25227,9 +25493,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25227
25493
|
};
|
|
25228
25494
|
const freeSpan = (p, supports) => {
|
|
25229
25495
|
if (supports.length === 0) return Infinity;
|
|
25496
|
+
if (p.spec.shape.kind === "box") {
|
|
25497
|
+
const g = bendGeometry(p.spec);
|
|
25498
|
+
if (!g.member) return spanOf(g, supports.flatMap((k) => contactsOf(p, k)));
|
|
25499
|
+
}
|
|
25230
25500
|
const d = p.dims;
|
|
25231
25501
|
const L = [0, 1, 2].sort((a, b) => d[b] - d[a])[0];
|
|
25232
|
-
const spans = supports.
|
|
25502
|
+
const spans = supports.flatMap((k) => contactsOf(p, k)).map(([lo, hi]) => [lo[L], hi[L]]);
|
|
25233
25503
|
let far = 0;
|
|
25234
25504
|
for (let i = 0; i <= 16; i++) {
|
|
25235
25505
|
const x = (i / 16 - 0.5) * d[L];
|
|
@@ -25279,7 +25549,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25279
25549
|
}
|
|
25280
25550
|
lowerOf.set(i, lower);
|
|
25281
25551
|
const max2 = parts[i].spec.structure?.maxSpan;
|
|
25282
|
-
|
|
25552
|
+
const tooLong = max2 !== void 0 && freeSpan(parts[i], lower.map((k) => parts[k])) > max2;
|
|
25553
|
+
const standing = parts[i].heldAsDesigned || standsOver(o, parts[i], lower);
|
|
25554
|
+
if (o.seeding && !standing) parts[i].heldAsDesigned = true;
|
|
25555
|
+
if (!parts[i].anchored && (tooLong || !(standing || parts[i].heldAsDesigned))) {
|
|
25283
25556
|
out.add(i);
|
|
25284
25557
|
dropped = true;
|
|
25285
25558
|
}
|
|
@@ -25733,20 +26006,46 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25733
26006
|
if (!o.hasStructure || !o.parts.some((p) => p.anchored)) return;
|
|
25734
26007
|
if (!pendingCollapse.has(o)) pendingCollapse.set(o, src);
|
|
25735
26008
|
};
|
|
26009
|
+
const isLaidMasonry = (p) => !!p.spec.units && p.spec.units.mortar !== p.spec.material && !p.spec.reinforcement && !p.st.stripped;
|
|
26010
|
+
const isTiledCover = (p) => p.spec.structure?.role === "roof" && p.mat.fracture === "shatter" && !p.spec.reinforcement && !p.spec.units;
|
|
26011
|
+
const crumbleMasonry = (o, p, src) => {
|
|
26012
|
+
if (isLost(p)) return;
|
|
26013
|
+
const [u, v] = planeAxes(p.thin);
|
|
26014
|
+
const grid = gridOf(p);
|
|
26015
|
+
const worn = p.rt.chips ?? {};
|
|
26016
|
+
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
26017
|
+
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));
|
|
26018
|
+
const { c } = partXf(o, p);
|
|
26019
|
+
const fragments = cells.length > 0 ? [
|
|
26020
|
+
...cellFragments(o, p, clumpUnits(cells, p.thin, unitSpan(p), isTiledCover(p) ? TILE_CLUMPS : unitClumps), vec.add(c, [0, 1, 0]), null, MASONRY_CRUMBLE_SPEED, p.st.mass, "m_", true),
|
|
26021
|
+
...plasterFlakes(o, p, cells, vec.add(c, [0, 1, 0]), MASONRY_CRUMBLE_SPEED, "mp_")
|
|
26022
|
+
] : [];
|
|
26023
|
+
p.st.status = "broken";
|
|
26024
|
+
p.st.hp = 0;
|
|
26025
|
+
p.st.mass = 0;
|
|
26026
|
+
emit2({ ...base(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
|
|
26027
|
+
debris2(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
|
|
26028
|
+
setStage(o, p, 3, {}, src);
|
|
26029
|
+
partLost(o, p, src);
|
|
26030
|
+
};
|
|
25736
26031
|
const flushCollapse = () => {
|
|
25737
26032
|
for (const [o, src] of [...pendingCollapse]) {
|
|
25738
26033
|
pendingCollapse.delete(o);
|
|
25739
26034
|
if (!objects.has(o.id) || objects.get(o.id) !== o) continue;
|
|
25740
|
-
|
|
26035
|
+
const crumbling = [];
|
|
26036
|
+
for (const g of [...o.st.groups]) {
|
|
25741
26037
|
const ps = g.map((id) => o.byId.get(id)).filter((p) => !isLost(p) && !o.collapsed.has(p.spec.id));
|
|
25742
26038
|
if (ps.length === 0 || g.some((id) => o.byId.get(id).anchored) || !ps.some((p) => p.structural)) continue;
|
|
25743
|
-
|
|
26039
|
+
const whole2 = ps.filter((p) => !isLaidMasonry(p) && !isTiledCover(p));
|
|
26040
|
+
crumbling.push(...ps.filter((p) => isLaidMasonry(p) || isTiledCover(p)));
|
|
26041
|
+
for (const p of whole2) {
|
|
25744
26042
|
o.collapsed.add(p.spec.id);
|
|
25745
26043
|
p.st.status = "collapsed";
|
|
25746
26044
|
setStage(o, p, 3, {}, src);
|
|
25747
26045
|
}
|
|
25748
|
-
emit2({ ...base(o, src), type: "collapse", parts:
|
|
26046
|
+
if (whole2.length > 0) emit2({ ...base(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum2, p) => sum2 + p.st.mass, 0) });
|
|
25749
26047
|
}
|
|
26048
|
+
for (const p of crumbling) crumbleMasonry(o, p, src);
|
|
25750
26049
|
}
|
|
25751
26050
|
};
|
|
25752
26051
|
const groundCfg = resolveGroundLoss(options.groundLoss);
|
|
@@ -25787,17 +26086,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25787
26086
|
let sum2 = 0;
|
|
25788
26087
|
let worst = -1;
|
|
25789
26088
|
let deepest = toWorld(o.st.position, o.st.rotation, [(box5.min[0] + box5.max[0]) / 2, box5.min[1], (box5.min[2] + box5.max[2]) / 2]);
|
|
26089
|
+
let voidBox = null;
|
|
25790
26090
|
for (let k = 0; k < n; k++) {
|
|
25791
26091
|
let open = 0;
|
|
25792
26092
|
let drop = 0;
|
|
26093
|
+
let cutSum = 0;
|
|
25793
26094
|
for (let c = 0; c < m; c++) {
|
|
25794
26095
|
const local2 = [0, box5.min[1], 0];
|
|
25795
26096
|
local2[long] = box5.min[long] + (k + 0.5) * step;
|
|
25796
26097
|
local2[across2] = box5.min[across2] + (c + 0.5) * (box5.max[across2] - box5.min[across2]) / m;
|
|
25797
26098
|
const world2 = toWorld(o.st.position, o.st.rotation, local2);
|
|
25798
26099
|
const cut = undercutAt(loss, Math.hypot(world2[0] - loss.x, world2[2] - loss.z), b.embed, groundCfg.spread);
|
|
25799
|
-
if (cut >= groundCfg.voidDepth)
|
|
26100
|
+
if (cut >= groundCfg.voidDepth) {
|
|
26101
|
+
open++;
|
|
26102
|
+
const along = local2[long] - box5.min[long];
|
|
26103
|
+
const side = local2[across2] - box5.min[across2];
|
|
26104
|
+
voidBox ?? (voidBox = { long: [along, along], across: [side, side] });
|
|
26105
|
+
voidBox.long = [Math.min(voidBox.long[0], along - step / 2), Math.max(voidBox.long[1], along + step / 2)];
|
|
26106
|
+
voidBox.across = [Math.min(voidBox.across[0], side), Math.max(voidBox.across[1], side)];
|
|
26107
|
+
}
|
|
25800
26108
|
drop += Math.min(cut, groundCfg.maxSettlement);
|
|
26109
|
+
cutSum += cut;
|
|
25801
26110
|
if (cut > worst) {
|
|
25802
26111
|
worst = cut;
|
|
25803
26112
|
deepest = world2;
|
|
@@ -25805,56 +26114,326 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25805
26114
|
}
|
|
25806
26115
|
voids += open;
|
|
25807
26116
|
sum2 += drop;
|
|
25808
|
-
slices.push({ void: open * 2 > m, drop: drop / m });
|
|
26117
|
+
slices.push({ void: open * 2 > m, drop: drop / m, cut: cutSum / m });
|
|
25809
26118
|
}
|
|
25810
|
-
return { long, step, slices, share: voids / (n * m), drop: sum2 / (n * m), deepest };
|
|
26119
|
+
return { long, step, slices, voidBox, share: voids / (n * m), drop: sum2 / (n * m), deepest };
|
|
25811
26120
|
};
|
|
25812
|
-
const
|
|
25813
|
-
const p = b.p;
|
|
26121
|
+
const sectionOfBearer = (p) => {
|
|
25814
26122
|
if (p.spec.shape.kind !== "box" || !p.mat.strength?.tensileMPa) return null;
|
|
25815
26123
|
const g = bendGeometry(p.spec);
|
|
25816
26124
|
if (g.gravity < 0) return null;
|
|
25817
26125
|
const footing = p.spec.structure?.role === "foundation" && g.member && !isReinforced(p.spec);
|
|
25818
26126
|
const spec = footing ? { ...p.spec, structure: { ...p.spec.structure, rebar: { ratio: groundCfg.beamRebarRatio } } } : p.spec;
|
|
25819
26127
|
const section = { b: sectionWidth(g, g.gravity), h: g.dims[g.gravity] };
|
|
25820
|
-
const
|
|
25821
|
-
const
|
|
25822
|
-
|
|
25823
|
-
|
|
25824
|
-
|
|
25825
|
-
const
|
|
25826
|
-
const
|
|
25827
|
-
const
|
|
25828
|
-
|
|
25829
|
-
|
|
25830
|
-
|
|
25831
|
-
|
|
25832
|
-
|
|
25833
|
-
|
|
26128
|
+
const steel = tensionSteel(spec, g.dims, section, flexure);
|
|
26129
|
+
const m = sectionMoments(p.mat, section, steel, flexure);
|
|
26130
|
+
return { g, section, steel, m, resists: p.st.cracked ? m.steel : m.ultimate };
|
|
26131
|
+
};
|
|
26132
|
+
const pillarsUnder = (o, b, fp, standing) => {
|
|
26133
|
+
const box5 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
26134
|
+
const across2 = fp.long === 0 ? 2 : 0;
|
|
26135
|
+
const out = [];
|
|
26136
|
+
for (const i of standing) {
|
|
26137
|
+
const q = o.parts[i];
|
|
26138
|
+
if (q.spec.structure?.role !== "column") continue;
|
|
26139
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
26140
|
+
const overlaps = c.max[across2] > box5.min[across2] && c.min[across2] < box5.max[across2] && c.max[fp.long] > box5.min[fp.long] && c.min[fp.long] < box5.max[fp.long];
|
|
26141
|
+
if (overlaps && Math.abs(c.min[1] - box5.max[1]) < PILLAR_SEAT) out.push((c.min[fp.long] + c.max[fp.long]) / 2 - box5.min[fp.long]);
|
|
26142
|
+
}
|
|
26143
|
+
return out;
|
|
26144
|
+
};
|
|
26145
|
+
const continuationOf = (o, b, fp, standing) => {
|
|
26146
|
+
const box5 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
26147
|
+
const across2 = fp.long === 0 ? 2 : 0;
|
|
26148
|
+
const ends = [false, false];
|
|
26149
|
+
for (const i of standing) {
|
|
26150
|
+
const q = o.parts[i];
|
|
26151
|
+
if (i === b.i || q.spec.structure?.role !== "foundation" || isTerrain(q)) continue;
|
|
26152
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
26153
|
+
const inLine = Math.abs((c.min[across2] + c.max[across2]) / 2 - (box5.min[across2] + box5.max[across2]) / 2) < PILLAR_SEAT && c.max[1] > box5.min[1] && c.min[1] < box5.max[1];
|
|
26154
|
+
if (!inLine) continue;
|
|
26155
|
+
if (Math.abs(c.max[fp.long] - box5.min[fp.long]) < PILLAR_SEAT) ends[0] = true;
|
|
26156
|
+
if (Math.abs(c.min[fp.long] - box5.max[fp.long]) < PILLAR_SEAT) ends[1] = true;
|
|
26157
|
+
}
|
|
26158
|
+
return ends;
|
|
26159
|
+
};
|
|
26160
|
+
const bearBeam = (o, b, fp, standing, sec) => {
|
|
26161
|
+
const length2 = fp.slices.length * fp.step;
|
|
26162
|
+
const load = lineLoad(sec.g, b.p.st.load ?? b.p.st.mass);
|
|
26163
|
+
const verdict = judgeBeam(fp.slices.map((slice) => slice.void), fp.step, {
|
|
26164
|
+
length: length2,
|
|
26165
|
+
depth: sec.section.h,
|
|
26166
|
+
load,
|
|
26167
|
+
resists: sec.resists,
|
|
26168
|
+
cracking: sec.m.cracking,
|
|
26169
|
+
spanDepth: groundCfg.bridgeSpanDepth,
|
|
26170
|
+
soilSafety: soilCfg.safety,
|
|
26171
|
+
pillars: pillarsUnder(o, b, fp, standing),
|
|
26172
|
+
loadFactor: structureSafety,
|
|
26173
|
+
continuous: continuationOf(o, b, fp, standing)
|
|
26174
|
+
});
|
|
26175
|
+
if (verdict.runs.length === 0) return { status: fp.share <= 1 - 1 / soilCfg.safety ? "settled" : "unsupported", failed: [], cracks: [] };
|
|
26176
|
+
if (verdict.tips) return { status: "unsupported", failed: [], cracks: [] };
|
|
26177
|
+
const cracks = [];
|
|
26178
|
+
const failed = [];
|
|
26179
|
+
const EI = (b.p.mat.strength.elasticGPa ?? 0) * 1e9 * sec.section.b * sec.section.h ** 3 / 12;
|
|
26180
|
+
for (const run2 of verdict.runs) {
|
|
26181
|
+
const k0 = Math.round(run2.start / fp.step);
|
|
26182
|
+
const k1 = Math.round(run2.end / fp.step);
|
|
26183
|
+
if (!run2.holds) {
|
|
26184
|
+
const free = run2.kind !== "cantilever" ? void 0 : run2.start <= 1e-9 ? "start" : "end";
|
|
26185
|
+
failed.push({ start: run2.start, end: run2.end, ...free ? { free } : {} });
|
|
26186
|
+
if (free !== "start") cracks.push({ at: run2.start, top: true });
|
|
26187
|
+
if (free !== "end") cracks.push({ at: run2.end, top: true });
|
|
26188
|
+
for (let k = k0; k < k1; k++) fp.slices[k].drop = Math.min(fp.slices[k].cut, run2.span / 2);
|
|
26189
|
+
continue;
|
|
26190
|
+
}
|
|
26191
|
+
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 });
|
|
26192
|
+
const stiffness = EI * (run2.cracks || b.p.st.cracked ? CRACKED_STIFFNESS : 1);
|
|
26193
|
+
const sag = stiffness > 0 ? load * run2.span ** 4 / (run2.kind === "cantilever" ? 8 * stiffness : 384 / 5 * stiffness) : groundCfg.maxSettlement;
|
|
26194
|
+
for (let k = k0; k < k1; k++) fp.slices[k].drop = Math.min(fp.slices[k].drop, sag);
|
|
26195
|
+
}
|
|
26196
|
+
return { status: failed.length ? "opened" : "bridged", failed, cracks };
|
|
26197
|
+
};
|
|
26198
|
+
const standingOver = (o, b, fp) => {
|
|
26199
|
+
const box5 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
26200
|
+
const vb = fp.voidBox;
|
|
26201
|
+
if (!vb) return [];
|
|
26202
|
+
const across2 = fp.long === 0 ? 2 : 0;
|
|
26203
|
+
const out = [];
|
|
26204
|
+
for (const j of o.byPart.get(b.p.spec.id) ?? []) {
|
|
26205
|
+
const k = j.ia === b.i ? j.ib : j.ia;
|
|
26206
|
+
if (j.st.open || restsOn(o, j, k) !== b.i) continue;
|
|
26207
|
+
const q = o.parts[k];
|
|
26208
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
26209
|
+
const along = (c.min[fp.long] + c.max[fp.long]) / 2 - box5.min[fp.long];
|
|
26210
|
+
const side = (c.min[across2] + c.max[across2]) / 2 - box5.min[across2];
|
|
26211
|
+
if (along >= vb.long[0] && along <= vb.long[1] && side >= vb.across[0] && side <= vb.across[1]) out.push({ q, j });
|
|
26212
|
+
}
|
|
26213
|
+
return out;
|
|
26214
|
+
};
|
|
26215
|
+
const bearPlate = (o, b, fp, sec) => {
|
|
26216
|
+
const vb = fp.voidBox;
|
|
26217
|
+
if (!vb) return { status: "settled", failed: [], cracks: [] };
|
|
26218
|
+
const across2 = Math.max(vb.long[1] - vb.long[0], vb.across[1] - vb.across[0]);
|
|
26219
|
+
const over = standingOver(o, b, fp);
|
|
26220
|
+
const verdict = judgePlate({
|
|
26221
|
+
across: across2,
|
|
26222
|
+
load: lineLoad(sec.g, b.p.st.mass),
|
|
26223
|
+
resists: sec.resists,
|
|
26224
|
+
cracking: sec.m.cracking,
|
|
26225
|
+
effectiveDepth: sec.steel.d,
|
|
26226
|
+
punching: PUNCHING_SHARE * (b.p.mat.strength.tensileMPa ?? 0) * 1e6,
|
|
26227
|
+
loadFactor: structureSafety,
|
|
26228
|
+
points: over.map(({ q }) => {
|
|
26229
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
26230
|
+
return { weight: (q.st.load ?? q.st.mass) * GRAVITY, side: Math.min(c.max[0] - c.min[0], c.max[2] - c.min[2]) };
|
|
26231
|
+
})
|
|
26232
|
+
});
|
|
26233
|
+
if (fp.share > 1 - 1 / soilCfg.safety) return { status: "unsupported", failed: [], cracks: [] };
|
|
26234
|
+
const cracks = verdict.cracks || !verdict.holds ? [{ at: vb.long[0], top: true }, { at: vb.long[1], top: true }] : [];
|
|
26235
|
+
if (verdict.holds) return { status: "bridged", failed: [], cracks };
|
|
26236
|
+
const box5 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
26237
|
+
const crossing = fp.long === 0 ? 2 : 0;
|
|
26238
|
+
const center = [(box5.min[0] + box5.max[0]) / 2, (box5.min[1] + box5.max[1]) / 2, (box5.min[2] + box5.max[2]) / 2];
|
|
26239
|
+
center[fp.long] = box5.min[fp.long] + (vb.long[0] + vb.long[1]) / 2;
|
|
26240
|
+
center[crossing] = box5.min[crossing] + (vb.across[0] + vb.across[1]) / 2;
|
|
26241
|
+
const radius = Math.max(vb.long[1] - vb.long[0], vb.across[1] - vb.across[0]) / 2;
|
|
26242
|
+
if (2 * radius >= Math.min(box5.max[0] - box5.min[0], box5.max[2] - box5.min[2])) return { status: "unsupported", failed: [], cracks: [] };
|
|
26243
|
+
return { status: "opened", failed: [{ start: vb.long[0], end: vb.long[1] }], cracks, hole: { center, radius } };
|
|
26244
|
+
};
|
|
26245
|
+
const bearLoss = (o, b, fp, standing) => {
|
|
26246
|
+
const sec = sectionOfBearer(b.p);
|
|
26247
|
+
if (sec?.g.member) return bearBeam(o, b, fp, standing, sec);
|
|
26248
|
+
if (sec && fp.voidBox) return bearPlate(o, b, fp, sec);
|
|
26249
|
+
return { status: fp.share <= 1 - 1 / soilCfg.safety ? "settled" : "unsupported", failed: [], cracks: [] };
|
|
26250
|
+
};
|
|
26251
|
+
const crackBearer = (o, b, fp, bearing2, src) => {
|
|
26252
|
+
if (bearing2.cracks.length === 0) return;
|
|
25834
26253
|
b.p.st.cracked = true;
|
|
25835
26254
|
const box5 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
25836
|
-
|
|
25837
|
-
|
|
25838
|
-
|
|
25839
|
-
|
|
26255
|
+
for (const crack of bearing2.cracks) {
|
|
26256
|
+
const local2 = [(box5.min[0] + box5.max[0]) / 2, crack.top ? box5.max[1] : box5.min[1], (box5.min[2] + box5.max[2]) / 2];
|
|
26257
|
+
local2[fp.long] = box5.min[fp.long] + crack.at;
|
|
26258
|
+
addCrack(o, b.p, toWorld(o.st.position, o.st.rotation, local2), rotateVec(o.st.rotation, [0, crack.top ? 1 : -1, 0]), box5.max[1] - box5.min[1], src);
|
|
26259
|
+
}
|
|
26260
|
+
};
|
|
26261
|
+
const openOver = (o, b, fp, failed, opened, src) => {
|
|
26262
|
+
const box5 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
26263
|
+
let lost = false;
|
|
26264
|
+
for (const j of o.byPart.get(b.p.spec.id) ?? []) {
|
|
26265
|
+
const k = j.ia === b.i ? j.ib : j.ia;
|
|
26266
|
+
if (j.st.open || restsOn(o, j, k) !== b.i) continue;
|
|
26267
|
+
const q = o.parts[k];
|
|
26268
|
+
if (isLost(q)) continue;
|
|
26269
|
+
const c = aabbOf(q.spec.shape, q.pos, q.q);
|
|
26270
|
+
const from = c.min[fp.long] - box5.min[fp.long];
|
|
26271
|
+
const to = c.max[fp.long] - box5.min[fp.long];
|
|
26272
|
+
const run2 = failed.find((r) => to > r.start && from < r.end);
|
|
26273
|
+
if (!run2) continue;
|
|
26274
|
+
if (from >= run2.start - fp.step && to <= run2.end + fp.step) {
|
|
26275
|
+
j.st.open = true;
|
|
26276
|
+
j.st.hp = 0;
|
|
26277
|
+
j.st.openedBy = "break";
|
|
26278
|
+
opened.push(j);
|
|
26279
|
+
lost = true;
|
|
26280
|
+
continue;
|
|
26281
|
+
}
|
|
26282
|
+
if (isSlender(q.spec, q.mat) && archOver(o, q, fp.long, [box5.min[fp.long] + run2.start, box5.min[fp.long] + run2.end], run2.free, opened, src)) lost = true;
|
|
26283
|
+
}
|
|
26284
|
+
return lost;
|
|
26285
|
+
};
|
|
26286
|
+
const archOver = (o, q, axis2, span, free, opened, src) => {
|
|
26287
|
+
var _a;
|
|
26288
|
+
const grid = gridOf(q);
|
|
26289
|
+
const worn = (_a = q.rt).chips ?? (_a.chips = {});
|
|
26290
|
+
const bottom = aabbOf(q.spec.shape, q.pos, q.q).min[1];
|
|
26291
|
+
const half = (span[1] - span[0]) / 2;
|
|
26292
|
+
const middle = (span[0] + span[1]) / 2;
|
|
26293
|
+
const out = [];
|
|
26294
|
+
grid.forEach((cell, i) => {
|
|
26295
|
+
if (worn[i] === -1) return;
|
|
26296
|
+
const at4 = toWorld(q.pos, q.q, cell.center);
|
|
26297
|
+
const height2 = at4[1] - bottom;
|
|
26298
|
+
const reach = height2 / Math.tan(ARCH_ANGLE);
|
|
26299
|
+
const under = free === "start" ? at4[axis2] <= span[1] - reach : free === "end" ? at4[axis2] >= span[0] + reach : Math.abs(at4[axis2] - middle) <= half - reach;
|
|
26300
|
+
if (under) out.push(i);
|
|
26301
|
+
});
|
|
26302
|
+
if (out.length === 0) return false;
|
|
26303
|
+
const centre = [0, bottom, 0];
|
|
26304
|
+
centre[axis2] = middle;
|
|
26305
|
+
const other = axis2 === 0 ? 2 : 0;
|
|
26306
|
+
centre[other] = q.pos[other];
|
|
26307
|
+
knockOutUnits(o, q, toWorld(o.st.position, o.st.rotation, centre), 0, out, src);
|
|
26308
|
+
const height = aabbOf(q.spec.shape, q.pos, q.q).max[1] - bottom;
|
|
26309
|
+
const corbel = height / Math.tan(ARCH_ANGLE);
|
|
26310
|
+
const opening = free === "start" ? [span[0], span[1] - corbel] : free === "end" ? [span[0] + corbel, span[1]] : [span[0] + corbel, span[1] - corbel];
|
|
26311
|
+
return opening[1] > opening[0] && spanOpening(o, q, axis2, opening, !!free, opened, src);
|
|
26312
|
+
};
|
|
26313
|
+
const spanOpening = (o, q, axis2, opening, overhang, opened, src) => {
|
|
26314
|
+
const qi = o.idx.get(q.spec.id);
|
|
26315
|
+
const length2 = opening[1] - opening[0];
|
|
26316
|
+
let lost = false;
|
|
26317
|
+
for (const j of [...o.byPart.get(q.spec.id) ?? []]) {
|
|
26318
|
+
const ri = j.ia === qi ? j.ib : j.ia;
|
|
26319
|
+
const r = o.parts[ri];
|
|
26320
|
+
if (j.st.open || isLost(r) || restsOn(o, j, ri) !== qi || !r.structural) continue;
|
|
26321
|
+
const sec = sectionOfBearer(r);
|
|
26322
|
+
if (sec && !sec.g.member && !restsOnlyOn(o, ri, qi)) continue;
|
|
26323
|
+
const load = sec ? lineLoad(sec.g, r.st.load ?? r.st.mass) : 0;
|
|
26324
|
+
const moment = load * length2 * length2 / (overhang ? 2 : 8) * structureSafety;
|
|
26325
|
+
const reach = (overhang ? 0.5 : 1) * groundCfg.bridgeSpanDepth * (sec?.section.h ?? 0);
|
|
26326
|
+
if (sec && length2 <= reach && moment <= sec.resists) {
|
|
26327
|
+
if (moment > sec.m.cracking && !r.st.cracked) {
|
|
26328
|
+
r.st.cracked = true;
|
|
26329
|
+
addCrack(o, r, partXf(o, r).c, rotateVec(o.st.rotation, [0, -1, 0]), sec.section.h, src);
|
|
26330
|
+
}
|
|
26331
|
+
continue;
|
|
26332
|
+
}
|
|
26333
|
+
if (sec?.g.member) {
|
|
26334
|
+
if (breakOver(o, r, axis2, opening, opened, src)) lost = true;
|
|
26335
|
+
continue;
|
|
26336
|
+
}
|
|
26337
|
+
hingeDrop(o, r, src);
|
|
26338
|
+
lost = true;
|
|
26339
|
+
}
|
|
26340
|
+
return lost;
|
|
25840
26341
|
};
|
|
25841
|
-
const
|
|
26342
|
+
const breakOver = (o, r, axis2, stretch, opened, src) => {
|
|
26343
|
+
var _a;
|
|
26344
|
+
const ri = o.idx.get(r.spec.id);
|
|
26345
|
+
((_a = r.rt).broken ?? (_a.broken = [])).push([axis2, stretch[0], stretch[1]]);
|
|
26346
|
+
r.st.cracked = true;
|
|
26347
|
+
const box5 = aabbOf(r.spec.shape, r.pos, r.q);
|
|
26348
|
+
for (const edge of stretch) {
|
|
26349
|
+
const at4 = [(box5.min[0] + box5.max[0]) / 2, box5.max[1], (box5.min[2] + box5.max[2]) / 2];
|
|
26350
|
+
at4[axis2] = edge;
|
|
26351
|
+
addCrack(o, r, toWorld(o.st.position, o.st.rotation, at4), rotateVec(o.st.rotation, [0, 1, 0]), box5.max[1] - box5.min[1], src);
|
|
26352
|
+
}
|
|
26353
|
+
const from = [(box5.min[0] + box5.max[0]) / 2, box5.min[1], (box5.min[2] + box5.max[2]) / 2];
|
|
26354
|
+
const to = [from[0], from[1], from[2]];
|
|
26355
|
+
from[axis2] = box5.min[axis2];
|
|
26356
|
+
to[axis2] = box5.max[axis2];
|
|
26357
|
+
const count = SETTLEMENT_POINTS;
|
|
26358
|
+
const drop = Array.from({ length: count }, (_, k) => {
|
|
26359
|
+
const x = box5.min[axis2] + (box5.max[axis2] - box5.min[axis2]) * k / (count - 1);
|
|
26360
|
+
return x <= stretch[0] || x >= stretch[1] ? 0 : Math.min(x - stretch[0], stretch[1] - x, Math.max(0, box5.min[1]));
|
|
26361
|
+
});
|
|
26362
|
+
r.st.settlement = mergeSettlement(r.st.settlement, { from, to, drop });
|
|
26363
|
+
r.st.subsidence = Math.max(r.st.subsidence ?? 0, drop.reduce((sum2, v) => sum2 + v, 0) / count);
|
|
26364
|
+
const middle = [from[0], from[1], from[2]];
|
|
26365
|
+
middle[axis2] = (stretch[0] + stretch[1]) / 2;
|
|
26366
|
+
emit2({ ...base(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box5.max[axis2] - box5.min[axis2]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
|
|
26367
|
+
let lost = false;
|
|
26368
|
+
for (const j of [...o.byPart.get(r.spec.id) ?? []]) {
|
|
26369
|
+
const ki = j.ia === ri ? j.ib : j.ia;
|
|
26370
|
+
const k = o.parts[ki];
|
|
26371
|
+
if (j.st.open || isLost(k) || restsOn(o, j, ki) !== ri) continue;
|
|
26372
|
+
const c = aabbOf(k.spec.shape, k.pos, k.q);
|
|
26373
|
+
const within = c.min[axis2] >= stretch[0] - SUPPORT_TOLERANCE && c.max[axis2] <= stretch[1] + SUPPORT_TOLERANCE;
|
|
26374
|
+
const sec = within ? null : sectionOfBearer(k);
|
|
26375
|
+
const plate3 = sec && !sec.g.member;
|
|
26376
|
+
const length2 = stretch[1] - stretch[0];
|
|
26377
|
+
const spans = plate3 && lineLoad(sec.g, k.st.load ?? k.st.mass) * length2 * length2 / 8 * structureSafety <= sec.resists;
|
|
26378
|
+
if (!within && (!plate3 || spans)) continue;
|
|
26379
|
+
j.st.open = true;
|
|
26380
|
+
j.st.hp = 0;
|
|
26381
|
+
j.st.openedBy = "break";
|
|
26382
|
+
opened.push(j);
|
|
26383
|
+
lost = true;
|
|
26384
|
+
}
|
|
26385
|
+
return lost;
|
|
26386
|
+
};
|
|
26387
|
+
const breakOut = (o, p, hole, src) => {
|
|
26388
|
+
if (p.st.opening) return;
|
|
26389
|
+
const lc = toLocal(p.pos, p.q, hole.center);
|
|
26390
|
+
lc[p.thin] = 0;
|
|
26391
|
+
const worldCenter = toWorld(o.st.position, o.st.rotation, toWorld(p.pos, p.q, lc));
|
|
26392
|
+
const [u, v] = planeAxes(p.thin);
|
|
26393
|
+
const worn = p.rt.chips;
|
|
26394
|
+
const cells = cellsWithin(gridOf(p).filter((_, i) => worn?.[i] !== -1), p.thin, lc, hole.radius);
|
|
26395
|
+
const removed = Math.min(p.st.mass, p.st.mass * Math.PI * hole.radius * hole.radius / (p.dims[u] * p.dims[v]));
|
|
26396
|
+
const fragments = cellFragments(o, p, cells, worldCenter, [0, -1, 0], 0.5, removed, "g");
|
|
26397
|
+
p.st.mass = Math.max(0, p.st.mass - removed);
|
|
26398
|
+
p.rt.removed = (p.rt.removed ?? 0) + removed;
|
|
26399
|
+
p.st.opening = { center: objLocal(o, worldCenter), radius: hole.radius };
|
|
26400
|
+
markDamaged(p);
|
|
26401
|
+
if (p.staged) {
|
|
26402
|
+
setStage(o, p, 1, {}, src);
|
|
26403
|
+
setStage(o, p, 2, { opening: { center: worldCenter, radius: hole.radius }, fragments }, src);
|
|
26404
|
+
} else emit2({ ...base(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
|
|
26405
|
+
debris2(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
|
|
26406
|
+
if (p.spec.reinforcement) exposeRebar(o, p, src);
|
|
26407
|
+
};
|
|
26408
|
+
const distort = (o, q, beta, at4, toward2, src) => {
|
|
25842
26409
|
const prior = q.rt.distortion ?? 0;
|
|
25843
|
-
|
|
26410
|
+
const bearing2 = q.spec.structure?.role === "wall";
|
|
26411
|
+
const crackAt = bearing2 ? groundCfg.bearingCrackDistortion : groundCfg.crackDistortion;
|
|
26412
|
+
const damageAt = bearing2 ? groundCfg.bearingDamageDistortion : groundCfg.damageDistortion;
|
|
26413
|
+
if (beta < crackAt || beta <= prior * DISTORTION_GROWTH) return;
|
|
25844
26414
|
q.rt.distortion = beta;
|
|
25845
26415
|
const box5 = aabbOf(q.spec.shape, q.pos, q.q);
|
|
25846
26416
|
const height = box5.max[1] - box5.min[1];
|
|
25847
|
-
const cracks = (d) => d <
|
|
26417
|
+
const cracks = (d) => d < crackAt ? 0 : Math.min(MAX_SETTLEMENT_CRACKS, 1 + Math.floor(Math.log2(d / crackAt)));
|
|
25848
26418
|
const count = Math.max(1, cracks(beta) - cracks(prior));
|
|
25849
26419
|
const axis2 = [0, 0, 0];
|
|
25850
26420
|
axis2[q.thin] = 1;
|
|
25851
26421
|
const normal = rotateVec(quat.mul(o.st.rotation, q.q), axis2);
|
|
25852
|
-
const length2 = Math.min(height * 0.6, SETTLEMENT_CRACK_LENGTH * Math.sqrt(beta /
|
|
26422
|
+
const length2 = Math.min(height * 0.6, SETTLEMENT_CRACK_LENGTH * Math.sqrt(beta / crackAt));
|
|
26423
|
+
const units = q.spec.units?.size;
|
|
26424
|
+
const step = units ? [Math.max(units[0], units[2]), units[1]] : [BRICK_STEP[0], BRICK_STEP[1]];
|
|
26425
|
+
const reach = Math.hypot(toward2[0], toward2[2]) || 1;
|
|
26426
|
+
const along = vec.normalize([toward2[0] / reach, 1, toward2[2] / reach]);
|
|
26427
|
+
const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
|
|
26428
|
+
const through = q.dims[q.thin];
|
|
25853
26429
|
for (let c = 0; c < count; c++) {
|
|
25854
|
-
const
|
|
25855
|
-
|
|
26430
|
+
const back = c * SETTLEMENT_CRACK_SPACING;
|
|
26431
|
+
const local2 = [clamp2(at4[0] - toward2[0] / reach * back, box5.min[0], box5.max[0]), box5.min[1] + height * (0.2 + 0.12 * c), clamp2(at4[2] - toward2[2] / reach * back, box5.min[2], box5.max[2])];
|
|
26432
|
+
const face = toLocal(q.pos, q.q, local2);
|
|
26433
|
+
face[q.thin] = through / 2;
|
|
26434
|
+
addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length2, src, { along, step, width, through });
|
|
25856
26435
|
}
|
|
25857
|
-
if (beta >=
|
|
26436
|
+
if (beta >= damageAt && prior < damageAt) {
|
|
25858
26437
|
q.st.hp = Math.max(1, q.st.hp - q.st.maxHp * groundCfg.distortionDamage);
|
|
25859
26438
|
markDamaged(q);
|
|
25860
26439
|
}
|
|
@@ -25868,18 +26447,53 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25868
26447
|
const q = o.parts[qi];
|
|
25869
26448
|
if (isLost(q) || isTerrain(q) || o.collapsed.has(q.spec.id) || !isSlender(q.spec, q.mat)) continue;
|
|
25870
26449
|
if (restsOn(o, j, qi) !== b.i) {
|
|
25871
|
-
|
|
26450
|
+
const side = [j.pos[0] - q.pos[0], 0, j.pos[2] - q.pos[2]];
|
|
26451
|
+
const own = q.st.settlement ? settlementAt(q.st.settlement, j.pos) : 0;
|
|
26452
|
+
const reach = Math.hypot(side[0], side[2]) || 1;
|
|
26453
|
+
const from = [j.pos[0] - side[0] / reach * BESIDE_CRACK_OFFSET, j.pos[1], j.pos[2] - side[2] / reach * BESIDE_CRACK_OFFSET];
|
|
26454
|
+
distort(o, q, Math.abs((b.p.st.subsidence ?? 0) - own) / DISTORTION_BASE, from, side, src);
|
|
25872
26455
|
continue;
|
|
25873
26456
|
}
|
|
25874
26457
|
const over = aabbOf(q.spec.shape, q.pos, q.q);
|
|
25875
26458
|
const k0 = clamp2(Math.floor((over.min[fp.long] - box5.min[fp.long]) / fp.step), 0, drops.length - 1);
|
|
25876
26459
|
const k1 = clamp2(Math.ceil((over.max[fp.long] - box5.min[fp.long]) / fp.step), k0 + 1, drops.length);
|
|
25877
|
-
const { value, at: at4 } = distortionOf(drops.slice(k0, k1), fp.step);
|
|
26460
|
+
const { value, at: at4, down } = distortionOf(relativeToChord(drops.slice(k0, k1)), fp.step);
|
|
25878
26461
|
const point = [(over.min[0] + over.max[0]) / 2, over.min[1], (over.min[2] + over.max[2]) / 2];
|
|
25879
26462
|
point[fp.long] = box5.min[fp.long] + (k0 + at4 + 0.5) * fp.step;
|
|
25880
|
-
|
|
26463
|
+
const toward2 = [0, 0, 0];
|
|
26464
|
+
toward2[fp.long] = down;
|
|
26465
|
+
distort(o, q, value, point, toward2, src);
|
|
25881
26466
|
}
|
|
25882
26467
|
};
|
|
26468
|
+
const settle = (o, b, fp) => {
|
|
26469
|
+
const box5 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
26470
|
+
const from = [(box5.min[0] + box5.max[0]) / 2, box5.min[1], (box5.min[2] + box5.max[2]) / 2];
|
|
26471
|
+
const to = [from[0], from[1], from[2]];
|
|
26472
|
+
from[fp.long] = box5.min[fp.long];
|
|
26473
|
+
to[fp.long] = box5.max[fp.long];
|
|
26474
|
+
const line = { from, to, drop: settlementProfile(fp.slices.map((slice) => slice.drop), fp.step) };
|
|
26475
|
+
const follows = { from, to, drop: line.drop.map((v) => Math.min(v, groundCfg.maxSettlement)) };
|
|
26476
|
+
const moved = /* @__PURE__ */ new Set([b.i]);
|
|
26477
|
+
let ring3 = [b.i];
|
|
26478
|
+
for (let depth = 0; depth <= SETTLEMENT_FOLLOW_DEPTH && ring3.length; depth++) {
|
|
26479
|
+
const next = [];
|
|
26480
|
+
for (const i of ring3) {
|
|
26481
|
+
const p = o.parts[i];
|
|
26482
|
+
p.st.settlement = mergeSettlement(p.st.settlement, i === b.i ? line : follows);
|
|
26483
|
+
if (i !== b.i) p.st.subsidence = Math.max(p.st.subsidence ?? 0, settlementAt(p.st.settlement, p.pos));
|
|
26484
|
+
for (const j of o.byPart.get(p.spec.id) ?? []) {
|
|
26485
|
+
const k = j.ia === i ? j.ib : j.ia;
|
|
26486
|
+
const q = o.parts[k];
|
|
26487
|
+
if (j.st.open || moved.has(k) || isLost(q) || isTerrain(q) || q.anchored) continue;
|
|
26488
|
+
if (q.structural && (i !== b.i || restsOn(o, j, k) !== i || !restsOnlyOn(o, k, i))) continue;
|
|
26489
|
+
moved.add(k);
|
|
26490
|
+
next.push(k);
|
|
26491
|
+
}
|
|
26492
|
+
}
|
|
26493
|
+
ring3 = next;
|
|
26494
|
+
}
|
|
26495
|
+
};
|
|
26496
|
+
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);
|
|
25883
26497
|
const loseGround = (o, b, opened) => {
|
|
25884
26498
|
if (b.p.anchored) {
|
|
25885
26499
|
b.p.anchored = false;
|
|
@@ -25893,38 +26507,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25893
26507
|
opened.push(j);
|
|
25894
26508
|
}
|
|
25895
26509
|
};
|
|
25896
|
-
const bearLoss = (o, b, fp, src) => {
|
|
25897
|
-
const voids = longestRun(fp.slices.map((slice) => slice.void));
|
|
25898
|
-
const bridge = voids ? bridgeOf(b, fp, voids) : null;
|
|
25899
|
-
if (voids && bridge && bridge.span >= bridge.depth) {
|
|
25900
|
-
if (!bridge.holds) return "unsupported";
|
|
25901
|
-
if (bridge.cracks) crackBridge(o, b, fp, voids, bridge, src);
|
|
25902
|
-
for (let k = voids.start; k < voids.end; k++) fp.slices[k].drop = Math.min(fp.slices[k].drop, bridge.sag);
|
|
25903
|
-
fp.drop = fp.slices.reduce((sum2, slice) => sum2 + slice.drop, 0) / fp.slices.length;
|
|
25904
|
-
return "bridged";
|
|
25905
|
-
}
|
|
25906
|
-
return fp.share <= 1 - 1 / soilCfg.safety ? "settled" : "unsupported";
|
|
25907
|
-
};
|
|
25908
26510
|
const undermine = (o, loss) => {
|
|
25909
26511
|
if (!o.hasStructure || !o.anyAnchor || o.st.soil?.status === "toppled") return;
|
|
25910
26512
|
const src = loss.source ?? "ground";
|
|
25911
26513
|
const opened = [];
|
|
25912
26514
|
const settled = [];
|
|
25913
26515
|
let lost = false;
|
|
25914
|
-
|
|
25915
|
-
|
|
25916
|
-
|
|
25917
|
-
|
|
25918
|
-
|
|
26516
|
+
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);
|
|
26517
|
+
const bearers = bearersOf(o);
|
|
26518
|
+
const pillarFirst = (b) => b.p.spec.structure?.role === "column" ? 0 : 1;
|
|
26519
|
+
const order = [...touched].sort((x, y) => pillarFirst(x.b) - pillarFirst(y.b));
|
|
26520
|
+
const standing = new Set(bearers.map((b) => b.i));
|
|
26521
|
+
for (const { b, fp } of order) {
|
|
26522
|
+
const bearing2 = bearLoss(o, b, fp, standing);
|
|
26523
|
+
if (bearing2.status === "unsupported") standing.delete(b.i);
|
|
26524
|
+
if (bearing2.status !== "unsupported" && !bendGeometry(b.p.spec).member) {
|
|
26525
|
+
const kept = fp.slices.filter((slice) => !slice.void);
|
|
26526
|
+
const flat2 = kept.length ? kept.reduce((sum2, slice) => sum2 + slice.drop, 0) / kept.length : 0;
|
|
26527
|
+
fp.slices.forEach((slice) => slice.drop = flat2);
|
|
26528
|
+
fp.drop = flat2;
|
|
26529
|
+
}
|
|
26530
|
+
if (bearing2.status !== "unsupported" && bendGeometry(b.p.spec).member) {
|
|
26531
|
+
const smooth2 = smoothProfile(fp.slices.map((slice) => slice.drop), fp.step, BEAM_SPREAD);
|
|
26532
|
+
fp.slices.forEach((slice, k) => slice.drop = bearing2.failed.some((r) => (k + 0.5) * fp.step > r.start && (k + 0.5) * fp.step < r.end) ? slice.drop : smooth2[k]);
|
|
26533
|
+
fp.drop = fp.slices.reduce((sum2, slice) => sum2 + slice.drop, 0) / Math.max(1, fp.slices.length);
|
|
26534
|
+
}
|
|
25919
26535
|
const before = b.p.st.subsidence ?? 0;
|
|
25920
26536
|
const drop = Math.max(before, fp.drop);
|
|
25921
|
-
|
|
26537
|
+
const peak = () => Math.max(0, ...b.p.st.settlement?.drop ?? []);
|
|
26538
|
+
const peakBefore = peak();
|
|
26539
|
+
if (bearing2.status === "unsupported") {
|
|
25922
26540
|
loseGround(o, b, opened);
|
|
25923
26541
|
lost = true;
|
|
25924
|
-
} else
|
|
25925
|
-
|
|
26542
|
+
} else {
|
|
26543
|
+
crackBearer(o, b, fp, bearing2, src);
|
|
26544
|
+
if (bearing2.failed.length && openOver(o, b, fp, bearing2.failed, opened, src)) lost = true;
|
|
26545
|
+
if (bearing2.hole) breakOut(o, b.p, bearing2.hole, src);
|
|
26546
|
+
settled.push({ b, fp });
|
|
26547
|
+
settle(o, b, fp);
|
|
26548
|
+
}
|
|
26549
|
+
if (bearing2.status === "settled" && drop - before < SUBSIDE_MIN && peak() - peakBefore < SUBSIDE_MIN) continue;
|
|
25926
26550
|
b.p.st.subsidence = drop;
|
|
25927
|
-
emit2({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status });
|
|
26551
|
+
emit2({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing2.status });
|
|
25928
26552
|
}
|
|
25929
26553
|
for (const { b, fp } of settled) crackOver(o, b, fp, src);
|
|
25930
26554
|
o.active = true;
|
|
@@ -25969,6 +26593,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25969
26593
|
return r ? { t0: r.t0, t1: r.t1, n: rotateVec(q, r.n0) } : null;
|
|
25970
26594
|
};
|
|
25971
26595
|
const rayPart = (o, p, origin, d) => rayPartRaw(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
|
|
26596
|
+
const PART_BOUND_SLACK = 1e-6;
|
|
25972
26597
|
const raySphereMiss = (origin, d, c, r, maxDist) => {
|
|
25973
26598
|
const oc = vec.sub(origin, c);
|
|
25974
26599
|
const b = vec.dot(oc, d);
|
|
@@ -25978,13 +26603,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25978
26603
|
if (disc < 0) return true;
|
|
25979
26604
|
return -b - Math.sqrt(disc) > maxDist;
|
|
25980
26605
|
};
|
|
26606
|
+
const partSphereMiss = (o, d, p, maxDist) => {
|
|
26607
|
+
const x = o[0] - p.pos[0], y = o[1] - p.pos[1], z = o[2] - p.pos[2];
|
|
26608
|
+
const r = p.bound + PART_BOUND_SLACK;
|
|
26609
|
+
const b = x * d[0] + y * d[1] + z * d[2];
|
|
26610
|
+
const cc = x * x + y * y + z * z - r * r;
|
|
26611
|
+
if (cc > 0 && b > 0) return true;
|
|
26612
|
+
const disc = b * b - cc;
|
|
26613
|
+
if (disc < 0) return true;
|
|
26614
|
+
return -b - Math.sqrt(disc) > maxDist;
|
|
26615
|
+
};
|
|
25981
26616
|
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false) => {
|
|
25982
26617
|
const d = vec.normalize(dir);
|
|
25983
26618
|
let best = null;
|
|
25984
26619
|
for (const o of objects.values()) {
|
|
25985
26620
|
if (raySphereMiss(origin, d, toWorld(o.st.position, o.st.rotation, o.bc), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
|
|
26621
|
+
const qi = quat.conjugate(o.st.rotation);
|
|
26622
|
+
const lo = rotateVec(qi, vec.sub(origin, o.st.position));
|
|
26623
|
+
const ld = rotateVec(qi, d);
|
|
25986
26624
|
for (const p of o.parts) {
|
|
25987
26625
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
26626
|
+
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
25988
26627
|
const r = rayPart(o, p, origin, d);
|
|
25989
26628
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
25990
26629
|
if (p.st.opening && insideOpening(o, p, vec.madd(origin, d, r.t0))) continue;
|
|
@@ -26112,8 +26751,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26112
26751
|
setStage(o, p, 1, {}, src);
|
|
26113
26752
|
return hole;
|
|
26114
26753
|
};
|
|
26115
|
-
const addCrack = (o, p, wp, wn, length2, src) => {
|
|
26116
|
-
const crack = { point: objLocal(o, wp), normal: objLocalDir(o, wn), length: Math.min(length2, Math.max(p.bound, 0.05)), rays: 5 + Math.floor(rnd2() * 5) };
|
|
26754
|
+
const addCrack = (o, p, wp, wn, length2, src, stair) => {
|
|
26755
|
+
const crack = { point: objLocal(o, wp), normal: objLocalDir(o, wn), length: Math.min(length2, Math.max(p.bound, 0.05)), rays: 5 + Math.floor(rnd2() * 5), ...stair ? { stair } : {} };
|
|
26117
26756
|
p.st.cracks.push(crack);
|
|
26118
26757
|
if (p.st.cracks.length > 16) p.st.cracks.shift();
|
|
26119
26758
|
markDamaged(p);
|
|
@@ -26240,6 +26879,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26240
26879
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
26241
26880
|
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 }));
|
|
26242
26881
|
const unitsOf2 = (p) => p.spec.units ?? { size: [p.mat.fragmentSize?.[1] ?? 0.2, p.mat.fragmentSize?.[1] ?? 0.2, p.thickness], bond: "stack" };
|
|
26882
|
+
const unitSpan = (p) => {
|
|
26883
|
+
const [u, v] = planeAxes(p.thin);
|
|
26884
|
+
const first = gridOf(p)[0];
|
|
26885
|
+
const size = unitsOf2(p).size;
|
|
26886
|
+
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])];
|
|
26887
|
+
};
|
|
26243
26888
|
const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
|
|
26244
26889
|
const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false) => {
|
|
26245
26890
|
const { c, q } = partXf(o, p);
|
|
@@ -26270,6 +26915,44 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26270
26915
|
};
|
|
26271
26916
|
});
|
|
26272
26917
|
};
|
|
26918
|
+
const plasterFlakes = (o, p, cells, hitW, speed, tag) => {
|
|
26919
|
+
const layer3 = p.layers.find((l) => l.mat.fracture === "crumble");
|
|
26920
|
+
if (!layer3 || cells.length === 0) return [];
|
|
26921
|
+
const { c, q } = partXf(o, p);
|
|
26922
|
+
const [u, v] = planeAxes(p.thin);
|
|
26923
|
+
const faces = layer3.def.faces === "both" ? [1, -1] : [layer3.def.faces === "+" ? 1 : -1];
|
|
26924
|
+
const area3 = cells.reduce((sum2, cell) => sum2 + cell.size[u] * cell.size[v], 0) * faces.length;
|
|
26925
|
+
const count = Math.min(MAX_PLASTER_FLAKES, Math.ceil(area3 / PLASTER_FLAKE_AREA));
|
|
26926
|
+
const out = [];
|
|
26927
|
+
for (let i = 0; i < count; i++) {
|
|
26928
|
+
const cell = cells[Math.floor(rnd2() * cells.length)];
|
|
26929
|
+
const face = faces[i % faces.length];
|
|
26930
|
+
const local2 = [cell.center[0], cell.center[1], cell.center[2]];
|
|
26931
|
+
local2[u] += (rnd2() - 0.5) * cell.size[u];
|
|
26932
|
+
local2[v] += (rnd2() - 0.5) * cell.size[v];
|
|
26933
|
+
local2[p.thin] = cell.center[p.thin] + face * (cell.size[p.thin] / 2 - layer3.def.thickness / 2);
|
|
26934
|
+
const size = [0, 0, 0];
|
|
26935
|
+
size[u] = 0.04 + 0.12 * rnd2();
|
|
26936
|
+
size[v] = 0.03 + 0.09 * rnd2();
|
|
26937
|
+
size[p.thin] = layer3.def.thickness;
|
|
26938
|
+
const cw = toWorld(c, q, local2);
|
|
26939
|
+
const out0 = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
26940
|
+
const k = speed * (0.4 + 0.9 * rnd2());
|
|
26941
|
+
out.push({
|
|
26942
|
+
id: `${p.spec.id}#${tag}${i}`,
|
|
26943
|
+
part: p.spec.id,
|
|
26944
|
+
material: layer3.def.material,
|
|
26945
|
+
shape: "scrap",
|
|
26946
|
+
center: cw,
|
|
26947
|
+
size,
|
|
26948
|
+
rotation: q,
|
|
26949
|
+
velocity: [out0[0] * k, out0[1] * k + 0.5 * rnd2(), out0[2] * k],
|
|
26950
|
+
angularVelocity: [(rnd2() - 0.5) * 12, (rnd2() - 0.5) * 12, (rnd2() - 0.5) * 12],
|
|
26951
|
+
mass: layer3.mat.density * size[0] * size[1] * size[2]
|
|
26952
|
+
});
|
|
26953
|
+
}
|
|
26954
|
+
return out;
|
|
26955
|
+
};
|
|
26273
26956
|
const worldBars = (o, p, bars) => {
|
|
26274
26957
|
const { c, q } = partXf(o, p);
|
|
26275
26958
|
return bars.map(([a, b]) => [toWorld(c, q, a), toWorld(c, q, b)]);
|
|
@@ -26507,6 +27190,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26507
27190
|
}
|
|
26508
27191
|
const bow2 = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
|
|
26509
27192
|
if (bow2 > 0) bars = bars.flatMap((bar2, i) => bendBar(bar2, p.thin, bow2 * BAR_BOW, i));
|
|
27193
|
+
const stirrups = memberStirrups(p.dims);
|
|
27194
|
+
if (stirrups.length > 0 && bars.length > 0) {
|
|
27195
|
+
if (p.st.stripped) bars = [...bars, ...stirrups];
|
|
27196
|
+
else for (const box5 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box5.center, box5.size));
|
|
27197
|
+
}
|
|
26510
27198
|
emit2({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
|
|
26511
27199
|
};
|
|
26512
27200
|
const openBreach = (o, p, center, total, energy, dir, src) => {
|
|
@@ -26577,6 +27265,33 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26577
27265
|
if (out.length === 0) return false;
|
|
26578
27266
|
return knockOutUnits(o, p, wp, energy, out, src);
|
|
26579
27267
|
};
|
|
27268
|
+
const wedgedUnder = (o, p, loose) => {
|
|
27269
|
+
if (loose.length === 0) return loose;
|
|
27270
|
+
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);
|
|
27271
|
+
if (!beam) return loose;
|
|
27272
|
+
const [, v] = planeAxes(p.thin);
|
|
27273
|
+
const grid = gridOf(p);
|
|
27274
|
+
const top = p.dims[v] / 2, course = unitSpan(p)[1];
|
|
27275
|
+
return loose.filter((i) => grid[i].center[v] + grid[i].size[v] / 2 < top - PANEL_EDGE_BEAM * course + 1e-4);
|
|
27276
|
+
};
|
|
27277
|
+
const panelEdge = (p, faces, seed) => {
|
|
27278
|
+
const [u, v] = planeAxes(p.thin);
|
|
27279
|
+
const [unitU, unitV] = unitSpan(p);
|
|
27280
|
+
const bottom = -p.dims[v] / 2, top = p.dims[v] / 2;
|
|
27281
|
+
const depth = (key2, most) => {
|
|
27282
|
+
const r = createRng2(seed ^ Math.imul(key2 + 1, 2654435761)).next();
|
|
27283
|
+
return Math.floor(r * r * (most + 1));
|
|
27284
|
+
};
|
|
27285
|
+
return (cell) => {
|
|
27286
|
+
const course = Math.round((cell.center[v] - bottom) / unitV - 0.5);
|
|
27287
|
+
const column = Math.round((cell.center[u] - faces.fromFace) / unitU - 0.5);
|
|
27288
|
+
const keyed = course % 2 === 0 ? 0.5 : 0;
|
|
27289
|
+
const side = Math.min(cell.center[u] - faces.fromFace, faces.toFace - cell.center[u]) / unitU;
|
|
27290
|
+
if (side < depth(course * 2, PANEL_EDGE_PILLAR) + keyed + 0.5) return true;
|
|
27291
|
+
if ((cell.center[v] - bottom) / unitV < depth(1e5 + column, PANEL_EDGE_BASE) + 1) return true;
|
|
27292
|
+
return (top - cell.center[v]) / unitV < Math.floor(createRng2(seed ^ Math.imul(200001 + column, 2654435761)).next() * (PANEL_EDGE_BEAM + 1));
|
|
27293
|
+
};
|
|
27294
|
+
};
|
|
26580
27295
|
const blastPanel = (o, p, point, energy, src) => {
|
|
26581
27296
|
var _a;
|
|
26582
27297
|
if (!p.staged || p.st.stripped || isLost(p) || !p.spec.units || p.spec.units.mortar === p.spec.material || p.spec.reinforcement) return false;
|
|
@@ -26588,12 +27303,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26588
27303
|
if (m === p || !m.spec.reinforcement || isLost(m) || m.spec.shape.kind !== "box") continue;
|
|
26589
27304
|
const mp = toLocal(p.pos, p.q, m.pos);
|
|
26590
27305
|
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;
|
|
26591
|
-
posts.push(mp[u]);
|
|
27306
|
+
posts.push({ x: mp[u], half: m.dims[u] / 2 });
|
|
26592
27307
|
}
|
|
26593
|
-
let from = -half, to = half;
|
|
26594
|
-
for (const x of posts) {
|
|
26595
|
-
if (x <= lp[u] && x > from)
|
|
26596
|
-
|
|
27308
|
+
let from = -half, to = half, fromFace = -half, toFace = half;
|
|
27309
|
+
for (const { x, half: w } of posts) {
|
|
27310
|
+
if (x <= lp[u] && x > from) {
|
|
27311
|
+
from = x;
|
|
27312
|
+
fromFace = x + w;
|
|
27313
|
+
}
|
|
27314
|
+
if (x >= lp[u] && x < to) {
|
|
27315
|
+
to = x;
|
|
27316
|
+
toFace = x - w;
|
|
27317
|
+
}
|
|
26597
27318
|
}
|
|
26598
27319
|
if (to - from < 0.2) return false;
|
|
26599
27320
|
const tnt = energy * DEFAULT_BLAST_IMPULSE.tntPerJoule;
|
|
@@ -26615,10 +27336,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26615
27336
|
const grid = gridOf(p);
|
|
26616
27337
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
26617
27338
|
const out = [];
|
|
27339
|
+
const edge = panelEdge(p, { fromFace, toFace }, seedOf2(...Array.from(`${o.id}|${p.spec.id}`, (char) => char.charCodeAt(0) / 1e3), from));
|
|
26618
27340
|
for (let i = 0; i < grid.length; i++) {
|
|
26619
27341
|
const cell = grid[i];
|
|
26620
27342
|
if (worn[i] === -1) continue;
|
|
26621
|
-
if (cell.center[u] - cell.size[u] / 2 >= from - 1e-6 && cell.center[u] + cell.size[u] / 2 <= to + 1e-6) out.push(i);
|
|
27343
|
+
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);
|
|
26622
27344
|
}
|
|
26623
27345
|
if (out.length === 0) return false;
|
|
26624
27346
|
for (const i of out) worn[i] = -1;
|
|
@@ -26631,7 +27353,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26631
27353
|
const grid = gridOf(p);
|
|
26632
27354
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
26633
27355
|
for (const i of out) worn[i] = -1;
|
|
26634
|
-
const
|
|
27356
|
+
const cast = p.spec.units?.mortar === p.spec.material;
|
|
27357
|
+
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)));
|
|
26635
27358
|
for (const i of loose) worn[i] = -1;
|
|
26636
27359
|
const blown = out.map((i) => grid[i]), fallen = loose.map((i) => grid[i]);
|
|
26637
27360
|
const volume = (cells2) => cells2.reduce((sum2, cell) => sum2 + cell.size[0] * cell.size[1] * cell.size[2], 0);
|
|
@@ -26642,8 +27365,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26642
27365
|
const chipped = (_b = p.st).chipped ?? (_b.chipped = []);
|
|
26643
27366
|
const tag = `x${chipped.length}_`;
|
|
26644
27367
|
const fragments = [
|
|
26645
|
-
...cellFragments(o, p,
|
|
26646
|
-
...fallen.length > 0 ? cellFragments(o, p,
|
|
27368
|
+
...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, null, speed, blownMass, tag, true),
|
|
27369
|
+
...fallen.length > 0 ? cellFragments(o, p, clumpUnits(fallen, p.thin, unitSpan(p), fallenClumps), wp, null, 0.3, fallenMass, `${tag}f`, true) : [],
|
|
27370
|
+
...plasterFlakes(o, p, blown, wp, speed, `${tag}p`)
|
|
26647
27371
|
];
|
|
26648
27372
|
const cells = [...blown, ...fallen];
|
|
26649
27373
|
const holes = localHolesOf(p);
|
|
@@ -26679,7 +27403,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26679
27403
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
26680
27404
|
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
26681
27405
|
const opened = (cell) => !!op && !!p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius;
|
|
26682
|
-
const loose = unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]));
|
|
27406
|
+
const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i])));
|
|
26683
27407
|
if (loose.length === 0) return 0;
|
|
26684
27408
|
for (const i of loose) worn[i] = -1;
|
|
26685
27409
|
const fallen = loose.map((i) => grid[i]);
|
|
@@ -26694,7 +27418,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26694
27418
|
}
|
|
26695
27419
|
}
|
|
26696
27420
|
const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
|
|
26697
|
-
const fragments = cellFragments(o, p,
|
|
27421
|
+
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);
|
|
26698
27422
|
const holes = localHolesOf(p);
|
|
26699
27423
|
p.st.holes = p.st.holes.filter((_, k) => !fallen.some((cell) => marksInBox(cell.center, cell.size, void 0, [holes[k]]).length > 0));
|
|
26700
27424
|
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]] });
|
|
@@ -27114,14 +27838,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27114
27838
|
}
|
|
27115
27839
|
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);
|
|
27116
27840
|
const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
|
|
27117
|
-
const
|
|
27118
|
-
const
|
|
27841
|
+
const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
|
|
27842
|
+
const member = caged2 && (isMember(p.dims) || dist2 > MEMBER_CUT_REACH * breachReach);
|
|
27843
|
+
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);
|
|
27119
27844
|
res.damage += dealt;
|
|
27120
27845
|
if (p.bend && flexure.enabled) bendByBlast(o, p, point, energy, radius, reach, src);
|
|
27121
27846
|
if (p.spec.units && p.spec.units.mortar !== p.spec.material) {
|
|
27122
27847
|
blastPanel(o, p, point, energy, src);
|
|
27123
27848
|
if (!isLost(p)) blastUnits(o, p, wp, energy, dist2, src);
|
|
27124
|
-
} else if (
|
|
27849
|
+
} else if (member) blastUnits(o, p, wp, energy, dist2, src);
|
|
27125
27850
|
else if (dist2 <= breachReach) addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
|
|
27126
27851
|
return reach;
|
|
27127
27852
|
};
|
|
@@ -29385,7 +30110,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29385
30110
|
const alongU = wall.aabb[2] - wall.aabb[0] >= wall.aabb[3] - wall.aabb[1];
|
|
29386
30111
|
const from = alongU ? wall.aabb[0] : wall.aabb[1];
|
|
29387
30112
|
const to = alongU ? wall.aabb[2] : wall.aabb[3];
|
|
29388
|
-
const
|
|
30113
|
+
const cross4 = alongU ? [wall.aabb[1], wall.aabb[3]] : [wall.aabb[0], wall.aabb[2]];
|
|
29389
30114
|
const rows = Math.max(1, Math.round((wall.y1 - wall.y0) / spec.rowHeight));
|
|
29390
30115
|
const rowHeight = (wall.y1 - wall.y0) / rows;
|
|
29391
30116
|
const cells = [];
|
|
@@ -29395,7 +30120,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29395
30120
|
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 });
|
|
29396
30121
|
}
|
|
29397
30122
|
const total = cells.reduce((sum2, cell) => sum2 + (cell.to - cell.from) * (cell.y1 - cell.y0), 0);
|
|
29398
|
-
const box22 = (cell) => alongU ? [cell.from,
|
|
30123
|
+
const box22 = (cell) => alongU ? [cell.from, cross4[0], cell.to, cross4[1]] : [cross4[0], cell.from, cross4[1], cell.to];
|
|
29399
30124
|
const pieces = cells.map((cell, index) => ({
|
|
29400
30125
|
id: `${wall.id}_${spec.unitLength ? "u" : "log"}${cell.row}_${index}`,
|
|
29401
30126
|
role: wall.role,
|
|
@@ -29593,7 +30318,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29593
30318
|
}
|
|
29594
30319
|
return spec;
|
|
29595
30320
|
};
|
|
29596
|
-
var MEMBER_CAGE = { spacing: 0.1, diameter:
|
|
30321
|
+
var MEMBER_CAGE = { spacing: 0.1, diameter: 0.01, unit: 0.1 };
|
|
29597
30322
|
var CAGED_ROLES = /* @__PURE__ */ new Set(["beam", "column"]);
|
|
29598
30323
|
var CAGE_COVER = 0.03;
|
|
29599
30324
|
var CAGE_BUCKLING_SHARE = 0.5;
|
|
@@ -31528,7 +32253,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31528
32253
|
}
|
|
31529
32254
|
var residentialTower = residentialTowerTemplate();
|
|
31530
32255
|
|
|
31531
|
-
// ../game-floorplan-three/dist/chunk-
|
|
32256
|
+
// ../game-floorplan-three/dist/chunk-EWU252NT.js
|
|
31532
32257
|
var __defProp4 = Object.defineProperty;
|
|
31533
32258
|
var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
31534
32259
|
var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -37924,7 +38649,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
37924
38649
|
if (!pc || pc.unit) return sp;
|
|
37925
38650
|
if (pc.role !== "wall" && pc.role !== "partition") {
|
|
37926
38651
|
const def = getAssembly(pc.assembly || (pc.material === "concrete" && ["slab", "beam", "column", "stair"].includes(pc.role) ? "reinforced_concrete" : ""));
|
|
37927
|
-
const
|
|
38652
|
+
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;
|
|
38653
|
+
const cage = bars ? pc.role === "column" && sp.shape.kind === "box" ? { ...bars, residualCapacity: cageResidualCapacity(sp.shape.size, bars, sp.structure?.capacity) } : { ...bars } : null;
|
|
37928
38654
|
const out = cage && !sp.reinforcement ? { ...sp, reinforcement: cage } : sp;
|
|
37929
38655
|
if (out.reinforcement && !out.units && pc.material === "concrete" && (pc.role === "beam" || pc.role === "column") && sp.shape.kind === "box") {
|
|
37930
38656
|
return { ...out, units: { size: [MEMBER_CAGE.unit, MEMBER_CAGE.unit, Math.min(...sp.shape.size)], bond: "stack", mortar: "concrete" } };
|
|
@@ -38130,6 +38856,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38130
38856
|
toHouse.value.copy(house.matrixWorld).invert().multiply(mesh3.matrixWorld);
|
|
38131
38857
|
return mesh3;
|
|
38132
38858
|
}
|
|
38859
|
+
const withMask = (material, mask) => {
|
|
38860
|
+
material.userData.breachMask = mask;
|
|
38861
|
+
return material;
|
|
38862
|
+
};
|
|
38133
38863
|
function unitsMaterial(core) {
|
|
38134
38864
|
const material = new THREE.MeshLambertMaterial({ color: 16777215, side: THREE.DoubleSide });
|
|
38135
38865
|
material.onBeforeCompile = (sh) => {
|
|
@@ -38214,13 +38944,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38214
38944
|
if (opening) discs.push({ s: along(opening.center), y: opening.center[1], r: opening.radius });
|
|
38215
38945
|
for (const k of spalls) flakes.push({ s: along(k.center), y: k.center[1], r: k.radius });
|
|
38216
38946
|
const boxes = chips2.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 }));
|
|
38217
|
-
const gone = (c) =>
|
|
38947
|
+
const gone = (c) => {
|
|
38948
|
+
const over = boxes.filter((k) => k.s1 > c.a && k.s0 < c.b && k.y1 > c.y0 && k.y0 < c.y1);
|
|
38949
|
+
const share = covered(c, over);
|
|
38950
|
+
if (share >= 0.9) return true;
|
|
38951
|
+
const s = (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2;
|
|
38952
|
+
return share >= 0.5 && over.some((k) => s >= k.s0 && s <= k.s1 && y >= k.y0 && y <= k.y1);
|
|
38953
|
+
};
|
|
38954
|
+
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;
|
|
38218
38955
|
const kept = [];
|
|
38219
|
-
for (const c of all) (
|
|
38956
|
+
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
38220
38957
|
for (const c of kept) shown.push({ c, part, units: units2, thick, mid });
|
|
38221
|
-
for (const
|
|
38222
|
-
if (holes.some((h) =>
|
|
38223
|
-
|
|
38958
|
+
for (const box5 of boxes) {
|
|
38959
|
+
if (holes.some((h) => box5.s0 >= h.a - 1e-4 && box5.s1 <= h.b + 1e-4 && box5.y0 >= h.y0 - 1e-4 && box5.y1 <= h.y1 + 1e-4)) continue;
|
|
38960
|
+
const k = id === view.host ? besidePillars({ a: box5.s0, b: box5.s1, y0: box5.y0, y1: box5.y1 }, pillars)[0] : { a: box5.s0, b: box5.s1, y0: box5.y0, y1: box5.y1 };
|
|
38961
|
+
if (!k) continue;
|
|
38962
|
+
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 });
|
|
38224
38963
|
}
|
|
38225
38964
|
}
|
|
38226
38965
|
const reach = SPALL_MIN + SPALL_RAGGED;
|
|
@@ -38249,6 +38988,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38249
38988
|
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));
|
|
38250
38989
|
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));
|
|
38251
38990
|
}
|
|
38991
|
+
for (const q of pillars) {
|
|
38992
|
+
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));
|
|
38993
|
+
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));
|
|
38994
|
+
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);
|
|
38995
|
+
}
|
|
38252
38996
|
mask.texture.needsUpdate = true;
|
|
38253
38997
|
core.texture.needsUpdate = true;
|
|
38254
38998
|
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);
|
|
@@ -38315,7 +39059,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38315
39059
|
items,
|
|
38316
39060
|
mask,
|
|
38317
39061
|
core,
|
|
38318
|
-
unitMaterial: unitsMaterial(core),
|
|
39062
|
+
unitMaterial: withMask(unitsMaterial(core), mask),
|
|
38319
39063
|
shells: [],
|
|
38320
39064
|
saved: null,
|
|
38321
39065
|
units: null,
|
|
@@ -68474,7 +69218,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68474
69218
|
var tangentA = { x: 0, y: 0, z: 0 };
|
|
68475
69219
|
var tangentB = { x: 0, y: 0, z: 0 };
|
|
68476
69220
|
var axis = { x: 0, y: 0, z: 0 };
|
|
68477
|
-
function
|
|
69221
|
+
function cross3(out, a, b) {
|
|
68478
69222
|
const x = a.y * b.z - a.z * b.y;
|
|
68479
69223
|
const y = a.z * b.x - a.x * b.z;
|
|
68480
69224
|
const z = a.x * b.y - a.y * b.x;
|
|
@@ -68499,8 +69243,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68499
69243
|
tangentA.x = 0;
|
|
68500
69244
|
tangentA.y = 1;
|
|
68501
69245
|
}
|
|
68502
|
-
normalize2(
|
|
68503
|
-
normalize2(
|
|
69246
|
+
normalize2(cross3(tangentB, axis, tangentA));
|
|
69247
|
+
normalize2(cross3(tangentA, tangentB, axis));
|
|
68504
69248
|
out.x = dx * cosTilt;
|
|
68505
69249
|
out.y = dy * cosTilt;
|
|
68506
69250
|
out.z = dz * cosTilt;
|