@adatechnology/game-weapons-three 0.21.3 → 0.21.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 +170 -23
- package/dist/index.global.js.map +1 -1
- package/package.json +8 -8
package/dist/index.global.js
CHANGED
|
@@ -23965,7 +23965,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
23965
23965
|
ricochetDeg: 10,
|
|
23966
23966
|
hitDebris: "chips",
|
|
23967
23967
|
breakDebris: "dust",
|
|
23968
|
-
visual: { innerColor: 12085567 },
|
|
23968
|
+
visual: { innerColor: 12085567, unitColor: 11031866 },
|
|
23969
23969
|
thermal: {
|
|
23970
23970
|
conductivity: 0.15,
|
|
23971
23971
|
heatCapacity: 2.5
|
|
@@ -24908,6 +24908,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24908
24908
|
var MEMBER_CRATER_CALIBRES = 3.4;
|
|
24909
24909
|
var MEMBER_BARED_MAX = 24;
|
|
24910
24910
|
var MEMBER_CUT_LOSS = 0.9;
|
|
24911
|
+
var MEMBER_UNIT_LOSS = 0.25;
|
|
24911
24912
|
var BLAST_EDGE_WEAR = 0.6;
|
|
24912
24913
|
var RESIDUAL_CAPACITY = 0.15;
|
|
24913
24914
|
var SEVER_BAND = 0.1;
|
|
@@ -26909,6 +26910,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26909
26910
|
const faceArea = (cell) => cell.size[u] * cell.size[v];
|
|
26910
26911
|
const total = cells.reduce((sum2, cell) => sum2 + faceArea(cell), 0) || 1;
|
|
26911
26912
|
const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
|
|
26913
|
+
const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
|
|
26912
26914
|
return cells.map((cell, i) => {
|
|
26913
26915
|
const cw = toWorld(c, q, cell.center);
|
|
26914
26916
|
const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
@@ -26927,7 +26929,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26927
26929
|
angularVelocity: [(rnd2() - 0.5) * 8, (rnd2() - 0.5) * 8, (rnd2() - 0.5) * 8],
|
|
26928
26930
|
mass: mass * faceArea(cell) / total,
|
|
26929
26931
|
...marks.length > 0 ? { marks } : {},
|
|
26930
|
-
...inner ? { inner } : {}
|
|
26932
|
+
...inner && laid ? { unit: true } : inner ? { inner } : {}
|
|
26931
26933
|
};
|
|
26932
26934
|
});
|
|
26933
26935
|
};
|
|
@@ -27003,10 +27005,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27003
27005
|
if (!cells?.length) return false;
|
|
27004
27006
|
const [u, v] = planeAxes(p.thin);
|
|
27005
27007
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
27008
|
+
if (p.spec.reinforcement && isMember(p.dims) && !p.st.stripped) {
|
|
27009
|
+
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
27010
|
+
const bands = Math.max(1, Math.round(p.dims[along] / MEMBER_BAND));
|
|
27011
|
+
const band = clamp2(Math.floor((lp[along] + p.dims[along] / 2) / p.dims[along] * bands), 0, bands - 1);
|
|
27012
|
+
if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
|
|
27013
|
+
}
|
|
27006
27014
|
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);
|
|
27007
27015
|
};
|
|
27008
27016
|
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
27009
|
-
var _a, _b;
|
|
27017
|
+
var _a, _b, _c, _d;
|
|
27010
27018
|
if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
|
|
27011
27019
|
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
27012
27020
|
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
@@ -27038,19 +27046,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27038
27046
|
exposeRebar(o, p, src);
|
|
27039
27047
|
}
|
|
27040
27048
|
}
|
|
27041
|
-
if (before >= MEMBER_CUT_LOSS || after2 < MEMBER_CUT_LOSS) return true;
|
|
27042
|
-
const axisUp = rotateVec(p.q, [0, 0, 0].map((_, k) => k === along ? 1 : 0));
|
|
27043
|
-
const standing = Math.abs(axisUp[1]) > 0.7;
|
|
27044
|
-
const upward = axisUp[1] >= 0 ? 1 : -1;
|
|
27045
27049
|
const grid = gridOf(p);
|
|
27046
|
-
const gone = p.rt.chips ?? {};
|
|
27050
|
+
const gone = (_c = p.rt).chips ?? (_c.chips = {});
|
|
27051
|
+
if (before >= MEMBER_CUT_LOSS || after2 < MEMBER_CUT_LOSS) {
|
|
27052
|
+
if (h <= REBAR_COVER) return true;
|
|
27053
|
+
const [u, v] = planeAxes(p.thin);
|
|
27054
|
+
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);
|
|
27055
|
+
if (hit < 0) return true;
|
|
27056
|
+
const wear = (_d = p.rt).cellWear ?? (_d.cellWear = {});
|
|
27057
|
+
const cell = grid[hit];
|
|
27058
|
+
wear[hit] = (wear[hit] ?? 0) + volume;
|
|
27059
|
+
if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
|
|
27060
|
+
return true;
|
|
27061
|
+
}
|
|
27047
27062
|
const out = [];
|
|
27048
27063
|
for (let i = 0; i < grid.length; i++) {
|
|
27049
27064
|
if (gone[i] === -1) continue;
|
|
27050
|
-
|
|
27051
|
-
const inBand = Math.abs(at4 - bandCenter) <= height / 2 + 1e-6;
|
|
27052
|
-
const above2 = standing && (at4 - bandCenter) * upward > height / 2;
|
|
27053
|
-
if (inBand || above2) out.push(i);
|
|
27065
|
+
if (Math.abs(grid[i].center[along] - bandCenter) <= height / 2 + 1e-6) out.push(i);
|
|
27054
27066
|
}
|
|
27055
27067
|
if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
|
|
27056
27068
|
giveAtCut(o, p, src);
|
|
@@ -32277,7 +32289,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32277
32289
|
}
|
|
32278
32290
|
var residentialTower = residentialTowerTemplate();
|
|
32279
32291
|
|
|
32280
|
-
// ../game-floorplan-three/dist/chunk-
|
|
32292
|
+
// ../game-floorplan-three/dist/chunk-HDRFS5H2.js
|
|
32281
32293
|
var __defProp4 = Object.defineProperty;
|
|
32282
32294
|
var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
32283
32295
|
var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -38816,6 +38828,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38816
38828
|
var SPALL_MIN = 0.025;
|
|
38817
38829
|
var SPALL_RAGGED = 0.045;
|
|
38818
38830
|
var COVER2 = 0.015;
|
|
38831
|
+
var LUMP_BAR_INSET = 0.035;
|
|
38832
|
+
var LUMPS_PER_BAR = 2;
|
|
38833
|
+
var LUMP_CHANCE = 0.6;
|
|
38834
|
+
var LUMP_MIN = 0.025;
|
|
38835
|
+
var LUMP_MAX = 0.05;
|
|
38836
|
+
var EDGE_LUMPS = 3;
|
|
38837
|
+
var EDGE_LUMP_MIN = 0.04;
|
|
38838
|
+
var EDGE_LUMP_MAX = 0.08;
|
|
38819
38839
|
var MAX_FLAKES = 64;
|
|
38820
38840
|
function clipToBox(unit, box5) {
|
|
38821
38841
|
const lo = [Math.max(unit.x - unit.sx / 2, box5[0]), Math.max(unit.y - unit.sy / 2, box5[1]), Math.max(unit.z - unit.sz / 2, box5[2])];
|
|
@@ -38861,6 +38881,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38861
38881
|
const dropped = [];
|
|
38862
38882
|
let lod = 0;
|
|
38863
38883
|
const unitGeometry = new THREE.BoxGeometry(1, 1, 1);
|
|
38884
|
+
let lumpShape = null;
|
|
38885
|
+
const lumpGeometry = () => {
|
|
38886
|
+
if (lumpShape) return lumpShape;
|
|
38887
|
+
const g = new THREE.IcosahedronGeometry(0.62, 0).toNonIndexed();
|
|
38888
|
+
const at4 = g.getAttribute("position");
|
|
38889
|
+
const moved = /* @__PURE__ */ new Map();
|
|
38890
|
+
for (let i = 0; i < at4.count; i++) {
|
|
38891
|
+
const key2 = `${at4.getX(i).toFixed(3)},${at4.getY(i).toFixed(3)},${at4.getZ(i).toFixed(3)}`;
|
|
38892
|
+
let k = moved.get(key2);
|
|
38893
|
+
if (k === void 0) {
|
|
38894
|
+
const x = Math.sin(moved.size * 12.9898 + 4.1) * 43758.5453;
|
|
38895
|
+
k = 0.7 + 0.45 * (x - Math.floor(x));
|
|
38896
|
+
moved.set(key2, k);
|
|
38897
|
+
}
|
|
38898
|
+
at4.setXYZ(i, at4.getX(i) * k, at4.getY(i) * k * 0.85, at4.getZ(i) * k);
|
|
38899
|
+
}
|
|
38900
|
+
g.computeVertexNormals();
|
|
38901
|
+
lumpShape = g;
|
|
38902
|
+
return g;
|
|
38903
|
+
};
|
|
38864
38904
|
const tmp = { m: new THREE.Matrix4(), q: new THREE.Quaternion(), p: new THREE.Vector3(), s: new THREE.Vector3(), c: new THREE.Color() };
|
|
38865
38905
|
const local2 = (p) => {
|
|
38866
38906
|
house.updateMatrixWorld(true);
|
|
@@ -39036,6 +39076,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39036
39076
|
const discs = [];
|
|
39037
39077
|
const flakes = [];
|
|
39038
39078
|
const shown = [];
|
|
39079
|
+
const castGone = [];
|
|
39039
39080
|
const pillars = pillarSpans(view);
|
|
39040
39081
|
for (const id of view.parts) {
|
|
39041
39082
|
const part = structure.byId.get(id), units2 = specOf(id).units, chips2 = view.chips.get(id), opening = view.openings.get(id), spalls = view.spalls.get(id);
|
|
@@ -39043,6 +39084,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39043
39084
|
const all = id === view.host ? own.flatMap((c) => besidePillars(c, pillars)) : own;
|
|
39044
39085
|
if (view.fallen.has(id)) {
|
|
39045
39086
|
holes.push(...all);
|
|
39087
|
+
view.kept.set(id, []);
|
|
39046
39088
|
continue;
|
|
39047
39089
|
}
|
|
39048
39090
|
const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
|
|
@@ -39060,6 +39102,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39060
39102
|
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;
|
|
39061
39103
|
const kept = [];
|
|
39062
39104
|
for (const c of all) (open(c) ? holes : kept).push(c);
|
|
39105
|
+
view.kept.set(id, kept);
|
|
39106
|
+
if (units2.mortar === part.material) {
|
|
39107
|
+
for (const c of all) if (!kept.includes(c)) castGone.push({ c, part, thick, mid });
|
|
39108
|
+
}
|
|
39063
39109
|
for (const c of kept) shown.push({ c, part, units: units2, thick, mid });
|
|
39064
39110
|
for (const box5 of boxes) {
|
|
39065
39111
|
if (holes.some((h) => box5.s0 >= h.a - 1e-4 && box5.s1 <= h.b + 1e-4 && box5.y0 >= h.y0 - 1e-4 && box5.y1 <= h.y1 + 1e-4)) continue;
|
|
@@ -39120,10 +39166,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39120
39166
|
at4(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
|
|
39121
39167
|
}
|
|
39122
39168
|
}
|
|
39123
|
-
|
|
39124
|
-
|
|
39125
|
-
view.units.dispose();
|
|
39126
|
-
}
|
|
39169
|
+
const lumps = stuckLumps(castGone, mask, view.bounds);
|
|
39170
|
+
if (view.units) dropUnits(view.units);
|
|
39127
39171
|
const units = new THREE.InstancedMesh(unitGeometry, view.unitMaterial, Math.max(1, list2.length));
|
|
39128
39172
|
units.name = "breach:" + view.host;
|
|
39129
39173
|
list2.forEach((u, i) => {
|
|
@@ -39137,6 +39181,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39137
39181
|
units.castShadow = true;
|
|
39138
39182
|
units.receiveShadow = true;
|
|
39139
39183
|
units.visible = lod === 0;
|
|
39184
|
+
if (lumps.length > 0) units.add(lumpMesh(lumps, view.unitMaterial));
|
|
39140
39185
|
house.add(units);
|
|
39141
39186
|
view.units = units;
|
|
39142
39187
|
view.gone = holes.length;
|
|
@@ -39176,9 +39221,70 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39176
39221
|
spalls: new Map(parts.map((id) => [id, []])),
|
|
39177
39222
|
openings: /* @__PURE__ */ new Map(),
|
|
39178
39223
|
flakes: 0,
|
|
39179
|
-
fallen: /* @__PURE__ */ new Set()
|
|
39224
|
+
fallen: /* @__PURE__ */ new Set(),
|
|
39225
|
+
kept: /* @__PURE__ */ new Map()
|
|
39180
39226
|
};
|
|
39181
39227
|
}
|
|
39228
|
+
function stuckLumps(gone, mask, bounds2) {
|
|
39229
|
+
const out = [];
|
|
39230
|
+
const grey = fragmentMaterial("concrete").color.getHex();
|
|
39231
|
+
for (const { c, part, thick, mid } of gone) {
|
|
39232
|
+
const p0 = (mask.alongU ? part.aabb[0] : part.aabb[1]) - mask.start, p1 = (mask.alongU ? part.aabb[2] : part.aabb[3]) - mask.start;
|
|
39233
|
+
for (const [edge, k0] of [[c.y0, 0], [c.y1, 4]]) {
|
|
39234
|
+
for (let k = k0; k < k0 + EDGE_LUMPS; k++) {
|
|
39235
|
+
const r = (n) => {
|
|
39236
|
+
const x = Math.sin(c.a * 63.1 + edge * 29.7 + mid * 17.3 + k * 5.3 + n * 2.9) * 43758.5453;
|
|
39237
|
+
return x - Math.floor(x);
|
|
39238
|
+
};
|
|
39239
|
+
const size = EDGE_LUMP_MIN + (EDGE_LUMP_MAX - EDGE_LUMP_MIN) * r(1);
|
|
39240
|
+
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);
|
|
39241
|
+
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);
|
|
39242
|
+
if (unit) out.push(unit);
|
|
39243
|
+
}
|
|
39244
|
+
}
|
|
39245
|
+
const bars = [p0 + LUMP_BAR_INSET, p1 - LUMP_BAR_INSET].filter((s) => s >= c.a - 1e-6 && s <= c.b + 1e-6);
|
|
39246
|
+
for (const s of bars) {
|
|
39247
|
+
for (const side of [-1, 1]) {
|
|
39248
|
+
const d = mid + side * (thick / 2 - LUMP_BAR_INSET);
|
|
39249
|
+
for (let k = 0; k < LUMPS_PER_BAR; k++) {
|
|
39250
|
+
const r = (n) => {
|
|
39251
|
+
const x = Math.sin(s * 91.7 + d * 47.3 + c.y0 * 113.1 + k * 7.9 + n * 3.3) * 43758.5453;
|
|
39252
|
+
return x - Math.floor(x);
|
|
39253
|
+
};
|
|
39254
|
+
if (r(1) > LUMP_CHANCE) continue;
|
|
39255
|
+
const y = c.y0 + (0.15 + 0.7 * r(2)) * (c.y1 - c.y0);
|
|
39256
|
+
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);
|
|
39257
|
+
const centre = mask.start + s + (r(6) - 0.5) * 0.02;
|
|
39258
|
+
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);
|
|
39259
|
+
if (unit) out.push(unit);
|
|
39260
|
+
}
|
|
39261
|
+
}
|
|
39262
|
+
}
|
|
39263
|
+
}
|
|
39264
|
+
return out;
|
|
39265
|
+
}
|
|
39266
|
+
function dropUnits(units) {
|
|
39267
|
+
for (const child of [...units.children]) if (child instanceof THREE.InstancedMesh) child.dispose();
|
|
39268
|
+
units.removeFromParent();
|
|
39269
|
+
units.dispose();
|
|
39270
|
+
}
|
|
39271
|
+
function lumpMesh(lumps, material) {
|
|
39272
|
+
const mesh3 = new THREE.InstancedMesh(lumpGeometry(), material, lumps.length);
|
|
39273
|
+
mesh3.name = "breach-lumps";
|
|
39274
|
+
lumps.forEach((u, i) => {
|
|
39275
|
+
const r = (n) => {
|
|
39276
|
+
const x = Math.sin(u.x * 71.3 + u.y * 37.9 + u.z * 53.1 + n * 9.7) * 43758.5453;
|
|
39277
|
+
return x - Math.floor(x);
|
|
39278
|
+
};
|
|
39279
|
+
tmp.q.setFromEuler(new THREE.Euler(r(1) * Math.PI, r(2) * Math.PI, r(3) * Math.PI));
|
|
39280
|
+
tmp.m.compose(tmp.p.set(u.x, u.y, u.z), tmp.q, tmp.s.set(u.sx, u.sy, u.sz));
|
|
39281
|
+
mesh3.setMatrixAt(i, tmp.m);
|
|
39282
|
+
mesh3.setColorAt(i, tmp.c.setHex(u.colour));
|
|
39283
|
+
});
|
|
39284
|
+
mesh3.castShadow = true;
|
|
39285
|
+
mesh3.receiveShadow = true;
|
|
39286
|
+
return mesh3;
|
|
39287
|
+
}
|
|
39182
39288
|
function cut(view) {
|
|
39183
39289
|
if (view.saved) return;
|
|
39184
39290
|
view.shells = view.items.map((it) => shell(it, view.mask));
|
|
@@ -39263,10 +39369,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39263
39369
|
paintQueues.add(queue);
|
|
39264
39370
|
function dispose(view) {
|
|
39265
39371
|
dirty.delete(view);
|
|
39266
|
-
if (view.units)
|
|
39267
|
-
view.units.removeFromParent();
|
|
39268
|
-
view.units.dispose();
|
|
39269
|
-
}
|
|
39372
|
+
if (view.units) dropUnits(view.units);
|
|
39270
39373
|
view.unitMaterial.dispose();
|
|
39271
39374
|
for (const m of view.shells) {
|
|
39272
39375
|
m.removeFromParent();
|
|
@@ -39277,6 +39380,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39277
39380
|
view.core.texture.dispose();
|
|
39278
39381
|
}
|
|
39279
39382
|
return {
|
|
39383
|
+
/**
|
|
39384
|
+
* 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
|
|
39385
|
+
* `alongU`) and up. Null while the wall is whole (all of the part stands).
|
|
39386
|
+
*/
|
|
39387
|
+
standing(partId) {
|
|
39388
|
+
const hostId = hostOf(partId), view = hostId ? views.get(hostId) : void 0;
|
|
39389
|
+
const spans = view?.saved ? view.kept.get(partId) : void 0;
|
|
39390
|
+
return view && spans ? { spans, alongU: view.mask.alongU, start: view.mask.start } : null;
|
|
39391
|
+
},
|
|
39280
39392
|
/** Handles a `stage` event of the house's object. Returns true when the wall was cut. */
|
|
39281
39393
|
stage(event) {
|
|
39282
39394
|
return event.stage === 2 && !!event.opening ? draw2(event.part, { opening: event.opening }) : false;
|
|
@@ -39671,13 +39783,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39671
39783
|
breach.flush(Infinity);
|
|
39672
39784
|
}, FOLLOW_FLUSH_FALLBACK_MS);
|
|
39673
39785
|
});
|
|
39786
|
+
const holders = /* @__PURE__ */ new Map();
|
|
39787
|
+
const holderOf = (pid) => {
|
|
39788
|
+
const known = holders.get(pid) ?? id;
|
|
39789
|
+
if (world.part(known, pid)) return known;
|
|
39790
|
+
for (const other of world.ids()) if (world.part(other, pid)) {
|
|
39791
|
+
holders.set(pid, other);
|
|
39792
|
+
return other;
|
|
39793
|
+
}
|
|
39794
|
+
return null;
|
|
39795
|
+
};
|
|
39796
|
+
const at4 = new THREE.Vector3(), turn2 = new THREE.Quaternion();
|
|
39797
|
+
const inSpec = (objectId, x, y, z) => {
|
|
39798
|
+
const o = world.state(objectId);
|
|
39799
|
+
if (!o) return null;
|
|
39800
|
+
const r = o.rotation;
|
|
39801
|
+
return at4.set(x - o.position[0], y - o.position[1], z - o.position[2]).applyQuaternion(turn2.set(r[0], r[1], r[2], r[3]).invert());
|
|
39802
|
+
};
|
|
39803
|
+
const blocks = (x, z, radius, y0, y1) => {
|
|
39804
|
+
for (const part of structure.parts) {
|
|
39805
|
+
const holder = holderOf(part.id), state = holder ? world.part(holder, part.id) : null;
|
|
39806
|
+
if (!holder || !state || state.status !== "intact" && state.status !== "damaged" && state.status !== "collapsed") continue;
|
|
39807
|
+
const low = inSpec(holder, x, y0, z);
|
|
39808
|
+
if (!low) continue;
|
|
39809
|
+
const ly0 = low.y, high = inSpec(holder, x, y1, z), ly1 = high.y, lx = high.x, lz = high.z;
|
|
39810
|
+
if (part.y1 <= Math.min(ly0, ly1) || part.y0 >= Math.max(ly0, ly1)) continue;
|
|
39811
|
+
const [u0, v0, u1, v1] = part.aabb, du = Math.max(u0 - lx, 0, lx - u1), dv = Math.max(v0 - lz, 0, lz - v1);
|
|
39812
|
+
if (du * du + dv * dv >= radius * radius) continue;
|
|
39813
|
+
const left = breach.standing(part.id);
|
|
39814
|
+
if (!left) return true;
|
|
39815
|
+
const s0 = (left.alongU ? lx : lz) - left.start;
|
|
39816
|
+
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;
|
|
39817
|
+
}
|
|
39818
|
+
return false;
|
|
39819
|
+
};
|
|
39820
|
+
const owns = (objectId) => objectId === id || [...holders.values()].includes(objectId);
|
|
39674
39821
|
return { restore: () => breach.restore(), dispose: () => {
|
|
39675
39822
|
offFollow();
|
|
39676
39823
|
breach.restore();
|
|
39677
39824
|
breach.release();
|
|
39678
39825
|
}, update: () => {
|
|
39679
39826
|
breach.flush();
|
|
39680
|
-
} };
|
|
39827
|
+
}, blocks, owns };
|
|
39681
39828
|
};
|
|
39682
39829
|
D.piece = (id) => D.active ? D.world.part(D.id, id) : null;
|
|
39683
39830
|
D.state = () => D.active ? D.world.state(D.id) : null;
|