@adatechnology/game-weapons-three 0.29.0 → 0.29.2
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 +171 -31
- package/dist/index.global.js.map +1 -1
- package/package.json +12 -12
package/dist/index.global.js
CHANGED
|
@@ -17281,7 +17281,8 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
17281
17281
|
seconds: 0.7
|
|
17282
17282
|
}
|
|
17283
17283
|
],
|
|
17284
|
-
reset: 1.2
|
|
17284
|
+
reset: 1.2,
|
|
17285
|
+
contactLength: 0.3
|
|
17285
17286
|
},
|
|
17286
17287
|
{
|
|
17287
17288
|
id: "two_hand_swing",
|
|
@@ -25009,6 +25010,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25009
25010
|
var THIN_SHEET_CRUSH = 5e-4;
|
|
25010
25011
|
var THIN_SHEET_CONTACT = 0.025;
|
|
25011
25012
|
var DMG_PER_J = 0.02;
|
|
25013
|
+
var THROW_SPREAD = 0.6;
|
|
25012
25014
|
var FRAGMENT_RAYS = 256;
|
|
25013
25015
|
var FRAGMENT_MAX_WEIGHT = 8;
|
|
25014
25016
|
var SHELTER_DEFAULTS = { k: 2800, brokenTransmission: 0.5, minPath: 5e-3 };
|
|
@@ -25052,6 +25054,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25052
25054
|
var MASONRY_CRUMBLE_SPEED = 0.6;
|
|
25053
25055
|
var MASONRY_TOPPLE = 0.4;
|
|
25054
25056
|
var MASONRY_TOPPLE_MIN_HEIGHT = 0.5;
|
|
25057
|
+
var SPIN_REACH = 0.1;
|
|
25058
|
+
var bornSpin = (size, chipSpin, rnd2) => {
|
|
25059
|
+
const reach2 = Math.hypot(size[0] ?? 0, size[1] ?? 0, size[2] ?? 0) / 2;
|
|
25060
|
+
const scale = reach2 <= SPIN_REACH ? 1 : SPIN_REACH / reach2;
|
|
25061
|
+
return [(rnd2() - 0.5) * chipSpin * scale, (rnd2() - 0.5) * chipSpin * scale, (rnd2() - 0.5) * chipSpin * scale];
|
|
25062
|
+
};
|
|
25055
25063
|
var TILE_CLUMPS = 160;
|
|
25056
25064
|
var TILE_THICKNESS = 0.018;
|
|
25057
25065
|
var PANEL_EDGE_PILLAR = 2;
|
|
@@ -27667,7 +27675,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27667
27675
|
size: [cell.size[0], cell.size[1], cell.size[2]],
|
|
27668
27676
|
rotation: q,
|
|
27669
27677
|
velocity: [dv[0] * k, dv[1] * k + 0.5 * rnd2(), dv[2] * k],
|
|
27670
|
-
angularVelocity:
|
|
27678
|
+
angularVelocity: bornSpin(cell.size, 8, rnd2),
|
|
27671
27679
|
mass: mass * faceArea(cell) / total,
|
|
27672
27680
|
...marks.length > 0 ? { marks } : {},
|
|
27673
27681
|
...inner && laid ? { unit: true } : inner ? { inner } : {}
|
|
@@ -27706,7 +27714,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27706
27714
|
size,
|
|
27707
27715
|
rotation: q,
|
|
27708
27716
|
velocity: [out0[0] * k, out0[1] * k + 0.5 * rnd2(), out0[2] * k],
|
|
27709
|
-
angularVelocity:
|
|
27717
|
+
angularVelocity: bornSpin(size, 12, rnd2),
|
|
27710
27718
|
mass: layer3.mat.density * size[0] * size[1] * size[2]
|
|
27711
27719
|
});
|
|
27712
27720
|
}
|
|
@@ -28032,7 +28040,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28032
28040
|
size,
|
|
28033
28041
|
rotation: q,
|
|
28034
28042
|
velocity: [vdir[0] * k, vdir[1] * k + 0.5 * rnd2(), vdir[2] * k],
|
|
28035
|
-
angularVelocity:
|
|
28043
|
+
angularVelocity: bornSpin(size, 20, rnd2),
|
|
28036
28044
|
mass: mass / n,
|
|
28037
28045
|
inner: true
|
|
28038
28046
|
});
|
|
@@ -28207,9 +28215,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28207
28215
|
at4[p.thin] = Math.sign(lp[p.thin]) * p.dims[p.thin] / 2;
|
|
28208
28216
|
const r = vec.distance(toWorld(p.pos, p.q, at4), centre);
|
|
28209
28217
|
const side = sideOnOverpressure(tnt, r);
|
|
28210
|
-
const
|
|
28218
|
+
const reflected2 = 2 * side + 6 * side * side / (side + 7 * 101325);
|
|
28211
28219
|
const impulse = bodyImpulse(tnt, r);
|
|
28212
|
-
if (
|
|
28220
|
+
if (reflected2 > PANEL_PRESSURE && impulse > PANEL_IMPULSE && (reflected2 - PANEL_PRESSURE) * (impulse - PANEL_IMPULSE) >= PANEL_PI) loaded++;
|
|
28213
28221
|
}
|
|
28214
28222
|
if (loaded < PANEL_POINTS_LOADED) return false;
|
|
28215
28223
|
const grid = gridOf(p);
|
|
@@ -28379,6 +28387,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28379
28387
|
loosened(o, opened, "break", src);
|
|
28380
28388
|
collapseCheck(o, src);
|
|
28381
28389
|
};
|
|
28390
|
+
const thrownAlong = (out, dir) => {
|
|
28391
|
+
const across2 = vec.madd(out, dir, -vec.dot(out, dir));
|
|
28392
|
+
return vec.normalize(vec.madd(dir, [across2[0], 0, across2[2]], THROW_SPREAD), dir);
|
|
28393
|
+
};
|
|
28382
28394
|
const failPart = (o, p, origin, dir, fragEnergy, cap, src, force) => {
|
|
28383
28395
|
if (isLost(p)) return;
|
|
28384
28396
|
if (p.st.stripped) {
|
|
@@ -28426,7 +28438,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28426
28438
|
const fragments = plan.map((f, i) => {
|
|
28427
28439
|
const cw = toWorld(c, q, f.center);
|
|
28428
28440
|
const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
|
|
28429
|
-
const dv = dir ?
|
|
28441
|
+
const dv = dir ? thrownAlong(out, dir) : out;
|
|
28430
28442
|
const k = speed * (0.6 + 0.8 * rnd2());
|
|
28431
28443
|
const marks = marksInBox(f.center, f.size, f.q, holes);
|
|
28432
28444
|
return {
|
|
@@ -28438,7 +28450,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28438
28450
|
size: f.size,
|
|
28439
28451
|
rotation: quat.mul(q, f.q),
|
|
28440
28452
|
velocity: [dv[0] * k, dv[1] * k + 0.5 * rnd2(), dv[2] * k],
|
|
28441
|
-
angularVelocity:
|
|
28453
|
+
angularVelocity: bornSpin(f.size, 12, rnd2),
|
|
28442
28454
|
mass: mass * f.weight / totW,
|
|
28443
28455
|
...marks.length > 0 ? { marks } : {},
|
|
28444
28456
|
...f.inner ? { inner: true } : {}
|
|
@@ -28577,7 +28589,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28577
28589
|
rotation: q,
|
|
28578
28590
|
velocity: v,
|
|
28579
28591
|
inner: true,
|
|
28580
|
-
angularVelocity:
|
|
28592
|
+
angularVelocity: bornSpin(size, 30, rnd2),
|
|
28581
28593
|
mass
|
|
28582
28594
|
});
|
|
28583
28595
|
}
|
|
@@ -53193,7 +53205,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
53193
53205
|
d: 0.38,
|
|
53194
53206
|
h: 0.3,
|
|
53195
53207
|
y: 0.9,
|
|
53196
|
-
solid:
|
|
53208
|
+
solid: true,
|
|
53197
53209
|
massKg: 14,
|
|
53198
53210
|
sounds: {
|
|
53199
53211
|
leaves: {
|
|
@@ -54770,12 +54782,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54770
54782
|
const zb = oz + inw * v1;
|
|
54771
54783
|
return { floor: p.floor, x0: ox + u0, x1: ox + u1, z0: Math.min(za, zb), z1: Math.max(za, zb) };
|
|
54772
54784
|
});
|
|
54773
|
-
const
|
|
54785
|
+
const CELL3 = 0.5;
|
|
54774
54786
|
const grid = /* @__PURE__ */ new Map();
|
|
54775
54787
|
const key2 = (a, i, j) => (a * 4096 + (i + 2048)) * 4096 + (j + 2048);
|
|
54776
54788
|
for (const s of segs) {
|
|
54777
|
-
for (let i = Math.floor(s.x0 /
|
|
54778
|
-
for (let j = Math.floor(s.z0 /
|
|
54789
|
+
for (let i = Math.floor(s.x0 / CELL3); i <= Math.floor(s.x1 / CELL3); i++) {
|
|
54790
|
+
for (let j = Math.floor(s.z0 / CELL3); j <= Math.floor(s.z1 / CELL3); j++) {
|
|
54779
54791
|
const k = key2(s.floor, i, j);
|
|
54780
54792
|
if (!grid.has(k)) grid.set(k, []);
|
|
54781
54793
|
grid.get(k).push(s);
|
|
@@ -54784,7 +54796,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54784
54796
|
}
|
|
54785
54797
|
return function blocked(x, z, floor2) {
|
|
54786
54798
|
const a = floor2 == null || floor2 < 0 ? 0 : floor2;
|
|
54787
|
-
const list2 = grid.get(key2(a, Math.floor(x /
|
|
54799
|
+
const list2 = grid.get(key2(a, Math.floor(x / CELL3), Math.floor(z / CELL3)));
|
|
54788
54800
|
if (!list2) return false;
|
|
54789
54801
|
for (const s of list2) if (x > s.x0 && x < s.x1 && z > s.z0 && z < s.z1) return true;
|
|
54790
54802
|
return false;
|
|
@@ -56085,7 +56097,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
56085
56097
|
}
|
|
56086
56098
|
var residentialTower = residentialTowerTemplate();
|
|
56087
56099
|
|
|
56088
|
-
// ../game-floorplan-three/dist/chunk-
|
|
56100
|
+
// ../game-floorplan-three/dist/chunk-OGYLJ4F7.js
|
|
56089
56101
|
var __defProp4 = Object.defineProperty;
|
|
56090
56102
|
var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
56091
56103
|
var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -93152,6 +93164,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93152
93164
|
var QUALITY = { $: "quality" };
|
|
93153
93165
|
var FRESH = { $: "fresh" };
|
|
93154
93166
|
var DIRECTION = { $: "direction" };
|
|
93167
|
+
var NORMAL = { $: "normal" };
|
|
93155
93168
|
var CAMERA_POSITION = { $: "cameraPosition" };
|
|
93156
93169
|
var burst = (system, count, spawn2) => ({ op: "burst", system, count, spawn: spawn2 });
|
|
93157
93170
|
var spawn = (system, options) => ({ op: "spawn", system, spawn: options });
|
|
@@ -93673,7 +93686,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93673
93686
|
var TIP22 = [-0.8, 1.38, 3.4 - 0.78];
|
|
93674
93687
|
var PORT2 = [-0.76, 1.4, 3.32];
|
|
93675
93688
|
var FORWARD3 = [0, 0, -1];
|
|
93676
|
-
var
|
|
93689
|
+
var NORMAL2 = [0, 0, 1];
|
|
93677
93690
|
var WALL_Z2 = -4.45;
|
|
93678
93691
|
var SHOTS = [[0, 0.45, 0.9], [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0], [0]];
|
|
93679
93692
|
var SHOT_TIME = pick2(pick2(SHOTS, PARAM), INDEX);
|
|
@@ -93698,8 +93711,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93698
93711
|
set("target", [add(-0.8, rnd(-0.4, 0.4)), add(1.4, rnd(-0.3, 0.3)), WALL_Z2]),
|
|
93699
93712
|
when(
|
|
93700
93713
|
eq(PARAM, SHOTGUN),
|
|
93701
|
-
[repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2],
|
|
93702
|
-
[call2("impact", "concrete", variable("target"),
|
|
93714
|
+
[repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2], NORMAL2, 0.35))],
|
|
93715
|
+
[call2("impact", "concrete", variable("target"), NORMAL2, ite(eq(PARAM, BARRETT), 2, 1))]
|
|
93703
93716
|
),
|
|
93704
93717
|
when(and(eq(PARAM, AK), eq(mod(round4(mul(SHOT_TIME, 10)), 3), 0)), [spawn("streak", { p: TIP22, dir: FORWARD3, cone: 0, sp: 90, life: 0.09, len: 0.025, c0: 16752704, a: 1 })])
|
|
93705
93718
|
)
|
|
@@ -94882,7 +94895,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94882
94895
|
...DEBRIS_EFFECT_FAMILIES.flatMap((family) => [stageCrack(family), breachDust(family), collapseDust(family)]),
|
|
94883
94896
|
REBAR_EXPOSE
|
|
94884
94897
|
];
|
|
94885
|
-
var FACING5 = [0, 0, 1];
|
|
94886
94898
|
var ORIGIN2 = [0, 0, 0];
|
|
94887
94899
|
var FORWARD4 = [0, 0, -1];
|
|
94888
94900
|
var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
|
|
@@ -94892,7 +94904,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94892
94904
|
team: "weapons",
|
|
94893
94905
|
budget: { particles: 40, decals: 1 },
|
|
94894
94906
|
loop: 2,
|
|
94895
|
-
timeline: [call2("impact", material, ORIGIN2,
|
|
94907
|
+
timeline: [call2("impact", material, ORIGIN2, NORMAL, 1, 0)]
|
|
94896
94908
|
});
|
|
94897
94909
|
var muzzleEffect = (weapon2) => ({
|
|
94898
94910
|
id: `muzzle_${weapon2}`,
|
|
@@ -95094,7 +95106,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
95094
95106
|
};
|
|
95095
95107
|
var VIEWMODEL_EFFECTS = [MUZZLE_FLASH2, SMOKE_PUFF, BACKBLAST, FLAME_JET];
|
|
95096
95108
|
var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
|
|
95109
|
+
var BODYWORK_IMPACT = {
|
|
95110
|
+
id: "impact_bodywork",
|
|
95111
|
+
pageId: "vehicle:impact_bodywork",
|
|
95112
|
+
team: "vehicles",
|
|
95113
|
+
budget: { particles: 80, debris: 20, lights: 1 },
|
|
95114
|
+
loop: 2,
|
|
95115
|
+
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
95116
|
+
};
|
|
95097
95117
|
var VEHICLE_EFFECTS = [
|
|
95118
|
+
BODYWORK_IMPACT,
|
|
95098
95119
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
95099
95120
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
95100
95121
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -95799,6 +95820,46 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
95799
95820
|
return evaluateCall(value.$, args.map((entry2) => resolve(entry2, context)));
|
|
95800
95821
|
}
|
|
95801
95822
|
}
|
|
95823
|
+
var PISTOL_BORE = 9e-3;
|
|
95824
|
+
var BARE_STEEL = 11778236;
|
|
95825
|
+
var DEFAULT_PAINT = 9147290;
|
|
95826
|
+
var DEFAULT_DIRECTION = [0, 0, -1];
|
|
95827
|
+
var MAX_SCALE = 3;
|
|
95828
|
+
var MIN_SCALE = 0.6;
|
|
95829
|
+
function reflected(direction, normal) {
|
|
95830
|
+
const along2 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
95831
|
+
const out = [direction[0] - 2 * along2 * normal[0], direction[1] - 2 * along2 * normal[1], direction[2] - 2 * along2 * normal[2]];
|
|
95832
|
+
const length2 = Math.hypot(out[0], out[1], out[2]);
|
|
95833
|
+
if (length2 < 1e-6 || Math.abs(along2) > 0.98) return normal;
|
|
95834
|
+
return [out[0] / length2, out[1] / length2, out[2] / length2];
|
|
95835
|
+
}
|
|
95836
|
+
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
95837
|
+
function bodyworkHitOf(values) {
|
|
95838
|
+
const raw = Array.isArray(values.direction) ? values.direction : [];
|
|
95839
|
+
const direction = raw.length === 3 && raw.every((entry2) => typeof entry2 === "number" && Number.isFinite(entry2)) ? [raw[0], raw[1], raw[2]] : DEFAULT_DIRECTION;
|
|
95840
|
+
return { direction, bore: numberOr(values.bore, PISTOL_BORE), paint: numberOr(values.paint, DEFAULT_PAINT), metal: numberOr(values.metal, BARE_STEEL) };
|
|
95841
|
+
}
|
|
95842
|
+
function bodyworkScale(bore) {
|
|
95843
|
+
return Math.min(MAX_SCALE, Math.max(MIN_SCALE, bore / PISTOL_BORE));
|
|
95844
|
+
}
|
|
95845
|
+
function bodyworkImpact(engine, point, normal, hit) {
|
|
95846
|
+
const scale = bodyworkScale(hit.bore);
|
|
95847
|
+
const off = reflected(hit.direction, normal);
|
|
95848
|
+
if (engine.quality < 2) {
|
|
95849
|
+
engine.burst("streak", Math.round(14 * scale), { p: point, dir: off, cone: 0.75, sp: [4, 12], life: [0.08, 0.3], len: 0.03, c0: 16774352, c1: 16738840, g: 9.8, gnd: 2 });
|
|
95850
|
+
engine.burst("add", 2, { p: plusScaled(point, normal, 0.01), size: [0.06 * scale, 0.12 * scale], life: 0.05, c0: 16770736, fi: 0 });
|
|
95851
|
+
engine.flash([plusScaled(point, normal, 0.15), 16760432, 1.6 * scale, 0.05, 4]);
|
|
95852
|
+
}
|
|
95853
|
+
const flakes = engine.scaled(Math.round(5 * scale));
|
|
95854
|
+
for (let index = 0; index < flakes; index++) {
|
|
95855
|
+
engine.debrisPiece({ p: point, dir: normal, cone: 0.9, sp: [1.2, 3.5], size: [8e-3 * scale, 12e-4, 6e-3 * scale], k: [0.5, 1.4], c: hit.paint, life: 6, bounce: 0.2 });
|
|
95856
|
+
}
|
|
95857
|
+
const slivers = engine.scaled(Math.round(2 * scale));
|
|
95858
|
+
for (let index = 0; index < slivers; index++) {
|
|
95859
|
+
engine.debrisPiece({ p: point, dir: off, cone: 0.6, sp: [2.5, 6], size: [25e-4, 15e-4, 0.01 * scale], k: [0.6, 1.3], c: hit.metal, life: 6, bounce: 0.35 });
|
|
95860
|
+
}
|
|
95861
|
+
engine.burst("normal", Math.round(6 * scale), { p: point, dir: normal, cone: 0.7, sp: [0.4, 1.4], drag: 2.5, life: [0.4, 0.9], size: [0.03, 0.07], grow: 3, c0: hit.paint, a: 0.45, g: -0.05 });
|
|
95862
|
+
}
|
|
95802
95863
|
var UP12 = [0, 1, 0];
|
|
95803
95864
|
var ZERO2 = [0, 0, 0];
|
|
95804
95865
|
var FULL_TURN_DRAWN = 6.283;
|
|
@@ -95948,9 +96009,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
95948
96009
|
casing: ({ engine }, [port, type]) => casing(engine, port, type),
|
|
95949
96010
|
chips: ({ engine }, [point, direction, count, spread2]) => chips(engine, point, direction, count, spread2),
|
|
95950
96011
|
spark_at: ({ engine }, [point, direction, count, spread2]) => sparkAt(engine, point, direction, count, spread2),
|
|
95951
|
-
rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count)
|
|
96012
|
+
rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count),
|
|
96013
|
+
bodywork_impact: ({ engine }, [point, normal, direction, bore, paint2, metal2]) => bodyworkImpact(engine, point, normal, bodyworkHitOf({ direction, bore, paint: paint2, metal: metal2 }))
|
|
95952
96014
|
};
|
|
95953
|
-
var
|
|
96015
|
+
var DEFAULT_DIRECTION2 = [0, 0, -1];
|
|
95954
96016
|
var DEFAULT_NORMAL = [0, 1, 0];
|
|
95955
96017
|
var SCREEN_FIELDS = {
|
|
95956
96018
|
shake: "shake",
|
|
@@ -96017,7 +96079,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96017
96079
|
return instance().fresh;
|
|
96018
96080
|
},
|
|
96019
96081
|
get direction() {
|
|
96020
|
-
return instance().setup.direction ??
|
|
96082
|
+
return instance().setup.direction ?? DEFAULT_DIRECTION2;
|
|
96021
96083
|
},
|
|
96022
96084
|
get normal() {
|
|
96023
96085
|
return instance().setup.normal ?? DEFAULT_NORMAL;
|
|
@@ -97775,6 +97837,69 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97775
97837
|
addScaled(out, tangentB, sinTilt * Math.sin(phase));
|
|
97776
97838
|
return out;
|
|
97777
97839
|
}
|
|
97840
|
+
var CELL2 = 0.12;
|
|
97841
|
+
var OBSTACLE_BOUNCE = 0.3;
|
|
97842
|
+
var radiusOf = (piece2) => Math.max(piece2.sx, piece2.sz) * 0.5;
|
|
97843
|
+
var thicknessOf2 = (piece2) => Math.min(piece2.sx, piece2.sy, piece2.sz);
|
|
97844
|
+
var cellKey2 = (i, k) => (i + 4096) * 8192 + (k + 4096);
|
|
97845
|
+
var RestingGrid = class {
|
|
97846
|
+
constructor() {
|
|
97847
|
+
__publicField3(this, "cells", /* @__PURE__ */ new Map());
|
|
97848
|
+
}
|
|
97849
|
+
clear() {
|
|
97850
|
+
for (const list2 of this.cells.values()) list2.length = 0;
|
|
97851
|
+
}
|
|
97852
|
+
rebuild(pieces) {
|
|
97853
|
+
this.clear();
|
|
97854
|
+
for (const piece2 of pieces) {
|
|
97855
|
+
if (!piece2.on || !piece2.rest) continue;
|
|
97856
|
+
const key2 = cellKey2(Math.floor(piece2.x / CELL2), Math.floor(piece2.z / CELL2));
|
|
97857
|
+
const list2 = this.cells.get(key2);
|
|
97858
|
+
if (list2) list2.push(piece2);
|
|
97859
|
+
else this.cells.set(key2, [piece2]);
|
|
97860
|
+
}
|
|
97861
|
+
}
|
|
97862
|
+
/** The height a piece at `piece`'s place lands at on the pieces under it (the top of the highest one it overlaps), or `-Infinity` over none. */
|
|
97863
|
+
supportUnder(piece2) {
|
|
97864
|
+
const i = Math.floor(piece2.x / CELL2);
|
|
97865
|
+
const k = Math.floor(piece2.z / CELL2);
|
|
97866
|
+
const reach2 = radiusOf(piece2);
|
|
97867
|
+
let top = -Infinity;
|
|
97868
|
+
for (let di = -1; di <= 1; di++) {
|
|
97869
|
+
for (let dk = -1; dk <= 1; dk++) {
|
|
97870
|
+
for (const other of this.cells.get(cellKey2(i + di, k + dk)) ?? []) {
|
|
97871
|
+
if (other === piece2) continue;
|
|
97872
|
+
if (Math.hypot(other.x - piece2.x, other.z - piece2.z) > reach2 + radiusOf(other)) continue;
|
|
97873
|
+
const otherTop = other.y + thicknessOf2(other) * 0.5;
|
|
97874
|
+
if (otherTop <= piece2.y + thicknessOf2(piece2) * 0.5) top = Math.max(top, otherTop + thicknessOf2(piece2) * 0.5);
|
|
97875
|
+
}
|
|
97876
|
+
}
|
|
97877
|
+
}
|
|
97878
|
+
return top;
|
|
97879
|
+
}
|
|
97880
|
+
};
|
|
97881
|
+
function pushOutOfObstacles(piece2, obstacles) {
|
|
97882
|
+
let moved = false;
|
|
97883
|
+
for (const body of obstacles) {
|
|
97884
|
+
if (piece2.y < body.bottom || piece2.y > body.top) continue;
|
|
97885
|
+
const dx = piece2.x - body.x;
|
|
97886
|
+
const dz = piece2.z - body.z;
|
|
97887
|
+
const distance4 = Math.hypot(dx, dz);
|
|
97888
|
+
const reach2 = body.radius + radiusOf(piece2);
|
|
97889
|
+
if (distance4 >= reach2) continue;
|
|
97890
|
+
const nx = distance4 > 1e-6 ? dx / distance4 : 1;
|
|
97891
|
+
const nz = distance4 > 1e-6 ? dz / distance4 : 0;
|
|
97892
|
+
piece2.x = body.x + nx * reach2;
|
|
97893
|
+
piece2.z = body.z + nz * reach2;
|
|
97894
|
+
const into = piece2.vx * nx + piece2.vz * nz;
|
|
97895
|
+
if (into < 0) {
|
|
97896
|
+
piece2.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
|
|
97897
|
+
piece2.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
|
|
97898
|
+
}
|
|
97899
|
+
moved = true;
|
|
97900
|
+
}
|
|
97901
|
+
return moved;
|
|
97902
|
+
}
|
|
97778
97903
|
var CAPACITY = 500;
|
|
97779
97904
|
var GRAVITY22 = 9.8;
|
|
97780
97905
|
var QUARTER_TURN4 = 1.5708;
|
|
@@ -97795,6 +97920,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97795
97920
|
__publicField3(this, "count", 0);
|
|
97796
97921
|
__publicField3(this, "next", 0);
|
|
97797
97922
|
__publicField3(this, "direction", { x: 0, y: 0, z: 0 });
|
|
97923
|
+
__publicField3(this, "resting", new RestingGrid());
|
|
97798
97924
|
}
|
|
97799
97925
|
spawn(options) {
|
|
97800
97926
|
const random = this.context.random;
|
|
@@ -97832,14 +97958,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97832
97958
|
}
|
|
97833
97959
|
update(dt) {
|
|
97834
97960
|
this.count = 0;
|
|
97961
|
+
const contacts = this.context.debrisContacts;
|
|
97962
|
+
const obstacles = contacts?.obstacles() ?? [];
|
|
97963
|
+
let moving = false;
|
|
97835
97964
|
for (const piece2 of this.pieces) {
|
|
97836
97965
|
if (!piece2.on) continue;
|
|
97837
|
-
this.count++;
|
|
97838
97966
|
piece2.life -= dt;
|
|
97839
|
-
if (piece2.life <= 0)
|
|
97840
|
-
|
|
97841
|
-
|
|
97842
|
-
|
|
97967
|
+
if (piece2.life <= 0) piece2.on = false;
|
|
97968
|
+
else if (!piece2.rest) moving = true;
|
|
97969
|
+
}
|
|
97970
|
+
if (moving && contacts) this.resting.rebuild(this.pieces);
|
|
97971
|
+
else this.resting.clear();
|
|
97972
|
+
for (const piece2 of this.pieces) {
|
|
97973
|
+
if (!piece2.on) continue;
|
|
97974
|
+
this.count++;
|
|
97975
|
+
if (obstacles.length > 0 && pushOutOfObstacles(piece2, obstacles)) piece2.rest = false;
|
|
97843
97976
|
if (!piece2.rest) this.move(piece2, dt);
|
|
97844
97977
|
}
|
|
97845
97978
|
}
|
|
@@ -97855,7 +97988,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97855
97988
|
piece2.rx += piece2.ax * dt;
|
|
97856
97989
|
piece2.ry += piece2.ay * dt;
|
|
97857
97990
|
piece2.rz += piece2.az * dt;
|
|
97858
|
-
const groundHeight = this.context.groundAt(piece2.x, piece2.z) + Math.min(piece2.sx, piece2.sy, piece2.sz) * 0.5;
|
|
97991
|
+
const groundHeight = Math.max(this.context.groundAt(piece2.x, piece2.z) + Math.min(piece2.sx, piece2.sy, piece2.sz) * 0.5, this.resting.supportUnder(piece2));
|
|
97859
97992
|
if (piece2.y >= groundHeight) return;
|
|
97860
97993
|
piece2.y = groundHeight;
|
|
97861
97994
|
piece2.vy *= -piece2.bounce;
|
|
@@ -98477,7 +98610,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98477
98610
|
var FIRE_FLICKER_SWAY = 0.25;
|
|
98478
98611
|
var FIRE_FLICKER_JITTER = 0.08;
|
|
98479
98612
|
var LENS_FADE = 0.16;
|
|
98480
|
-
var FLOOR_NORMAL_Y = 0.9;
|
|
98481
98613
|
function rotate2(q, v) {
|
|
98482
98614
|
const [qx, qy, qz, qw] = q;
|
|
98483
98615
|
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
@@ -98515,6 +98647,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98515
98647
|
this.decals = new DecalPool(this.context);
|
|
98516
98648
|
this.lights = new FlashLightPool(this.context);
|
|
98517
98649
|
}
|
|
98650
|
+
/**
|
|
98651
|
+
* Turns on the touch of the debris pieces (a game's world; the Workshop page's recording has none): they pile on the pieces at rest under them, and the
|
|
98652
|
+
* upright bodies `obstacles` answers (the player, asked once a frame while a piece moves) stop them and push them. `null` turns it off.
|
|
98653
|
+
*/
|
|
98654
|
+
setDebrisContacts(obstacles) {
|
|
98655
|
+
if (obstacles) this.context.debrisContacts = { obstacles };
|
|
98656
|
+
else delete this.context.debrisContacts;
|
|
98657
|
+
}
|
|
98518
98658
|
get random() {
|
|
98519
98659
|
return this.context.random;
|
|
98520
98660
|
}
|
|
@@ -98606,7 +98746,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
98606
98746
|
const [x, y, z] = this.place([recipe2[0], recipe2[1], recipe2[2]]);
|
|
98607
98747
|
const options = recipe2[5];
|
|
98608
98748
|
const normal = options?.n ? this.turn(options.n) : void 0;
|
|
98609
|
-
const onFloor = !normal
|
|
98749
|
+
const onFloor = !normal;
|
|
98610
98750
|
args = [x, onFloor ? this.context.groundAt(x, z) : y, z, recipe2[3], recipe2[4], normal ? { ...options, n: normal } : options];
|
|
98611
98751
|
}
|
|
98612
98752
|
this.context.trace?.("decal", args);
|