@adatechnology/game-items-three 0.8.2 → 0.8.3
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 +170 -23
- 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
|
|
@@ -16163,6 +16163,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
16163
16163
|
var MEMBER_CRATER_CALIBRES = 3.4;
|
|
16164
16164
|
var MEMBER_BARED_MAX = 24;
|
|
16165
16165
|
var MEMBER_CUT_LOSS = 0.9;
|
|
16166
|
+
var MEMBER_UNIT_LOSS = 0.25;
|
|
16166
16167
|
var BLAST_EDGE_WEAR = 0.6;
|
|
16167
16168
|
var RESIDUAL_CAPACITY = 0.15;
|
|
16168
16169
|
var SEVER_BAND = 0.1;
|
|
@@ -18164,6 +18165,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18164
18165
|
const faceArea = (cell) => cell.size[u] * cell.size[v];
|
|
18165
18166
|
const total = cells.reduce((sum, cell) => sum + faceArea(cell), 0) || 1;
|
|
18166
18167
|
const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
|
|
18168
|
+
const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
|
|
18167
18169
|
return cells.map((cell, i) => {
|
|
18168
18170
|
const cw = toWorld(c, q, cell.center);
|
|
18169
18171
|
const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
@@ -18182,7 +18184,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18182
18184
|
angularVelocity: [(rnd() - 0.5) * 8, (rnd() - 0.5) * 8, (rnd() - 0.5) * 8],
|
|
18183
18185
|
mass: mass * faceArea(cell) / total,
|
|
18184
18186
|
...marks.length > 0 ? { marks } : {},
|
|
18185
|
-
...inner ? { inner } : {}
|
|
18187
|
+
...inner && laid ? { unit: true } : inner ? { inner } : {}
|
|
18186
18188
|
};
|
|
18187
18189
|
});
|
|
18188
18190
|
};
|
|
@@ -18258,10 +18260,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18258
18260
|
if (!cells?.length) return false;
|
|
18259
18261
|
const [u, v] = planeAxes(p.thin);
|
|
18260
18262
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
18263
|
+
if (p.spec.reinforcement && isMember(p.dims) && !p.st.stripped) {
|
|
18264
|
+
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
18265
|
+
const bands = Math.max(1, Math.round(p.dims[along] / MEMBER_BAND));
|
|
18266
|
+
const band = clamp2(Math.floor((lp[along] + p.dims[along] / 2) / p.dims[along] * bands), 0, bands - 1);
|
|
18267
|
+
if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
|
|
18268
|
+
}
|
|
18261
18269
|
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
18270
|
};
|
|
18263
18271
|
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
18264
|
-
var _a, _b;
|
|
18272
|
+
var _a, _b, _c, _d;
|
|
18265
18273
|
if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
|
|
18266
18274
|
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
18267
18275
|
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
@@ -18293,19 +18301,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
18293
18301
|
exposeRebar(o, p, src);
|
|
18294
18302
|
}
|
|
18295
18303
|
}
|
|
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
18304
|
const grid = gridOf(p);
|
|
18301
|
-
const gone = p.rt.chips ?? {};
|
|
18305
|
+
const gone = (_c = p.rt).chips ?? (_c.chips = {});
|
|
18306
|
+
if (before >= MEMBER_CUT_LOSS || after < MEMBER_CUT_LOSS) {
|
|
18307
|
+
if (h <= REBAR_COVER) return true;
|
|
18308
|
+
const [u, v] = planeAxes(p.thin);
|
|
18309
|
+
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
|
+
if (hit < 0) return true;
|
|
18311
|
+
const wear = (_d = p.rt).cellWear ?? (_d.cellWear = {});
|
|
18312
|
+
const cell = grid[hit];
|
|
18313
|
+
wear[hit] = (wear[hit] ?? 0) + volume;
|
|
18314
|
+
if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
|
|
18315
|
+
return true;
|
|
18316
|
+
}
|
|
18302
18317
|
const out = [];
|
|
18303
18318
|
for (let i = 0; i < grid.length; i++) {
|
|
18304
18319
|
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);
|
|
18320
|
+
if (Math.abs(grid[i].center[along] - bandCenter) <= height / 2 + 1e-6) out.push(i);
|
|
18309
18321
|
}
|
|
18310
18322
|
if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
|
|
18311
18323
|
giveAtCut(o, p, src);
|
|
@@ -23532,7 +23544,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23532
23544
|
}
|
|
23533
23545
|
var residentialTower = residentialTowerTemplate();
|
|
23534
23546
|
|
|
23535
|
-
// ../game-floorplan-three/dist/chunk-
|
|
23547
|
+
// ../game-floorplan-three/dist/chunk-HDRFS5H2.js
|
|
23536
23548
|
var __defProp3 = Object.defineProperty;
|
|
23537
23549
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
23538
23550
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -30071,6 +30083,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30071
30083
|
var SPALL_MIN = 0.025;
|
|
30072
30084
|
var SPALL_RAGGED = 0.045;
|
|
30073
30085
|
var COVER2 = 0.015;
|
|
30086
|
+
var LUMP_BAR_INSET = 0.035;
|
|
30087
|
+
var LUMPS_PER_BAR = 2;
|
|
30088
|
+
var LUMP_CHANCE = 0.6;
|
|
30089
|
+
var LUMP_MIN = 0.025;
|
|
30090
|
+
var LUMP_MAX = 0.05;
|
|
30091
|
+
var EDGE_LUMPS = 3;
|
|
30092
|
+
var EDGE_LUMP_MIN = 0.04;
|
|
30093
|
+
var EDGE_LUMP_MAX = 0.08;
|
|
30074
30094
|
var MAX_FLAKES = 64;
|
|
30075
30095
|
function clipToBox(unit, box4) {
|
|
30076
30096
|
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 +30136,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30116
30136
|
const dropped = [];
|
|
30117
30137
|
let lod = 0;
|
|
30118
30138
|
const unitGeometry = new THREE.BoxGeometry(1, 1, 1);
|
|
30139
|
+
let lumpShape = null;
|
|
30140
|
+
const lumpGeometry = () => {
|
|
30141
|
+
if (lumpShape) return lumpShape;
|
|
30142
|
+
const g = new THREE.IcosahedronGeometry(0.62, 0).toNonIndexed();
|
|
30143
|
+
const at2 = g.getAttribute("position");
|
|
30144
|
+
const moved = /* @__PURE__ */ new Map();
|
|
30145
|
+
for (let i = 0; i < at2.count; i++) {
|
|
30146
|
+
const key2 = `${at2.getX(i).toFixed(3)},${at2.getY(i).toFixed(3)},${at2.getZ(i).toFixed(3)}`;
|
|
30147
|
+
let k = moved.get(key2);
|
|
30148
|
+
if (k === void 0) {
|
|
30149
|
+
const x = Math.sin(moved.size * 12.9898 + 4.1) * 43758.5453;
|
|
30150
|
+
k = 0.7 + 0.45 * (x - Math.floor(x));
|
|
30151
|
+
moved.set(key2, k);
|
|
30152
|
+
}
|
|
30153
|
+
at2.setXYZ(i, at2.getX(i) * k, at2.getY(i) * k * 0.85, at2.getZ(i) * k);
|
|
30154
|
+
}
|
|
30155
|
+
g.computeVertexNormals();
|
|
30156
|
+
lumpShape = g;
|
|
30157
|
+
return g;
|
|
30158
|
+
};
|
|
30119
30159
|
const tmp = { m: new THREE.Matrix4(), q: new THREE.Quaternion(), p: new THREE.Vector3(), s: new THREE.Vector3(), c: new THREE.Color() };
|
|
30120
30160
|
const local = (p) => {
|
|
30121
30161
|
house.updateMatrixWorld(true);
|
|
@@ -30291,6 +30331,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30291
30331
|
const discs = [];
|
|
30292
30332
|
const flakes = [];
|
|
30293
30333
|
const shown = [];
|
|
30334
|
+
const castGone = [];
|
|
30294
30335
|
const pillars = pillarSpans(view);
|
|
30295
30336
|
for (const id of view.parts) {
|
|
30296
30337
|
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 +30339,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30298
30339
|
const all = id === view.host ? own.flatMap((c) => besidePillars(c, pillars)) : own;
|
|
30299
30340
|
if (view.fallen.has(id)) {
|
|
30300
30341
|
holes.push(...all);
|
|
30342
|
+
view.kept.set(id, []);
|
|
30301
30343
|
continue;
|
|
30302
30344
|
}
|
|
30303
30345
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
@@ -30315,6 +30357,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30315
30357
|
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
30358
|
const kept = [];
|
|
30317
30359
|
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
30360
|
+
view.kept.set(id, kept);
|
|
30361
|
+
if (units2.mortar === part.material) {
|
|
30362
|
+
for (const c of all) if (!kept.includes(c)) castGone.push({ c, part, thick, mid });
|
|
30363
|
+
}
|
|
30318
30364
|
for (const c of kept) shown.push({ c, part, units: units2, thick, mid });
|
|
30319
30365
|
for (const box4 of boxes) {
|
|
30320
30366
|
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 +30421,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30375
30421
|
at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
|
|
30376
30422
|
}
|
|
30377
30423
|
}
|
|
30378
|
-
|
|
30379
|
-
|
|
30380
|
-
view.units.dispose();
|
|
30381
|
-
}
|
|
30424
|
+
const lumps = stuckLumps(castGone, mask, view.bounds);
|
|
30425
|
+
if (view.units) dropUnits(view.units);
|
|
30382
30426
|
const units = new THREE.InstancedMesh(unitGeometry, view.unitMaterial, Math.max(1, list2.length));
|
|
30383
30427
|
units.name = "breach:" + view.host;
|
|
30384
30428
|
list2.forEach((u, i) => {
|
|
@@ -30392,6 +30436,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30392
30436
|
units.castShadow = true;
|
|
30393
30437
|
units.receiveShadow = true;
|
|
30394
30438
|
units.visible = lod === 0;
|
|
30439
|
+
if (lumps.length > 0) units.add(lumpMesh(lumps, view.unitMaterial));
|
|
30395
30440
|
house.add(units);
|
|
30396
30441
|
view.units = units;
|
|
30397
30442
|
view.gone = holes.length;
|
|
@@ -30431,9 +30476,70 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30431
30476
|
spalls: new Map(parts.map((id) => [id, []])),
|
|
30432
30477
|
openings: /* @__PURE__ */ new Map(),
|
|
30433
30478
|
flakes: 0,
|
|
30434
|
-
fallen: /* @__PURE__ */ new Set()
|
|
30479
|
+
fallen: /* @__PURE__ */ new Set(),
|
|
30480
|
+
kept: /* @__PURE__ */ new Map()
|
|
30435
30481
|
};
|
|
30436
30482
|
}
|
|
30483
|
+
function stuckLumps(gone, mask, bounds2) {
|
|
30484
|
+
const out = [];
|
|
30485
|
+
const grey = fragmentMaterial("concrete").color.getHex();
|
|
30486
|
+
for (const { c, part, thick, mid } of gone) {
|
|
30487
|
+
const p0 = (mask.alongU ? part.aabb[0] : part.aabb[1]) - mask.start, p1 = (mask.alongU ? part.aabb[2] : part.aabb[3]) - mask.start;
|
|
30488
|
+
for (const [edge, k0] of [[c.y0, 0], [c.y1, 4]]) {
|
|
30489
|
+
for (let k = k0; k < k0 + EDGE_LUMPS; k++) {
|
|
30490
|
+
const r = (n) => {
|
|
30491
|
+
const x = Math.sin(c.a * 63.1 + edge * 29.7 + mid * 17.3 + k * 5.3 + n * 2.9) * 43758.5453;
|
|
30492
|
+
return x - Math.floor(x);
|
|
30493
|
+
};
|
|
30494
|
+
const size = EDGE_LUMP_MIN + (EDGE_LUMP_MAX - EDGE_LUMP_MIN) * r(1);
|
|
30495
|
+
const centre = mask.start + c.a + (0.1 + 0.8 * r(2)) * (c.b - c.a), d = mid + (r(3) - 0.5) * (thick - 2 * LUMP_BAR_INSET);
|
|
30496
|
+
const unit = clipToBox({ x: mask.alongU ? centre : d, y: edge, z: mask.alongU ? d : centre, sx: size, sy: size * (0.6 + 0.5 * r(4)), sz: size, colour: tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(5)).getHex() }, bounds2);
|
|
30497
|
+
if (unit) out.push(unit);
|
|
30498
|
+
}
|
|
30499
|
+
}
|
|
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 s of bars) {
|
|
30502
|
+
for (const side of [-1, 1]) {
|
|
30503
|
+
const d = mid + side * (thick / 2 - LUMP_BAR_INSET);
|
|
30504
|
+
for (let k = 0; k < LUMPS_PER_BAR; k++) {
|
|
30505
|
+
const r = (n) => {
|
|
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
|
+
};
|
|
30509
|
+
if (r(1) > LUMP_CHANCE) continue;
|
|
30510
|
+
const y = c.y0 + (0.15 + 0.7 * r(2)) * (c.y1 - c.y0);
|
|
30511
|
+
const sa = LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(3), sy = LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(4), sd = LUMP_MIN + (LUMP_MAX - LUMP_MIN) * r(5);
|
|
30512
|
+
const centre = mask.start + s + (r(6) - 0.5) * 0.02;
|
|
30513
|
+
const unit = clipToBox({ x: mask.alongU ? centre : d, y, z: mask.alongU ? d : centre, sx: mask.alongU ? sa : sd, sy, sz: mask.alongU ? sd : sa, colour: tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex() }, bounds2);
|
|
30514
|
+
if (unit) out.push(unit);
|
|
30515
|
+
}
|
|
30516
|
+
}
|
|
30517
|
+
}
|
|
30518
|
+
}
|
|
30519
|
+
return out;
|
|
30520
|
+
}
|
|
30521
|
+
function dropUnits(units) {
|
|
30522
|
+
for (const child of [...units.children]) if (child instanceof THREE.InstancedMesh) child.dispose();
|
|
30523
|
+
units.removeFromParent();
|
|
30524
|
+
units.dispose();
|
|
30525
|
+
}
|
|
30526
|
+
function lumpMesh(lumps, material) {
|
|
30527
|
+
const mesh2 = new THREE.InstancedMesh(lumpGeometry(), material, lumps.length);
|
|
30528
|
+
mesh2.name = "breach-lumps";
|
|
30529
|
+
lumps.forEach((u, i) => {
|
|
30530
|
+
const r = (n) => {
|
|
30531
|
+
const x = Math.sin(u.x * 71.3 + u.y * 37.9 + u.z * 53.1 + n * 9.7) * 43758.5453;
|
|
30532
|
+
return x - Math.floor(x);
|
|
30533
|
+
};
|
|
30534
|
+
tmp.q.setFromEuler(new THREE.Euler(r(1) * Math.PI, r(2) * Math.PI, r(3) * Math.PI));
|
|
30535
|
+
tmp.m.compose(tmp.p.set(u.x, u.y, u.z), tmp.q, tmp.s.set(u.sx, u.sy, u.sz));
|
|
30536
|
+
mesh2.setMatrixAt(i, tmp.m);
|
|
30537
|
+
mesh2.setColorAt(i, tmp.c.setHex(u.colour));
|
|
30538
|
+
});
|
|
30539
|
+
mesh2.castShadow = true;
|
|
30540
|
+
mesh2.receiveShadow = true;
|
|
30541
|
+
return mesh2;
|
|
30542
|
+
}
|
|
30437
30543
|
function cut(view) {
|
|
30438
30544
|
if (view.saved) return;
|
|
30439
30545
|
view.shells = view.items.map((it) => shell(it, view.mask));
|
|
@@ -30518,10 +30624,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30518
30624
|
paintQueues.add(queue);
|
|
30519
30625
|
function dispose(view) {
|
|
30520
30626
|
dirty.delete(view);
|
|
30521
|
-
if (view.units)
|
|
30522
|
-
view.units.removeFromParent();
|
|
30523
|
-
view.units.dispose();
|
|
30524
|
-
}
|
|
30627
|
+
if (view.units) dropUnits(view.units);
|
|
30525
30628
|
view.unitMaterial.dispose();
|
|
30526
30629
|
for (const m of view.shells) {
|
|
30527
30630
|
m.removeFromParent();
|
|
@@ -30532,6 +30635,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30532
30635
|
view.core.texture.dispose();
|
|
30533
30636
|
}
|
|
30534
30637
|
return {
|
|
30638
|
+
/**
|
|
30639
|
+
* 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
|
|
30640
|
+
* `alongU`) and up. Null while the wall is whole (all of the part stands).
|
|
30641
|
+
*/
|
|
30642
|
+
standing(partId) {
|
|
30643
|
+
const hostId = hostOf(partId), view = hostId ? views.get(hostId) : void 0;
|
|
30644
|
+
const spans = view?.saved ? view.kept.get(partId) : void 0;
|
|
30645
|
+
return view && spans ? { spans, alongU: view.mask.alongU, start: view.mask.start } : null;
|
|
30646
|
+
},
|
|
30535
30647
|
/** Handles a `stage` event of the house's object. Returns true when the wall was cut. */
|
|
30536
30648
|
stage(event) {
|
|
30537
30649
|
return event.stage === 2 && !!event.opening ? draw(event.part, { opening: event.opening }) : false;
|
|
@@ -30926,13 +31038,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30926
31038
|
breach.flush(Infinity);
|
|
30927
31039
|
}, FOLLOW_FLUSH_FALLBACK_MS);
|
|
30928
31040
|
});
|
|
31041
|
+
const holders = /* @__PURE__ */ new Map();
|
|
31042
|
+
const holderOf = (pid) => {
|
|
31043
|
+
const known = holders.get(pid) ?? id;
|
|
31044
|
+
if (world.part(known, pid)) return known;
|
|
31045
|
+
for (const other of world.ids()) if (world.part(other, pid)) {
|
|
31046
|
+
holders.set(pid, other);
|
|
31047
|
+
return other;
|
|
31048
|
+
}
|
|
31049
|
+
return null;
|
|
31050
|
+
};
|
|
31051
|
+
const at2 = new THREE.Vector3(), turn = new THREE.Quaternion();
|
|
31052
|
+
const inSpec = (objectId, x, y, z) => {
|
|
31053
|
+
const o = world.state(objectId);
|
|
31054
|
+
if (!o) return null;
|
|
31055
|
+
const r = o.rotation;
|
|
31056
|
+
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());
|
|
31057
|
+
};
|
|
31058
|
+
const blocks = (x, z, radius, y0, y1) => {
|
|
31059
|
+
for (const part of structure.parts) {
|
|
31060
|
+
const holder = holderOf(part.id), state = holder ? world.part(holder, part.id) : null;
|
|
31061
|
+
if (!holder || !state || state.status !== "intact" && state.status !== "damaged" && state.status !== "collapsed") continue;
|
|
31062
|
+
const low = inSpec(holder, x, y0, z);
|
|
31063
|
+
if (!low) continue;
|
|
31064
|
+
const ly0 = low.y, high = inSpec(holder, x, y1, z), ly1 = high.y, lx = high.x, lz = high.z;
|
|
31065
|
+
if (part.y1 <= Math.min(ly0, ly1) || part.y0 >= Math.max(ly0, ly1)) continue;
|
|
31066
|
+
const [u0, v0, u1, v1] = part.aabb, du = Math.max(u0 - lx, 0, lx - u1), dv = Math.max(v0 - lz, 0, lz - v1);
|
|
31067
|
+
if (du * du + dv * dv >= radius * radius) continue;
|
|
31068
|
+
const left = breach.standing(part.id);
|
|
31069
|
+
if (!left) return true;
|
|
31070
|
+
const s0 = (left.alongU ? lx : lz) - left.start;
|
|
31071
|
+
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;
|
|
31072
|
+
}
|
|
31073
|
+
return false;
|
|
31074
|
+
};
|
|
31075
|
+
const owns = (objectId) => objectId === id || [...holders.values()].includes(objectId);
|
|
30929
31076
|
return { restore: () => breach.restore(), dispose: () => {
|
|
30930
31077
|
offFollow();
|
|
30931
31078
|
breach.restore();
|
|
30932
31079
|
breach.release();
|
|
30933
31080
|
}, update: () => {
|
|
30934
31081
|
breach.flush();
|
|
30935
|
-
} };
|
|
31082
|
+
}, blocks, owns };
|
|
30936
31083
|
};
|
|
30937
31084
|
D.piece = (id) => D.active ? D.world.part(D.id, id) : null;
|
|
30938
31085
|
D.state = () => D.active ? D.world.state(D.id) : null;
|