@adatechnology/game-weapons-three 0.21.2 → 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/{chunk-7WOQSHOL.js → chunk-O5SQTNFW.js} +19 -6
- package/dist/chunk-O5SQTNFW.js.map +1 -0
- package/dist/index.global.js +297 -43
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-7WOQSHOL.js.map +0 -1
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;
|
|
@@ -67866,9 +68013,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67866
68013
|
});
|
|
67867
68014
|
}
|
|
67868
68015
|
function placementOf(entry2) {
|
|
68016
|
+
const carrier = entry2.carrier;
|
|
68017
|
+
if (carrier) return { origin: carrier.origin, anchor: entry2.anchor, yaw: entry2.yaw, carrier, ...carrier.orientation ? { orientation: carrier.orientation } : {} };
|
|
67869
68018
|
const origin = entry2.follow ? [entry2.origin[0] + positionOf2(entry2.follow)[0], entry2.origin[1] + positionOf2(entry2.follow)[1], entry2.origin[2] + positionOf2(entry2.follow)[2]] : entry2.origin;
|
|
67870
68019
|
return { origin, anchor: entry2.anchor, yaw: entry2.yaw, ...entry2.orientation ? { orientation: entry2.orientation } : {} };
|
|
67871
68020
|
}
|
|
68021
|
+
function moveCarrier(entry2) {
|
|
68022
|
+
const pose = entry2.track?.();
|
|
68023
|
+
if (!pose || !entry2.carrier) return;
|
|
68024
|
+
entry2.carrier.origin = [pose.point[0], pose.point[1], pose.point[2]];
|
|
68025
|
+
if (pose.orientation) entry2.carrier.orientation = pose.orientation;
|
|
68026
|
+
}
|
|
67872
68027
|
function drawing(entry2, action) {
|
|
67873
68028
|
const context = engine.context;
|
|
67874
68029
|
const shared3 = context.random;
|
|
@@ -67894,7 +68049,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67894
68049
|
anchor: def.anchor ?? ORIGIN5,
|
|
67895
68050
|
yaw: yawOf(heading, playOptions.direction),
|
|
67896
68051
|
orientation: playOptions.orientation,
|
|
67897
|
-
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
|
|
68052
|
+
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
|
|
68053
|
+
track: playOptions.track,
|
|
68054
|
+
carrier: playOptions.track ? { origin: point, orientation: playOptions.orientation } : void 0
|
|
67898
68055
|
};
|
|
67899
68056
|
playing.push(entry2);
|
|
67900
68057
|
drawing(
|
|
@@ -67916,11 +68073,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67916
68073
|
for (let index = playing.length - 1; index >= 0; index--) {
|
|
67917
68074
|
const entry2 = playing[index];
|
|
67918
68075
|
const instance = entry2.instance;
|
|
68076
|
+
moveCarrier(entry2);
|
|
67919
68077
|
instance.setup = { ...instance.setup, placement: placementOf(entry2) };
|
|
67920
68078
|
drawing(entry2, () => instance.step(dt));
|
|
67921
68079
|
if (instance.time >= entry2.seconds) playing.splice(index, 1);
|
|
67922
68080
|
}
|
|
67923
68081
|
},
|
|
68082
|
+
retrack() {
|
|
68083
|
+
let tracked = false;
|
|
68084
|
+
for (const entry2 of playing) {
|
|
68085
|
+
if (!entry2.carrier) continue;
|
|
68086
|
+
moveCarrier(entry2);
|
|
68087
|
+
tracked = true;
|
|
68088
|
+
}
|
|
68089
|
+
return tracked;
|
|
68090
|
+
},
|
|
67924
68091
|
clear() {
|
|
67925
68092
|
playing.length = 0;
|
|
67926
68093
|
},
|
|
@@ -69532,6 +69699,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69532
69699
|
}
|
|
69533
69700
|
}
|
|
69534
69701
|
};
|
|
69702
|
+
function rotate(q, v) {
|
|
69703
|
+
const [qx, qy, qz, qw] = q;
|
|
69704
|
+
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
69705
|
+
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
69706
|
+
const iz = qw * v[2] + qx * v[1] - qy * v[0];
|
|
69707
|
+
const iw = -qx * v[0] - qy * v[1] - qz * v[2];
|
|
69708
|
+
return [ix * qw + iw * -qx + iy * -qz - iz * -qy, iy * qw + iw * -qy + iz * -qx - ix * -qz, iz * qw + iw * -qz + ix * -qy - iy * -qx];
|
|
69709
|
+
}
|
|
69710
|
+
function carriedPoint(carried) {
|
|
69711
|
+
const { carrier, local: local2 } = carried;
|
|
69712
|
+
const turned = carrier.orientation ? rotate(carrier.orientation, local2) : local2;
|
|
69713
|
+
return [carrier.origin[0] + turned[0], carrier.origin[1] + turned[1], carrier.origin[2] + turned[2]];
|
|
69714
|
+
}
|
|
69535
69715
|
var CAPACITY3 = 400;
|
|
69536
69716
|
var IDENTITY2 = [0, 0, 0, 1];
|
|
69537
69717
|
function multiply2(a, b) {
|
|
@@ -69549,7 +69729,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69549
69729
|
get count() {
|
|
69550
69730
|
return this.particles.length;
|
|
69551
69731
|
}
|
|
69552
|
-
spawn(options, frame2 = IDENTITY2) {
|
|
69732
|
+
spawn(options, frame2 = IDENTITY2, carried) {
|
|
69553
69733
|
const velocity = options.v ?? [0, 0, 0];
|
|
69554
69734
|
const world = options.wv ?? [0, 0, 0];
|
|
69555
69735
|
const particle = {
|
|
@@ -69566,6 +69746,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69566
69746
|
y: options.p[1],
|
|
69567
69747
|
z: options.p[2],
|
|
69568
69748
|
frame: options.roll ? multiply2(frame2, aboutX(options.roll)) : frame2,
|
|
69749
|
+
roll: options.roll ? aboutX(options.roll) : void 0,
|
|
69750
|
+
carried,
|
|
69751
|
+
drift: [0, 0, 0],
|
|
69569
69752
|
at: options.at ?? [0, 0, 0],
|
|
69570
69753
|
rx: options.rot?.[0] ?? 0,
|
|
69571
69754
|
ry: options.rot?.[1] ?? 0,
|
|
@@ -69606,9 +69789,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69606
69789
|
particle.vy *= keep;
|
|
69607
69790
|
particle.vz *= keep;
|
|
69608
69791
|
}
|
|
69609
|
-
particle.
|
|
69610
|
-
|
|
69611
|
-
|
|
69792
|
+
if (particle.carried) this.ride(particle, dt);
|
|
69793
|
+
else {
|
|
69794
|
+
particle.x += particle.vx * dt;
|
|
69795
|
+
particle.y += particle.vy * dt;
|
|
69796
|
+
particle.z += particle.vz * dt;
|
|
69797
|
+
}
|
|
69612
69798
|
particle.rx += particle.spin[0] * dt;
|
|
69613
69799
|
particle.ry += particle.spin[1] * dt;
|
|
69614
69800
|
particle.rz += particle.spin[2] * dt;
|
|
@@ -69619,6 +69805,30 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69619
69805
|
clear() {
|
|
69620
69806
|
this.particles.length = 0;
|
|
69621
69807
|
}
|
|
69808
|
+
/** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
|
|
69809
|
+
follow() {
|
|
69810
|
+
for (const particle of this.particles) if (particle.carried) this.place(particle);
|
|
69811
|
+
}
|
|
69812
|
+
/** A carried piece: how far its own velocity took it, then its place on the carrier. */
|
|
69813
|
+
ride(particle, dt) {
|
|
69814
|
+
const drift = particle.drift;
|
|
69815
|
+
drift[0] += particle.vx * dt;
|
|
69816
|
+
drift[1] += particle.vy * dt;
|
|
69817
|
+
drift[2] += particle.vz * dt;
|
|
69818
|
+
this.place(particle);
|
|
69819
|
+
}
|
|
69820
|
+
/** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
|
|
69821
|
+
place(particle) {
|
|
69822
|
+
const carried = particle.carried;
|
|
69823
|
+
if (!carried) return;
|
|
69824
|
+
const drift = particle.drift;
|
|
69825
|
+
const [x, y, z] = carriedPoint(carried);
|
|
69826
|
+
particle.x = x + drift[0];
|
|
69827
|
+
particle.y = y + drift[1];
|
|
69828
|
+
particle.z = z + drift[2];
|
|
69829
|
+
const turn2 = carried.carrier.orientation;
|
|
69830
|
+
if (turn2) particle.frame = particle.roll ? multiply2(turn2, particle.roll) : turn2;
|
|
69831
|
+
}
|
|
69622
69832
|
};
|
|
69623
69833
|
var DEFAULT_FADE_IN = 0.1;
|
|
69624
69834
|
var FLOATS_PER_VECTOR = 3;
|
|
@@ -69979,8 +70189,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69979
70189
|
}
|
|
69980
70190
|
flash(point, color2, intensity, duration, distance4, force, steady) {
|
|
69981
70191
|
const { level } = this.context.quality;
|
|
69982
|
-
if (level >= 1 && !force) return;
|
|
69983
|
-
if (level >= 2 && force !== "boom") return;
|
|
70192
|
+
if (level >= 1 && !force) return void 0;
|
|
70193
|
+
if (level >= 2 && force !== "boom") return void 0;
|
|
69984
70194
|
const light = this.lights[this.next++ % LIGHT_CAPACITY];
|
|
69985
70195
|
light.x = point[0];
|
|
69986
70196
|
light.y = point[1];
|
|
@@ -69992,17 +70202,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69992
70202
|
light.t = 0;
|
|
69993
70203
|
light.steady = steady === true;
|
|
69994
70204
|
light.intensity = intensity;
|
|
70205
|
+
light.carried = void 0;
|
|
70206
|
+
return light;
|
|
69995
70207
|
}
|
|
69996
70208
|
clear() {
|
|
69997
70209
|
for (const light of this.lights) light.intensity = 0;
|
|
69998
70210
|
for (const light of this.fire) light.intensity = 0;
|
|
69999
70211
|
}
|
|
70212
|
+
/** Puts every carried light that burns where its carrier is now. */
|
|
70213
|
+
follow() {
|
|
70214
|
+
for (const light of this.lights) if (light.intensity > 0 && light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
70215
|
+
}
|
|
70000
70216
|
update(dt) {
|
|
70001
70217
|
for (const light of this.lights) {
|
|
70002
70218
|
if (light.intensity <= 0) continue;
|
|
70003
70219
|
light.t += dt;
|
|
70004
70220
|
const age = light.t / light.duration;
|
|
70005
70221
|
light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
|
|
70222
|
+
if (light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
70006
70223
|
}
|
|
70007
70224
|
}
|
|
70008
70225
|
};
|
|
@@ -70010,7 +70227,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70010
70227
|
var FIRE_FLICKER_SWAY = 0.25;
|
|
70011
70228
|
var FIRE_FLICKER_JITTER = 0.08;
|
|
70012
70229
|
var LENS_FADE = 0.16;
|
|
70013
|
-
function
|
|
70230
|
+
function rotate2(q, v) {
|
|
70014
70231
|
const [qx, qy, qz, qw] = q;
|
|
70015
70232
|
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
70016
70233
|
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
@@ -70067,7 +70284,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70067
70284
|
if (!placement) return point;
|
|
70068
70285
|
const { anchor, origin, yaw, orientation } = placement;
|
|
70069
70286
|
if (orientation) {
|
|
70070
|
-
const turned =
|
|
70287
|
+
const turned = rotate2(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
|
|
70071
70288
|
return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
|
|
70072
70289
|
}
|
|
70073
70290
|
const x = point[0] - anchor[0];
|
|
@@ -70076,11 +70293,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70076
70293
|
const sin2 = Math.sin(yaw);
|
|
70077
70294
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
70078
70295
|
}
|
|
70296
|
+
/** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
|
|
70297
|
+
local(point) {
|
|
70298
|
+
const placement = this.placement;
|
|
70299
|
+
if (!placement) return point;
|
|
70300
|
+
const offset = [point[0] - placement.anchor[0], point[1] - placement.anchor[1], point[2] - placement.anchor[2]];
|
|
70301
|
+
if (placement.carrier?.orientation) return offset;
|
|
70302
|
+
const turned = this.place(point);
|
|
70303
|
+
return [turned[0] - placement.origin[0], turned[1] - placement.origin[1], turned[2] - placement.origin[2]];
|
|
70304
|
+
}
|
|
70079
70305
|
/** A direction or velocity of the recipe's space in the world. */
|
|
70080
70306
|
turn(vector2) {
|
|
70081
70307
|
const placement = this.placement;
|
|
70082
70308
|
if (!placement) return vector2;
|
|
70083
|
-
if (placement.orientation) return
|
|
70309
|
+
if (placement.orientation) return rotate2(placement.orientation, vector2);
|
|
70084
70310
|
const cos2 = Math.cos(placement.yaw);
|
|
70085
70311
|
const sin2 = Math.sin(placement.yaw);
|
|
70086
70312
|
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
@@ -70115,7 +70341,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70115
70341
|
const options = placement ? { ...recipe2, p: this.place(recipe2.p), ...recipe2.v ? { v: this.turn(recipe2.v) } : {} } : recipe2;
|
|
70116
70342
|
this.context.trace?.("mesh", [options]);
|
|
70117
70343
|
const grouped = recipe2.at !== void 0 || recipe2.roll !== void 0;
|
|
70118
|
-
|
|
70344
|
+
const carried = placement?.carrier && grouped ? { carrier: placement.carrier, local: this.local(recipe2.p) } : void 0;
|
|
70345
|
+
return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0, carried);
|
|
70119
70346
|
}
|
|
70120
70347
|
debrisPiece(recipe2) {
|
|
70121
70348
|
const options = this.placed(recipe2);
|
|
@@ -70139,9 +70366,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70139
70366
|
}
|
|
70140
70367
|
/** `steady` (a seventh number): the light holds its intensity for its duration and goes out, where the Workshop's fades with the square of its age. */
|
|
70141
70368
|
flash(recipe2) {
|
|
70142
|
-
const
|
|
70369
|
+
const placement = this.placement;
|
|
70370
|
+
const args = placement ? [this.place(recipe2[0]), recipe2[1], recipe2[2], recipe2[3], recipe2[4], recipe2[5], recipe2[6]] : recipe2;
|
|
70143
70371
|
this.context.trace?.("flash", args.slice(0, 6));
|
|
70144
|
-
this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
70372
|
+
const light = this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
70373
|
+
if (light && placement?.carrier) light.carried = { carrier: placement.carrier, local: this.local(recipe2[0]) };
|
|
70145
70374
|
}
|
|
70146
70375
|
/** `fireLight` (W400): sways with the clock and flickers with one draw. */
|
|
70147
70376
|
fireLight(slot, recipe2, intensity, time) {
|
|
@@ -70300,6 +70529,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70300
70529
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
70301
70530
|
return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
|
|
70302
70531
|
},
|
|
70532
|
+
follow() {
|
|
70533
|
+
if (!engine || !player?.retrack()) return false;
|
|
70534
|
+
engine.meshes.follow();
|
|
70535
|
+
engine.lights.follow();
|
|
70536
|
+
return true;
|
|
70537
|
+
},
|
|
70303
70538
|
burst: (kind, point, normal, count, speed, spriteOptions) => spriteSystem.burst(kind, point, normal, count, speed, spriteOptions),
|
|
70304
70539
|
spawn: (kind, point, velocity, spriteOptions) => spriteSystem.spawn(kind, point, velocity, spriteOptions),
|
|
70305
70540
|
onLand: (owner, listener) => spriteSystem.onLand(owner, listener),
|
|
@@ -70448,7 +70683,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70448
70683
|
};
|
|
70449
70684
|
}
|
|
70450
70685
|
|
|
70451
|
-
// ../game-vfx-three/dist/chunk-
|
|
70686
|
+
// ../game-vfx-three/dist/chunk-HJXLYDNY.js
|
|
70452
70687
|
var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
|
|
70453
70688
|
void main(){vec3 R=vec3(viewMatrix[0][0],viewMatrix[1][0],viewMatrix[2][0]);vec3 Up=vec3(viewMatrix[0][1],viewMatrix[1][1],viewMatrix[2][1]);
|
|
70454
70689
|
vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
|
|
@@ -71883,7 +72118,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71883
72118
|
...request.orientation ? { orientation: request.orientation } : {},
|
|
71884
72119
|
...request.seed !== void 0 ? { seed: request.seed } : {},
|
|
71885
72120
|
...request.param !== void 0 ? { param: request.param } : {},
|
|
71886
|
-
...request.values ? { values: request.values } : {}
|
|
72121
|
+
...request.values ? { values: request.values } : {},
|
|
72122
|
+
...request.track ? { track: request.track } : {}
|
|
71887
72123
|
});
|
|
71888
72124
|
},
|
|
71889
72125
|
stop: (handle) => world.stop(handle),
|
|
@@ -71912,6 +72148,11 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71912
72148
|
syncAll();
|
|
71913
72149
|
overlay?.update(screenNow());
|
|
71914
72150
|
},
|
|
72151
|
+
present() {
|
|
72152
|
+
if (!world.follow()) return;
|
|
72153
|
+
lights.sync();
|
|
72154
|
+
workshopLayers?.sync();
|
|
72155
|
+
},
|
|
71915
72156
|
warmUpProbes() {
|
|
71916
72157
|
releaseAnchors();
|
|
71917
72158
|
marks.prepare();
|
|
@@ -71965,9 +72206,13 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71965
72206
|
const seed = () => 1 + Math.floor(random() * 2147483646);
|
|
71966
72207
|
const barrel = (orientation) => vec3(new THREE.Vector3(1, 0, 0).applyQuaternion(orientation));
|
|
71967
72208
|
return {
|
|
71968
|
-
muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless) {
|
|
72209
|
+
muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless, track) {
|
|
71969
72210
|
if (profile.puffs <= 0 && profile.flash <= 0) return;
|
|
71970
|
-
|
|
72211
|
+
const follow = track ? () => {
|
|
72212
|
+
const pose = track();
|
|
72213
|
+
return pose ? { point: vec3(pose.position), orientation: quaternion(pose.orientation) } : null;
|
|
72214
|
+
} : void 0;
|
|
72215
|
+
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.flash, point: vec3(position), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed(), values: { size, ...profile }, ...follow ? { track: follow } : {} });
|
|
71971
72216
|
},
|
|
71972
72217
|
smoke(position, velocity, size, life, opacity) {
|
|
71973
72218
|
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec3(position), seed: seed(), values: { vx: velocity.x, vy: velocity.y, vz: velocity.z, radius: size, life, opacity } });
|
|
@@ -72360,17 +72605,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
72360
72605
|
particles.spawn(round5.group, toWorld2(session, vector2(-0.2, 1.1, 1.2)), { kind: "round", life: 25, radius: round5.radius, bounce: 0.3, spin: vector2(8, 12, 6), onRest: restFlat, ownsGeometry: true });
|
|
72361
72606
|
} else ejectFromPort(false);
|
|
72362
72607
|
};
|
|
72608
|
+
const trackOf = (mark) => () => root.parent ? { position: positionOf3(mark), orientation: root.getWorldQuaternion(new THREE.Quaternion()) } : null;
|
|
72363
72609
|
return (event) => {
|
|
72364
72610
|
const data = event.data ?? {};
|
|
72365
72611
|
switch (event.type) {
|
|
72366
72612
|
case "muzzle_flash":
|
|
72367
72613
|
if (data.at === "ugl") {
|
|
72368
|
-
|
|
72614
|
+
const ugl = parts.uglMuzzle;
|
|
72615
|
+
if (ugl && world.layers.muzzleFlash) world.afterPose(() => effects.muzzleFlash(positionOf3(ugl), root.getWorldQuaternion(new THREE.Quaternion()), UGL_FLASH, void 0, trackOf(ugl)));
|
|
72369
72616
|
} else if (parts.muzzle && world.layers.muzzleFlash && (session.def.action.kind === "firearm" || session.def.action.kind === "launcher")) {
|
|
72370
72617
|
const profile = muzzleSmokeOf({ caliber: session.caliber, weapon: session.def, suppressed: session.suppressed });
|
|
72371
72618
|
const size = session.def.action.kind === "launcher" ? 2.2 : FLASH_BY_CASE[session.caseType];
|
|
72372
72619
|
const muzzle2 = parts.muzzle;
|
|
72373
|
-
world.afterPose(() => effects.muzzleFlash(positionOf3(muzzle2), root.getWorldQuaternion(new THREE.Quaternion()), size, profile));
|
|
72620
|
+
world.afterPose(() => effects.muzzleFlash(positionOf3(muzzle2), root.getWorldQuaternion(new THREE.Quaternion()), size, profile, trackOf(muzzle2)));
|
|
72374
72621
|
}
|
|
72375
72622
|
break;
|
|
72376
72623
|
case "eject_casing":
|
|
@@ -72959,11 +73206,17 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
72959
73206
|
play: (request) => {
|
|
72960
73207
|
if (!lens2 || !request.point) return worldSink.play(request);
|
|
72961
73208
|
const at4 = toWorldLens(camera2, lensPoint.set(...request.point), worldFovOf(), lens2.fov);
|
|
72962
|
-
|
|
73209
|
+
const track = request.track;
|
|
73210
|
+
return worldSink.play({ ...request, point: [at4.x, at4.y, at4.z], ...track ? { track: () => seenThroughLens(track()) } : {} });
|
|
72963
73211
|
},
|
|
72964
73212
|
stop: (handle) => worldSink.stop(handle)
|
|
72965
73213
|
} : void 0;
|
|
72966
73214
|
const effects = createEffects(THREE, lensSink, random);
|
|
73215
|
+
function seenThroughLens(pose) {
|
|
73216
|
+
if (!pose || !lens2) return pose;
|
|
73217
|
+
const at4 = toWorldLens(camera2, trackPoint.set(...pose.point), worldFovOf(), lens2.fov);
|
|
73218
|
+
return { ...pose, point: [at4.x, at4.y, at4.z] };
|
|
73219
|
+
}
|
|
72967
73220
|
const hand = new THREE.Group();
|
|
72968
73221
|
hand.name = VIEWMODEL_NODE_NAME;
|
|
72969
73222
|
scene.add(hand);
|
|
@@ -73130,6 +73383,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
73130
73383
|
let lens2 = null;
|
|
73131
73384
|
let lensLayer = -1;
|
|
73132
73385
|
const lensPoint = new THREE.Vector3();
|
|
73386
|
+
const trackPoint = new THREE.Vector3();
|
|
73133
73387
|
const worldFovOf = () => camera2.fov ?? 72;
|
|
73134
73388
|
const setLens = (kind) => {
|
|
73135
73389
|
const fov = kind ? VIEW_HOLD[kind].fov : null;
|