@adatechnology/game-items-three 0.8.2 → 0.8.4
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 +278 -43
- package/dist/index.global.js.map +1 -1
- package/package.json +8 -8
package/dist/index.global.js
CHANGED
|
@@ -15220,7 +15220,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
15220
15220
|
ricochetDeg: 10,
|
|
15221
15221
|
hitDebris: "chips",
|
|
15222
15222
|
breakDebris: "dust",
|
|
15223
|
-
visual: { innerColor: 12085567 },
|
|
15223
|
+
visual: { innerColor: 12085567, unitColor: 11031866 },
|
|
15224
15224
|
thermal: {
|
|
15225
15225
|
conductivity: 0.15,
|
|
15226
15226
|
heatCapacity: 2.5
|
|
@@ -16161,8 +16161,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16161
16161
|
var PANEL_POINTS_LOADED = 4;
|
|
16162
16162
|
var MEMBER_BAND = 0.1;
|
|
16163
16163
|
var MEMBER_CRATER_CALIBRES = 3.4;
|
|
16164
|
-
var MEMBER_BARED_MAX = 24;
|
|
16165
16164
|
var MEMBER_CUT_LOSS = 0.9;
|
|
16165
|
+
var MEMBER_UNIT_LOSS = 0.12;
|
|
16166
|
+
var JOINT_OPEN_SHARE = 0.6;
|
|
16166
16167
|
var BLAST_EDGE_WEAR = 0.6;
|
|
16167
16168
|
var RESIDUAL_CAPACITY = 0.15;
|
|
16168
16169
|
var SEVER_BAND = 0.1;
|
|
@@ -17897,7 +17898,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
17897
17898
|
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
17898
17899
|
const r = rayPart(o, p, origin, d);
|
|
17899
17900
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
17900
|
-
if (p.st.opening && insideOpening(o, p, vec.madd(origin, d, r.t0))) continue;
|
|
17901
|
+
if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
17902
|
+
if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
17901
17903
|
if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
17902
17904
|
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 };
|
|
17903
17905
|
}
|
|
@@ -18093,7 +18095,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18093
18095
|
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]));
|
|
18094
18096
|
return len;
|
|
18095
18097
|
};
|
|
18096
|
-
const
|
|
18098
|
+
const onFoundation = (o, j) => o.parts[j.ia].spec.structure?.role === "foundation" || o.parts[j.ib].spec.structure?.role === "foundation";
|
|
18099
|
+
const wornStretches = /* @__PURE__ */ new WeakMap();
|
|
18100
|
+
const wornShare = (o, j, point, span) => {
|
|
18101
|
+
const A = partWorldAabb(o, o.parts[j.ia]), B = partWorldAabb(o, o.parts[j.ib]);
|
|
18102
|
+
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]));
|
|
18103
|
+
const axis = [0, 1, 2].reduce((best, k) => hi[k] - lo[k] > hi[best] - lo[best] ? k : best, 0);
|
|
18104
|
+
const length = hi[axis] - lo[axis];
|
|
18105
|
+
if (length <= span) return 1;
|
|
18106
|
+
const at2 = clamp2(point[axis], lo[axis], hi[axis]);
|
|
18107
|
+
const from = Math.max(lo[axis], at2 - span / 2), to = Math.min(hi[axis], at2 + span / 2);
|
|
18108
|
+
const worn = [...wornStretches.get(j) ?? [], [from, to]].sort((x, y) => x[0] - y[0]);
|
|
18109
|
+
wornStretches.set(j, worn);
|
|
18110
|
+
let covered = 0, end = -Infinity;
|
|
18111
|
+
for (const [a, b] of worn) {
|
|
18112
|
+
covered += Math.max(0, b - Math.max(a, end));
|
|
18113
|
+
end = Math.max(end, b);
|
|
18114
|
+
}
|
|
18115
|
+
return covered / length;
|
|
18116
|
+
};
|
|
18117
|
+
const isTrim = (p) => (p.spec.structure?.role ?? "none") === "none";
|
|
18118
|
+
const wearJoints = (o, p, amount, near, radius = 0.06, src, split = false, span, blast) => {
|
|
18097
18119
|
if (amount <= 0) return;
|
|
18098
18120
|
const mine = (o.byPart.get(p.spec.id) ?? []).filter((j) => !j.st.open);
|
|
18099
18121
|
if (split && mine.length) amount /= mine.length;
|
|
@@ -18101,7 +18123,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18101
18123
|
if (j.st.open) continue;
|
|
18102
18124
|
if (j.spec.kind === "rebar" && (isReinforced(o.parts[j.ia].spec) || isReinforced(o.parts[j.ib].spec))) continue;
|
|
18103
18125
|
if (near && jointReach(o, j, near) > Math.max(radius, jointReachLimit(o, j))) continue;
|
|
18126
|
+
if (blast && (isTrim(o.parts[j.ia]) || isTrim(o.parts[j.ib])) && jointReach(o, j, blast.point) > Math.max(blast.reach, jointReachLimit(o, j))) continue;
|
|
18104
18127
|
j.st.hp -= span === void 0 ? amount : Math.min(amount, j.st.maxHp) * Math.min(1, span / Math.max(jointLength(o, j), 1e-6));
|
|
18128
|
+
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);
|
|
18105
18129
|
if (j.st.hp <= 0) {
|
|
18106
18130
|
j.st.hp = 0;
|
|
18107
18131
|
j.st.open = true;
|
|
@@ -18147,6 +18171,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18147
18171
|
const lc = toLocal(p.pos, p.q, op.center);
|
|
18148
18172
|
return Math.hypot(lp[u] - lc[u], lp[v] - lc[v]) <= op.radius;
|
|
18149
18173
|
};
|
|
18174
|
+
const throughAperture = (p, objectPoint) => {
|
|
18175
|
+
const [u, v] = planeAxes(p.thin);
|
|
18176
|
+
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
18177
|
+
return (p.spec.apertures ?? []).some((ap) => {
|
|
18178
|
+
const du = lp[u] - (ap.offset?.[0] ?? 0);
|
|
18179
|
+
const dv = lp[v] - (ap.offset?.[1] ?? 0);
|
|
18180
|
+
if (Math.abs(du) > ap.size[0] / 2 || Math.abs(dv) > ap.size[1] / 2) return false;
|
|
18181
|
+
if (!ap.bars || ap.bars.spacing <= 0) return true;
|
|
18182
|
+
const along = ap.bars.axis === 0 ? du + ap.size[0] / 2 : dv + ap.size[1] / 2;
|
|
18183
|
+
return Math.abs(along - Math.round(along / ap.bars.spacing) * ap.bars.spacing) > ap.bars.width / 2;
|
|
18184
|
+
});
|
|
18185
|
+
};
|
|
18150
18186
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
18151
18187
|
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 }));
|
|
18152
18188
|
const unitsOf2 = (p) => p.spec.units ?? { size: [p.mat.fragmentSize?.[1] ?? 0.2, p.mat.fragmentSize?.[1] ?? 0.2, p.thickness], bond: "stack" };
|
|
@@ -18164,6 +18200,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18164
18200
|
const faceArea = (cell) => cell.size[u] * cell.size[v];
|
|
18165
18201
|
const total = cells.reduce((sum, cell) => sum + faceArea(cell), 0) || 1;
|
|
18166
18202
|
const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
|
|
18203
|
+
const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
|
|
18167
18204
|
return cells.map((cell, i) => {
|
|
18168
18205
|
const cw = toWorld(c, q, cell.center);
|
|
18169
18206
|
const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
@@ -18182,7 +18219,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18182
18219
|
angularVelocity: [(rnd() - 0.5) * 8, (rnd() - 0.5) * 8, (rnd() - 0.5) * 8],
|
|
18183
18220
|
mass: mass * faceArea(cell) / total,
|
|
18184
18221
|
...marks.length > 0 ? { marks } : {},
|
|
18185
|
-
...inner ? { inner } : {}
|
|
18222
|
+
...inner && laid ? { unit: true } : inner ? { inner } : {}
|
|
18186
18223
|
};
|
|
18187
18224
|
});
|
|
18188
18225
|
};
|
|
@@ -18258,10 +18295,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18258
18295
|
if (!cells?.length) return false;
|
|
18259
18296
|
const [u, v] = planeAxes(p.thin);
|
|
18260
18297
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
18298
|
+
if (p.spec.reinforcement && isMember(p.dims) && !p.st.stripped) {
|
|
18299
|
+
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
18300
|
+
const bands = Math.max(1, Math.round(p.dims[along] / MEMBER_BAND));
|
|
18301
|
+
const band = clamp2(Math.floor((lp[along] + p.dims[along] / 2) / p.dims[along] * bands), 0, bands - 1);
|
|
18302
|
+
if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
|
|
18303
|
+
}
|
|
18261
18304
|
return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
|
|
18262
18305
|
};
|
|
18306
|
+
const wornLocally = (p) => !!p.spec.reinforcement && !!p.spec.units && p.spec.units.mortar === p.spec.material && isMember(p.dims) && p.spec.shape.kind === "box";
|
|
18263
18307
|
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
18264
|
-
var _a, _b;
|
|
18308
|
+
var _a, _b, _c;
|
|
18265
18309
|
if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
|
|
18266
18310
|
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
18267
18311
|
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
@@ -18283,29 +18327,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18283
18327
|
worn[band] = after;
|
|
18284
18328
|
markDamaged(p);
|
|
18285
18329
|
const bandCenter = -p.dims[along] / 2 + (band + 0.5) * height;
|
|
18286
|
-
if (h > REBAR_COVER && after < MEMBER_CUT_LOSS) {
|
|
18287
|
-
const bared = (_b = p.rt).bared ?? (_b.bared = []);
|
|
18288
|
-
const center = [lp[0], lp[1], lp[2]];
|
|
18289
|
-
const size = [p.dims[0], p.dims[1], p.dims[2]];
|
|
18290
|
-
for (let a = 0; a < 3; a++) if (Math.abs(ld[a]) < 0.5) size[a] = 2 * r;
|
|
18291
|
-
if (bared.length < MEMBER_BARED_MAX && !bared.some((box4) => box4.center.every((x, a) => Math.abs(x - center[a]) < box4.size[a] / 4))) {
|
|
18292
|
-
bared.push({ center, size });
|
|
18293
|
-
exposeRebar(o, p, src);
|
|
18294
|
-
}
|
|
18295
|
-
}
|
|
18296
|
-
if (before >= MEMBER_CUT_LOSS || after < MEMBER_CUT_LOSS) return true;
|
|
18297
|
-
const axisUp = rotateVec(p.q, [0, 0, 0].map((_, k) => k === along ? 1 : 0));
|
|
18298
|
-
const standing = Math.abs(axisUp[1]) > 0.7;
|
|
18299
|
-
const upward = axisUp[1] >= 0 ? 1 : -1;
|
|
18300
18330
|
const grid = gridOf(p);
|
|
18301
|
-
const gone = p.rt.chips ?? {};
|
|
18331
|
+
const gone = (_b = p.rt).chips ?? (_b.chips = {});
|
|
18332
|
+
if (before >= MEMBER_CUT_LOSS || after < MEMBER_CUT_LOSS) {
|
|
18333
|
+
if (h <= REBAR_COVER) return true;
|
|
18334
|
+
const [u, v] = planeAxes(p.thin);
|
|
18335
|
+
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);
|
|
18336
|
+
if (hit < 0) return true;
|
|
18337
|
+
const wear = (_c = p.rt).cellWear ?? (_c.cellWear = {});
|
|
18338
|
+
const cell = grid[hit];
|
|
18339
|
+
wear[hit] = (wear[hit] ?? 0) + volume;
|
|
18340
|
+
if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
|
|
18341
|
+
return true;
|
|
18342
|
+
}
|
|
18302
18343
|
const out = [];
|
|
18303
18344
|
for (let i = 0; i < grid.length; i++) {
|
|
18304
18345
|
if (gone[i] === -1) continue;
|
|
18305
|
-
|
|
18306
|
-
const inBand = Math.abs(at2 - bandCenter) <= height / 2 + 1e-6;
|
|
18307
|
-
const above = standing && (at2 - bandCenter) * upward > height / 2;
|
|
18308
|
-
if (inBand || above) out.push(i);
|
|
18346
|
+
if (Math.abs(grid[i].center[along] - bandCenter) <= height / 2 + 1e-6) out.push(i);
|
|
18309
18347
|
}
|
|
18310
18348
|
if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
|
|
18311
18349
|
giveAtCut(o, p, src);
|
|
@@ -18896,6 +18934,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18896
18934
|
const chained = trigger !== void 0 && chainDelayOf(p.spec, trigger) !== void 0;
|
|
18897
18935
|
if (chained && p.st.hp <= 0 && p.rt.chainDue === void 0) p.st.hp = Math.min(prev, 1);
|
|
18898
18936
|
if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
|
|
18937
|
+
if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
|
|
18899
18938
|
const done = prev - p.st.hp;
|
|
18900
18939
|
if (done > 0) emit({ ...base(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
|
|
18901
18940
|
if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy, cap, src);
|
|
@@ -19105,7 +19144,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19105
19144
|
checkIgnite(o, p, src);
|
|
19106
19145
|
}
|
|
19107
19146
|
}
|
|
19108
|
-
|
|
19147
|
+
const stretch = 2 * BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
|
|
19148
|
+
wearJoints(o, p, Ein * 0.5, void 0, 0, src, false, stretch, { point, reach: stretch });
|
|
19109
19149
|
const amount = Ein * DMG_PER_J * (mat.damageScale?.explosive ?? 1);
|
|
19110
19150
|
if (blastFrontSpeed > 0 && dist > 0 && mat.tags?.includes("glass")) {
|
|
19111
19151
|
frontQueue.push({ o, p, due: time + dist / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
|
|
@@ -19249,7 +19289,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
19249
19289
|
const path = Math.min(r.t1, L) - t0;
|
|
19250
19290
|
if (path < shelter.minPath) continue;
|
|
19251
19291
|
const mid = vec.madd(point, d, t0 + path / 2);
|
|
19252
|
-
const opening = p.st.opening && insideOpening(o, p, mid);
|
|
19292
|
+
const opening = p.st.opening && insideOpening(o, p, objLocal(o, mid));
|
|
19253
19293
|
if (opening && was & FLAG_OPEN) continue;
|
|
19254
19294
|
if (p.st.stripped && was & FLAG_OPEN) continue;
|
|
19255
19295
|
const resistance = p.mat.hpPerKg * p.mat.density * path * (p.mat.damageScale?.shelter ?? 1);
|
|
@@ -21560,6 +21600,42 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21560
21600
|
}
|
|
21561
21601
|
return { ...next, capacities };
|
|
21562
21602
|
}
|
|
21603
|
+
var planeAxes2 = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
|
|
21604
|
+
function toPartFrame(part, point) {
|
|
21605
|
+
const dx = point[0] - part.position[0];
|
|
21606
|
+
const dz = point[2] - part.position[2];
|
|
21607
|
+
const angle = -(part.rotation?.[1] ?? 0);
|
|
21608
|
+
return [dx * Math.cos(angle) + dz * Math.sin(angle), point[1] - part.position[1], -dx * Math.sin(angle) + dz * Math.cos(angle)];
|
|
21609
|
+
}
|
|
21610
|
+
function wallApertures(part, windows) {
|
|
21611
|
+
if (part.shape.kind !== "box") return [];
|
|
21612
|
+
const size = part.shape.size;
|
|
21613
|
+
const thin = size.indexOf(Math.min(...size));
|
|
21614
|
+
if (thin === 1) return [];
|
|
21615
|
+
const [along] = planeAxes2(thin);
|
|
21616
|
+
const turn = part.rotation?.[1] ?? 0;
|
|
21617
|
+
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];
|
|
21618
|
+
return windows.map((opening2) => {
|
|
21619
|
+
const middle = (opening2.from + opening2.to) / 2;
|
|
21620
|
+
const centre2 = alongU ? [middle, (opening2.y0 + opening2.y1) / 2, part.position[2]] : [part.position[0], (opening2.y0 + opening2.y1) / 2, middle];
|
|
21621
|
+
const local = toPartFrame(part, centre2);
|
|
21622
|
+
return { size: [opening2.to - opening2.from, opening2.y1 - opening2.y0], offset: [local[along], local[1]] };
|
|
21623
|
+
});
|
|
21624
|
+
}
|
|
21625
|
+
function withWindowApertures(spec, openings) {
|
|
21626
|
+
const byWall = /* @__PURE__ */ new Map();
|
|
21627
|
+
for (const opening2 of openings) if (opening2.kind === "window") byWall.set(opening2.wall, [...byWall.get(opening2.wall) ?? [], opening2]);
|
|
21628
|
+
if (!byWall.size) return spec;
|
|
21629
|
+
return {
|
|
21630
|
+
...spec,
|
|
21631
|
+
parts: spec.parts.map((part) => {
|
|
21632
|
+
const windows = byWall.get(part.id);
|
|
21633
|
+
if (!windows) return part;
|
|
21634
|
+
const apertures = wallApertures(part, windows);
|
|
21635
|
+
return apertures.length ? { ...part, apertures: [...part.apertures ?? [], ...apertures] } : part;
|
|
21636
|
+
})
|
|
21637
|
+
};
|
|
21638
|
+
}
|
|
21563
21639
|
var RAFT_THICKNESS = 0.25;
|
|
21564
21640
|
var PILE_AREA = 9;
|
|
21565
21641
|
var RAFT_MARGIN = 0.15;
|
|
@@ -21658,7 +21734,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
21658
21734
|
const infill = new Set(portico && slabOptions ? kept.filter((part) => part.role === "wall").map((part) => part.id) : []);
|
|
21659
21735
|
const beams = new Set(parts.filter((part) => part.role === "beam" && (part.beamKind === "bond_beam" || part.slab !== void 0)).map((part) => part.id));
|
|
21660
21736
|
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" }));
|
|
21661
|
-
const
|
|
21737
|
+
const built = { name: options.name ?? "house", parts: specs, joints, tags: ["structure", "house"] };
|
|
21738
|
+
const spec = detail === "coarse" && options.windowApertures !== false ? withWindowApertures(built, structure.openings) : built;
|
|
21662
21739
|
return onSoil(withRebar(spec, structure, options, portico, slabOptions !== void 0), structure, options);
|
|
21663
21740
|
}
|
|
21664
21741
|
function withRebar(spec, structure, options, portico, panelled) {
|
|
@@ -23532,7 +23609,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23532
23609
|
}
|
|
23533
23610
|
var residentialTower = residentialTowerTemplate();
|
|
23534
23611
|
|
|
23535
|
-
// ../game-floorplan-three/dist/chunk-
|
|
23612
|
+
// ../game-floorplan-three/dist/chunk-RZF4G6CY.js
|
|
23536
23613
|
var __defProp3 = Object.defineProperty;
|
|
23537
23614
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
23538
23615
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -24588,6 +24665,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24588
24665
|
function installHouseWindows(K, shared2) {
|
|
24589
24666
|
const { EPS: EPS3, Y0, boxC, bx, cursor, pieceRecord, roomAt } = K;
|
|
24590
24667
|
const FRAME_COLORS = { budget: 15856110, mid: 12830924, high: 2829875, commercial: 11844287 };
|
|
24668
|
+
const ALUMINIUM_PROFILE_KG_PER_M = 1.2, SILL_KG_PER_M = 6, STEEL_KG_PER_M3 = 7850, GRILLE_BAR = 0.016;
|
|
24591
24669
|
const SILL_COLORS = { budget: 15131870, mid: 14277076, high: 3816770, commercial: 13225166 };
|
|
24592
24670
|
function windows() {
|
|
24593
24671
|
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;
|
|
@@ -24603,7 +24681,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24603
24681
|
}
|
|
24604
24682
|
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;
|
|
24605
24683
|
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);
|
|
24606
|
-
const
|
|
24684
|
+
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);
|
|
24685
|
+
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);
|
|
24686
|
+
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 } });
|
|
24607
24687
|
cursor.pc = frame2;
|
|
24608
24688
|
bar2(a, ya, a + t, yb, "metal", fr);
|
|
24609
24689
|
bar2(b - t, ya, b, yb, "metal", fr);
|
|
@@ -24622,7 +24702,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24622
24702
|
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_);
|
|
24623
24703
|
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_);
|
|
24624
24704
|
if (R.facade.grilles && !cut) {
|
|
24625
|
-
const g = C.gate != null ? C.gate : 2763310, go = outside * (th / 2 + 0.07), n = Math.max(3, Math.round(j.width / 0.12));
|
|
24705
|
+
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;
|
|
24706
|
+
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 } } });
|
|
24626
24707
|
for (let k = 0; k <= n; k++) {
|
|
24627
24708
|
const u = a + 0.03 + k * (j.width - 0.06) / n;
|
|
24628
24709
|
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);
|
|
@@ -24632,6 +24713,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24632
24713
|
if (alongU) bx("metal", a, y0 + y, L + go - 0.012, b, y0 + y + 0.025, L + go + 0.012, g);
|
|
24633
24714
|
else bx("metal", L + go - 0.012, y0 + y, a, L + go + 0.012, y0 + y + 0.025, b, g);
|
|
24634
24715
|
}
|
|
24716
|
+
cursor.pc = frame2;
|
|
24635
24717
|
}
|
|
24636
24718
|
cursor.pc = null;
|
|
24637
24719
|
}
|
|
@@ -29886,6 +29968,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29886
29968
|
else if (def.kind === "swing" || def.kind === "drawer") tagObject(def.name, [def.outer], "mdf", null, { mass: 6 });
|
|
29887
29969
|
}
|
|
29888
29970
|
}
|
|
29971
|
+
function apertureOf(sp, ap) {
|
|
29972
|
+
if (!ap || sp.shape.kind !== "box") return null;
|
|
29973
|
+
const size = sp.shape.size, depth = ap.alongU ? 2 : 0;
|
|
29974
|
+
if (size[depth] > Math.min(size[ap.alongU ? 0 : 2], size[1])) return null;
|
|
29975
|
+
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]] };
|
|
29976
|
+
if (ap.bars) out.bars = { axis: 0, spacing: ap.bars.spacing, width: ap.bars.width };
|
|
29977
|
+
return out;
|
|
29978
|
+
}
|
|
29889
29979
|
function assembleStructure(r0, root) {
|
|
29890
29980
|
const E0 = r0.structure || { parts: [], supports: [], levels: [], elevation: 0 }, meshes = /* @__PURE__ */ new Map(), add = (id, it) => {
|
|
29891
29981
|
let l = meshes.get(id);
|
|
@@ -29930,7 +30020,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29930
30020
|
if (!b) continue;
|
|
29931
30021
|
const vol = Math.max(1e-6, (b[3] - b[0]) * (b[4] - b[1]) * (b[5] - b[2]));
|
|
29932
30022
|
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 };
|
|
29933
|
-
for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units"]) if (pc[k] != null) p[k] = pc[k];
|
|
30023
|
+
for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units", "aperture"]) if (pc[k] != null) p[k] = pc[k];
|
|
29934
30024
|
parts.push(p);
|
|
29935
30025
|
byId.set(id, p);
|
|
29936
30026
|
}
|
|
@@ -30003,6 +30093,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30003
30093
|
if (!pc0) return sp;
|
|
30004
30094
|
const extra = {};
|
|
30005
30095
|
for (const k of ["contains", "explodes", "thickness", "fill", "tags"]) if (pc0[k] != null && sp[k] == null) extra[k] = pc0[k];
|
|
30096
|
+
const aperture = apertureOf(sp, pc0.aperture);
|
|
30097
|
+
if (aperture) extra.apertures = [aperture];
|
|
30006
30098
|
return Object.keys(extra).length ? { ...sp, ...extra } : sp;
|
|
30007
30099
|
});
|
|
30008
30100
|
spec.parts = spec.parts.map((sp) => {
|
|
@@ -30026,7 +30118,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30026
30118
|
return sp;
|
|
30027
30119
|
}
|
|
30028
30120
|
});
|
|
30029
|
-
|
|
30121
|
+
const walls = new Set((E0.openings ?? []).map((op) => op.wall));
|
|
30122
|
+
return withWindowApertures({ ...spec, parts: spec.parts.map((sp) => walls.has(sp.id) && sp.apertures ? (({ apertures: _gone, ...rest2 }) => rest2)(sp) : sp) }, E0.openings ?? []);
|
|
30030
30123
|
}
|
|
30031
30124
|
};
|
|
30032
30125
|
return structure;
|
|
@@ -30071,6 +30164,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30071
30164
|
var SPALL_MIN = 0.025;
|
|
30072
30165
|
var SPALL_RAGGED = 0.045;
|
|
30073
30166
|
var COVER2 = 0.015;
|
|
30167
|
+
var LUMP_BAR_INSET = 0.035;
|
|
30168
|
+
var LUMPS_PER_BAR = 1;
|
|
30169
|
+
var LUMP_CHANCE = 0.5;
|
|
30170
|
+
var LUMP_MIN = 0.025;
|
|
30171
|
+
var LUMP_MAX = 0.05;
|
|
30172
|
+
var EDGE_LUMPS = 2;
|
|
30173
|
+
var EDGE_LUMP_MIN = 0.04;
|
|
30174
|
+
var EDGE_LUMP_MAX = 0.08;
|
|
30074
30175
|
var MAX_FLAKES = 64;
|
|
30075
30176
|
function clipToBox(unit, box4) {
|
|
30076
30177
|
const lo = [Math.max(unit.x - unit.sx / 2, box4[0]), Math.max(unit.y - unit.sy / 2, box4[1]), Math.max(unit.z - unit.sz / 2, box4[2])];
|
|
@@ -30116,6 +30217,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30116
30217
|
const dropped = [];
|
|
30117
30218
|
let lod = 0;
|
|
30118
30219
|
const unitGeometry = new THREE.BoxGeometry(1, 1, 1);
|
|
30220
|
+
let lumpShape = null;
|
|
30221
|
+
const lumpGeometry = () => {
|
|
30222
|
+
if (lumpShape) return lumpShape;
|
|
30223
|
+
const g = new THREE.IcosahedronGeometry(0.62, 0).toNonIndexed();
|
|
30224
|
+
const at2 = g.getAttribute("position");
|
|
30225
|
+
const moved = /* @__PURE__ */ new Map();
|
|
30226
|
+
for (let i = 0; i < at2.count; i++) {
|
|
30227
|
+
const key2 = `${at2.getX(i).toFixed(3)},${at2.getY(i).toFixed(3)},${at2.getZ(i).toFixed(3)}`;
|
|
30228
|
+
let k = moved.get(key2);
|
|
30229
|
+
if (k === void 0) {
|
|
30230
|
+
const x = Math.sin(moved.size * 12.9898 + 4.1) * 43758.5453;
|
|
30231
|
+
k = 0.7 + 0.45 * (x - Math.floor(x));
|
|
30232
|
+
moved.set(key2, k);
|
|
30233
|
+
}
|
|
30234
|
+
at2.setXYZ(i, at2.getX(i) * k, at2.getY(i) * k * 0.85, at2.getZ(i) * k);
|
|
30235
|
+
}
|
|
30236
|
+
g.computeVertexNormals();
|
|
30237
|
+
lumpShape = g;
|
|
30238
|
+
return g;
|
|
30239
|
+
};
|
|
30119
30240
|
const tmp = { m: new THREE.Matrix4(), q: new THREE.Quaternion(), p: new THREE.Vector3(), s: new THREE.Vector3(), c: new THREE.Color() };
|
|
30120
30241
|
const local = (p) => {
|
|
30121
30242
|
house.updateMatrixWorld(true);
|
|
@@ -30291,6 +30412,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30291
30412
|
const discs = [];
|
|
30292
30413
|
const flakes = [];
|
|
30293
30414
|
const shown = [];
|
|
30415
|
+
const castGone = [];
|
|
30294
30416
|
const pillars = pillarSpans(view);
|
|
30295
30417
|
for (const id of view.parts) {
|
|
30296
30418
|
const part = structure.byId.get(id), units2 = specOf(id).units, chips = view.chips.get(id), opening = view.openings.get(id), spalls = view.spalls.get(id);
|
|
@@ -30298,6 +30420,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30298
30420
|
const all = id === view.host ? own.flatMap((c) => besidePillars(c, pillars)) : own;
|
|
30299
30421
|
if (view.fallen.has(id)) {
|
|
30300
30422
|
holes.push(...all);
|
|
30423
|
+
view.kept.set(id, []);
|
|
30301
30424
|
continue;
|
|
30302
30425
|
}
|
|
30303
30426
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
@@ -30315,6 +30438,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30315
30438
|
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;
|
|
30316
30439
|
const kept = [];
|
|
30317
30440
|
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
30441
|
+
view.kept.set(id, kept);
|
|
30442
|
+
if (units2.mortar === part.material) {
|
|
30443
|
+
for (const c of all) if (!kept.includes(c)) castGone.push({ c, part, thick, mid });
|
|
30444
|
+
}
|
|
30318
30445
|
for (const c of kept) shown.push({ c, part, units: units2, thick, mid });
|
|
30319
30446
|
for (const box4 of boxes) {
|
|
30320
30447
|
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;
|
|
@@ -30375,10 +30502,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30375
30502
|
at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
|
|
30376
30503
|
}
|
|
30377
30504
|
}
|
|
30378
|
-
|
|
30379
|
-
|
|
30380
|
-
view.units.dispose();
|
|
30381
|
-
}
|
|
30505
|
+
const lumps = stuckLumps(castGone, mask, view.bounds);
|
|
30506
|
+
if (view.units) dropUnits(view.units);
|
|
30382
30507
|
const units = new THREE.InstancedMesh(unitGeometry, view.unitMaterial, Math.max(1, list2.length));
|
|
30383
30508
|
units.name = "breach:" + view.host;
|
|
30384
30509
|
list2.forEach((u, i) => {
|
|
@@ -30392,6 +30517,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30392
30517
|
units.castShadow = true;
|
|
30393
30518
|
units.receiveShadow = true;
|
|
30394
30519
|
units.visible = lod === 0;
|
|
30520
|
+
if (lumps.length > 0) units.add(lumpMesh(lumps, view.unitMaterial));
|
|
30395
30521
|
house.add(units);
|
|
30396
30522
|
view.units = units;
|
|
30397
30523
|
view.gone = holes.length;
|
|
@@ -30431,9 +30557,77 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30431
30557
|
spalls: new Map(parts.map((id) => [id, []])),
|
|
30432
30558
|
openings: /* @__PURE__ */ new Map(),
|
|
30433
30559
|
flakes: 0,
|
|
30434
|
-
fallen: /* @__PURE__ */ new Set()
|
|
30560
|
+
fallen: /* @__PURE__ */ new Set(),
|
|
30561
|
+
kept: /* @__PURE__ */ new Map()
|
|
30435
30562
|
};
|
|
30436
30563
|
}
|
|
30564
|
+
function stuckLumps(gone, mask, bounds2) {
|
|
30565
|
+
const out = [];
|
|
30566
|
+
const grey = fragmentMaterial("concrete").color.getHex();
|
|
30567
|
+
const stone = (s, y, d, size, r) => {
|
|
30568
|
+
const centre = mask.start + s;
|
|
30569
|
+
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);
|
|
30570
|
+
if (unit) out.push(unit);
|
|
30571
|
+
};
|
|
30572
|
+
for (const { c, part, thick, mid } of gone) {
|
|
30573
|
+
const p0 = (mask.alongU ? part.aabb[0] : part.aabb[1]) - mask.start, p1 = (mask.alongU ? part.aabb[2] : part.aabb[3]) - mask.start;
|
|
30574
|
+
const lying = p1 - p0 > part.y1 - part.y0;
|
|
30575
|
+
const random = (seed) => (n) => {
|
|
30576
|
+
const x = Math.sin(seed + n * 3.3) * 43758.5453;
|
|
30577
|
+
return x - Math.floor(x);
|
|
30578
|
+
};
|
|
30579
|
+
const faces = lying ? [[c.a, 1], [c.b, 2]] : [[c.y0, 1], [c.y1, 2]];
|
|
30580
|
+
for (const [face, f] of faces) {
|
|
30581
|
+
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));
|
|
30582
|
+
if (open) continue;
|
|
30583
|
+
for (let k = 0; k < EDGE_LUMPS; k++) {
|
|
30584
|
+
const r = random(c.a * 63.1 + c.y0 * 29.7 + mid * 17.3 + f * 11.1 + k * 5.3);
|
|
30585
|
+
const size = EDGE_LUMP_MIN + (EDGE_LUMP_MAX - EDGE_LUMP_MIN) * r(1);
|
|
30586
|
+
const d = mid + (r(3) - 0.5) * (thick - 2 * LUMP_BAR_INSET);
|
|
30587
|
+
const s = lying ? face : c.a + (0.1 + 0.8 * r(2)) * (c.b - c.a);
|
|
30588
|
+
const y = lying ? c.y0 + (0.1 + 0.8 * r(2)) * (c.y1 - c.y0) : face;
|
|
30589
|
+
stone(s, y, d, [size, size * (0.6 + 0.5 * r(4)), size], r);
|
|
30590
|
+
}
|
|
30591
|
+
}
|
|
30592
|
+
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);
|
|
30593
|
+
for (const bar2 of bars) {
|
|
30594
|
+
for (const side of [-1, 1]) {
|
|
30595
|
+
const d = mid + side * (thick / 2 - LUMP_BAR_INSET);
|
|
30596
|
+
for (let k = 0; k < LUMPS_PER_BAR; k++) {
|
|
30597
|
+
const r = random(bar2 * 91.7 + d * 47.3 + c.y0 * 113.1 + c.a * 19.9 + k * 7.9);
|
|
30598
|
+
if (r(1) > LUMP_CHANCE) continue;
|
|
30599
|
+
const at2 = 0.15 + 0.7 * r(2), jitter = (r(6) - 0.5) * 0.02;
|
|
30600
|
+
const s = lying ? c.a + at2 * (c.b - c.a) : bar2 + jitter;
|
|
30601
|
+
const y = lying ? bar2 + jitter : c.y0 + at2 * (c.y1 - c.y0);
|
|
30602
|
+
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);
|
|
30603
|
+
}
|
|
30604
|
+
}
|
|
30605
|
+
}
|
|
30606
|
+
}
|
|
30607
|
+
return out;
|
|
30608
|
+
}
|
|
30609
|
+
function dropUnits(units) {
|
|
30610
|
+
for (const child of [...units.children]) if (child instanceof THREE.InstancedMesh) child.dispose();
|
|
30611
|
+
units.removeFromParent();
|
|
30612
|
+
units.dispose();
|
|
30613
|
+
}
|
|
30614
|
+
function lumpMesh(lumps, material) {
|
|
30615
|
+
const mesh2 = new THREE.InstancedMesh(lumpGeometry(), material, lumps.length);
|
|
30616
|
+
mesh2.name = "breach-lumps";
|
|
30617
|
+
lumps.forEach((u, i) => {
|
|
30618
|
+
const r = (n) => {
|
|
30619
|
+
const x = Math.sin(u.x * 71.3 + u.y * 37.9 + u.z * 53.1 + n * 9.7) * 43758.5453;
|
|
30620
|
+
return x - Math.floor(x);
|
|
30621
|
+
};
|
|
30622
|
+
tmp.q.setFromEuler(new THREE.Euler(r(1) * Math.PI, r(2) * Math.PI, r(3) * Math.PI));
|
|
30623
|
+
tmp.m.compose(tmp.p.set(u.x, u.y, u.z), tmp.q, tmp.s.set(u.sx, u.sy, u.sz));
|
|
30624
|
+
mesh2.setMatrixAt(i, tmp.m);
|
|
30625
|
+
mesh2.setColorAt(i, tmp.c.setHex(u.colour));
|
|
30626
|
+
});
|
|
30627
|
+
mesh2.castShadow = true;
|
|
30628
|
+
mesh2.receiveShadow = true;
|
|
30629
|
+
return mesh2;
|
|
30630
|
+
}
|
|
30437
30631
|
function cut(view) {
|
|
30438
30632
|
if (view.saved) return;
|
|
30439
30633
|
view.shells = view.items.map((it) => shell(it, view.mask));
|
|
@@ -30518,10 +30712,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30518
30712
|
paintQueues.add(queue);
|
|
30519
30713
|
function dispose(view) {
|
|
30520
30714
|
dirty.delete(view);
|
|
30521
|
-
if (view.units)
|
|
30522
|
-
view.units.removeFromParent();
|
|
30523
|
-
view.units.dispose();
|
|
30524
|
-
}
|
|
30715
|
+
if (view.units) dropUnits(view.units);
|
|
30525
30716
|
view.unitMaterial.dispose();
|
|
30526
30717
|
for (const m of view.shells) {
|
|
30527
30718
|
m.removeFromParent();
|
|
@@ -30532,6 +30723,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30532
30723
|
view.core.texture.dispose();
|
|
30533
30724
|
}
|
|
30534
30725
|
return {
|
|
30726
|
+
/**
|
|
30727
|
+
* What still stands of the units of `partId` once its wall is cut, as drawn: spans along the wall from `start` (in the house's space, along u when
|
|
30728
|
+
* `alongU`) and up. Null while the wall is whole (all of the part stands).
|
|
30729
|
+
*/
|
|
30730
|
+
standing(partId) {
|
|
30731
|
+
const hostId = hostOf(partId), view = hostId ? views.get(hostId) : void 0;
|
|
30732
|
+
const spans = view?.saved ? view.kept.get(partId) : void 0;
|
|
30733
|
+
return view && spans ? { spans, alongU: view.mask.alongU, start: view.mask.start } : null;
|
|
30734
|
+
},
|
|
30535
30735
|
/** Handles a `stage` event of the house's object. Returns true when the wall was cut. */
|
|
30536
30736
|
stage(event) {
|
|
30537
30737
|
return event.stage === 2 && !!event.opening ? draw(event.part, { opening: event.opening }) : false;
|
|
@@ -30926,13 +31126,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30926
31126
|
breach.flush(Infinity);
|
|
30927
31127
|
}, FOLLOW_FLUSH_FALLBACK_MS);
|
|
30928
31128
|
});
|
|
31129
|
+
const holders = /* @__PURE__ */ new Map();
|
|
31130
|
+
const holderOf = (pid) => {
|
|
31131
|
+
const known = holders.get(pid) ?? id;
|
|
31132
|
+
if (world.part(known, pid)) return known;
|
|
31133
|
+
for (const other of world.ids()) if (world.part(other, pid)) {
|
|
31134
|
+
holders.set(pid, other);
|
|
31135
|
+
return other;
|
|
31136
|
+
}
|
|
31137
|
+
return null;
|
|
31138
|
+
};
|
|
31139
|
+
const at2 = new THREE.Vector3(), turn = new THREE.Quaternion();
|
|
31140
|
+
const inSpec = (objectId, x, y, z) => {
|
|
31141
|
+
const o = world.state(objectId);
|
|
31142
|
+
if (!o) return null;
|
|
31143
|
+
const r = o.rotation;
|
|
31144
|
+
return at2.set(x - o.position[0], y - o.position[1], z - o.position[2]).applyQuaternion(turn.set(r[0], r[1], r[2], r[3]).invert());
|
|
31145
|
+
};
|
|
31146
|
+
const blocks = (x, z, radius, y0, y1) => {
|
|
31147
|
+
for (const part of structure.parts) {
|
|
31148
|
+
const holder = holderOf(part.id), state = holder ? world.part(holder, part.id) : null;
|
|
31149
|
+
if (!holder || !state || state.status !== "intact" && state.status !== "damaged" && state.status !== "collapsed") continue;
|
|
31150
|
+
const low = inSpec(holder, x, y0, z);
|
|
31151
|
+
if (!low) continue;
|
|
31152
|
+
const ly0 = low.y, high = inSpec(holder, x, y1, z), ly1 = high.y, lx = high.x, lz = high.z;
|
|
31153
|
+
if (part.y1 <= Math.min(ly0, ly1) || part.y0 >= Math.max(ly0, ly1)) continue;
|
|
31154
|
+
const [u0, v0, u1, v1] = part.aabb, du = Math.max(u0 - lx, 0, lx - u1), dv = Math.max(v0 - lz, 0, lz - v1);
|
|
31155
|
+
if (du * du + dv * dv >= radius * radius) continue;
|
|
31156
|
+
const left = breach.standing(part.id);
|
|
31157
|
+
if (!left) return true;
|
|
31158
|
+
const s0 = (left.alongU ? lx : lz) - left.start;
|
|
31159
|
+
if (left.spans.some((c) => c.b > s0 - radius && c.a < s0 + radius && c.y1 > Math.min(ly0, ly1) && c.y0 < Math.max(ly0, ly1))) return true;
|
|
31160
|
+
}
|
|
31161
|
+
return false;
|
|
31162
|
+
};
|
|
31163
|
+
const owns = (objectId) => objectId === id || [...holders.values()].includes(objectId);
|
|
30929
31164
|
return { restore: () => breach.restore(), dispose: () => {
|
|
30930
31165
|
offFollow();
|
|
30931
31166
|
breach.restore();
|
|
30932
31167
|
breach.release();
|
|
30933
31168
|
}, update: () => {
|
|
30934
31169
|
breach.flush();
|
|
30935
|
-
} };
|
|
31170
|
+
}, blocks, owns };
|
|
30936
31171
|
};
|
|
30937
31172
|
D.piece = (id) => D.active ? D.world.part(D.id, id) : null;
|
|
30938
31173
|
D.state = () => D.active ? D.world.state(D.id) : null;
|