@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.js
CHANGED
|
@@ -2604,22 +2604,22 @@ var SHOPFRONT_GLASS = {
|
|
|
2604
2604
|
};
|
|
2605
2605
|
|
|
2606
2606
|
// src/effects/vector-math.ts
|
|
2607
|
-
function normalized(
|
|
2608
|
-
const length = Math.sqrt(
|
|
2607
|
+
function normalized(vector2) {
|
|
2608
|
+
const length = Math.sqrt(vector2[0] * vector2[0] + vector2[1] * vector2[1] + vector2[2] * vector2[2]) || 1;
|
|
2609
2609
|
const inverse = 1 / length;
|
|
2610
|
-
return [
|
|
2610
|
+
return [vector2[0] * inverse, vector2[1] * inverse, vector2[2] * inverse];
|
|
2611
2611
|
}
|
|
2612
|
-
function plus(
|
|
2613
|
-
return [
|
|
2612
|
+
function plus(vector2, x, y, z) {
|
|
2613
|
+
return [vector2[0] + x, vector2[1] + y, vector2[2] + z];
|
|
2614
2614
|
}
|
|
2615
|
-
function scaledBy(
|
|
2616
|
-
return [
|
|
2615
|
+
function scaledBy(vector2, factor) {
|
|
2616
|
+
return [vector2[0] * factor, vector2[1] * factor, vector2[2] * factor];
|
|
2617
2617
|
}
|
|
2618
|
-
function plusScaled(
|
|
2619
|
-
return [
|
|
2618
|
+
function plusScaled(vector2, direction, factor) {
|
|
2619
|
+
return [vector2[0] + direction[0] * factor, vector2[1] + direction[1] * factor, vector2[2] + direction[2] * factor];
|
|
2620
2620
|
}
|
|
2621
|
-
function negated(
|
|
2622
|
-
return [-
|
|
2621
|
+
function negated(vector2) {
|
|
2622
|
+
return [-vector2[0], -vector2[1], -vector2[2]];
|
|
2623
2623
|
}
|
|
2624
2624
|
|
|
2625
2625
|
// src/effects/destruction/door-stages.ts
|
|
@@ -3988,10 +3988,35 @@ var VEHICLE_EFFECTS = [
|
|
|
3988
3988
|
aliasOf(FUEL_LEAK, "vehicle_leak_ignited", {})
|
|
3989
3989
|
];
|
|
3990
3990
|
|
|
3991
|
+
// src/effects/particles/single-particles.ts
|
|
3992
|
+
var vector = [variable("vx"), variable("vy"), variable("vz")];
|
|
3993
|
+
var range = (name) => [variable(name), variable(name)];
|
|
3994
|
+
var singleParticle = (id, system) => ({
|
|
3995
|
+
id,
|
|
3996
|
+
pageId: `particle:${id}`,
|
|
3997
|
+
team: "world",
|
|
3998
|
+
budget: { particles: 1, lights: 0 },
|
|
3999
|
+
loop: 1e-3,
|
|
4000
|
+
timeline: [
|
|
4001
|
+
spawn(system, {
|
|
4002
|
+
p: [0, 0, 0],
|
|
4003
|
+
v: vector,
|
|
4004
|
+
life: range("life"),
|
|
4005
|
+
size: range("size"),
|
|
4006
|
+
grow: variable("grow"),
|
|
4007
|
+
c0: variable("color"),
|
|
4008
|
+
a: variable("alpha"),
|
|
4009
|
+
g: variable("gravity"),
|
|
4010
|
+
drag: variable("drag")
|
|
4011
|
+
})
|
|
4012
|
+
]
|
|
4013
|
+
});
|
|
4014
|
+
var SINGLE_PARTICLE_EFFECTS = [singleParticle("particle_puff", "normal"), singleParticle("particle_glow", "add"), singleParticle("particle_streak", "streak")];
|
|
4015
|
+
|
|
3991
4016
|
// src/effects/catalog.ts
|
|
3992
4017
|
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];
|
|
3993
4018
|
var WORKSHOP_EFFECTS = Object.fromEntries(ALL_EFFECTS.map((effect) => [effect.id, effect]));
|
|
3994
|
-
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
4019
|
+
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS, ...SINGLE_PARTICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
3995
4020
|
function patchEffects(base, changes) {
|
|
3996
4021
|
const result = { ...base };
|
|
3997
4022
|
for (const [id, change] of Object.entries(changes)) {
|
|
@@ -4700,8 +4725,8 @@ function resolve(value, context) {
|
|
|
4700
4725
|
var UP12 = [0, 1, 0];
|
|
4701
4726
|
var ZERO = [0, 0, 0];
|
|
4702
4727
|
var FULL_TURN_DRAWN = 6.283;
|
|
4703
|
-
function scaledSizes(
|
|
4704
|
-
return [
|
|
4728
|
+
function scaledSizes(range2, factor) {
|
|
4729
|
+
return [range2[0] * Math.sqrt(factor), range2[1] * Math.sqrt(factor)];
|
|
4705
4730
|
}
|
|
4706
4731
|
function fireEmit(engine, key, dt, centre, radius, factor, options = {}) {
|
|
4707
4732
|
const wind = options.wind ?? ZERO;
|
|
@@ -5779,13 +5804,14 @@ function composeMushroom(context, spec) {
|
|
|
5779
5804
|
function composeAfterEffects(context) {
|
|
5780
5805
|
const { core, def, random, x, y, z } = context;
|
|
5781
5806
|
const mark = def.mark;
|
|
5782
|
-
|
|
5807
|
+
const keepsMarks = !core.marklessAt?.(x, z);
|
|
5808
|
+
if (keepsMarks && mark.crater && mark.dent && y < 1.2) {
|
|
5783
5809
|
core.emit({ type: "crater", x, z, radius: mark.crater, depth: mark.dent });
|
|
5784
5810
|
core.trace?.crater?.(x, z, mark.crater, mark.dent);
|
|
5785
5811
|
addCrater(core.marks, core.ground, random, { x, z, radius: mark.crater, depth: mark.dent, marks: core.layers.mark });
|
|
5786
5812
|
if (core.layers.shrapnel) composeRimDebris(context);
|
|
5787
5813
|
}
|
|
5788
|
-
if (mark.scorch && y < 1.2 && core.layers.mark) {
|
|
5814
|
+
if (keepsMarks && mark.scorch && y < 1.2 && core.layers.mark) {
|
|
5789
5815
|
core.trace?.scorch?.(x, z, mark.scorch);
|
|
5790
5816
|
addScorch(core.marks, random, x, z, mark.scorch);
|
|
5791
5817
|
}
|
|
@@ -6601,9 +6627,9 @@ var SpriteKindSystem = class {
|
|
|
6601
6627
|
var TWO_PI_ROUNDED = 6.2832;
|
|
6602
6628
|
var WIDE_CONE = 3.1;
|
|
6603
6629
|
var UP13 = [0, 1, 0];
|
|
6604
|
-
function drawRange(random,
|
|
6605
|
-
if (Array.isArray(
|
|
6606
|
-
return
|
|
6630
|
+
function drawRange(random, range2) {
|
|
6631
|
+
if (Array.isArray(range2)) return random.between(range2[0], range2[1]);
|
|
6632
|
+
return range2 || 0;
|
|
6607
6633
|
}
|
|
6608
6634
|
function randomUnit(random, out) {
|
|
6609
6635
|
const up = random.next() * 2 - 1;
|
|
@@ -7387,13 +7413,13 @@ var WorkshopEngine = class {
|
|
|
7387
7413
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
7388
7414
|
}
|
|
7389
7415
|
/** A direction or velocity of the recipe's space in the world. */
|
|
7390
|
-
turn(
|
|
7416
|
+
turn(vector2) {
|
|
7391
7417
|
const placement = this.placement;
|
|
7392
|
-
if (!placement) return
|
|
7393
|
-
if (placement.orientation) return rotate(placement.orientation,
|
|
7418
|
+
if (!placement) return vector2;
|
|
7419
|
+
if (placement.orientation) return rotate(placement.orientation, vector2);
|
|
7394
7420
|
const cos2 = Math.cos(placement.yaw);
|
|
7395
7421
|
const sin2 = Math.sin(placement.yaw);
|
|
7396
|
-
return [cos2 *
|
|
7422
|
+
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
7397
7423
|
}
|
|
7398
7424
|
placed(options) {
|
|
7399
7425
|
if (!this.placement) return options;
|
|
@@ -7580,6 +7606,7 @@ function createVfx(options = {}) {
|
|
|
7580
7606
|
spawned: { puffs: 0, sparks: 0, chunks: 0, lights: 0 },
|
|
7581
7607
|
clock: { time: 0, lastBlast: -1, lod: 1, forcedLod: null },
|
|
7582
7608
|
groundAt,
|
|
7609
|
+
...options.marklessAt ? { marklessAt: options.marklessAt } : {},
|
|
7583
7610
|
emit: (request) => options.onRequest?.(request)
|
|
7584
7611
|
};
|
|
7585
7612
|
function definitionOf(id) {
|
|
@@ -7606,6 +7633,7 @@ function createVfx(options = {}) {
|
|
|
7606
7633
|
return player ?? (player = createEffectPlayer({ engine: workshop(), effects, view }));
|
|
7607
7634
|
}
|
|
7608
7635
|
return {
|
|
7636
|
+
hostGroundAt: options.groundAt,
|
|
7609
7637
|
play(id, point, playOptions = {}) {
|
|
7610
7638
|
if (!(id in effects)) return null;
|
|
7611
7639
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
@@ -8602,10 +8630,10 @@ var START_TARGET = [0, 1, 0];
|
|
|
8602
8630
|
function subtract(a, b) {
|
|
8603
8631
|
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
8604
8632
|
}
|
|
8605
|
-
function unit(
|
|
8606
|
-
const length = Math.sqrt(
|
|
8633
|
+
function unit(vector2) {
|
|
8634
|
+
const length = Math.sqrt(vector2[0] * vector2[0] + vector2[1] * vector2[1] + vector2[2] * vector2[2]) || 1;
|
|
8607
8635
|
const inverse = 1 / length;
|
|
8608
|
-
return [
|
|
8636
|
+
return [vector2[0] * inverse, vector2[1] * inverse, vector2[2] * inverse];
|
|
8609
8637
|
}
|
|
8610
8638
|
function crossProduct(a, b) {
|
|
8611
8639
|
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]];
|