@adatechnology/game-vfx 0.6.0 → 0.8.0
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.d.ts +6 -0
- package/dist/index.global.js +54 -26
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +54 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -710,6 +710,8 @@ interface VfxCore {
|
|
|
710
710
|
forcedLod: number | null;
|
|
711
711
|
};
|
|
712
712
|
groundAt(x: number, z: number): number;
|
|
713
|
+
/** A surface that keeps no mark here (`VfxOptions.marklessAt`). */
|
|
714
|
+
marklessAt?: (x: number, z: number) => boolean;
|
|
713
715
|
emit(request: VfxSideRequest): void;
|
|
714
716
|
}
|
|
715
717
|
|
|
@@ -1650,6 +1652,8 @@ interface VfxOptions {
|
|
|
1650
1652
|
readonly areaCap?: AreaCap | false;
|
|
1651
1653
|
/** Height of the ground for what bounces. Default: the `ground` field, else flat at 0. */
|
|
1652
1654
|
readonly groundAt?: (x: number, z: number) => number;
|
|
1655
|
+
/** A surface that keeps no mark here (water): a blast over it leaves no crater, scorch or rim of rock. */
|
|
1656
|
+
readonly marklessAt?: (x: number, z: number) => boolean;
|
|
1653
1657
|
/** A deformable ground the craters dig into (see `createGroundField`). */
|
|
1654
1658
|
readonly ground?: GroundField;
|
|
1655
1659
|
readonly wind?: Vec3Like;
|
|
@@ -1754,6 +1758,8 @@ interface VfxWorld {
|
|
|
1754
1758
|
screen(): Readonly<ScreenState>;
|
|
1755
1759
|
stats(): VfxStats;
|
|
1756
1760
|
pools(): VfxPoolsView;
|
|
1761
|
+
/** The host's own ground height (`VfxOptions.groundAt`), or undefined when the effects land on the vfx `ground` field: what a renderer lays the scorch and dirt marks on, so they line a crater the host's terrain dug. */
|
|
1762
|
+
readonly hostGroundAt: ((x: number, z: number) => number) | undefined;
|
|
1757
1763
|
/** The live lingering fires, oldest first. */
|
|
1758
1764
|
fires(): readonly Fire[];
|
|
1759
1765
|
/** Hears every mark the moment it is made, and when they are cleared. Returns the function that stops listening. */
|
package/dist/index.global.js
CHANGED
|
@@ -2681,22 +2681,22 @@ var GameVfx = (() => {
|
|
|
2681
2681
|
};
|
|
2682
2682
|
|
|
2683
2683
|
// src/effects/vector-math.ts
|
|
2684
|
-
function normalized(
|
|
2685
|
-
const length = Math.sqrt(
|
|
2684
|
+
function normalized(vector2) {
|
|
2685
|
+
const length = Math.sqrt(vector2[0] * vector2[0] + vector2[1] * vector2[1] + vector2[2] * vector2[2]) || 1;
|
|
2686
2686
|
const inverse = 1 / length;
|
|
2687
|
-
return [
|
|
2687
|
+
return [vector2[0] * inverse, vector2[1] * inverse, vector2[2] * inverse];
|
|
2688
2688
|
}
|
|
2689
|
-
function plus(
|
|
2690
|
-
return [
|
|
2689
|
+
function plus(vector2, x, y, z) {
|
|
2690
|
+
return [vector2[0] + x, vector2[1] + y, vector2[2] + z];
|
|
2691
2691
|
}
|
|
2692
|
-
function scaledBy(
|
|
2693
|
-
return [
|
|
2692
|
+
function scaledBy(vector2, factor) {
|
|
2693
|
+
return [vector2[0] * factor, vector2[1] * factor, vector2[2] * factor];
|
|
2694
2694
|
}
|
|
2695
|
-
function plusScaled(
|
|
2696
|
-
return [
|
|
2695
|
+
function plusScaled(vector2, direction, factor) {
|
|
2696
|
+
return [vector2[0] + direction[0] * factor, vector2[1] + direction[1] * factor, vector2[2] + direction[2] * factor];
|
|
2697
2697
|
}
|
|
2698
|
-
function negated(
|
|
2699
|
-
return [-
|
|
2698
|
+
function negated(vector2) {
|
|
2699
|
+
return [-vector2[0], -vector2[1], -vector2[2]];
|
|
2700
2700
|
}
|
|
2701
2701
|
|
|
2702
2702
|
// src/effects/destruction/door-stages.ts
|
|
@@ -4065,10 +4065,35 @@ var GameVfx = (() => {
|
|
|
4065
4065
|
aliasOf(FUEL_LEAK, "vehicle_leak_ignited", {})
|
|
4066
4066
|
];
|
|
4067
4067
|
|
|
4068
|
+
// src/effects/particles/single-particles.ts
|
|
4069
|
+
var vector = [variable("vx"), variable("vy"), variable("vz")];
|
|
4070
|
+
var range = (name) => [variable(name), variable(name)];
|
|
4071
|
+
var singleParticle = (id, system) => ({
|
|
4072
|
+
id,
|
|
4073
|
+
pageId: `particle:${id}`,
|
|
4074
|
+
team: "world",
|
|
4075
|
+
budget: { particles: 1, lights: 0 },
|
|
4076
|
+
loop: 1e-3,
|
|
4077
|
+
timeline: [
|
|
4078
|
+
spawn(system, {
|
|
4079
|
+
p: [0, 0, 0],
|
|
4080
|
+
v: vector,
|
|
4081
|
+
life: range("life"),
|
|
4082
|
+
size: range("size"),
|
|
4083
|
+
grow: variable("grow"),
|
|
4084
|
+
c0: variable("color"),
|
|
4085
|
+
a: variable("alpha"),
|
|
4086
|
+
g: variable("gravity"),
|
|
4087
|
+
drag: variable("drag")
|
|
4088
|
+
})
|
|
4089
|
+
]
|
|
4090
|
+
});
|
|
4091
|
+
var SINGLE_PARTICLE_EFFECTS = [singleParticle("particle_puff", "normal"), singleParticle("particle_glow", "add"), singleParticle("particle_streak", "streak")];
|
|
4092
|
+
|
|
4068
4093
|
// src/effects/catalog.ts
|
|
4069
4094
|
var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, RAIN_AND_PUDDLES, FOG_AND_ASH, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, HEADLIGHTS_IN_RAIN, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
|
|
4070
4095
|
var WORKSHOP_EFFECTS = Object.fromEntries(ALL_EFFECTS.map((effect) => [effect.id, effect]));
|
|
4071
|
-
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
4096
|
+
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS, ...SINGLE_PARTICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
4072
4097
|
function patchEffects(base, changes) {
|
|
4073
4098
|
const result = { ...base };
|
|
4074
4099
|
for (const [id, change] of Object.entries(changes)) {
|
|
@@ -4777,8 +4802,8 @@ var GameVfx = (() => {
|
|
|
4777
4802
|
var UP12 = [0, 1, 0];
|
|
4778
4803
|
var ZERO = [0, 0, 0];
|
|
4779
4804
|
var FULL_TURN_DRAWN = 6.283;
|
|
4780
|
-
function scaledSizes(
|
|
4781
|
-
return [
|
|
4805
|
+
function scaledSizes(range2, factor) {
|
|
4806
|
+
return [range2[0] * Math.sqrt(factor), range2[1] * Math.sqrt(factor)];
|
|
4782
4807
|
}
|
|
4783
4808
|
function fireEmit(engine, key, dt, centre, radius, factor, options = {}) {
|
|
4784
4809
|
const wind = options.wind ?? ZERO;
|
|
@@ -5856,13 +5881,14 @@ var GameVfx = (() => {
|
|
|
5856
5881
|
function composeAfterEffects(context) {
|
|
5857
5882
|
const { core, def, random, x, y, z } = context;
|
|
5858
5883
|
const mark = def.mark;
|
|
5859
|
-
|
|
5884
|
+
const keepsMarks = !core.marklessAt?.(x, z);
|
|
5885
|
+
if (keepsMarks && mark.crater && mark.dent && y < 1.2) {
|
|
5860
5886
|
core.emit({ type: "crater", x, z, radius: mark.crater, depth: mark.dent });
|
|
5861
5887
|
core.trace?.crater?.(x, z, mark.crater, mark.dent);
|
|
5862
5888
|
addCrater(core.marks, core.ground, random, { x, z, radius: mark.crater, depth: mark.dent, marks: core.layers.mark });
|
|
5863
5889
|
if (core.layers.shrapnel) composeRimDebris(context);
|
|
5864
5890
|
}
|
|
5865
|
-
if (mark.scorch && y < 1.2 && core.layers.mark) {
|
|
5891
|
+
if (keepsMarks && mark.scorch && y < 1.2 && core.layers.mark) {
|
|
5866
5892
|
core.trace?.scorch?.(x, z, mark.scorch);
|
|
5867
5893
|
addScorch(core.marks, random, x, z, mark.scorch);
|
|
5868
5894
|
}
|
|
@@ -6678,9 +6704,9 @@ var GameVfx = (() => {
|
|
|
6678
6704
|
var TWO_PI_ROUNDED = 6.2832;
|
|
6679
6705
|
var WIDE_CONE = 3.1;
|
|
6680
6706
|
var UP13 = [0, 1, 0];
|
|
6681
|
-
function drawRange(random,
|
|
6682
|
-
if (Array.isArray(
|
|
6683
|
-
return
|
|
6707
|
+
function drawRange(random, range2) {
|
|
6708
|
+
if (Array.isArray(range2)) return random.between(range2[0], range2[1]);
|
|
6709
|
+
return range2 || 0;
|
|
6684
6710
|
}
|
|
6685
6711
|
function randomUnit(random, out) {
|
|
6686
6712
|
const up = random.next() * 2 - 1;
|
|
@@ -7464,13 +7490,13 @@ var GameVfx = (() => {
|
|
|
7464
7490
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
7465
7491
|
}
|
|
7466
7492
|
/** A direction or velocity of the recipe's space in the world. */
|
|
7467
|
-
turn(
|
|
7493
|
+
turn(vector2) {
|
|
7468
7494
|
const placement = this.placement;
|
|
7469
|
-
if (!placement) return
|
|
7470
|
-
if (placement.orientation) return rotate(placement.orientation,
|
|
7495
|
+
if (!placement) return vector2;
|
|
7496
|
+
if (placement.orientation) return rotate(placement.orientation, vector2);
|
|
7471
7497
|
const cos2 = Math.cos(placement.yaw);
|
|
7472
7498
|
const sin2 = Math.sin(placement.yaw);
|
|
7473
|
-
return [cos2 *
|
|
7499
|
+
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
7474
7500
|
}
|
|
7475
7501
|
placed(options) {
|
|
7476
7502
|
if (!this.placement) return options;
|
|
@@ -7657,6 +7683,7 @@ var GameVfx = (() => {
|
|
|
7657
7683
|
spawned: { puffs: 0, sparks: 0, chunks: 0, lights: 0 },
|
|
7658
7684
|
clock: { time: 0, lastBlast: -1, lod: 1, forcedLod: null },
|
|
7659
7685
|
groundAt,
|
|
7686
|
+
...options.marklessAt ? { marklessAt: options.marklessAt } : {},
|
|
7660
7687
|
emit: (request) => options.onRequest?.(request)
|
|
7661
7688
|
};
|
|
7662
7689
|
function definitionOf(id) {
|
|
@@ -7683,6 +7710,7 @@ var GameVfx = (() => {
|
|
|
7683
7710
|
return player ?? (player = createEffectPlayer({ engine: workshop(), effects, view }));
|
|
7684
7711
|
}
|
|
7685
7712
|
return {
|
|
7713
|
+
hostGroundAt: options.groundAt,
|
|
7686
7714
|
play(id, point, playOptions = {}) {
|
|
7687
7715
|
if (!(id in effects)) return null;
|
|
7688
7716
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
@@ -8679,10 +8707,10 @@ var GameVfx = (() => {
|
|
|
8679
8707
|
function subtract(a, b) {
|
|
8680
8708
|
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
8681
8709
|
}
|
|
8682
|
-
function unit(
|
|
8683
|
-
const length = Math.sqrt(
|
|
8710
|
+
function unit(vector2) {
|
|
8711
|
+
const length = Math.sqrt(vector2[0] * vector2[0] + vector2[1] * vector2[1] + vector2[2] * vector2[2]) || 1;
|
|
8684
8712
|
const inverse = 1 / length;
|
|
8685
|
-
return [
|
|
8713
|
+
return [vector2[0] * inverse, vector2[1] * inverse, vector2[2] * inverse];
|
|
8686
8714
|
}
|
|
8687
8715
|
function crossProduct(a, b) {
|
|
8688
8716
|
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|