@adatechnology/game-items-three 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +310 -66
- package/dist/index.global.js.map +1 -1
- package/package.json +9 -9
package/dist/index.global.js
CHANGED
|
@@ -16109,6 +16109,58 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16109
16109
|
if (ductility >= 0.3) return 1;
|
|
16110
16110
|
return (1 + 4 * (0.3 - ductility) / 0.3) * Math.min(25, Math.max(1, (0.02 / Math.max(thickness, 1e-4)) ** 2));
|
|
16111
16111
|
};
|
|
16112
|
+
var SWEEP_BROAD_SLACK = 1e-3;
|
|
16113
|
+
var sweptBounds = (origins, direction, length) => {
|
|
16114
|
+
if (origins.length === 0 || !Number.isFinite(length)) return null;
|
|
16115
|
+
const min = [Infinity, Infinity, Infinity];
|
|
16116
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
16117
|
+
for (const origin of origins) {
|
|
16118
|
+
for (let k = 0; k < 3; k++) {
|
|
16119
|
+
const end = origin[k] + direction[k] * length;
|
|
16120
|
+
min[k] = Math.min(min[k], origin[k], end);
|
|
16121
|
+
max[k] = Math.max(max[k], origin[k], end);
|
|
16122
|
+
}
|
|
16123
|
+
}
|
|
16124
|
+
for (let k = 0; k < 3; k++) {
|
|
16125
|
+
if (!Number.isFinite(min[k]) || !Number.isFinite(max[k])) return null;
|
|
16126
|
+
min[k] -= SWEEP_BROAD_SLACK;
|
|
16127
|
+
max[k] += SWEEP_BROAD_SLACK;
|
|
16128
|
+
}
|
|
16129
|
+
return { min, max };
|
|
16130
|
+
};
|
|
16131
|
+
var sphereTouchesBounds = (bounds, centre, radius) => {
|
|
16132
|
+
let distanceSquared = 0;
|
|
16133
|
+
for (let k = 0; k < 3; k++) {
|
|
16134
|
+
const below = bounds.min[k] - centre[k];
|
|
16135
|
+
const above = centre[k] - bounds.max[k];
|
|
16136
|
+
if (below > 0) distanceSquared += below * below;
|
|
16137
|
+
else if (above > 0) distanceSquared += above * above;
|
|
16138
|
+
}
|
|
16139
|
+
return distanceSquared <= radius * radius;
|
|
16140
|
+
};
|
|
16141
|
+
var boundsTouch = (a, b) => a.min[0] <= b.max[0] && a.max[0] >= b.min[0] && a.min[1] <= b.max[1] && a.max[1] >= b.min[1] && a.min[2] <= b.max[2] && a.max[2] >= b.min[2];
|
|
16142
|
+
var boundsInFrame = (bounds, position, rotation) => {
|
|
16143
|
+
const inverse = quat.conjugate(rotation);
|
|
16144
|
+
const centre = [(bounds.min[0] + bounds.max[0]) / 2 - position[0], (bounds.min[1] + bounds.max[1]) / 2 - position[1], (bounds.min[2] + bounds.max[2]) / 2 - position[2]];
|
|
16145
|
+
const size = [bounds.max[0] - bounds.min[0], bounds.max[1] - bounds.min[1], bounds.max[2] - bounds.min[2]];
|
|
16146
|
+
return aabbOf({ kind: "box", size }, rotateVec(inverse, centre), inverse);
|
|
16147
|
+
};
|
|
16148
|
+
var rayMissesBounds = (origin, direction, maxDistance, bounds) => {
|
|
16149
|
+
let near = 0;
|
|
16150
|
+
let far = maxDistance;
|
|
16151
|
+
for (let k = 0; k < 3; k++) {
|
|
16152
|
+
if (direction[k] === 0) {
|
|
16153
|
+
if (origin[k] < bounds.min[k] || origin[k] > bounds.max[k]) return true;
|
|
16154
|
+
continue;
|
|
16155
|
+
}
|
|
16156
|
+
const a = (bounds.min[k] - origin[k]) / direction[k];
|
|
16157
|
+
const b = (bounds.max[k] - origin[k]) / direction[k];
|
|
16158
|
+
near = Math.max(near, Math.min(a, b));
|
|
16159
|
+
far = Math.min(far, Math.max(a, b));
|
|
16160
|
+
if (near > far) return true;
|
|
16161
|
+
}
|
|
16162
|
+
return false;
|
|
16163
|
+
};
|
|
16112
16164
|
var THIN_SHEET_DISHING = 5e-3;
|
|
16113
16165
|
var SWEEP_BACK = 0.01;
|
|
16114
16166
|
function sweepOrigins(box4, d, spacing) {
|
|
@@ -16161,9 +16213,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16161
16213
|
var PANEL_POINTS_LOADED = 4;
|
|
16162
16214
|
var MEMBER_BAND = 0.1;
|
|
16163
16215
|
var MEMBER_CRATER_CALIBRES = 3.4;
|
|
16164
|
-
var MEMBER_BARED_MAX = 24;
|
|
16165
16216
|
var MEMBER_CUT_LOSS = 0.9;
|
|
16166
|
-
var MEMBER_UNIT_LOSS = 0.
|
|
16217
|
+
var MEMBER_UNIT_LOSS = 0.12;
|
|
16218
|
+
var JOINT_OPEN_SHARE = 0.6;
|
|
16167
16219
|
var BLAST_EDGE_WEAR = 0.6;
|
|
16168
16220
|
var RESIDUAL_CAPACITY = 0.15;
|
|
16169
16221
|
var SEVER_BAND = 0.1;
|
|
@@ -16293,6 +16345,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16293
16345
|
const ignitionRules = resolveIgnitionRules(options.ignition);
|
|
16294
16346
|
const breachBlastFactor = options.breach?.blastFactor ?? BREACH_BLAST_FACTOR;
|
|
16295
16347
|
const chipEnergy = options.breach?.chipEnergy ?? CHIP_ENERGY;
|
|
16348
|
+
const broadPhase = options.broadPhase ?? true;
|
|
16296
16349
|
const chainLinkCap = options.chainLinksPerUpdate !== void 0 && options.chainLinksPerUpdate >= 1 ? Math.floor(options.chainLinksPerUpdate) : Infinity;
|
|
16297
16350
|
const rng3 = createRng(options.seed ?? 1);
|
|
16298
16351
|
const rnd = () => rng3.next();
|
|
@@ -16398,6 +16451,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16398
16451
|
unsup: [],
|
|
16399
16452
|
anyAnchor: false,
|
|
16400
16453
|
order: ++orderCounter,
|
|
16454
|
+
loose: carry?.loose ?? false,
|
|
16401
16455
|
base: { pos: [pos[0], pos[1], pos[2]], rot: [rot[0], rot[1], rot[2], rot[3]] }
|
|
16402
16456
|
};
|
|
16403
16457
|
for (const ps of spec.parts) {
|
|
@@ -17885,28 +17939,109 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17885
17939
|
if (disc < 0) return true;
|
|
17886
17940
|
return -b - Math.sqrt(disc) > maxDist;
|
|
17887
17941
|
};
|
|
17888
|
-
const
|
|
17942
|
+
const worldCentres = /* @__PURE__ */ new WeakMap();
|
|
17943
|
+
const worldCentreOf = (o) => {
|
|
17944
|
+
const p = o.st.position, q = o.st.rotation, c = o.bc;
|
|
17945
|
+
const known = worldCentres.get(o);
|
|
17946
|
+
if (known) {
|
|
17947
|
+
const k = known.key;
|
|
17948
|
+
if (k[0] === p[0] && k[1] === p[1] && k[2] === p[2] && k[3] === q[0] && k[4] === q[1] && k[5] === q[2] && k[6] === q[3] && k[7] === c[0] && k[8] === c[1] && k[9] === c[2]) return known.centre;
|
|
17949
|
+
}
|
|
17950
|
+
const centre = toWorld(p, q, c);
|
|
17951
|
+
worldCentres.set(o, { key: [p[0], p[1], p[2], q[0], q[1], q[2], q[3], c[0], c[1], c[2]], centre });
|
|
17952
|
+
return centre;
|
|
17953
|
+
};
|
|
17954
|
+
const implPartBox = (im, ps) => {
|
|
17955
|
+
const ov = im.poses.get(ps.id);
|
|
17956
|
+
return aabbOf(ps.shape, toWorld(im.position, im.rotation, ov?.pos ?? ps.position), quat.mul(im.rotation, ov?.q ?? quatFromEuler(...ps.rotation ?? [0, 0, 0])));
|
|
17957
|
+
};
|
|
17958
|
+
const implBounds = /* @__PURE__ */ new WeakMap();
|
|
17959
|
+
const implBoundsOf = (im) => {
|
|
17960
|
+
const spec = im.impl.describe();
|
|
17961
|
+
const p = im.position, q = im.rotation;
|
|
17962
|
+
const known = implBounds.get(im);
|
|
17963
|
+
if (known && known.spec === spec) {
|
|
17964
|
+
const k = known.key;
|
|
17965
|
+
if (k[0] === p[0] && k[1] === p[1] && k[2] === p[2] && k[3] === q[0] && k[4] === q[1] && k[5] === q[2] && k[6] === q[3] && k[7] === im.posesVersion) return known.bounds;
|
|
17966
|
+
}
|
|
17967
|
+
const min = [Infinity, Infinity, Infinity];
|
|
17968
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
17969
|
+
for (const ps of spec.parts) {
|
|
17970
|
+
const box4 = implPartBox(im, ps);
|
|
17971
|
+
for (let k = 0; k < 3; k++) {
|
|
17972
|
+
min[k] = Math.min(min[k], box4.min[k] - SWEEP_BROAD_SLACK);
|
|
17973
|
+
max[k] = Math.max(max[k], box4.max[k] + SWEEP_BROAD_SLACK);
|
|
17974
|
+
}
|
|
17975
|
+
}
|
|
17976
|
+
const bounds = { min, max };
|
|
17977
|
+
implBounds.set(im, { spec, key: [p[0], p[1], p[2], q[0], q[1], q[2], q[3], im.posesVersion], bounds });
|
|
17978
|
+
return bounds;
|
|
17979
|
+
};
|
|
17980
|
+
const sweepScope = (origins, d, length, ignore) => {
|
|
17981
|
+
const bounds = sweptBounds(origins, d, length);
|
|
17982
|
+
if (!bounds) return null;
|
|
17983
|
+
const scoped = [];
|
|
17984
|
+
const parts = /* @__PURE__ */ new Map();
|
|
17985
|
+
for (const o of objects.values()) {
|
|
17986
|
+
if (!sphereTouchesBounds(bounds, worldCentreOf(o), o.br + SWEEP_BROAD_SLACK)) continue;
|
|
17987
|
+
const local = boundsInFrame(bounds, o.st.position, o.st.rotation);
|
|
17988
|
+
const near = o.parts.filter((p) => !isLost(p) && !ignore.has(`${o.id}\0${p.spec.id}`) && sphereTouchesBounds(local, p.pos, p.bound + PART_BOUND_SLACK + SWEEP_BROAD_SLACK));
|
|
17989
|
+
if (near.length === 0) continue;
|
|
17990
|
+
scoped.push(o);
|
|
17991
|
+
parts.set(o, near);
|
|
17992
|
+
}
|
|
17993
|
+
const scopedImpls = [];
|
|
17994
|
+
const implParts2 = /* @__PURE__ */ new Map();
|
|
17995
|
+
for (const im of impls.values()) {
|
|
17996
|
+
if (!boundsTouch(bounds, implBoundsOf(im))) continue;
|
|
17997
|
+
const near = im.impl.describe().parts.filter((ps) => !ignore.has(`${im.impl.id}\0${ps.id}`) && boundsTouch(bounds, implPartBox(im, ps)));
|
|
17998
|
+
if (near.length === 0) continue;
|
|
17999
|
+
scopedImpls.push(im);
|
|
18000
|
+
implParts2.set(im, near);
|
|
18001
|
+
}
|
|
18002
|
+
return { objects: scoped, parts, impls: scopedImpls, implParts: implParts2 };
|
|
18003
|
+
};
|
|
18004
|
+
let sweepCounts = null;
|
|
18005
|
+
let lastSweep = { objectVisits: 0, partVisits: 0, shapeTests: 0, shapeTested: [] };
|
|
18006
|
+
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope) => {
|
|
17889
18007
|
const d = vec.normalize(dir);
|
|
18008
|
+
const minRadius = skip.minObjectRadius ?? 0;
|
|
17890
18009
|
let best = null;
|
|
17891
|
-
|
|
17892
|
-
|
|
18010
|
+
const counts = sweepCounts;
|
|
18011
|
+
for (const o of scope ? scope.objects : objects.values()) {
|
|
18012
|
+
if (counts) counts.objectVisits++;
|
|
18013
|
+
if (skip.skipLoose && o.loose || o.br < minRadius) continue;
|
|
18014
|
+
if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
|
|
17893
18015
|
const qi = quat.conjugate(o.st.rotation);
|
|
17894
18016
|
const lo = rotateVec(qi, vec.sub(origin, o.st.position));
|
|
17895
18017
|
const ld = rotateVec(qi, d);
|
|
17896
|
-
for (const p of o.parts) {
|
|
18018
|
+
for (const p of scope?.parts.get(o) ?? o.parts) {
|
|
18019
|
+
if (counts) counts.partVisits++;
|
|
17897
18020
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
17898
18021
|
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
18022
|
+
if (counts) {
|
|
18023
|
+
counts.shapeTests++;
|
|
18024
|
+
counts.shapeTested.add(o.id);
|
|
18025
|
+
}
|
|
17899
18026
|
const r = rayPart(o, p, origin, d);
|
|
17900
18027
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
17901
|
-
if (p.st.opening && insideOpening(o, p, vec.madd(origin, d, r.t0))) continue;
|
|
18028
|
+
if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
18029
|
+
if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
17902
18030
|
if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
17903
18031
|
if (!best || r.t0 < best.distance) best = { object: o.id, part: p.spec.id, point: vec.madd(origin, d, r.t0), normal: r.n, distance: r.t0, pathLen: r.t1 - r.t0 };
|
|
17904
18032
|
}
|
|
17905
18033
|
}
|
|
17906
|
-
for (const im of worldOnly ? [] : impls.values()) {
|
|
18034
|
+
for (const im of worldOnly ? [] : scope ? scope.impls : impls.values()) {
|
|
18035
|
+
if (counts) counts.objectVisits++;
|
|
18036
|
+
if (!scope && broadPhase && rayMissesBounds(origin, d, maxDist, implBoundsOf(im))) continue;
|
|
17907
18037
|
let boxHit = null;
|
|
17908
|
-
for (const ps of im.impl.describe().parts) {
|
|
18038
|
+
for (const ps of scope?.implParts.get(im) ?? im.impl.describe().parts) {
|
|
18039
|
+
if (counts) counts.partVisits++;
|
|
17909
18040
|
if (ignore?.has(`${im.impl.id}\0${ps.id}`)) continue;
|
|
18041
|
+
if (counts) {
|
|
18042
|
+
counts.shapeTests++;
|
|
18043
|
+
counts.shapeTested.add(im.impl.id);
|
|
18044
|
+
}
|
|
17910
18045
|
const ov = im.poses.get(ps.id);
|
|
17911
18046
|
const r = rayPartRaw(im.position, im.rotation, ps, ov?.q ?? quatFromEuler(...ps.rotation ?? [0, 0, 0]), origin, d, ov?.pos);
|
|
17912
18047
|
if (!r || r.t1 < 0 || r.t0 > maxDist) continue;
|
|
@@ -18094,7 +18229,28 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18094
18229
|
for (let k = 0; k < 3; k++) len = Math.max(len, Math.min(A.max[k], B.max[k]) - Math.max(A.min[k], B.min[k]));
|
|
18095
18230
|
return len;
|
|
18096
18231
|
};
|
|
18097
|
-
const
|
|
18232
|
+
const onFoundation = (o, j) => o.parts[j.ia].spec.structure?.role === "foundation" || o.parts[j.ib].spec.structure?.role === "foundation";
|
|
18233
|
+
const wornStretches = /* @__PURE__ */ new WeakMap();
|
|
18234
|
+
const wornShare = (o, j, point, span) => {
|
|
18235
|
+
const A = partWorldAabb(o, o.parts[j.ia]), B = partWorldAabb(o, o.parts[j.ib]);
|
|
18236
|
+
const lo = [0, 1, 2].map((k) => Math.max(A.min[k], B.min[k])), hi = [0, 1, 2].map((k) => Math.min(A.max[k], B.max[k]));
|
|
18237
|
+
const axis = [0, 1, 2].reduce((best, k) => hi[k] - lo[k] > hi[best] - lo[best] ? k : best, 0);
|
|
18238
|
+
const length = hi[axis] - lo[axis];
|
|
18239
|
+
if (length <= span) return 1;
|
|
18240
|
+
const at2 = clamp2(point[axis], lo[axis], hi[axis]);
|
|
18241
|
+
const from = Math.max(lo[axis], at2 - span / 2), to = Math.min(hi[axis], at2 + span / 2);
|
|
18242
|
+
const worn = [...wornStretches.get(j) ?? [], [from, to]].sort((x, y) => x[0] - y[0]);
|
|
18243
|
+
wornStretches.set(j, worn);
|
|
18244
|
+
let covered = 0, end = -Infinity;
|
|
18245
|
+
for (const [a, b] of worn) {
|
|
18246
|
+
covered += Math.max(0, b - Math.max(a, end));
|
|
18247
|
+
end = Math.max(end, b);
|
|
18248
|
+
}
|
|
18249
|
+
return covered / length;
|
|
18250
|
+
};
|
|
18251
|
+
const isTrim = (p) => (p.spec.structure?.role ?? "none") === "none";
|
|
18252
|
+
const fixesTrim = (o, j) => isTrim(o.parts[j.ia]) !== isTrim(o.parts[j.ib]);
|
|
18253
|
+
const wearJoints = (o, p, amount, near, radius = 0.06, src, split = false, span, blast) => {
|
|
18098
18254
|
if (amount <= 0) return;
|
|
18099
18255
|
const mine = (o.byPart.get(p.spec.id) ?? []).filter((j) => !j.st.open);
|
|
18100
18256
|
if (split && mine.length) amount /= mine.length;
|
|
@@ -18102,7 +18258,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18102
18258
|
if (j.st.open) continue;
|
|
18103
18259
|
if (j.spec.kind === "rebar" && (isReinforced(o.parts[j.ia].spec) || isReinforced(o.parts[j.ib].spec))) continue;
|
|
18104
18260
|
if (near && jointReach(o, j, near) > Math.max(radius, jointReachLimit(o, j))) continue;
|
|
18261
|
+
if (blast && fixesTrim(o, j) && jointReach(o, j, blast.point) > Math.max(blast.reach, jointReachLimit(o, j))) continue;
|
|
18105
18262
|
j.st.hp -= span === void 0 ? amount : Math.min(amount, j.st.maxHp) * Math.min(1, span / Math.max(jointLength(o, j), 1e-6));
|
|
18263
|
+
if (j.st.hp <= 0 && blast && span !== void 0 && onFoundation(o, j) && wornShare(o, j, blast.point, span) < JOINT_OPEN_SHARE) j.st.hp = Math.min(j.st.maxHp, 1);
|
|
18106
18264
|
if (j.st.hp <= 0) {
|
|
18107
18265
|
j.st.hp = 0;
|
|
18108
18266
|
j.st.open = true;
|
|
@@ -18148,6 +18306,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18148
18306
|
const lc = toLocal(p.pos, p.q, op.center);
|
|
18149
18307
|
return Math.hypot(lp[u] - lc[u], lp[v] - lc[v]) <= op.radius;
|
|
18150
18308
|
};
|
|
18309
|
+
const throughAperture = (p, objectPoint) => {
|
|
18310
|
+
const [u, v] = planeAxes(p.thin);
|
|
18311
|
+
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
18312
|
+
return (p.spec.apertures ?? []).some((ap) => {
|
|
18313
|
+
const du = lp[u] - (ap.offset?.[0] ?? 0);
|
|
18314
|
+
const dv = lp[v] - (ap.offset?.[1] ?? 0);
|
|
18315
|
+
if (Math.abs(du) > ap.size[0] / 2 || Math.abs(dv) > ap.size[1] / 2) return false;
|
|
18316
|
+
if (!ap.bars || ap.bars.spacing <= 0) return true;
|
|
18317
|
+
const along = ap.bars.axis === 0 ? du + ap.size[0] / 2 : dv + ap.size[1] / 2;
|
|
18318
|
+
return Math.abs(along - Math.round(along / ap.bars.spacing) * ap.bars.spacing) > ap.bars.width / 2;
|
|
18319
|
+
});
|
|
18320
|
+
};
|
|
18151
18321
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
18152
18322
|
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 }));
|
|
18153
18323
|
const unitsOf2 = (p) => p.spec.units ?? { size: [p.mat.fragmentSize?.[1] ?? 0.2, p.mat.fragmentSize?.[1] ?? 0.2, p.thickness], bond: "stack" };
|
|
@@ -18268,8 +18438,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18268
18438
|
}
|
|
18269
18439
|
return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
|
|
18270
18440
|
};
|
|
18441
|
+
const wornLocally = (p) => !!p.spec.reinforcement && !!p.spec.units && p.spec.units.mortar === p.spec.material && isMember(p.dims) && p.spec.shape.kind === "box";
|
|
18271
18442
|
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
18272
|
-
var _a, _b, _c
|
|
18443
|
+
var _a, _b, _c;
|
|
18273
18444
|
if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
|
|
18274
18445
|
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
18275
18446
|
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
@@ -18291,24 +18462,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18291
18462
|
worn[band] = after;
|
|
18292
18463
|
markDamaged(p);
|
|
18293
18464
|
const bandCenter = -p.dims[along] / 2 + (band + 0.5) * height;
|
|
18294
|
-
if (h > REBAR_COVER && after < MEMBER_CUT_LOSS) {
|
|
18295
|
-
const bared = (_b = p.rt).bared ?? (_b.bared = []);
|
|
18296
|
-
const center = [lp[0], lp[1], lp[2]];
|
|
18297
|
-
const size = [p.dims[0], p.dims[1], p.dims[2]];
|
|
18298
|
-
for (let a = 0; a < 3; a++) if (Math.abs(ld[a]) < 0.5) size[a] = 2 * r;
|
|
18299
|
-
if (bared.length < MEMBER_BARED_MAX && !bared.some((box4) => box4.center.every((x, a) => Math.abs(x - center[a]) < box4.size[a] / 4))) {
|
|
18300
|
-
bared.push({ center, size });
|
|
18301
|
-
exposeRebar(o, p, src);
|
|
18302
|
-
}
|
|
18303
|
-
}
|
|
18304
18465
|
const grid = gridOf(p);
|
|
18305
|
-
const gone = (
|
|
18466
|
+
const gone = (_b = p.rt).chips ?? (_b.chips = {});
|
|
18306
18467
|
if (before >= MEMBER_CUT_LOSS || after < MEMBER_CUT_LOSS) {
|
|
18307
18468
|
if (h <= REBAR_COVER) return true;
|
|
18308
18469
|
const [u, v] = planeAxes(p.thin);
|
|
18309
18470
|
const hit = grid.findIndex((cell2, i) => gone[i] !== -1 && Math.abs(lp[u] - cell2.center[u]) <= cell2.size[u] / 2 && Math.abs(lp[v] - cell2.center[v]) <= cell2.size[v] / 2);
|
|
18310
18471
|
if (hit < 0) return true;
|
|
18311
|
-
const wear = (
|
|
18472
|
+
const wear = (_c = p.rt).cellWear ?? (_c.cellWear = {});
|
|
18312
18473
|
const cell = grid[hit];
|
|
18313
18474
|
wear[hit] = (wear[hit] ?? 0) + volume;
|
|
18314
18475
|
if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
|
|
@@ -18908,6 +19069,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18908
19069
|
const chained = trigger !== void 0 && chainDelayOf(p.spec, trigger) !== void 0;
|
|
18909
19070
|
if (chained && p.st.hp <= 0 && p.rt.chainDue === void 0) p.st.hp = Math.min(prev, 1);
|
|
18910
19071
|
if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
|
|
19072
|
+
if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
|
|
18911
19073
|
const done = prev - p.st.hp;
|
|
18912
19074
|
if (done > 0) emit({ ...base(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
|
|
18913
19075
|
if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy, cap, src);
|
|
@@ -19117,7 +19279,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19117
19279
|
checkIgnite(o, p, src);
|
|
19118
19280
|
}
|
|
19119
19281
|
}
|
|
19120
|
-
|
|
19282
|
+
const stretch = 2 * BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
|
|
19283
|
+
wearJoints(o, p, Ein * 0.5, void 0, 0, src, false, stretch, { point, reach: stretch });
|
|
19121
19284
|
const amount = Ein * DMG_PER_J * (mat.damageScale?.explosive ?? 1);
|
|
19122
19285
|
if (blastFrontSpeed > 0 && dist > 0 && mat.tags?.includes("glass")) {
|
|
19123
19286
|
frontQueue.push({ o, p, due: time + dist / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
|
|
@@ -19261,7 +19424,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19261
19424
|
const path = Math.min(r.t1, L) - t0;
|
|
19262
19425
|
if (path < shelter.minPath) continue;
|
|
19263
19426
|
const mid = vec.madd(point, d, t0 + path / 2);
|
|
19264
|
-
const opening = p.st.opening && insideOpening(o, p, mid);
|
|
19427
|
+
const opening = p.st.opening && insideOpening(o, p, objLocal(o, mid));
|
|
19265
19428
|
if (opening && was & FLAG_OPEN) continue;
|
|
19266
19429
|
if (p.st.stripped && was & FLAG_OPEN) continue;
|
|
19267
19430
|
const resistance = p.mat.hpPerKg * p.mat.density * path * (p.mat.damageScale?.shelter ?? 1);
|
|
@@ -19830,7 +19993,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19830
19993
|
register(impl, opts = {}) {
|
|
19831
19994
|
const id = opts.id ?? impl.id;
|
|
19832
19995
|
if (taken(id)) throw new Error(`object "${id}" already exists`);
|
|
19833
|
-
impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map() });
|
|
19996
|
+
impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map(), posesVersion: 0 });
|
|
19834
19997
|
return id;
|
|
19835
19998
|
},
|
|
19836
19999
|
setPartPose(objectId, partId, position, rotation) {
|
|
@@ -19839,6 +20002,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19839
20002
|
if (im) {
|
|
19840
20003
|
im.impl.setPartPose?.(partId, position, rotation);
|
|
19841
20004
|
im.poses.set(partId, { pos: [position[0], position[1], position[2]], q });
|
|
20005
|
+
im.posesVersion++;
|
|
19842
20006
|
return;
|
|
19843
20007
|
}
|
|
19844
20008
|
const o = getObj(objectId);
|
|
@@ -19894,7 +20058,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19894
20058
|
const inNew = (pid) => moved.has(pid);
|
|
19895
20059
|
const inOld = (pid) => !moved.has(pid);
|
|
19896
20060
|
const pos = o.st.position, rot = o.st.rotation;
|
|
19897
|
-
const fresh = build(sub(inNew), nid, pos, rot, carryFor(inNew, (a, b) => inNew(a) && inNew(b)));
|
|
20061
|
+
const fresh = build(sub(inNew), nid, pos, rot, { ...carryFor(inNew, (a, b) => inNew(a) && inNew(b)), loose: true });
|
|
19898
20062
|
const restCarry = carryFor(inOld, (a, b) => !(inNew(a) && inNew(b)));
|
|
19899
20063
|
if (o.st.soil) restCarry.soil = o.st.soil;
|
|
19900
20064
|
if (o.soil?.sets.size) restCarry.soilSets = Object.fromEntries(o.soil.sets);
|
|
@@ -19966,8 +20130,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19966
20130
|
if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
|
|
19967
20131
|
pendingLosses.push({ ...loss });
|
|
19968
20132
|
},
|
|
19969
|
-
raycast(origin, direction, maxDistance = Infinity) {
|
|
19970
|
-
const r = raycastInternal(origin, direction, maxDistance, void 0, false, true);
|
|
20133
|
+
raycast(origin, direction, maxDistance = Infinity, options2) {
|
|
20134
|
+
const r = raycastInternal(origin, direction, maxDistance, void 0, false, true, options2);
|
|
19971
20135
|
return r ? { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance } : null;
|
|
19972
20136
|
},
|
|
19973
20137
|
sweepBox(box4, direction, distance2, options2 = {}) {
|
|
@@ -19981,13 +20145,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19981
20145
|
else if (hosted) for (const p of hosted.impl.describe().parts) ignore.add(`${hosted.impl.id}\0${p.id}`);
|
|
19982
20146
|
}
|
|
19983
20147
|
let best = null;
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
20148
|
+
const origins = sweepOrigins(box4, d, options2.spacing ?? 0.2);
|
|
20149
|
+
const length = distance2 + SWEEP_BACK;
|
|
20150
|
+
const scope = broadPhase ? sweepScope(origins, d, length, ignore) ?? void 0 : void 0;
|
|
20151
|
+
const counts = { objectVisits: 0, partVisits: 0, shapeTests: 0, shapeTested: /* @__PURE__ */ new Set() };
|
|
20152
|
+
sweepCounts = counts;
|
|
20153
|
+
try {
|
|
20154
|
+
for (const origin of origins) {
|
|
20155
|
+
const r = raycastInternal(origin, d, length, ignore.size > 0 ? ignore : void 0, false, false, {}, scope);
|
|
20156
|
+
if (!r || best && r.distance >= best.distance) continue;
|
|
20157
|
+
best = { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: Math.max(0, r.distance - SWEEP_BACK) };
|
|
20158
|
+
}
|
|
20159
|
+
} finally {
|
|
20160
|
+
sweepCounts = null;
|
|
20161
|
+
lastSweep = { objectVisits: counts.objectVisits, partVisits: counts.partVisits, shapeTests: counts.shapeTests, shapeTested: [...counts.shapeTested] };
|
|
19988
20162
|
}
|
|
19989
20163
|
return best;
|
|
19990
20164
|
},
|
|
20165
|
+
sweepProbe() {
|
|
20166
|
+
return lastSweep;
|
|
20167
|
+
},
|
|
19991
20168
|
shoot(origin, direction, energy, caliber, source, round3) {
|
|
19992
20169
|
const extras = typeof round3 === "number" ? { piercing: round3 } : round3 ?? {};
|
|
19993
20170
|
return withCollapses(run(withBlow("ballistic", () => {
|
|
@@ -20220,7 +20397,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20220
20397
|
rng: rng3.state(),
|
|
20221
20398
|
counter,
|
|
20222
20399
|
objects: [...objects.values()].map((o) => {
|
|
20223
|
-
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] } : {} };
|
|
20400
|
+
const runtime = { parts: {}, joints: {}, collapsed: [...o.collapsed], ...o.loose ? { loose: true } : {}, ...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] } : {} };
|
|
20224
20401
|
for (const p of o.parts) runtime.parts[p.spec.id] = clone(p.rt);
|
|
20225
20402
|
for (const j of o.joints) runtime.joints[j.spec.id] = j.step;
|
|
20226
20403
|
return { id: o.id, spec: clone(o.spec), state: clone(o.st), runtime };
|
|
@@ -20243,7 +20420,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
20243
20420
|
joints: new Map(state.joints.map((st) => [st.id, { st, step: e.runtime?.joints[st.id] ?? 0 }])),
|
|
20244
20421
|
collapsed: e.runtime?.collapsed,
|
|
20245
20422
|
...e.runtime?.unanchored ? { unanchored: e.runtime.unanchored } : {},
|
|
20246
|
-
...e.runtime?.wind ? { wind: e.runtime.wind } : {}
|
|
20423
|
+
...e.runtime?.wind ? { wind: e.runtime.wind } : {},
|
|
20424
|
+
...e.runtime?.loose ? { loose: true } : {}
|
|
20247
20425
|
};
|
|
20248
20426
|
let pos = state.position, rot = state.rotation;
|
|
20249
20427
|
if (state.soil) {
|
|
@@ -21572,6 +21750,42 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21572
21750
|
}
|
|
21573
21751
|
return { ...next, capacities };
|
|
21574
21752
|
}
|
|
21753
|
+
var planeAxes2 = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
|
|
21754
|
+
function toPartFrame(part, point) {
|
|
21755
|
+
const dx = point[0] - part.position[0];
|
|
21756
|
+
const dz = point[2] - part.position[2];
|
|
21757
|
+
const angle = -(part.rotation?.[1] ?? 0);
|
|
21758
|
+
return [dx * Math.cos(angle) + dz * Math.sin(angle), point[1] - part.position[1], -dx * Math.sin(angle) + dz * Math.cos(angle)];
|
|
21759
|
+
}
|
|
21760
|
+
function wallApertures(part, windows) {
|
|
21761
|
+
if (part.shape.kind !== "box") return [];
|
|
21762
|
+
const size = part.shape.size;
|
|
21763
|
+
const thin = size.indexOf(Math.min(...size));
|
|
21764
|
+
if (thin === 1) return [];
|
|
21765
|
+
const [along] = planeAxes2(thin);
|
|
21766
|
+
const turn = part.rotation?.[1] ?? 0;
|
|
21767
|
+
const alongU = Math.abs(Math.cos(turn)) * size[0] + Math.abs(Math.sin(turn)) * size[2] >= Math.abs(Math.sin(turn)) * size[0] + Math.abs(Math.cos(turn)) * size[2];
|
|
21768
|
+
return windows.map((opening2) => {
|
|
21769
|
+
const middle = (opening2.from + opening2.to) / 2;
|
|
21770
|
+
const centre2 = alongU ? [middle, (opening2.y0 + opening2.y1) / 2, part.position[2]] : [part.position[0], (opening2.y0 + opening2.y1) / 2, middle];
|
|
21771
|
+
const local = toPartFrame(part, centre2);
|
|
21772
|
+
return { size: [opening2.to - opening2.from, opening2.y1 - opening2.y0], offset: [local[along], local[1]] };
|
|
21773
|
+
});
|
|
21774
|
+
}
|
|
21775
|
+
function withWindowApertures(spec, openings) {
|
|
21776
|
+
const byWall = /* @__PURE__ */ new Map();
|
|
21777
|
+
for (const opening2 of openings) if (opening2.kind === "window") byWall.set(opening2.wall, [...byWall.get(opening2.wall) ?? [], opening2]);
|
|
21778
|
+
if (!byWall.size) return spec;
|
|
21779
|
+
return {
|
|
21780
|
+
...spec,
|
|
21781
|
+
parts: spec.parts.map((part) => {
|
|
21782
|
+
const windows = byWall.get(part.id);
|
|
21783
|
+
if (!windows) return part;
|
|
21784
|
+
const apertures = wallApertures(part, windows);
|
|
21785
|
+
return apertures.length ? { ...part, apertures: [...part.apertures ?? [], ...apertures] } : part;
|
|
21786
|
+
})
|
|
21787
|
+
};
|
|
21788
|
+
}
|
|
21575
21789
|
var RAFT_THICKNESS = 0.25;
|
|
21576
21790
|
var PILE_AREA = 9;
|
|
21577
21791
|
var RAFT_MARGIN = 0.15;
|
|
@@ -21670,7 +21884,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21670
21884
|
const infill = new Set(portico && slabOptions ? kept.filter((part) => part.role === "wall").map((part) => part.id) : []);
|
|
21671
21885
|
const beams = new Set(parts.filter((part) => part.role === "beam" && (part.beamKind === "bond_beam" || part.slab !== void 0)).map((part) => part.id));
|
|
21672
21886
|
const joints = supports.filter((s) => present.has(s.part) && present.has(s.on)).map((s) => ({ id: `${s.part}~${s.on}`, a: s.part, b: s.on, kind: s.joint, bears: s.bears === false || beams.has(s.part) && infill.has(s.on) ? false : "a_on_b" }));
|
|
21673
|
-
const
|
|
21887
|
+
const built = { name: options.name ?? "house", parts: specs, joints, tags: ["structure", "house"] };
|
|
21888
|
+
const spec = detail === "coarse" && options.windowApertures !== false ? withWindowApertures(built, structure.openings) : built;
|
|
21674
21889
|
return onSoil(withRebar(spec, structure, options, portico, slabOptions !== void 0), structure, options);
|
|
21675
21890
|
}
|
|
21676
21891
|
function withRebar(spec, structure, options, portico, panelled) {
|
|
@@ -23544,7 +23759,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23544
23759
|
}
|
|
23545
23760
|
var residentialTower = residentialTowerTemplate();
|
|
23546
23761
|
|
|
23547
|
-
// ../game-floorplan-three/dist/chunk-
|
|
23762
|
+
// ../game-floorplan-three/dist/chunk-XOLKY3ZJ.js
|
|
23548
23763
|
var __defProp3 = Object.defineProperty;
|
|
23549
23764
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
23550
23765
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -24600,6 +24815,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24600
24815
|
function installHouseWindows(K, shared2) {
|
|
24601
24816
|
const { EPS: EPS3, Y0, boxC, bx, cursor, pieceRecord, roomAt } = K;
|
|
24602
24817
|
const FRAME_COLORS = { budget: 15856110, mid: 12830924, high: 2829875, commercial: 11844287 };
|
|
24818
|
+
const ALUMINIUM_PROFILE_KG_PER_M = 1.2, SILL_KG_PER_M = 6, STEEL_KG_PER_M3 = 7850, GRILLE_BAR = 0.016;
|
|
24603
24819
|
const SILL_COLORS = { budget: 15131870, mid: 14277076, high: 3816770, commercial: 13225166 };
|
|
24604
24820
|
function windows() {
|
|
24605
24821
|
const R = shared2.ctx.r, cut = shared2.ctx.cut, C = shared2.ctx.colors, structure = R.style, fr = FRAME_COLORS[structure] || FRAME_COLORS.budget, pe_ = SILL_COLORS[structure] || SILL_COLORS.budget;
|
|
@@ -24615,7 +24831,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24615
24831
|
}
|
|
24616
24832
|
const wref = R.walls.find((w) => w.floor === f && w.axis === j.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS3), th = wref ? wref.thickness || 0.15 : 0.15, t = 0.05, tt = th + 0.02;
|
|
24617
24833
|
const bar2 = (u0, y_0, u1, y_1, mat, color2, tw = tt) => alongU ? bx(mat, u0, y0 + y_0, L - tw / 2, u1, y0 + y_1, L + tw / 2, color2) : bx(mat, L - tw / 2, y0 + y_0, u0, L + tw / 2, y0 + y_1, u1, color2);
|
|
24618
|
-
const
|
|
24834
|
+
const outside0 = !roomAt(f, alongU ? j.at : L + 0.4, alongU ? L + 0.4 : j.at) || !roomAt(f, alongU ? j.at : L - 0.4, alongU ? L - 0.4 : j.at);
|
|
24835
|
+
const frameMass = ALUMINIUM_PROFILE_KG_PER_M * (2 * (j.width + (yb - ya)) + j.width + (j.width > 0.9 ? yb - ya : 0)) + (outside0 ? SILL_KG_PER_M * (j.width + 0.1) : 0);
|
|
24836
|
+
const frame2 = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f, mass: frameMass, aperture: { alongU, a: a + t, b: b - t, y0: y0 + ya + t, y1: y0 + yb - t } });
|
|
24619
24837
|
cursor.pc = frame2;
|
|
24620
24838
|
bar2(a, ya, a + t, yb, "metal", fr);
|
|
24621
24839
|
bar2(b - t, ya, b, yb, "metal", fr);
|
|
@@ -24634,7 +24852,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24634
24852
|
if (alongU) bx("plaster", a - 0.05, y0 + ya - 0.04, L + (outside > 0 ? th / 2 : -th / 2 - 0.08), b + 0.05, y0 + ya, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), pe_);
|
|
24635
24853
|
else bx("plaster", L + (outside > 0 ? th / 2 : -th / 2 - 0.08), y0 + ya - 0.04, a - 0.05, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), y0 + ya, b + 0.05, pe_);
|
|
24636
24854
|
if (R.facade.grilles && !cut) {
|
|
24637
|
-
const g = C.gate != null ? C.gate : 2763310, go = outside * (th / 2 + 0.07), n = Math.max(3, Math.round(j.width / 0.12));
|
|
24855
|
+
const g = C.gate != null ? C.gate : 2763310, go = outside * (th / 2 + 0.07), n = Math.max(3, Math.round(j.width / 0.12)), spacing = (j.width - 0.06) / n;
|
|
24856
|
+
cursor.pc = pieceRecord("window_grille:" + j.id, "steel", null, { floor: f, mass: STEEL_KG_PER_M3 * ((n + 1) * (yb - ya + 0.06) * GRILLE_BAR * GRILLE_BAR + 3 * j.width * 0.025 * 0.024), aperture: { alongU, a: a + 0.03, b: a + 0.03 + n * spacing, y0: y0 + ya - 0.03, y1: y0 + yb + 0.03, bars: { spacing, width: GRILLE_BAR } } });
|
|
24638
24857
|
for (let k = 0; k <= n; k++) {
|
|
24639
24858
|
const u = a + 0.03 + k * (j.width - 0.06) / n;
|
|
24640
24859
|
if (alongU) bx("metal", u - 8e-3, y0 + ya - 0.03, L + go - 8e-3, u + 8e-3, y0 + yb + 0.03, L + go + 8e-3, g);
|
|
@@ -24644,6 +24863,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24644
24863
|
if (alongU) bx("metal", a, y0 + y, L + go - 0.012, b, y0 + y + 0.025, L + go + 0.012, g);
|
|
24645
24864
|
else bx("metal", L + go - 0.012, y0 + y, a, L + go + 0.012, y0 + y + 0.025, b, g);
|
|
24646
24865
|
}
|
|
24866
|
+
cursor.pc = frame2;
|
|
24647
24867
|
}
|
|
24648
24868
|
cursor.pc = null;
|
|
24649
24869
|
}
|
|
@@ -29898,6 +30118,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29898
30118
|
else if (def.kind === "swing" || def.kind === "drawer") tagObject(def.name, [def.outer], "mdf", null, { mass: 6 });
|
|
29899
30119
|
}
|
|
29900
30120
|
}
|
|
30121
|
+
function apertureOf(sp, ap) {
|
|
30122
|
+
if (!ap || sp.shape.kind !== "box") return null;
|
|
30123
|
+
const size = sp.shape.size, depth = ap.alongU ? 2 : 0;
|
|
30124
|
+
if (size[depth] > Math.min(size[ap.alongU ? 0 : 2], size[1])) return null;
|
|
30125
|
+
const out = { size: [ap.b - ap.a, ap.y1 - ap.y0], offset: [(ap.a + ap.b) / 2 - sp.position[ap.alongU ? 0 : 2], (ap.y0 + ap.y1) / 2 - sp.position[1]] };
|
|
30126
|
+
if (ap.bars) out.bars = { axis: 0, spacing: ap.bars.spacing, width: ap.bars.width };
|
|
30127
|
+
return out;
|
|
30128
|
+
}
|
|
29901
30129
|
function assembleStructure(r0, root) {
|
|
29902
30130
|
const E0 = r0.structure || { parts: [], supports: [], levels: [], elevation: 0 }, meshes = /* @__PURE__ */ new Map(), add = (id, it) => {
|
|
29903
30131
|
let l = meshes.get(id);
|
|
@@ -29942,7 +30170,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29942
30170
|
if (!b) continue;
|
|
29943
30171
|
const vol = Math.max(1e-6, (b[3] - b[0]) * (b[4] - b[1]) * (b[5] - b[2]));
|
|
29944
30172
|
const p = { id, role: "none", material: pc.mat, aabb: [b[0], b[2], b[3], b[5]], y0: b[1], y1: b[4], floor: pc.floor != null ? pc.floor : floorAtY(b[1] + 0.1), mass: pc.mass != null ? pc.mass : Math.max(0.5, vol * (DENSITY[pc.mat] || 800) * (pc.fill != null ? pc.fill : 0.15)), meshes: meshes.get(id).length, extra: true };
|
|
29945
|
-
for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units"]) if (pc[k] != null) p[k] = pc[k];
|
|
30173
|
+
for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units", "aperture"]) if (pc[k] != null) p[k] = pc[k];
|
|
29946
30174
|
parts.push(p);
|
|
29947
30175
|
byId.set(id, p);
|
|
29948
30176
|
}
|
|
@@ -30015,6 +30243,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30015
30243
|
if (!pc0) return sp;
|
|
30016
30244
|
const extra = {};
|
|
30017
30245
|
for (const k of ["contains", "explodes", "thickness", "fill", "tags"]) if (pc0[k] != null && sp[k] == null) extra[k] = pc0[k];
|
|
30246
|
+
const aperture = apertureOf(sp, pc0.aperture);
|
|
30247
|
+
if (aperture) extra.apertures = [aperture];
|
|
30018
30248
|
return Object.keys(extra).length ? { ...sp, ...extra } : sp;
|
|
30019
30249
|
});
|
|
30020
30250
|
spec.parts = spec.parts.map((sp) => {
|
|
@@ -30038,7 +30268,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30038
30268
|
return sp;
|
|
30039
30269
|
}
|
|
30040
30270
|
});
|
|
30041
|
-
|
|
30271
|
+
const walls = new Set((E0.openings ?? []).map((op) => op.wall));
|
|
30272
|
+
return withWindowApertures({ ...spec, parts: spec.parts.map((sp) => walls.has(sp.id) && sp.apertures ? (({ apertures: _gone, ...rest2 }) => rest2)(sp) : sp) }, E0.openings ?? []);
|
|
30042
30273
|
}
|
|
30043
30274
|
};
|
|
30044
30275
|
return structure;
|
|
@@ -30084,11 +30315,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30084
30315
|
var SPALL_RAGGED = 0.045;
|
|
30085
30316
|
var COVER2 = 0.015;
|
|
30086
30317
|
var LUMP_BAR_INSET = 0.035;
|
|
30087
|
-
var LUMPS_PER_BAR =
|
|
30088
|
-
var LUMP_CHANCE = 0.
|
|
30318
|
+
var LUMPS_PER_BAR = 1;
|
|
30319
|
+
var LUMP_CHANCE = 0.5;
|
|
30089
30320
|
var LUMP_MIN = 0.025;
|
|
30090
30321
|
var LUMP_MAX = 0.05;
|
|
30091
|
-
var EDGE_LUMPS =
|
|
30322
|
+
var EDGE_LUMPS = 2;
|
|
30092
30323
|
var EDGE_LUMP_MIN = 0.04;
|
|
30093
30324
|
var EDGE_LUMP_MAX = 0.08;
|
|
30094
30325
|
var MAX_FLAKES = 64;
|
|
@@ -30483,35 +30714,42 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30483
30714
|
function stuckLumps(gone, mask, bounds2) {
|
|
30484
30715
|
const out = [];
|
|
30485
30716
|
const grey = fragmentMaterial("concrete").color.getHex();
|
|
30717
|
+
const stone = (s, y, d, size, r) => {
|
|
30718
|
+
const centre = mask.start + s;
|
|
30719
|
+
const unit = clipToBox({ x: mask.alongU ? centre : d, y, z: mask.alongU ? d : centre, sx: mask.alongU ? size[0] : size[2], sy: size[1], sz: mask.alongU ? size[2] : size[0], colour: tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex() }, bounds2);
|
|
30720
|
+
if (unit) out.push(unit);
|
|
30721
|
+
};
|
|
30486
30722
|
for (const { c, part, thick, mid } of gone) {
|
|
30487
30723
|
const p0 = (mask.alongU ? part.aabb[0] : part.aabb[1]) - mask.start, p1 = (mask.alongU ? part.aabb[2] : part.aabb[3]) - mask.start;
|
|
30488
|
-
|
|
30489
|
-
|
|
30490
|
-
|
|
30491
|
-
|
|
30492
|
-
|
|
30493
|
-
|
|
30724
|
+
const lying = p1 - p0 > part.y1 - part.y0;
|
|
30725
|
+
const random = (seed) => (n) => {
|
|
30726
|
+
const x = Math.sin(seed + n * 3.3) * 43758.5453;
|
|
30727
|
+
return x - Math.floor(x);
|
|
30728
|
+
};
|
|
30729
|
+
const faces = lying ? [[c.a, 1], [c.b, 2]] : [[c.y0, 1], [c.y1, 2]];
|
|
30730
|
+
for (const [face, f] of faces) {
|
|
30731
|
+
const open = gone.some((g) => g.part === part && g.c !== c && (lying ? Math.abs((f === 1 ? g.c.b : g.c.a) - face) < 1e-4 && g.c.y1 > c.y0 + 1e-4 && g.c.y0 < c.y1 - 1e-4 : Math.abs((f === 1 ? g.c.y1 : g.c.y0) - face) < 1e-4 && g.c.b > c.a + 1e-4 && g.c.a < c.b - 1e-4));
|
|
30732
|
+
if (open) continue;
|
|
30733
|
+
for (let k = 0; k < EDGE_LUMPS; k++) {
|
|
30734
|
+
const r = random(c.a * 63.1 + c.y0 * 29.7 + mid * 17.3 + f * 11.1 + k * 5.3);
|
|
30494
30735
|
const size = EDGE_LUMP_MIN + (EDGE_LUMP_MAX - EDGE_LUMP_MIN) * r(1);
|
|
30495
|
-
const
|
|
30496
|
-
const
|
|
30497
|
-
|
|
30736
|
+
const d = mid + (r(3) - 0.5) * (thick - 2 * LUMP_BAR_INSET);
|
|
30737
|
+
const s = lying ? face : c.a + (0.1 + 0.8 * r(2)) * (c.b - c.a);
|
|
30738
|
+
const y = lying ? c.y0 + (0.1 + 0.8 * r(2)) * (c.y1 - c.y0) : face;
|
|
30739
|
+
stone(s, y, d, [size, size * (0.6 + 0.5 * r(4)), size], r);
|
|
30498
30740
|
}
|
|
30499
30741
|
}
|
|
30500
|
-
const bars = [p0 + LUMP_BAR_INSET, p1 - LUMP_BAR_INSET].filter((s) => s >= c.a - 1e-6 && s <= c.b + 1e-6);
|
|
30501
|
-
for (const
|
|
30742
|
+
const bars = lying ? [part.y0 + LUMP_BAR_INSET, part.y1 - LUMP_BAR_INSET].filter((y) => y >= c.y0 - 1e-6 && y <= c.y1 + 1e-6) : [p0 + LUMP_BAR_INSET, p1 - LUMP_BAR_INSET].filter((s) => s >= c.a - 1e-6 && s <= c.b + 1e-6);
|
|
30743
|
+
for (const bar2 of bars) {
|
|
30502
30744
|
for (const side of [-1, 1]) {
|
|
30503
30745
|
const d = mid + side * (thick / 2 - LUMP_BAR_INSET);
|
|
30504
30746
|
for (let k = 0; k < LUMPS_PER_BAR; k++) {
|
|
30505
|
-
const r = (
|
|
30506
|
-
const x = Math.sin(s * 91.7 + d * 47.3 + c.y0 * 113.1 + k * 7.9 + n * 3.3) * 43758.5453;
|
|
30507
|
-
return x - Math.floor(x);
|
|
30508
|
-
};
|
|
30747
|
+
const r = random(bar2 * 91.7 + d * 47.3 + c.y0 * 113.1 + c.a * 19.9 + k * 7.9);
|
|
30509
30748
|
if (r(1) > LUMP_CHANCE) continue;
|
|
30510
|
-
const
|
|
30511
|
-
const
|
|
30512
|
-
const
|
|
30513
|
-
|
|
30514
|
-
if (unit) out.push(unit);
|
|
30749
|
+
const at2 = 0.15 + 0.7 * r(2), jitter = (r(6) - 0.5) * 0.02;
|
|
30750
|
+
const s = lying ? c.a + at2 * (c.b - c.a) : bar2 + jitter;
|
|
30751
|
+
const y = lying ? bar2 + jitter : c.y0 + at2 * (c.y1 - c.y0);
|
|
30752
|
+
stone(s, y, d, [LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(3), LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(4), LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(5)], r);
|
|
30515
30753
|
}
|
|
30516
30754
|
}
|
|
30517
30755
|
}
|
|
@@ -30733,9 +30971,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30733
30971
|
dropped.length = 0;
|
|
30734
30972
|
},
|
|
30735
30973
|
flush,
|
|
30736
|
-
/** Takes this house's painting out of the renderer's queue (the house goes away); `claim` puts it back. */
|
|
30974
|
+
/** Takes this house's painting out of the renderer's queue (the house goes away) and frees the unit shapes on the GPU; `claim` puts it back (three.js uploads the shapes again when drawn). */
|
|
30737
30975
|
release() {
|
|
30738
30976
|
paintQueues.delete(queue);
|
|
30977
|
+
unitGeometry.dispose();
|
|
30978
|
+
lumpShape?.dispose();
|
|
30739
30979
|
},
|
|
30740
30980
|
/** The painting of this house alone. */
|
|
30741
30981
|
deferredQueue: () => queue,
|
|
@@ -31002,6 +31242,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31002
31242
|
D.deactivate = () => {
|
|
31003
31243
|
if (off) off();
|
|
31004
31244
|
off = null;
|
|
31245
|
+
if (R && D.id && D.active) R.release?.(D.id);
|
|
31005
31246
|
D.restore();
|
|
31006
31247
|
if (R && D.id && D.active) R.unbind(D.id);
|
|
31007
31248
|
if (D.active && D.world.has(D.id)) D.world.remove(D.id);
|
|
@@ -31084,7 +31325,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
31084
31325
|
D.piece = (id) => D.active ? D.world.part(D.id, id) : null;
|
|
31085
31326
|
D.state = () => D.active ? D.world.state(D.id) : null;
|
|
31086
31327
|
D.reset = () => {
|
|
31087
|
-
if (D.active)
|
|
31328
|
+
if (D.active) {
|
|
31329
|
+
R?.releasePieces?.(D.id);
|
|
31330
|
+
D.world.reset(D.id);
|
|
31331
|
+
}
|
|
31088
31332
|
D.restore();
|
|
31089
31333
|
};
|
|
31090
31334
|
D.strike = (pid, point, type, amount, d) => {
|