@adatechnology/game-items-three 0.7.9 → 0.8.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/{chunk-76GT7V27.js → chunk-V4L35AWB.js} +34 -8
- package/dist/chunk-V4L35AWB.js.map +1 -0
- package/dist/index.global.js +1098 -60
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-76GT7V27.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1785,9 +1785,9 @@ var GameItemsThree = (() => {
|
|
|
1785
1785
|
}
|
|
1786
1786
|
return points;
|
|
1787
1787
|
}
|
|
1788
|
-
function extrudeOf(
|
|
1789
|
-
if (Array.isArray(
|
|
1790
|
-
const shape =
|
|
1788
|
+
function extrudeOf(shapes2, options = {}) {
|
|
1789
|
+
if (Array.isArray(shapes2) || !shapes2 || options.extrudePath !== void 0 || options.UVGenerator !== void 0) return null;
|
|
1790
|
+
const shape = shapes2;
|
|
1791
1791
|
const outer = linePoints(shape);
|
|
1792
1792
|
if (!outer) return null;
|
|
1793
1793
|
const holes = [];
|
|
@@ -1835,11 +1835,11 @@ var GameItemsThree = (() => {
|
|
|
1835
1835
|
return made(viaCache({ kind: "lathe", points: profile, ...defined({ segments, phiStart, phiLength }) }, () => lathe(profile, segments, phiStart, phiLength)));
|
|
1836
1836
|
},
|
|
1837
1837
|
TorusGeometry: (radius, tube2, radialSegments, tubularSegments, arc) => made(viaCache({ kind: "torus", ...defined({ radius, tube: tube2, radialSegments, tubularSegments, arc }) }, () => torus(radius, tube2, radialSegments, tubularSegments, arc))),
|
|
1838
|
-
ExtrudeGeometry: (
|
|
1839
|
-
const buffers =
|
|
1840
|
-
if (!buffers) return new THREE.ExtrudeGeometry(
|
|
1838
|
+
ExtrudeGeometry: (shapes2, extrudeOptions) => {
|
|
1839
|
+
const buffers = shapes2 === void 0 ? null : extrudeOf(shapes2, extrudeOptions);
|
|
1840
|
+
if (!buffers) return new THREE.ExtrudeGeometry(shapes2, extrudeOptions);
|
|
1841
1841
|
const geometry = toGeometry(THREE, buffers);
|
|
1842
|
-
geometry.parameters = { shapes, options: extrudeOptions ?? {} };
|
|
1842
|
+
geometry.parameters = { shapes: shapes2, options: extrudeOptions ?? {} };
|
|
1843
1843
|
return geometry;
|
|
1844
1844
|
}
|
|
1845
1845
|
};
|
|
@@ -1936,6 +1936,10 @@ var GameItemsThree = (() => {
|
|
|
1936
1936
|
return { geometries, materials, textures, skeletons };
|
|
1937
1937
|
}
|
|
1938
1938
|
var marked = /* @__PURE__ */ new WeakSet();
|
|
1939
|
+
function markShared(...resources) {
|
|
1940
|
+
for (const resource of resources) marked.add(resource);
|
|
1941
|
+
return resources;
|
|
1942
|
+
}
|
|
1939
1943
|
var shared = (r) => r.userData?.shared === true || marked.has(r);
|
|
1940
1944
|
function releaseObject3D(roots, options = {}) {
|
|
1941
1945
|
const list2 = Array.isArray(roots) ? roots : [roots];
|
|
@@ -3431,11 +3435,11 @@ var GameItemsThree = (() => {
|
|
|
3431
3435
|
id: "crowbar",
|
|
3432
3436
|
teamId: "pe_cabra",
|
|
3433
3437
|
teamBox: [
|
|
3434
|
-
0.
|
|
3435
|
-
1.
|
|
3436
|
-
0.
|
|
3438
|
+
0.3559,
|
|
3439
|
+
1.6698,
|
|
3440
|
+
0.068
|
|
3437
3441
|
],
|
|
3438
|
-
scale: 0.
|
|
3442
|
+
scale: 0.449156
|
|
3439
3443
|
},
|
|
3440
3444
|
{
|
|
3441
3445
|
id: "hammer",
|
|
@@ -6003,9 +6007,34 @@ var GameItemsThree = (() => {
|
|
|
6003
6007
|
var amoxicillin = ({ T: T2, mesh: mesh2, bx, G, metal, plastic, paper: paper2 }) => G(mesh2(bx(0.8, 0.42, 0.24), paper2(15789798)), mesh2(bx(0.81, 0.1, 0.25), plastic(5141127), [0, 0.1, 0]), mesh2(bx(0.6, 0.04, 0.3), metal(12172736), [0.15, -0.24, 0.25], [0, 0.3, 0]), ...[0, 1, 2, 3].map((k) => mesh2(new T2.SphereGeometry(0.05, 10, 8), plastic(14263361), [-0.05 + k * 0.14, -0.21, 0.3], [0, 0, 0], [1, 0.6, 1])));
|
|
6004
6008
|
|
|
6005
6009
|
// src/models/crowbar.ts
|
|
6006
|
-
var
|
|
6007
|
-
|
|
6008
|
-
|
|
6010
|
+
var CURVE = [[0, -0.8, 0], [0, 0.5, 0], [0.012, 0.625, 0], [0.06, 0.7, 0], [0.12, 0.715, 0], [0.19, 0.685, 0], [0.26, 0.63, 0]];
|
|
6011
|
+
var BAR_RADIUS = 0.026;
|
|
6012
|
+
var CHISEL = [[-0.024, -0.79], [0.024, -0.79], [0.016, -0.86], [4e-3, -0.928], [-8e-3, -0.928], [-0.022, -0.86]];
|
|
6013
|
+
var CHISEL_WIDTH = 0.06;
|
|
6014
|
+
var shapes = /* @__PURE__ */ new WeakMap();
|
|
6015
|
+
var shapesOf = (T2, extrude2) => {
|
|
6016
|
+
const cached = shapes.get(T2);
|
|
6017
|
+
if (cached) return cached;
|
|
6018
|
+
const curve = new T2.CatmullRomCurve3(CURVE.map((point) => new T2.Vector3(...point)));
|
|
6019
|
+
const bar2 = new T2.TubeGeometry(curve, 30, BAR_RADIUS, 6);
|
|
6020
|
+
const chisel = extrude2(CHISEL, CHISEL_WIDTH, 4e-3);
|
|
6021
|
+
chisel.translate(0, 0, -CHISEL_WIDTH / 2);
|
|
6022
|
+
markShared(bar2);
|
|
6023
|
+
markShared(chisel);
|
|
6024
|
+
const made = { bar: bar2, chisel };
|
|
6025
|
+
shapes.set(T2, made);
|
|
6026
|
+
return made;
|
|
6027
|
+
};
|
|
6028
|
+
var crowbar = ({ T: T2, mesh: mesh2, bx, extrude: extrude2, G, metal }) => {
|
|
6029
|
+
const forged = metal(7764863);
|
|
6030
|
+
const steel = metal(9277844);
|
|
6031
|
+
const end = CURVE[CURVE.length - 1];
|
|
6032
|
+
const before = CURVE[CURVE.length - 2];
|
|
6033
|
+
const angle = Math.atan2(end[1] - before[1], end[0] - before[0]);
|
|
6034
|
+
const along = (distance2) => [end[0] + Math.cos(angle) * distance2, end[1] + Math.sin(angle) * distance2, 0];
|
|
6035
|
+
const prongs = [-1, 1].map((side) => mesh2(bx(0.1, 0.016, 0.022), steel, [...along(0.03)].map((value, index) => index === 2 ? side * 0.014 : value), [0, 0, angle]));
|
|
6036
|
+
const { bar: bar2, chisel } = shapesOf(T2, extrude2);
|
|
6037
|
+
return G(mesh2(bar2, forged), mesh2(chisel, steel), ...prongs);
|
|
6009
6038
|
};
|
|
6010
6039
|
|
|
6011
6040
|
// src/models/hammer.ts
|
|
@@ -13596,21 +13625,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13596
13625
|
for (const row of rows.values()) for (const i of row) if (!held.has(i)) loose.push(i);
|
|
13597
13626
|
return loose;
|
|
13598
13627
|
};
|
|
13599
|
-
var
|
|
13628
|
+
var clumpUnits = (cells, thin, unit, cap) => {
|
|
13600
13629
|
if (cells.length <= cap) return [...cells];
|
|
13601
13630
|
const [u, v] = planeAxes(thin);
|
|
13602
|
-
let lo0 = Infinity, lo1 = Infinity
|
|
13631
|
+
let lo0 = Infinity, lo1 = Infinity;
|
|
13603
13632
|
for (const cell of cells) {
|
|
13604
13633
|
lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
|
|
13605
|
-
hi0 = Math.max(hi0, cell.center[u] + cell.size[u] / 2);
|
|
13606
13634
|
lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
|
|
13607
|
-
hi1 = Math.max(hi1, cell.center[v] + cell.size[v] / 2);
|
|
13608
13635
|
}
|
|
13609
|
-
let
|
|
13610
|
-
for (; ; ) {
|
|
13636
|
+
let along = 1, up = 1;
|
|
13637
|
+
for (let grow = 0; ; grow++) {
|
|
13611
13638
|
const bins = /* @__PURE__ */ new Map();
|
|
13612
13639
|
for (const cell of cells) {
|
|
13613
|
-
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]))}`;
|
|
13614
13641
|
const bin = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
|
|
13615
13642
|
for (let k = 0; k < 3; k++) {
|
|
13616
13643
|
bin.lo[k] = Math.min(bin.lo[k], cell.center[k] - cell.size[k] / 2);
|
|
@@ -13621,7 +13648,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13621
13648
|
if (bins.size <= cap) {
|
|
13622
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]] }));
|
|
13623
13650
|
}
|
|
13624
|
-
|
|
13651
|
+
if (grow % 2 === 0) up++;
|
|
13652
|
+
else along++;
|
|
13625
13653
|
}
|
|
13626
13654
|
};
|
|
13627
13655
|
var MAX_SPALLS = 64;
|
|
@@ -13690,6 +13718,39 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
13690
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]]));
|
|
13691
13719
|
return out;
|
|
13692
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
|
+
};
|
|
13693
13754
|
var clipBarsToBox = (bars, u, v, center, size) => {
|
|
13694
13755
|
const out = [];
|
|
13695
13756
|
for (const [a, b] of bars) {
|
|
@@ -14103,6 +14164,220 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
14103
14164
|
const stable = converged && cholesky3(ev.Jt, [0, 0, 0]) !== null;
|
|
14104
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]] };
|
|
14105
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
|
+
}
|
|
14281
|
+
var GROUND_LOSS_DEFAULTS = {
|
|
14282
|
+
footingDepth: 0.5,
|
|
14283
|
+
spread: 1,
|
|
14284
|
+
voidDepth: 0.05,
|
|
14285
|
+
maxSettlement: 0.05,
|
|
14286
|
+
crackDistortion: 1 / 300,
|
|
14287
|
+
damageDistortion: 1 / 150,
|
|
14288
|
+
bearingCrackDistortion: 1 / 500,
|
|
14289
|
+
bearingDamageDistortion: 1 / 300,
|
|
14290
|
+
distortionDamage: 0.3,
|
|
14291
|
+
bridgeSpanDepth: 10,
|
|
14292
|
+
beamRebarRatio: 4e-3
|
|
14293
|
+
};
|
|
14294
|
+
var DISTORTION_BASE = 1;
|
|
14295
|
+
var FOOTPRINT_STEP = 0.1;
|
|
14296
|
+
var FOOTPRINT_MAX_SAMPLES = 40;
|
|
14297
|
+
var resolveGroundLoss = (options = {}) => ({
|
|
14298
|
+
...GROUND_LOSS_DEFAULTS,
|
|
14299
|
+
...Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0))
|
|
14300
|
+
});
|
|
14301
|
+
var bowlDepth = (loss, r) => r >= loss.radius ? 0 : loss.depth * (1 - (r / loss.radius) ** 2);
|
|
14302
|
+
var undercutAt = (loss, r, embed, spread2) => {
|
|
14303
|
+
if (loss.depth <= embed || loss.radius <= 0) return 0;
|
|
14304
|
+
const reach = Math.min(r, loss.radius);
|
|
14305
|
+
const cut = (t) => bowlDepth(loss, t) - Math.max(0, r - t) / spread2 - embed;
|
|
14306
|
+
const steepest = loss.radius * loss.radius / (2 * loss.depth * spread2);
|
|
14307
|
+
return Math.max(0, cut(reach), cut(Math.min(reach, steepest)), cut(0));
|
|
14308
|
+
};
|
|
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)));
|
|
14315
|
+
};
|
|
14316
|
+
var distortionOf = (drops, step) => {
|
|
14317
|
+
const span = Math.max(1, Math.round(DISTORTION_BASE / step));
|
|
14318
|
+
let value = 0;
|
|
14319
|
+
let at2 = 0;
|
|
14320
|
+
let down = 1;
|
|
14321
|
+
for (let i = 0; i < drops.length; i++) {
|
|
14322
|
+
const j = Math.min(drops.length - 1, i + span);
|
|
14323
|
+
if (j === i) continue;
|
|
14324
|
+
const change = drops[j] - drops[i];
|
|
14325
|
+
const beta = Math.abs(change) / Math.max((j - i) * step, DISTORTION_BASE);
|
|
14326
|
+
if (beta > value) {
|
|
14327
|
+
value = beta;
|
|
14328
|
+
at2 = (i + j) / 2;
|
|
14329
|
+
down = change >= 0 ? 1 : -1;
|
|
14330
|
+
}
|
|
14331
|
+
}
|
|
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;
|
|
14380
|
+
};
|
|
14106
14381
|
var wind_terrain_default = [
|
|
14107
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 },
|
|
14108
14383
|
{ id: "II", zg: 300, b: { A: 1, B: 1, C: 1 }, p: { A: 0.085, B: 0.09, C: 0.1 }, z0: 0.05 },
|
|
@@ -15898,12 +16173,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15898
16173
|
var SUPPORT_TOLERANCE = 0.05;
|
|
15899
16174
|
var UNIT_FRAGMENT_FACTOR = 4;
|
|
15900
16175
|
var BREACH_GRID_CAP = 4096;
|
|
16176
|
+
var MASONRY_CRUMBLE_SPEED = 0.6;
|
|
16177
|
+
var TILE_CLUMPS = 160;
|
|
16178
|
+
var PANEL_EDGE_PILLAR = 2;
|
|
16179
|
+
var PANEL_EDGE_BASE = 4;
|
|
16180
|
+
var PANEL_EDGE_BEAM = 3;
|
|
16181
|
+
var PLASTER_FLAKE_AREA = 0.25;
|
|
16182
|
+
var MAX_PLASTER_FLAKES = 24;
|
|
15901
16183
|
var CHIP_ENERGY = 200;
|
|
15902
16184
|
var CHIP_SPLASH = 0.5;
|
|
15903
16185
|
var CRATER_SPENT = 0.6;
|
|
15904
16186
|
var EDGE_REACH = 1.5;
|
|
15905
16187
|
var BAR_BOW = 0.08;
|
|
15906
16188
|
var BULLET_JOINT_SPAN = 0.3;
|
|
16189
|
+
var SUBSIDE_MIN = 1e-3;
|
|
16190
|
+
var DISTORTION_GROWTH = 1.2;
|
|
16191
|
+
var MAX_SETTLEMENT_CRACKS = 4;
|
|
16192
|
+
var SETTLEMENT_CRACK_LENGTH = 0.3;
|
|
16193
|
+
var SETTLEMENT_CRACK_SPACING = 0.4;
|
|
16194
|
+
var SETTLEMENT_CRACK_OPENING = 0.3;
|
|
16195
|
+
var MIN_CRACK_WIDTH = 5e-4;
|
|
16196
|
+
var MAX_CRACK_WIDTH = 0.02;
|
|
16197
|
+
var BESIDE_CRACK_OFFSET = 0.8;
|
|
16198
|
+
var BRICK_STEP = [0.2, 0.1];
|
|
16199
|
+
var SETTLEMENT_FOLLOW_DEPTH = 2;
|
|
16200
|
+
var CRACKED_STIFFNESS = 0.4;
|
|
16201
|
+
var PILLAR_SEAT = 0.05;
|
|
16202
|
+
var PUNCHING_SHARE = 0.5;
|
|
16203
|
+
var ARCH_ANGLE = Math.PI / 3;
|
|
15907
16204
|
var CUT_SLICE = 1;
|
|
15908
16205
|
var cutFactorOf = (shape) => clamp2(Math.max(...shapeDims(shape)) / CUT_SLICE, 1, 50);
|
|
15909
16206
|
var clamp2 = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
@@ -15979,6 +16276,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15979
16276
|
for (const m of options.materials ?? []) materials.set(m.id, m);
|
|
15980
16277
|
const ambient = options.ambientC ?? 20;
|
|
15981
16278
|
const maxFragments = options.maxFragments ?? 24;
|
|
16279
|
+
const unitClumps = maxFragments * UNIT_FRAGMENT_FACTOR;
|
|
16280
|
+
const fallenClumps = Math.max(2, Math.round(unitClumps / 4));
|
|
15982
16281
|
const maxDents = options.maxDents ?? 24;
|
|
15983
16282
|
const maxHoles = options.maxHoles ?? 32;
|
|
15984
16283
|
const fireSpread = options.fireSpread ?? 0.6;
|
|
@@ -16093,6 +16392,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16093
16392
|
dirty: false,
|
|
16094
16393
|
maxStress: 0,
|
|
16095
16394
|
collapsed: new Set(carry?.collapsed ?? []),
|
|
16395
|
+
unanchored: new Set(carry?.unanchored ?? []),
|
|
16096
16396
|
unsup: [],
|
|
16097
16397
|
anyAnchor: false,
|
|
16098
16398
|
order: ++orderCounter,
|
|
@@ -16188,6 +16488,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16188
16488
|
o.byPart.get(r.b).push(j);
|
|
16189
16489
|
o.st.joints.push(jst);
|
|
16190
16490
|
}
|
|
16491
|
+
for (const id2 of o.unanchored) {
|
|
16492
|
+
const p = o.byId.get(id2);
|
|
16493
|
+
if (p) p.anchored = false;
|
|
16494
|
+
}
|
|
16191
16495
|
for (const [jid, c] of carry?.joints ?? []) if (c.st.open && !o.jointMap.has(jid)) o.st.joints.push(c.st);
|
|
16192
16496
|
updateBound(o);
|
|
16193
16497
|
o.anyAnchor = o.parts.some((p) => p.anchored);
|
|
@@ -16284,6 +16588,61 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16284
16588
|
return (above + p.st.mass * share) / load;
|
|
16285
16589
|
};
|
|
16286
16590
|
};
|
|
16591
|
+
const contactsOf = (p, support) => {
|
|
16592
|
+
const box4 = contactBox(p, support);
|
|
16593
|
+
const broken = support.rt.broken;
|
|
16594
|
+
if (!broken?.length) return [box4];
|
|
16595
|
+
let pieces = [box4];
|
|
16596
|
+
for (const [axis, from, to] of broken) {
|
|
16597
|
+
const a = [p.pos[0], p.pos[1], p.pos[2]];
|
|
16598
|
+
const b = [p.pos[0], p.pos[1], p.pos[2]];
|
|
16599
|
+
a[axis] = from;
|
|
16600
|
+
b[axis] = to;
|
|
16601
|
+
const la = toLocal(p.pos, p.q, a);
|
|
16602
|
+
const lb = toLocal(p.pos, p.q, b);
|
|
16603
|
+
const k = [0, 1, 2].reduce((best, c) => Math.abs(lb[c] - la[c]) > Math.abs(lb[best] - la[best]) ? c : best, 0);
|
|
16604
|
+
const lo = Math.min(la[k], lb[k]);
|
|
16605
|
+
const hi = Math.max(la[k], lb[k]);
|
|
16606
|
+
pieces = pieces.flatMap(([min, max]) => {
|
|
16607
|
+
if (hi <= min[k] || lo >= max[k]) return [[min, max]];
|
|
16608
|
+
const out = [];
|
|
16609
|
+
if (lo > min[k]) {
|
|
16610
|
+
const end = [max[0], max[1], max[2]];
|
|
16611
|
+
end[k] = lo;
|
|
16612
|
+
out.push([min, end]);
|
|
16613
|
+
}
|
|
16614
|
+
if (hi < max[k]) {
|
|
16615
|
+
const start = [min[0], min[1], min[2]];
|
|
16616
|
+
start[k] = hi;
|
|
16617
|
+
out.push([start, max]);
|
|
16618
|
+
}
|
|
16619
|
+
return out;
|
|
16620
|
+
});
|
|
16621
|
+
}
|
|
16622
|
+
return pieces;
|
|
16623
|
+
};
|
|
16624
|
+
const fixedJoint = (j) => j.spec.kind === "rebar" || j.spec.kind === "fused" || j.spec.kind === "weld";
|
|
16625
|
+
const standsOver = (o, p, lower) => {
|
|
16626
|
+
const role = p.spec.structure?.role;
|
|
16627
|
+
if (role !== "slab" && role !== "roof" || p.spec.shape.kind !== "box" || lower.length === 0) return true;
|
|
16628
|
+
if (Math.abs(rotateVec(p.q, [0, 0, 0].map((_, k) => k === p.thin ? 1 : 0))[1]) < 0.9) return true;
|
|
16629
|
+
const i = o.idx.get(p.spec.id);
|
|
16630
|
+
for (const j of o.byPart.get(p.spec.id) ?? []) {
|
|
16631
|
+
if (j.st.open) continue;
|
|
16632
|
+
if (fixedJoint(j) && lower.includes(restsOn(o, j, i)) || j.spec.kind === "tie") return true;
|
|
16633
|
+
}
|
|
16634
|
+
const corners = [];
|
|
16635
|
+
for (const k of lower) {
|
|
16636
|
+
for (const [lo, hi] of contactsOf(p, o.parts[k])) {
|
|
16637
|
+
for (let c = 0; c < 4; c++) {
|
|
16638
|
+
const local = [c & 1 ? hi[0] : lo[0], (lo[1] + hi[1]) / 2, c & 2 ? hi[2] : lo[2]];
|
|
16639
|
+
const at2 = toWorld(p.pos, p.q, local);
|
|
16640
|
+
corners.push([at2[0], at2[2]]);
|
|
16641
|
+
}
|
|
16642
|
+
}
|
|
16643
|
+
}
|
|
16644
|
+
return restsOver([p.pos[0], p.pos[2]], corners, 0);
|
|
16645
|
+
};
|
|
16287
16646
|
const borneOn = (p, supports) => {
|
|
16288
16647
|
if (supports.length === 0) return void 0;
|
|
16289
16648
|
const boxes = supports.map((support) => contactBox(p, support));
|
|
@@ -16339,7 +16698,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16339
16698
|
const key2 = lower.join(",");
|
|
16340
16699
|
if (key2 !== p.spanKey) {
|
|
16341
16700
|
p.spanKey = key2;
|
|
16342
|
-
p.span = spanOf(g, lower.
|
|
16701
|
+
p.span = spanOf(g, lower.flatMap((k) => contactsOf(p, o.parts[k])));
|
|
16343
16702
|
}
|
|
16344
16703
|
p.restMoment = 0;
|
|
16345
16704
|
if (g.gravity < 0 || p.span <= 0) return 0;
|
|
@@ -16405,9 +16764,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16405
16764
|
};
|
|
16406
16765
|
const freeSpan = (p, supports) => {
|
|
16407
16766
|
if (supports.length === 0) return Infinity;
|
|
16767
|
+
if (p.spec.shape.kind === "box") {
|
|
16768
|
+
const g = bendGeometry(p.spec);
|
|
16769
|
+
if (!g.member) return spanOf(g, supports.flatMap((k) => contactsOf(p, k)));
|
|
16770
|
+
}
|
|
16408
16771
|
const d = p.dims;
|
|
16409
16772
|
const L = [0, 1, 2].sort((a, b) => d[b] - d[a])[0];
|
|
16410
|
-
const spans = supports.
|
|
16773
|
+
const spans = supports.flatMap((k) => contactsOf(p, k)).map(([lo, hi]) => [lo[L], hi[L]]);
|
|
16411
16774
|
let far = 0;
|
|
16412
16775
|
for (let i = 0; i <= 16; i++) {
|
|
16413
16776
|
const x = (i / 16 - 0.5) * d[L];
|
|
@@ -16457,7 +16820,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16457
16820
|
}
|
|
16458
16821
|
lowerOf.set(i, lower);
|
|
16459
16822
|
const max = parts[i].spec.structure?.maxSpan;
|
|
16460
|
-
|
|
16823
|
+
const tooLong = max !== void 0 && freeSpan(parts[i], lower.map((k) => parts[k])) > max;
|
|
16824
|
+
const standing = parts[i].heldAsDesigned || standsOver(o, parts[i], lower);
|
|
16825
|
+
if (o.seeding && !standing) parts[i].heldAsDesigned = true;
|
|
16826
|
+
if (!parts[i].anchored && (tooLong || !(standing || parts[i].heldAsDesigned))) {
|
|
16461
16827
|
out.add(i);
|
|
16462
16828
|
dropped = true;
|
|
16463
16829
|
}
|
|
@@ -16911,20 +17277,561 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16911
17277
|
if (!o.hasStructure || !o.parts.some((p) => p.anchored)) return;
|
|
16912
17278
|
if (!pendingCollapse.has(o)) pendingCollapse.set(o, src);
|
|
16913
17279
|
};
|
|
17280
|
+
const isLaidMasonry = (p) => !!p.spec.units && p.spec.units.mortar !== p.spec.material && !p.spec.reinforcement && !p.st.stripped;
|
|
17281
|
+
const isTiledCover = (p) => p.spec.structure?.role === "roof" && p.mat.fracture === "shatter" && !p.spec.reinforcement && !p.spec.units;
|
|
17282
|
+
const crumbleMasonry = (o, p, src) => {
|
|
17283
|
+
if (isLost(p)) return;
|
|
17284
|
+
const [u, v] = planeAxes(p.thin);
|
|
17285
|
+
const grid = gridOf(p);
|
|
17286
|
+
const worn = p.rt.chips ?? {};
|
|
17287
|
+
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
17288
|
+
const cells = grid.filter((cell, i) => worn[i] !== -1 && !(op && p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius));
|
|
17289
|
+
const { c } = partXf(o, p);
|
|
17290
|
+
const fragments = cells.length > 0 ? [
|
|
17291
|
+
...cellFragments(o, p, clumpUnits(cells, p.thin, unitSpan(p), isTiledCover(p) ? TILE_CLUMPS : unitClumps), vec.add(c, [0, 1, 0]), null, MASONRY_CRUMBLE_SPEED, p.st.mass, "m_", true),
|
|
17292
|
+
...plasterFlakes(o, p, cells, vec.add(c, [0, 1, 0]), MASONRY_CRUMBLE_SPEED, "mp_")
|
|
17293
|
+
] : [];
|
|
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
|
+
};
|
|
16914
17302
|
const flushCollapse = () => {
|
|
16915
17303
|
for (const [o, src] of [...pendingCollapse]) {
|
|
16916
17304
|
pendingCollapse.delete(o);
|
|
16917
17305
|
if (!objects.has(o.id) || objects.get(o.id) !== o) continue;
|
|
16918
|
-
|
|
17306
|
+
const crumbling = [];
|
|
17307
|
+
for (const g of [...o.st.groups]) {
|
|
16919
17308
|
const ps = g.map((id) => o.byId.get(id)).filter((p) => !isLost(p) && !o.collapsed.has(p.spec.id));
|
|
16920
17309
|
if (ps.length === 0 || g.some((id) => o.byId.get(id).anchored) || !ps.some((p) => p.structural)) continue;
|
|
16921
|
-
|
|
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) {
|
|
16922
17313
|
o.collapsed.add(p.spec.id);
|
|
16923
17314
|
p.st.status = "collapsed";
|
|
16924
17315
|
setStage(o, p, 3, {}, src);
|
|
16925
17316
|
}
|
|
16926
|
-
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) });
|
|
16927
17318
|
}
|
|
17319
|
+
for (const p of crumbling) crumbleMasonry(o, p, src);
|
|
17320
|
+
}
|
|
17321
|
+
};
|
|
17322
|
+
const groundCfg = resolveGroundLoss(options.groundLoss);
|
|
17323
|
+
const pendingLosses = [];
|
|
17324
|
+
const bearersOf = (o) => {
|
|
17325
|
+
const terrain = /* @__PURE__ */ new Set();
|
|
17326
|
+
o.parts.forEach((p, i) => {
|
|
17327
|
+
if (isTerrain(p) && !isLost(p)) terrain.add(i);
|
|
17328
|
+
});
|
|
17329
|
+
const tops = [...terrain].map((i) => aabbOf(o.parts[i].spec.shape, o.parts[i].pos, o.parts[i].q).max[1]);
|
|
17330
|
+
const out = [];
|
|
17331
|
+
o.parts.forEach((p, i) => {
|
|
17332
|
+
if (terrain.has(i) || isLost(p) || o.collapsed.has(p.spec.id) || p.spec.structure?.pile) return;
|
|
17333
|
+
const ground = (o.byPart.get(p.spec.id) ?? []).filter((j) => !j.st.open && terrain.has(restsOn(o, j, i)));
|
|
17334
|
+
if (!p.anchored && ground.length === 0) return;
|
|
17335
|
+
const bottom = aabbOf(p.spec.shape, p.pos, p.q).min[1];
|
|
17336
|
+
const depth = Math.max(0, (tops.length ? Math.max(...tops) : bottom) - bottom);
|
|
17337
|
+
const footed = p.spec.structure?.role === "wall" || p.spec.structure?.role === "column";
|
|
17338
|
+
out.push({ p, i, ground, embed: footed ? Math.max(depth, groundCfg.footingDepth) : depth });
|
|
17339
|
+
});
|
|
17340
|
+
return out;
|
|
17341
|
+
};
|
|
17342
|
+
const nearLoss = (o, p, loss) => {
|
|
17343
|
+
const box4 = partWorldAabb(o, p);
|
|
17344
|
+
const dx = Math.max(box4.min[0] - loss.x, 0, loss.x - box4.max[0]);
|
|
17345
|
+
const dz = Math.max(box4.min[2] - loss.z, 0, loss.z - box4.max[2]);
|
|
17346
|
+
return Math.hypot(dx, dz) < loss.radius + loss.depth * groundCfg.spread;
|
|
17347
|
+
};
|
|
17348
|
+
const footprintOf = (o, b, loss) => {
|
|
17349
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17350
|
+
const long = box4.max[0] - box4.min[0] >= box4.max[2] - box4.min[2] ? 0 : 2;
|
|
17351
|
+
const across2 = long === 0 ? 2 : 0;
|
|
17352
|
+
const n = clamp2(Math.ceil((box4.max[long] - box4.min[long]) / FOOTPRINT_STEP), 1, FOOTPRINT_MAX_SAMPLES);
|
|
17353
|
+
const m = clamp2(Math.ceil((box4.max[across2] - box4.min[across2]) / FOOTPRINT_STEP), 1, FOOTPRINT_MAX_SAMPLES);
|
|
17354
|
+
const step = (box4.max[long] - box4.min[long]) / n;
|
|
17355
|
+
const slices = [];
|
|
17356
|
+
let voids = 0;
|
|
17357
|
+
let sum = 0;
|
|
17358
|
+
let worst = -1;
|
|
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;
|
|
17361
|
+
for (let k = 0; k < n; k++) {
|
|
17362
|
+
let open = 0;
|
|
17363
|
+
let drop = 0;
|
|
17364
|
+
let cutSum = 0;
|
|
17365
|
+
for (let c = 0; c < m; c++) {
|
|
17366
|
+
const local = [0, box4.min[1], 0];
|
|
17367
|
+
local[long] = box4.min[long] + (k + 0.5) * step;
|
|
17368
|
+
local[across2] = box4.min[across2] + (c + 0.5) * (box4.max[across2] - box4.min[across2]) / m;
|
|
17369
|
+
const world2 = toWorld(o.st.position, o.st.rotation, local);
|
|
17370
|
+
const cut = undercutAt(loss, Math.hypot(world2[0] - loss.x, world2[2] - loss.z), b.embed, groundCfg.spread);
|
|
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
|
+
}
|
|
17379
|
+
drop += Math.min(cut, groundCfg.maxSettlement);
|
|
17380
|
+
cutSum += cut;
|
|
17381
|
+
if (cut > worst) {
|
|
17382
|
+
worst = cut;
|
|
17383
|
+
deepest = world2;
|
|
17384
|
+
}
|
|
17385
|
+
}
|
|
17386
|
+
voids += open;
|
|
17387
|
+
sum += drop;
|
|
17388
|
+
slices.push({ void: open * 2 > m, drop: drop / m, cut: cutSum / m });
|
|
17389
|
+
}
|
|
17390
|
+
return { long, step, slices, voidBox, share: voids / (n * m), drop: sum / (n * m), deepest };
|
|
17391
|
+
};
|
|
17392
|
+
const sectionOfBearer = (p) => {
|
|
17393
|
+
if (p.spec.shape.kind !== "box" || !p.mat.strength?.tensileMPa) return null;
|
|
17394
|
+
const g = bendGeometry(p.spec);
|
|
17395
|
+
if (g.gravity < 0) return null;
|
|
17396
|
+
const footing = p.spec.structure?.role === "foundation" && g.member && !isReinforced(p.spec);
|
|
17397
|
+
const spec = footing ? { ...p.spec, structure: { ...p.spec.structure, rebar: { ratio: groundCfg.beamRebarRatio } } } : p.spec;
|
|
17398
|
+
const section = { b: sectionWidth(g, g.gravity), h: g.dims[g.gravity] };
|
|
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;
|
|
17524
|
+
b.p.st.cracked = true;
|
|
17525
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
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
|
+
}
|
|
17531
|
+
};
|
|
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) => {
|
|
17680
|
+
const prior = q.rt.distortion ?? 0;
|
|
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;
|
|
17685
|
+
q.rt.distortion = beta;
|
|
17686
|
+
const box4 = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17687
|
+
const height = box4.max[1] - box4.min[1];
|
|
17688
|
+
const cracks = (d) => d < crackAt ? 0 : Math.min(MAX_SETTLEMENT_CRACKS, 1 + Math.floor(Math.log2(d / crackAt)));
|
|
17689
|
+
const count = Math.max(1, cracks(beta) - cracks(prior));
|
|
17690
|
+
const axis = [0, 0, 0];
|
|
17691
|
+
axis[q.thin] = 1;
|
|
17692
|
+
const normal = rotateVec(quat.mul(o.st.rotation, q.q), axis);
|
|
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];
|
|
17700
|
+
for (let c = 0; c < count; c++) {
|
|
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 });
|
|
17706
|
+
}
|
|
17707
|
+
if (beta >= damageAt && prior < damageAt) {
|
|
17708
|
+
q.st.hp = Math.max(1, q.st.hp - q.st.maxHp * groundCfg.distortionDamage);
|
|
17709
|
+
markDamaged(q);
|
|
17710
|
+
}
|
|
17711
|
+
};
|
|
17712
|
+
const crackOver = (o, b, fp, src) => {
|
|
17713
|
+
const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
|
|
17714
|
+
const drops = fp.slices.map((slice) => slice.drop);
|
|
17715
|
+
for (const j of o.byPart.get(b.p.spec.id) ?? []) {
|
|
17716
|
+
if (j.st.open) continue;
|
|
17717
|
+
const qi = j.ia === b.i ? j.ib : j.ia;
|
|
17718
|
+
const q = o.parts[qi];
|
|
17719
|
+
if (isLost(q) || isTerrain(q) || o.collapsed.has(q.spec.id) || !isSlender(q.spec, q.mat)) continue;
|
|
17720
|
+
if (restsOn(o, j, qi) !== b.i) {
|
|
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);
|
|
17726
|
+
continue;
|
|
17727
|
+
}
|
|
17728
|
+
const over = aabbOf(q.spec.shape, q.pos, q.q);
|
|
17729
|
+
const k0 = clamp2(Math.floor((over.min[fp.long] - box4.min[fp.long]) / fp.step), 0, drops.length - 1);
|
|
17730
|
+
const k1 = clamp2(Math.ceil((over.max[fp.long] - box4.min[fp.long]) / fp.step), k0 + 1, drops.length);
|
|
17731
|
+
const { value, at: at2, down } = distortionOf(relativeToChord(drops.slice(k0, k1)), fp.step);
|
|
17732
|
+
const point = [(over.min[0] + over.max[0]) / 2, over.min[1], (over.min[2] + over.max[2]) / 2];
|
|
17733
|
+
point[fp.long] = box4.min[fp.long] + (k0 + at2 + 0.5) * fp.step;
|
|
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;
|
|
17765
|
+
}
|
|
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);
|
|
17768
|
+
const loseGround = (o, b, opened) => {
|
|
17769
|
+
if (b.p.anchored) {
|
|
17770
|
+
b.p.anchored = false;
|
|
17771
|
+
o.unanchored.add(b.p.spec.id);
|
|
17772
|
+
}
|
|
17773
|
+
for (const j of b.ground) {
|
|
17774
|
+
if (j.st.open) continue;
|
|
17775
|
+
j.st.open = true;
|
|
17776
|
+
j.st.hp = 0;
|
|
17777
|
+
j.st.openedBy = "break";
|
|
17778
|
+
opened.push(j);
|
|
17779
|
+
}
|
|
17780
|
+
};
|
|
17781
|
+
const undermine = (o, loss) => {
|
|
17782
|
+
if (!o.hasStructure || !o.anyAnchor || o.st.soil?.status === "toppled") return;
|
|
17783
|
+
const src = loss.source ?? "ground";
|
|
17784
|
+
const opened = [];
|
|
17785
|
+
const settled = [];
|
|
17786
|
+
let lost = false;
|
|
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
|
+
}
|
|
17806
|
+
const before = b.p.st.subsidence ?? 0;
|
|
17807
|
+
const drop = Math.max(before, fp.drop);
|
|
17808
|
+
const peak = () => Math.max(0, ...b.p.st.settlement?.drop ?? []);
|
|
17809
|
+
const peakBefore = peak();
|
|
17810
|
+
if (bearing.status === "unsupported") {
|
|
17811
|
+
loseGround(o, b, opened);
|
|
17812
|
+
lost = true;
|
|
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;
|
|
17821
|
+
b.p.st.subsidence = drop;
|
|
17822
|
+
emit({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing.status });
|
|
17823
|
+
}
|
|
17824
|
+
for (const { b, fp } of settled) crackOver(o, b, fp, src);
|
|
17825
|
+
o.active = true;
|
|
17826
|
+
if (!lost) return;
|
|
17827
|
+
solveStructure(o);
|
|
17828
|
+
recomputeGroups(o);
|
|
17829
|
+
detachEvents(o, opened, "break", src);
|
|
17830
|
+
collapseCheck(o, src);
|
|
17831
|
+
};
|
|
17832
|
+
const applyGroundLosses = () => {
|
|
17833
|
+
for (let loss = pendingLosses.shift(); loss; loss = pendingLosses.shift()) {
|
|
17834
|
+
for (const o of [...objects.values()]) if (objects.get(o.id) === o) undermine(o, loss);
|
|
16928
17835
|
}
|
|
16929
17836
|
};
|
|
16930
17837
|
const getObj = (id) => {
|
|
@@ -16957,6 +17864,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16957
17864
|
return r ? { t0: r.t0, t1: r.t1, n: rotateVec(q, r.n0) } : null;
|
|
16958
17865
|
};
|
|
16959
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;
|
|
16960
17868
|
const raySphereMiss = (origin, d, c, r, maxDist) => {
|
|
16961
17869
|
const oc = vec.sub(origin, c);
|
|
16962
17870
|
const b = vec.dot(oc, d);
|
|
@@ -16966,13 +17874,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16966
17874
|
if (disc < 0) return true;
|
|
16967
17875
|
return -b - Math.sqrt(disc) > maxDist;
|
|
16968
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
|
+
};
|
|
16969
17887
|
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false) => {
|
|
16970
17888
|
const d = vec.normalize(dir);
|
|
16971
17889
|
let best = null;
|
|
16972
17890
|
for (const o of objects.values()) {
|
|
16973
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);
|
|
16974
17895
|
for (const p of o.parts) {
|
|
16975
17896
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
17897
|
+
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
16976
17898
|
const r = rayPart(o, p, origin, d);
|
|
16977
17899
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
16978
17900
|
if (p.st.opening && insideOpening(o, p, vec.madd(origin, d, r.t0))) continue;
|
|
@@ -17100,8 +18022,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17100
18022
|
setStage(o, p, 1, {}, src);
|
|
17101
18023
|
return hole;
|
|
17102
18024
|
};
|
|
17103
|
-
const addCrack = (o, p, wp, wn, length, src) => {
|
|
17104
|
-
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 } : {} };
|
|
17105
18027
|
p.st.cracks.push(crack);
|
|
17106
18028
|
if (p.st.cracks.length > 16) p.st.cracks.shift();
|
|
17107
18029
|
markDamaged(p);
|
|
@@ -17228,6 +18150,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17228
18150
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
17229
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 }));
|
|
17230
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
|
+
};
|
|
17231
18159
|
const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
|
|
17232
18160
|
const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false) => {
|
|
17233
18161
|
const { c, q } = partXf(o, p);
|
|
@@ -17258,6 +18186,44 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17258
18186
|
};
|
|
17259
18187
|
});
|
|
17260
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
|
+
};
|
|
17261
18227
|
const worldBars = (o, p, bars) => {
|
|
17262
18228
|
const { c, q } = partXf(o, p);
|
|
17263
18229
|
return bars.map(([a, b]) => [toWorld(c, q, a), toWorld(c, q, b)]);
|
|
@@ -17495,6 +18461,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17495
18461
|
}
|
|
17496
18462
|
const bow = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
|
|
17497
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
|
+
}
|
|
17498
18469
|
emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
|
|
17499
18470
|
};
|
|
17500
18471
|
const openBreach = (o, p, center, total, energy, dir, src) => {
|
|
@@ -17565,6 +18536,33 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17565
18536
|
if (out.length === 0) return false;
|
|
17566
18537
|
return knockOutUnits(o, p, wp, energy, out, src);
|
|
17567
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
|
+
};
|
|
17568
18566
|
const blastPanel = (o, p, point, energy, src) => {
|
|
17569
18567
|
var _a;
|
|
17570
18568
|
if (!p.staged || p.st.stripped || isLost(p) || !p.spec.units || p.spec.units.mortar === p.spec.material || p.spec.reinforcement) return false;
|
|
@@ -17576,12 +18574,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17576
18574
|
if (m === p || !m.spec.reinforcement || isLost(m) || m.spec.shape.kind !== "box") continue;
|
|
17577
18575
|
const mp = toLocal(p.pos, p.q, m.pos);
|
|
17578
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;
|
|
17579
|
-
posts.push(mp[u]);
|
|
18577
|
+
posts.push({ x: mp[u], half: m.dims[u] / 2 });
|
|
17580
18578
|
}
|
|
17581
|
-
let from = -half, to = half;
|
|
17582
|
-
for (const x of posts) {
|
|
17583
|
-
if (x <= lp[u] && x > from)
|
|
17584
|
-
|
|
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
|
+
}
|
|
17585
18589
|
}
|
|
17586
18590
|
if (to - from < 0.2) return false;
|
|
17587
18591
|
const tnt = energy * DEFAULT_BLAST_IMPULSE.tntPerJoule;
|
|
@@ -17603,10 +18607,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17603
18607
|
const grid = gridOf(p);
|
|
17604
18608
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
17605
18609
|
const out = [];
|
|
18610
|
+
const edge = panelEdge(p, { fromFace, toFace }, seedOf2(...Array.from(`${o.id}|${p.spec.id}`, (char) => char.charCodeAt(0) / 1e3), from));
|
|
17606
18611
|
for (let i = 0; i < grid.length; i++) {
|
|
17607
18612
|
const cell = grid[i];
|
|
17608
18613
|
if (worn[i] === -1) continue;
|
|
17609
|
-
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);
|
|
17610
18615
|
}
|
|
17611
18616
|
if (out.length === 0) return false;
|
|
17612
18617
|
for (const i of out) worn[i] = -1;
|
|
@@ -17619,7 +18624,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17619
18624
|
const grid = gridOf(p);
|
|
17620
18625
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
17621
18626
|
for (const i of out) worn[i] = -1;
|
|
17622
|
-
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)));
|
|
17623
18629
|
for (const i of loose) worn[i] = -1;
|
|
17624
18630
|
const blown = out.map((i) => grid[i]), fallen = loose.map((i) => grid[i]);
|
|
17625
18631
|
const volume = (cells2) => cells2.reduce((sum, cell) => sum + cell.size[0] * cell.size[1] * cell.size[2], 0);
|
|
@@ -17630,8 +18636,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17630
18636
|
const chipped = (_b = p.st).chipped ?? (_b.chipped = []);
|
|
17631
18637
|
const tag = `x${chipped.length}_`;
|
|
17632
18638
|
const fragments = [
|
|
17633
|
-
...cellFragments(o, p,
|
|
17634
|
-
...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`)
|
|
17635
18642
|
];
|
|
17636
18643
|
const cells = [...blown, ...fallen];
|
|
17637
18644
|
const holes = localHolesOf(p);
|
|
@@ -17667,7 +18674,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17667
18674
|
const worn = (_a = p.rt).chips ?? (_a.chips = {});
|
|
17668
18675
|
const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
|
|
17669
18676
|
const opened = (cell) => !!op && !!p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius;
|
|
17670
|
-
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])));
|
|
17671
18678
|
if (loose.length === 0) return 0;
|
|
17672
18679
|
for (const i of loose) worn[i] = -1;
|
|
17673
18680
|
const fallen = loose.map((i) => grid[i]);
|
|
@@ -17682,7 +18689,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17682
18689
|
}
|
|
17683
18690
|
}
|
|
17684
18691
|
const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
|
|
17685
|
-
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);
|
|
17686
18693
|
const holes = localHolesOf(p);
|
|
17687
18694
|
p.st.holes = p.st.holes.filter((_, k) => !fallen.some((cell) => marksInBox(cell.center, cell.size, void 0, [holes[k]]).length > 0));
|
|
17688
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]] });
|
|
@@ -18102,14 +19109,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18102
19109
|
}
|
|
18103
19110
|
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);
|
|
18104
19111
|
const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
|
|
18105
|
-
const
|
|
18106
|
-
const
|
|
19112
|
+
const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
|
|
19113
|
+
const member = caged2 && (isMember(p.dims) || dist > MEMBER_CUT_REACH * breachReach);
|
|
19114
|
+
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);
|
|
18107
19115
|
res.damage += dealt;
|
|
18108
19116
|
if (p.bend && flexure.enabled) bendByBlast(o, p, point, energy, radius, reach, src);
|
|
18109
19117
|
if (p.spec.units && p.spec.units.mortar !== p.spec.material) {
|
|
18110
19118
|
blastPanel(o, p, point, energy, src);
|
|
18111
19119
|
if (!isLost(p)) blastUnits(o, p, wp, energy, dist, src);
|
|
18112
|
-
} else if (
|
|
19120
|
+
} else if (member) blastUnits(o, p, wp, energy, dist, src);
|
|
18113
19121
|
else if (dist <= breachReach) addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
|
|
18114
19122
|
return reach;
|
|
18115
19123
|
};
|
|
@@ -18938,18 +19946,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18938
19946
|
blastProbe.partsNear = 0;
|
|
18939
19947
|
return withCollapses(run(() => blastWorld(point, energy, radius, source, blast)));
|
|
18940
19948
|
},
|
|
19949
|
+
groundLoss(loss) {
|
|
19950
|
+
if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
|
|
19951
|
+
pendingLosses.push({ ...loss });
|
|
19952
|
+
},
|
|
18941
19953
|
raycast(origin, direction, maxDistance = Infinity) {
|
|
18942
19954
|
const r = raycastInternal(origin, direction, maxDistance, void 0, false, true);
|
|
18943
19955
|
return r ? { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance } : null;
|
|
18944
19956
|
},
|
|
18945
19957
|
sweepBox(box4, direction, distance2, options2 = {}) {
|
|
18946
19958
|
const d = vec.normalize(direction);
|
|
18947
|
-
const
|
|
18948
|
-
const
|
|
18949
|
-
|
|
19959
|
+
const ignoredIds = options2.ignore === void 0 ? [] : typeof options2.ignore === "string" ? [options2.ignore] : options2.ignore;
|
|
19960
|
+
const ignore = /* @__PURE__ */ new Set();
|
|
19961
|
+
for (const id of ignoredIds) {
|
|
19962
|
+
const ignored = objects.get(id);
|
|
19963
|
+
const hosted = ignored ? void 0 : impls.get(id);
|
|
19964
|
+
if (ignored) for (const p of ignored.parts) ignore.add(`${ignored.id}\0${p.spec.id}`);
|
|
19965
|
+
else if (hosted) for (const p of hosted.impl.describe().parts) ignore.add(`${hosted.impl.id}\0${p.id}`);
|
|
19966
|
+
}
|
|
18950
19967
|
let best = null;
|
|
18951
19968
|
for (const origin of sweepOrigins(box4, d, options2.spacing ?? 0.2)) {
|
|
18952
|
-
const r = raycastInternal(origin, d, distance2 + SWEEP_BACK, ignore);
|
|
19969
|
+
const r = raycastInternal(origin, d, distance2 + SWEEP_BACK, ignore.size > 0 ? ignore : void 0);
|
|
18953
19970
|
if (!r || best && r.distance >= best.distance) continue;
|
|
18954
19971
|
best = { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: Math.max(0, r.distance - SWEEP_BACK) };
|
|
18955
19972
|
}
|
|
@@ -19140,6 +20157,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19140
20157
|
if (!(dt > 0)) return [];
|
|
19141
20158
|
return run(() => {
|
|
19142
20159
|
time += dt;
|
|
20160
|
+
applyGroundLosses();
|
|
19143
20161
|
const sources = [];
|
|
19144
20162
|
for (const o of [...objects.values()]) if (o.active) stepObject(o, dt, sources);
|
|
19145
20163
|
for (const o of [...objects.values()]) if (o.soil && objects.get(o.id) === o) stepSoil(o, dt);
|
|
@@ -19186,7 +20204,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19186
20204
|
rng: rng3.state(),
|
|
19187
20205
|
counter,
|
|
19188
20206
|
objects: [...objects.values()].map((o) => {
|
|
19189
|
-
const runtime = { parts: {}, joints: {}, collapsed: [...o.collapsed], ...o.soil?.sets.size ? { soil: Object.fromEntries(o.soil.sets) } : {}, ...o.wind ? { wind: [o.wind.dyn.x, o.wind.dyn.v, o.wind.dyn.y, o.wind.dyn.w, o.wind.dyn.peak] } : {} };
|
|
20207
|
+
const runtime = { parts: {}, joints: {}, collapsed: [...o.collapsed], ...o.unanchored.size ? { unanchored: [...o.unanchored] } : {}, ...o.soil?.sets.size ? { soil: Object.fromEntries(o.soil.sets) } : {}, ...o.wind ? { wind: [o.wind.dyn.x, o.wind.dyn.v, o.wind.dyn.y, o.wind.dyn.w, o.wind.dyn.peak] } : {} };
|
|
19190
20208
|
for (const p of o.parts) runtime.parts[p.spec.id] = clone(p.rt);
|
|
19191
20209
|
for (const j of o.joints) runtime.joints[j.spec.id] = j.step;
|
|
19192
20210
|
return { id: o.id, spec: clone(o.spec), state: clone(o.st), runtime };
|
|
@@ -19208,6 +20226,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19208
20226
|
),
|
|
19209
20227
|
joints: new Map(state.joints.map((st) => [st.id, { st, step: e.runtime?.joints[st.id] ?? 0 }])),
|
|
19210
20228
|
collapsed: e.runtime?.collapsed,
|
|
20229
|
+
...e.runtime?.unanchored ? { unanchored: e.runtime.unanchored } : {},
|
|
19211
20230
|
...e.runtime?.wind ? { wind: e.runtime.wind } : {}
|
|
19212
20231
|
};
|
|
19213
20232
|
let pos = state.position, rot = state.rotation;
|
|
@@ -20362,7 +21381,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20362
21381
|
const alongU = wall.aabb[2] - wall.aabb[0] >= wall.aabb[3] - wall.aabb[1];
|
|
20363
21382
|
const from = alongU ? wall.aabb[0] : wall.aabb[1];
|
|
20364
21383
|
const to = alongU ? wall.aabb[2] : wall.aabb[3];
|
|
20365
|
-
const
|
|
21384
|
+
const cross2 = alongU ? [wall.aabb[1], wall.aabb[3]] : [wall.aabb[0], wall.aabb[2]];
|
|
20366
21385
|
const rows = Math.max(1, Math.round((wall.y1 - wall.y0) / spec.rowHeight));
|
|
20367
21386
|
const rowHeight = (wall.y1 - wall.y0) / rows;
|
|
20368
21387
|
const cells = [];
|
|
@@ -20372,7 +21391,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20372
21391
|
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 });
|
|
20373
21392
|
}
|
|
20374
21393
|
const total = cells.reduce((sum, cell) => sum + (cell.to - cell.from) * (cell.y1 - cell.y0), 0);
|
|
20375
|
-
const box22 = (cell) => alongU ? [cell.from,
|
|
21394
|
+
const box22 = (cell) => alongU ? [cell.from, cross2[0], cell.to, cross2[1]] : [cross2[0], cell.from, cross2[1], cell.to];
|
|
20376
21395
|
const pieces = cells.map((cell, index) => ({
|
|
20377
21396
|
id: `${wall.id}_${spec.unitLength ? "u" : "log"}${cell.row}_${index}`,
|
|
20378
21397
|
role: wall.role,
|
|
@@ -20570,7 +21589,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20570
21589
|
}
|
|
20571
21590
|
return spec;
|
|
20572
21591
|
};
|
|
20573
|
-
var MEMBER_CAGE = { spacing: 0.1, diameter:
|
|
21592
|
+
var MEMBER_CAGE = { spacing: 0.1, diameter: 0.01, unit: 0.1 };
|
|
20574
21593
|
var CAGED_ROLES = /* @__PURE__ */ new Set(["beam", "column"]);
|
|
20575
21594
|
var CAGE_COVER = 0.03;
|
|
20576
21595
|
var CAGE_BUCKLING_SHARE = 0.5;
|
|
@@ -22505,7 +23524,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22505
23524
|
}
|
|
22506
23525
|
var residentialTower = residentialTowerTemplate();
|
|
22507
23526
|
|
|
22508
|
-
// ../game-floorplan-three/dist/chunk-
|
|
23527
|
+
// ../game-floorplan-three/dist/chunk-EWU252NT.js
|
|
22509
23528
|
var __defProp3 = Object.defineProperty;
|
|
22510
23529
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
22511
23530
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -28901,7 +29920,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28901
29920
|
if (!pc || pc.unit) return sp;
|
|
28902
29921
|
if (pc.role !== "wall" && pc.role !== "partition") {
|
|
28903
29922
|
const def = getAssembly(pc.assembly || (pc.material === "concrete" && ["slab", "beam", "column", "stair"].includes(pc.role) ? "reinforced_concrete" : ""));
|
|
28904
|
-
const
|
|
29923
|
+
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;
|
|
29924
|
+
const cage = bars ? pc.role === "column" && sp.shape.kind === "box" ? { ...bars, residualCapacity: cageResidualCapacity(sp.shape.size, bars, sp.structure?.capacity) } : { ...bars } : null;
|
|
28905
29925
|
const out = cage && !sp.reinforcement ? { ...sp, reinforcement: cage } : sp;
|
|
28906
29926
|
if (out.reinforcement && !out.units && pc.material === "concrete" && (pc.role === "beam" || pc.role === "column") && sp.shape.kind === "box") {
|
|
28907
29927
|
return { ...out, units: { size: [MEMBER_CAGE.unit, MEMBER_CAGE.unit, Math.min(...sp.shape.size)], bond: "stack", mortar: "concrete" } };
|
|
@@ -29107,6 +30127,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29107
30127
|
toHouse.value.copy(house.matrixWorld).invert().multiply(mesh2.matrixWorld);
|
|
29108
30128
|
return mesh2;
|
|
29109
30129
|
}
|
|
30130
|
+
const withMask = (material, mask) => {
|
|
30131
|
+
material.userData.breachMask = mask;
|
|
30132
|
+
return material;
|
|
30133
|
+
};
|
|
29110
30134
|
function unitsMaterial(core) {
|
|
29111
30135
|
const material = new THREE.MeshLambertMaterial({ color: 16777215, side: THREE.DoubleSide });
|
|
29112
30136
|
material.onBeforeCompile = (sh) => {
|
|
@@ -29191,13 +30215,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29191
30215
|
if (opening) discs.push({ s: along(opening.center), y: opening.center[1], r: opening.radius });
|
|
29192
30216
|
for (const k of spalls) flakes.push({ s: along(k.center), y: k.center[1], r: k.radius });
|
|
29193
30217
|
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 }));
|
|
29194
|
-
const gone = (c) =>
|
|
30218
|
+
const gone = (c) => {
|
|
30219
|
+
const over = boxes.filter((k) => k.s1 > c.a && k.s0 < c.b && k.y1 > c.y0 && k.y0 < c.y1);
|
|
30220
|
+
const share = covered(c, over);
|
|
30221
|
+
if (share >= 0.9) return true;
|
|
30222
|
+
const s = (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2;
|
|
30223
|
+
return share >= 0.5 && over.some((k) => s >= k.s0 && s <= k.s1 && y >= k.y0 && y <= k.y1);
|
|
30224
|
+
};
|
|
30225
|
+
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;
|
|
29195
30226
|
const kept = [];
|
|
29196
|
-
for (const c of all) (
|
|
30227
|
+
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
29197
30228
|
for (const c of kept) shown.push({ c, part, units: units2, thick, mid });
|
|
29198
|
-
for (const
|
|
29199
|
-
if (holes.some((h) =>
|
|
29200
|
-
|
|
30229
|
+
for (const box4 of boxes) {
|
|
30230
|
+
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;
|
|
30231
|
+
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 };
|
|
30232
|
+
if (!k) continue;
|
|
30233
|
+
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 });
|
|
29201
30234
|
}
|
|
29202
30235
|
}
|
|
29203
30236
|
const reach = SPALL_MIN + SPALL_RAGGED;
|
|
@@ -29226,6 +30259,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29226
30259
|
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));
|
|
29227
30260
|
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));
|
|
29228
30261
|
}
|
|
30262
|
+
for (const q of pillars) {
|
|
30263
|
+
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));
|
|
30264
|
+
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));
|
|
30265
|
+
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);
|
|
30266
|
+
}
|
|
29229
30267
|
mask.texture.needsUpdate = true;
|
|
29230
30268
|
core.texture.needsUpdate = true;
|
|
29231
30269
|
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);
|
|
@@ -29292,7 +30330,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29292
30330
|
items,
|
|
29293
30331
|
mask,
|
|
29294
30332
|
core,
|
|
29295
|
-
unitMaterial: unitsMaterial(core),
|
|
30333
|
+
unitMaterial: withMask(unitsMaterial(core), mask),
|
|
29296
30334
|
shells: [],
|
|
29297
30335
|
saved: null,
|
|
29298
30336
|
units: null,
|