@adatechnology/game-vfx 0.12.0 → 0.14.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/README.md +27 -2
- package/dist/index.d.ts +359 -3
- package/dist/index.global.js +818 -88
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +818 -88
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -24,6 +24,9 @@ var GameVfx = (() => {
|
|
|
24
24
|
var index_exports = {};
|
|
25
25
|
__export(index_exports, {
|
|
26
26
|
AREA_CAP_GAME: () => AREA_CAP_GAME,
|
|
27
|
+
DEBRIS_COLOR_VARIABLE: () => DEBRIS_COLOR_VARIABLE,
|
|
28
|
+
DEBRIS_EFFECT_FAMILIES: () => DEBRIS_EFFECT_FAMILIES,
|
|
29
|
+
DUST_COLOR_VARIABLE: () => DUST_COLOR_VARIABLE,
|
|
27
30
|
EVENT_BUDGET: () => EVENT_BUDGET,
|
|
28
31
|
EVENT_EFFECTS: () => EVENT_EFFECTS,
|
|
29
32
|
EVENT_EFFECTS_MAP: () => EVENT_EFFECTS_MAP,
|
|
@@ -36,6 +39,7 @@ var GameVfx = (() => {
|
|
|
36
39
|
GAME_EFFECTS: () => GAME_EFFECTS,
|
|
37
40
|
LOD_GAME: () => LOD_GAME,
|
|
38
41
|
LOD_LAB: () => LOD_LAB,
|
|
42
|
+
MATERIAL_EVENT_EFFECTS: () => MATERIAL_EVENT_EFFECTS,
|
|
39
43
|
MeshPool: () => MeshPool,
|
|
40
44
|
OrderedPool: () => OrderedPool,
|
|
41
45
|
PROFILES: () => PROFILES,
|
|
@@ -48,6 +52,11 @@ var GameVfx = (() => {
|
|
|
48
52
|
SpriteKindSystem: () => SpriteKindSystem,
|
|
49
53
|
VFX_LAYERS: () => VFX_LAYERS,
|
|
50
54
|
VIEWMODEL_EFFECTS: () => VIEWMODEL_EFFECTS,
|
|
55
|
+
WATER_BLASTS: () => WATER_BLASTS,
|
|
56
|
+
WATER_BLAST_KINDS: () => WATER_BLAST_KINDS,
|
|
57
|
+
WATER_LIMITS: () => WATER_LIMITS,
|
|
58
|
+
WATER_SHOT_BY_CALIBER: () => WATER_SHOT_BY_CALIBER,
|
|
59
|
+
WATER_SHOT_PROFILES: () => WATER_SHOT_PROFILES,
|
|
51
60
|
WORKSHOP_BEHAVIORS: () => WORKSHOP_BEHAVIORS,
|
|
52
61
|
WORKSHOP_EFFECTS: () => WORKSHOP_EFFECTS,
|
|
53
62
|
WORKSHOP_PUDDLES: () => WORKSHOP_PUDDLES,
|
|
@@ -60,6 +69,7 @@ var GameVfx = (() => {
|
|
|
60
69
|
createSchedule: () => createSchedule,
|
|
61
70
|
createScreenState: () => createScreenState,
|
|
62
71
|
createVfx: () => createVfx,
|
|
72
|
+
createWaterEffects: () => createWaterEffects,
|
|
63
73
|
createWorkshopBehaviors: () => createWorkshopBehaviors,
|
|
64
74
|
effectForEvent: () => effectForEvent,
|
|
65
75
|
estimateCost: () => estimateCost,
|
|
@@ -73,10 +83,16 @@ var GameVfx = (() => {
|
|
|
73
83
|
patchEffects: () => patchEffects,
|
|
74
84
|
patchExplosions: () => patchExplosions,
|
|
75
85
|
patchSpriteKinds: () => patchSpriteKinds,
|
|
86
|
+
patchWaterShotProfiles: () => patchWaterShotProfiles,
|
|
87
|
+
planWaterBlast: () => planWaterBlast,
|
|
88
|
+
planWaterShot: () => planWaterShot,
|
|
76
89
|
resolveStrings: () => resolveStrings,
|
|
90
|
+
resolveWaterBlast: () => resolveWaterBlast,
|
|
91
|
+
resolveWaterShotProfile: () => resolveWaterShotProfile,
|
|
77
92
|
slideAlong: () => slideAlong,
|
|
78
93
|
streamFor: () => streamFor,
|
|
79
94
|
updateScreen: () => updateScreen,
|
|
95
|
+
waterShotClassOf: () => waterShotClassOf,
|
|
80
96
|
workshopGround: () => workshopGround
|
|
81
97
|
});
|
|
82
98
|
|
|
@@ -3758,67 +3774,59 @@ var GameVfx = (() => {
|
|
|
3758
3774
|
]
|
|
3759
3775
|
};
|
|
3760
3776
|
|
|
3761
|
-
// src/effects/events.ts
|
|
3777
|
+
// src/effects/material-events.ts
|
|
3778
|
+
var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
|
|
3779
|
+
var DEBRIS_COLOR_VARIABLE = "debrisColor";
|
|
3780
|
+
var DUST_COLOR_VARIABLE = "dustColor";
|
|
3781
|
+
var FAMILIES = {
|
|
3782
|
+
wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
|
|
3783
|
+
masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
|
|
3784
|
+
glass: { debris: 11061464, dust: 12572386, piece: [0.04, 4e-3, 0.04], spin: 14, cloud: 0.25, sparks: false, glints: true },
|
|
3785
|
+
metal: { debris: 9080726, dust: 9078138, piece: [0.04, 6e-3, 0.03], spin: 8, cloud: 0.15, sparks: true, glints: false },
|
|
3786
|
+
soft: { debris: 10130568, dust: 11578014, piece: [0.025, 4e-3, 0.02], spin: 6, cloud: 0.3, sparks: false, glints: false },
|
|
3787
|
+
soil: { debris: 8022613, dust: 9075298, piece: [0.03, 0.025, 0.03], spin: 3, cloud: 1, sparks: false, glints: false }
|
|
3788
|
+
};
|
|
3789
|
+
var ORIGIN = [0, 0, 0];
|
|
3762
3790
|
var FACING4 = [0, 0, 1];
|
|
3763
3791
|
var UP11 = [0, 1, 0];
|
|
3764
|
-
var
|
|
3765
|
-
var
|
|
3766
|
-
var
|
|
3767
|
-
var
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
var muzzleEffect = (weapon) => ({
|
|
3776
|
-
id: `muzzle_${weapon}`,
|
|
3777
|
-
pageId: `event:muzzle_${weapon}`,
|
|
3778
|
-
team: "weapons",
|
|
3779
|
-
budget: { particles: 60, lights: 1 },
|
|
3780
|
-
loop: 2.4,
|
|
3781
|
-
timeline: [call2("muzzle", weapon, ORIGIN, FORWARD4)]
|
|
3782
|
-
});
|
|
3783
|
-
var casingEffect = (id, type) => ({
|
|
3784
|
-
id,
|
|
3785
|
-
pageId: `event:${id}`,
|
|
3786
|
-
team: "weapons",
|
|
3787
|
-
budget: { debris: 1 },
|
|
3788
|
-
loop: 2,
|
|
3789
|
-
timeline: [call2("casing", ORIGIN, type)]
|
|
3790
|
-
});
|
|
3791
|
-
var EVENT_EFFECTS = [
|
|
3792
|
-
...IMPACT_MATERIALS.map(impactEffect),
|
|
3793
|
-
...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
|
|
3794
|
-
casingEffect("casing_brass", ""),
|
|
3795
|
-
casingEffect("casing_shell", "shell"),
|
|
3796
|
-
casingEffect("casing_50", "50"),
|
|
3797
|
-
{
|
|
3798
|
-
// door_stages (W856-871): the dust a blow shakes loose from the frame and the splinters.
|
|
3799
|
-
id: "stage_crack",
|
|
3800
|
-
pageId: "event:stage_crack",
|
|
3792
|
+
var grow = (piece, factor) => [piece[0] * factor, piece[1] * factor, piece[2] * factor];
|
|
3793
|
+
var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
|
|
3794
|
+
var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
|
|
3795
|
+
var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
|
|
3796
|
+
var glints = (look, count) => look.glints ? [burst("add", count, { p: ORIGIN, r: 0.2, size: [0.02, 0.05], life: [0.2, 0.5], c0: 16777215, a: 0.9, fi: 0.3 })] : [];
|
|
3797
|
+
function stageCrack(family) {
|
|
3798
|
+
const look = FAMILIES[family];
|
|
3799
|
+
const dust = look.sparks ? [] : [burst("normal", 12, { p: ORIGIN, box: [0.3, 0.05, 0.02], dir: [0, -0.287, 0.958], cone: 0.6, sp: [0.2, 0.8], drag: 1.5, life: [0.8, 1.4], size: [0.08, 0.16], grow: 3, c0: dustTone(look), a: 0.45, g: 0.4 })];
|
|
3800
|
+
return {
|
|
3801
|
+
id: `stage_crack_${family}`,
|
|
3802
|
+
pageId: `event:stage_crack_${family}`,
|
|
3801
3803
|
team: "destruction",
|
|
3802
|
-
budget: { particles:
|
|
3804
|
+
budget: { particles: 16, debris: 6 },
|
|
3803
3805
|
loop: 2,
|
|
3804
3806
|
timeline: [
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
+
...dust,
|
|
3808
|
+
...sparks(look, 8),
|
|
3809
|
+
...glints(look, 4),
|
|
3810
|
+
repeat(scaled(look.sparks ? 1 : 4), debris({ p: ORIGIN, box: [0.15, 0.15, 0.02], dir: [0, 0.287, 0.958], cone: 0.6, sp: [1, 2.5], size: look.piece, k: [0.6, 1.4], spin: look.spin, c: debrisTone(look), life: 12 }))
|
|
3807
3811
|
]
|
|
3808
|
-
}
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3812
|
+
};
|
|
3813
|
+
}
|
|
3814
|
+
function breachDust(family) {
|
|
3815
|
+
const look = FAMILIES[family];
|
|
3816
|
+
return {
|
|
3817
|
+
id: `breach_dust_${family}`,
|
|
3818
|
+
pageId: `event:breach_dust_${family}`,
|
|
3813
3819
|
team: "destruction",
|
|
3814
3820
|
budget: { particles: 90, debris: 16 },
|
|
3815
3821
|
loop: 5,
|
|
3816
3822
|
timeline: [
|
|
3817
3823
|
screen({ add: { shake: 0.25 } }),
|
|
3818
|
-
|
|
3819
|
-
|
|
3824
|
+
...sparks(look, 14),
|
|
3825
|
+
...glints(look, 20),
|
|
3826
|
+
burst("normal", Math.round(30 * look.cloud), { p: ORIGIN, box: [1.4, 0.8, 0.2], sp: [0.3, 1.2], drag: 1.5, life: [1.5, 2.6], size: [0.4, 0.7], grow: 3, c0: dustTone(look), c1: 4867648, a: 0.45 }),
|
|
3827
|
+
repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: grow(look.piece, 2.2), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 20 })),
|
|
3820
3828
|
repeat(
|
|
3821
|
-
scaled(60),
|
|
3829
|
+
scaled(Math.round(60 * look.cloud)),
|
|
3822
3830
|
spawn("normal", local("angle", rnd(0, 6.283), {
|
|
3823
3831
|
p: [rnd(-1.4, 1.4), 0.2, rnd(-0.6, 0.4)],
|
|
3824
3832
|
dir: vnorm([cos(variable("angle")), 0.3, sin(variable("angle"))]),
|
|
@@ -3828,27 +3836,30 @@ var GameVfx = (() => {
|
|
|
3828
3836
|
life: [2.5, 4.5],
|
|
3829
3837
|
size: [0.6, 1],
|
|
3830
3838
|
grow: 3,
|
|
3831
|
-
c0:
|
|
3839
|
+
c0: dustTone(look),
|
|
3832
3840
|
c1: 4867648,
|
|
3833
3841
|
a: 0.45,
|
|
3834
3842
|
fi: 0.12
|
|
3835
3843
|
}))
|
|
3836
3844
|
)
|
|
3837
3845
|
]
|
|
3838
|
-
}
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3846
|
+
};
|
|
3847
|
+
}
|
|
3848
|
+
function collapseDust(family) {
|
|
3849
|
+
const look = FAMILIES[family];
|
|
3850
|
+
return {
|
|
3851
|
+
id: `collapse_dust_${family}`,
|
|
3852
|
+
pageId: `event:collapse_dust_${family}`,
|
|
3843
3853
|
team: "destruction",
|
|
3844
3854
|
budget: { particles: 350, debris: 26 },
|
|
3845
3855
|
loop: 8,
|
|
3846
3856
|
timeline: [
|
|
3847
3857
|
screen({ add: { shake: 0.45 } }),
|
|
3848
|
-
|
|
3849
|
-
repeat(
|
|
3858
|
+
...sparks(look, 20),
|
|
3859
|
+
repeat(6, debris({ p: ORIGIN, box: [2, 0.05, 0.6], v: [rnd(-0.5, 0.5), rnd(-0.5, 0), rnd(0, 0.8)], sp: 0, size: [rnd(0.5, 1.1), look.piece[1] > 0.01 ? 0.25 : 0.03, rnd(0.4, 0.8)], c: debrisTone(look), spin: 3, life: 30, bounce: 0.1 })),
|
|
3860
|
+
repeat(scaled(20), debris({ p: ORIGIN, box: [2.1, 0.1, 0.7], v: [rnd(-1, 1), rnd(-1, 1), rnd(0, 1.5)], sp: 0, size: grow(look.piece, 3.4), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 30 })),
|
|
3850
3861
|
repeat(
|
|
3851
|
-
scaled(70),
|
|
3862
|
+
scaled(Math.round(70 * look.cloud)),
|
|
3852
3863
|
spawn("normal", local("angle", rnd(-0.4, 3.5), {
|
|
3853
3864
|
p: [rnd(-2, 2), 0.2, rnd(-0.5, 0.5)],
|
|
3854
3865
|
dir: vnorm([mul(cos(variable("angle")), 0.6), 0.25, sin(variable("angle"))]),
|
|
@@ -3858,14 +3869,68 @@ var GameVfx = (() => {
|
|
|
3858
3869
|
life: [3, 6],
|
|
3859
3870
|
size: [0.7, 1.2],
|
|
3860
3871
|
grow: 3,
|
|
3861
|
-
c0:
|
|
3872
|
+
c0: dustTone(look),
|
|
3862
3873
|
c1: 4867648,
|
|
3863
3874
|
a: 0.5,
|
|
3864
3875
|
fi: 0.12
|
|
3865
3876
|
}))
|
|
3866
3877
|
)
|
|
3867
3878
|
]
|
|
3868
|
-
}
|
|
3879
|
+
};
|
|
3880
|
+
}
|
|
3881
|
+
var MASONRY = FAMILIES.masonry;
|
|
3882
|
+
var REBAR_EXPOSE = {
|
|
3883
|
+
id: "rebar_expose",
|
|
3884
|
+
pageId: "event:rebar_expose",
|
|
3885
|
+
team: "destruction",
|
|
3886
|
+
budget: { particles: 24, debris: 8 },
|
|
3887
|
+
loop: 2,
|
|
3888
|
+
timeline: [
|
|
3889
|
+
repeat(scaled(8), debris({ p: ORIGIN, dir: UP11, cone: 0.9, sp: [1, 3], size: MASONRY.piece, k: [0.6, 1.4], spin: MASONRY.spin, c: debrisTone(MASONRY), life: 20 })),
|
|
3890
|
+
burst("normal", 8, { p: ORIGIN, dir: UP11, cone: 0.8, sp: [0.3, 1.2], drag: 2, life: [0.8, 1.4], size: [0.08, 0.15], grow: 3, c0: dustTone(MASONRY), a: 0.4 }),
|
|
3891
|
+
call2("rust_at", ORIGIN, 6)
|
|
3892
|
+
]
|
|
3893
|
+
};
|
|
3894
|
+
var MATERIAL_EVENT_EFFECTS = [
|
|
3895
|
+
...DEBRIS_EFFECT_FAMILIES.flatMap((family) => [stageCrack(family), breachDust(family), collapseDust(family)]),
|
|
3896
|
+
REBAR_EXPOSE
|
|
3897
|
+
];
|
|
3898
|
+
|
|
3899
|
+
// src/effects/events.ts
|
|
3900
|
+
var FACING5 = [0, 0, 1];
|
|
3901
|
+
var ORIGIN2 = [0, 0, 0];
|
|
3902
|
+
var FORWARD4 = [0, 0, -1];
|
|
3903
|
+
var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
|
|
3904
|
+
var impactEffect = (material) => ({
|
|
3905
|
+
id: `impact_${material}`,
|
|
3906
|
+
pageId: `event:impact_${material}`,
|
|
3907
|
+
team: "weapons",
|
|
3908
|
+
budget: { particles: 40, decals: 1 },
|
|
3909
|
+
loop: 2,
|
|
3910
|
+
timeline: [call2("impact", material, ORIGIN2, FACING5, 1, 0)]
|
|
3911
|
+
});
|
|
3912
|
+
var muzzleEffect = (weapon) => ({
|
|
3913
|
+
id: `muzzle_${weapon}`,
|
|
3914
|
+
pageId: `event:muzzle_${weapon}`,
|
|
3915
|
+
team: "weapons",
|
|
3916
|
+
budget: { particles: 60, lights: 1 },
|
|
3917
|
+
loop: 2.4,
|
|
3918
|
+
timeline: [call2("muzzle", weapon, ORIGIN2, FORWARD4)]
|
|
3919
|
+
});
|
|
3920
|
+
var casingEffect = (id, type) => ({
|
|
3921
|
+
id,
|
|
3922
|
+
pageId: `event:${id}`,
|
|
3923
|
+
team: "weapons",
|
|
3924
|
+
budget: { debris: 1 },
|
|
3925
|
+
loop: 2,
|
|
3926
|
+
timeline: [call2("casing", ORIGIN2, type)]
|
|
3927
|
+
});
|
|
3928
|
+
var EVENT_EFFECTS = [
|
|
3929
|
+
...IMPACT_MATERIALS.map(impactEffect),
|
|
3930
|
+
...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
|
|
3931
|
+
casingEffect("casing_brass", ""),
|
|
3932
|
+
casingEffect("casing_shell", "shell"),
|
|
3933
|
+
casingEffect("casing_50", "50"),
|
|
3869
3934
|
{
|
|
3870
3935
|
// shopfront_glass (W846-855): the pane coming down as shards, the flash of the glints and the pale dust.
|
|
3871
3936
|
id: "glass_burst",
|
|
@@ -3877,21 +3942,13 @@ var GameVfx = (() => {
|
|
|
3877
3942
|
screen({ add: { shake: 0.08 } }),
|
|
3878
3943
|
repeat(
|
|
3879
3944
|
scaled(75),
|
|
3880
|
-
debris({ p:
|
|
3945
|
+
debris({ p: ORIGIN2, box: [1.25, 0.85, 0.02], v: [rnd(-0.4, 0.4), rnd(-0.5, 0.8), rnd(0.6, 2)], sp: 0, size: [rnd(0.05, 0.18), 6e-3, rnd(0.05, 0.18)], c: 11061464, spin: 14, life: 30, bounce: 0.15 })
|
|
3881
3946
|
),
|
|
3882
|
-
burst("add", 30, { p:
|
|
3947
|
+
burst("add", 30, { p: ORIGIN2, box: [1.2, 0.8, 0.05], size: [0.02, 0.05], life: [0.2, 0.6], c0: 16777215, a: 0.9, fi: 0.3 }),
|
|
3883
3948
|
burst("normal", 20, { p: [0, -0.6, 0.1], box: [1.2, 0.5, 0.1], sp: [0.2, 0.6], drag: 2, life: [0.8, 1.4], size: [0.12, 0.2], grow: 3, c0: 12572386, a: 0.2 })
|
|
3884
3949
|
]
|
|
3885
3950
|
},
|
|
3886
|
-
|
|
3887
|
-
// The chips macro the page uses on wood (W849) plus rust (`rustAt`), for rebar laid bare in concrete.
|
|
3888
|
-
id: "rebar_expose",
|
|
3889
|
-
pageId: "event:rebar_expose",
|
|
3890
|
-
team: "destruction",
|
|
3891
|
-
budget: { particles: 20, debris: 8 },
|
|
3892
|
-
loop: 2,
|
|
3893
|
-
timeline: [call2("chips", ORIGIN, UP11, 8, 0.9), call2("rust_at", ORIGIN, 6)]
|
|
3894
|
-
}
|
|
3951
|
+
...MATERIAL_EVENT_EFFECTS
|
|
3895
3952
|
];
|
|
3896
3953
|
|
|
3897
3954
|
// src/effects/weapons/viewmodel.ts
|
|
@@ -3904,7 +3961,7 @@ var GameVfx = (() => {
|
|
|
3904
3961
|
var FLASH_OPACITY = 0.95;
|
|
3905
3962
|
var FLAME_COLORS = [16742946, 16760896, 13121050, 16773296];
|
|
3906
3963
|
var FLAME_ADDITIVE = 3;
|
|
3907
|
-
var
|
|
3964
|
+
var ORIGIN3 = [0, 0, 0];
|
|
3908
3965
|
var SIZE = variable("size");
|
|
3909
3966
|
var FLASH_SCALE = variable("flash");
|
|
3910
3967
|
var fallback = (name, defaultValue) => ite(ne(variable(name), void 0), variable(name), defaultValue);
|
|
@@ -3952,7 +4009,7 @@ var GameVfx = (() => {
|
|
|
3952
4009
|
grow: 2.2
|
|
3953
4010
|
})
|
|
3954
4011
|
];
|
|
3955
|
-
var flashPiece = (shape, radius, height, width, at3, rot, color) => mesh({ shape, r: radius, ...height === void 0 ? {} : { h: height }, seg: width, seg2: shape === "sphere" ? 8 : 1, p:
|
|
4012
|
+
var flashPiece = (shape, radius, height, width, at3, rot, color) => mesh({ shape, r: radius, ...height === void 0 ? {} : { h: height }, seg: width, seg2: shape === "sphere" ? 8 : 1, p: ORIGIN3, at: at3, rot, roll: variable("roll"), ramp: FLASH_RAMP, life: FLASH_SECONDS, c0: color, a: FLASH_OPACITY, add: true });
|
|
3956
4013
|
var MUZZLE_FLASH2 = {
|
|
3957
4014
|
id: "viewmodel_muzzle_flash",
|
|
3958
4015
|
pageId: "event:viewmodel_muzzle_flash",
|
|
@@ -3979,7 +4036,7 @@ var GameVfx = (() => {
|
|
|
3979
4036
|
repeat(4, append("angles", add(div(mul(INDEX, PI), 2), mul(rand(), 0.6)))),
|
|
3980
4037
|
set("roll", mul(rand(), PI)),
|
|
3981
4038
|
when(gt(FLASH_SCALE, 0), [
|
|
3982
|
-
flash(
|
|
4039
|
+
flash(ORIGIN3, 16756832, mul(4, SIZE, FLASH_SCALE), FLASH_SECONDS, mul(2, SIZE, FLASH_SCALE), true, true),
|
|
3983
4040
|
flashPiece("cone_open", mul(0.013, SIZE, FLASH_SCALE), mul(0.085, SIZE, FLASH_SCALE), 10, [mul(0.042, SIZE, FLASH_SCALE), 0, 0], [0, 0, -PI / 2], 16757575),
|
|
3984
4041
|
repeat(
|
|
3985
4042
|
4,
|
|
@@ -3999,7 +4056,7 @@ var GameVfx = (() => {
|
|
|
3999
4056
|
repeat(
|
|
4000
4057
|
variable("puffs"),
|
|
4001
4058
|
puff2(
|
|
4002
|
-
|
|
4059
|
+
ORIGIN3,
|
|
4003
4060
|
[add(variable("drift"), mul(rand(), variable("driftSpread"))), add(variable("rise"), mul(rand(), variable("riseSpread"))), mul(sub(rand(), 0.5), variable("sideSpread"))],
|
|
4004
4061
|
[0, 0, 0],
|
|
4005
4062
|
mul(variable("radius"), SIZE),
|
|
@@ -4016,7 +4073,7 @@ var GameVfx = (() => {
|
|
|
4016
4073
|
team: "weapons",
|
|
4017
4074
|
budget: { particles: 1 },
|
|
4018
4075
|
loop: 0.1,
|
|
4019
|
-
timeline: [puff2(
|
|
4076
|
+
timeline: [puff2(ORIGIN3, void 0, [variable("vx"), variable("vy"), variable("vz")], variable("radius"), variable("life"), variable("opacity"))]
|
|
4020
4077
|
};
|
|
4021
4078
|
var BACKBLAST = {
|
|
4022
4079
|
id: "launcher_backblast",
|
|
@@ -4025,8 +4082,8 @@ var GameVfx = (() => {
|
|
|
4025
4082
|
budget: { particles: 40 },
|
|
4026
4083
|
loop: 0.1,
|
|
4027
4084
|
timeline: [
|
|
4028
|
-
repeat(26, puff2(
|
|
4029
|
-
repeat(14, ...flameBit(
|
|
4085
|
+
repeat(26, puff2(ORIGIN3, [neg(add(1.5, mul(rand(), 3))), 0, 0], [wide(1.4), wide(0.8), wide(1.4)], add(0.03, mul(rand(), 0.03)), add(1.8, mul(rand(), 1.4)), 0.5)),
|
|
4086
|
+
repeat(14, ...flameBit(ORIGIN3, [neg(add(2, mul(rand(), 2))), 0, 0], [wide(1), wide(0.6), wide(1)], 0.02, 0.25))
|
|
4030
4087
|
]
|
|
4031
4088
|
};
|
|
4032
4089
|
var FLAME_JET = {
|
|
@@ -4165,7 +4222,7 @@ var GameVfx = (() => {
|
|
|
4165
4222
|
// src/effects/behaviors/blocks.ts
|
|
4166
4223
|
var COLUMNS = 6;
|
|
4167
4224
|
var ROWS = 5;
|
|
4168
|
-
var
|
|
4225
|
+
var ORIGIN4 = [-2.2, 0, 2.6];
|
|
4169
4226
|
var BLOCK_SIZE = [0.5, 0.44, 0.25];
|
|
4170
4227
|
var OBJECT_ID_DRAWS2 = 4;
|
|
4171
4228
|
var FLOOR2 = 0.13;
|
|
@@ -4208,7 +4265,7 @@ var GameVfx = (() => {
|
|
|
4208
4265
|
const chipScale = random.between(0.8, 1.3) * scale;
|
|
4209
4266
|
for (let draw = 0; draw < OBJECT_ID_DRAWS2; draw++) random.next();
|
|
4210
4267
|
best.holes.push({ x: offsetX, y: offsetY, scale, chipTurn, chipScale });
|
|
4211
|
-
impact(host.engine, "concrete", [
|
|
4268
|
+
impact(host.engine, "concrete", [ORIGIN4[0] + x, y, ORIGIN4[2] + 0.13], [0, 0, 1], 0.8);
|
|
4212
4269
|
} else if (action === "collapse") {
|
|
4213
4270
|
const { x, y } = args;
|
|
4214
4271
|
for (const block of blocks) {
|
|
@@ -4260,7 +4317,7 @@ var GameVfx = (() => {
|
|
|
4260
4317
|
}
|
|
4261
4318
|
|
|
4262
4319
|
// src/effects/behaviors/car.ts
|
|
4263
|
-
var
|
|
4320
|
+
var ORIGIN5 = [5.6, 0, 0.8];
|
|
4264
4321
|
var MAX_TILT = 0.25;
|
|
4265
4322
|
function createCarBehavior() {
|
|
4266
4323
|
let y = 0;
|
|
@@ -4293,7 +4350,7 @@ var GameVfx = (() => {
|
|
|
4293
4350
|
}
|
|
4294
4351
|
},
|
|
4295
4352
|
query(_host, name, args) {
|
|
4296
|
-
if (name === "position") return [
|
|
4353
|
+
if (name === "position") return [ORIGIN5[0], y, ORIGIN5[2]];
|
|
4297
4354
|
if (name === "point") {
|
|
4298
4355
|
const [x, py, z] = args;
|
|
4299
4356
|
const point = carPoint(x, py, z);
|
|
@@ -5198,7 +5255,7 @@ var GameVfx = (() => {
|
|
|
5198
5255
|
};
|
|
5199
5256
|
|
|
5200
5257
|
// src/effects/player.ts
|
|
5201
|
-
var
|
|
5258
|
+
var ORIGIN6 = [0, 0, 0];
|
|
5202
5259
|
var DEFAULT_HEADING = [0, 0, -1];
|
|
5203
5260
|
var DEFAULT_MAX_INSTANCES = 48;
|
|
5204
5261
|
var ENDLESS_SECONDS = 60;
|
|
@@ -5275,7 +5332,7 @@ var GameVfx = (() => {
|
|
|
5275
5332
|
random: playOptions.seed !== void 0 ? streamOf(playOptions.seed) : void 0,
|
|
5276
5333
|
follow: playOptions.follow,
|
|
5277
5334
|
origin: point,
|
|
5278
|
-
anchor: def.anchor ??
|
|
5335
|
+
anchor: def.anchor ?? ORIGIN6,
|
|
5279
5336
|
yaw: yawOf(heading, playOptions.direction),
|
|
5280
5337
|
orientation: playOptions.orientation,
|
|
5281
5338
|
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
|
|
@@ -7974,9 +8031,9 @@ var GameVfx = (() => {
|
|
|
7974
8031
|
// src/data/event-effects.json
|
|
7975
8032
|
var event_effects_default = {
|
|
7976
8033
|
spall: "impact_{material}",
|
|
7977
|
-
stage: { "1": "
|
|
8034
|
+
stage: { "1": "stage_crack_{material}", "2": "breach_dust_{material}", "3": "collapse_dust_{material}" },
|
|
7978
8035
|
expose: "rebar_expose",
|
|
7979
|
-
collapse: "
|
|
8036
|
+
collapse: "collapse_dust_{material}",
|
|
7980
8037
|
explode: "explosion",
|
|
7981
8038
|
fracture: { glass: "glass_burst" }
|
|
7982
8039
|
};
|
|
@@ -7986,9 +8043,14 @@ var GameVfx = (() => {
|
|
|
7986
8043
|
function effectForEvent(event, map = EVENT_EFFECTS_MAP) {
|
|
7987
8044
|
const entry = map[event.kind];
|
|
7988
8045
|
if (entry === void 0) return void 0;
|
|
7989
|
-
if (typeof entry === "string") return
|
|
8046
|
+
if (typeof entry === "string") return withMaterial(entry, event.material);
|
|
7990
8047
|
const key = event.stage !== void 0 ? String(event.stage) : event.material;
|
|
7991
|
-
|
|
8048
|
+
const chosen = key === void 0 ? void 0 : entry[key];
|
|
8049
|
+
return chosen === void 0 ? void 0 : withMaterial(chosen, event.material);
|
|
8050
|
+
}
|
|
8051
|
+
function withMaterial(entry, material) {
|
|
8052
|
+
if (!entry.includes("{material}")) return entry;
|
|
8053
|
+
return material ? entry.replace("{material}", material) : void 0;
|
|
7992
8054
|
}
|
|
7993
8055
|
|
|
7994
8056
|
// src/locales/en.ts
|
|
@@ -9036,6 +9098,674 @@ var GameVfx = (() => {
|
|
|
9036
9098
|
reset
|
|
9037
9099
|
};
|
|
9038
9100
|
}
|
|
9101
|
+
|
|
9102
|
+
// src/water/motion.ts
|
|
9103
|
+
var WATER_GRAVITY = 9.81;
|
|
9104
|
+
var DROP_DRAG = 0.25;
|
|
9105
|
+
var MIST_DRAG = 1.2;
|
|
9106
|
+
function moveDrop(drop, context) {
|
|
9107
|
+
const { dt } = context;
|
|
9108
|
+
drop.age += dt;
|
|
9109
|
+
const keep = Math.exp(-DROP_DRAG * dt);
|
|
9110
|
+
drop.vx *= keep;
|
|
9111
|
+
drop.vz *= keep;
|
|
9112
|
+
drop.vy = drop.vy * keep - WATER_GRAVITY * dt;
|
|
9113
|
+
drop.x += drop.vx * dt;
|
|
9114
|
+
drop.y += drop.vy * dt;
|
|
9115
|
+
drop.z += drop.vz * dt;
|
|
9116
|
+
if (drop.vy < 0 && drop.y <= drop.level) {
|
|
9117
|
+
context.landed(drop);
|
|
9118
|
+
return false;
|
|
9119
|
+
}
|
|
9120
|
+
return drop.age < drop.life;
|
|
9121
|
+
}
|
|
9122
|
+
function ageRing(ring2, dt) {
|
|
9123
|
+
if (ring2.delay > 0) {
|
|
9124
|
+
ring2.delay -= dt;
|
|
9125
|
+
ring2.alpha = 0;
|
|
9126
|
+
return true;
|
|
9127
|
+
}
|
|
9128
|
+
ring2.age += dt;
|
|
9129
|
+
const t = Math.min(1, ring2.age / ring2.life);
|
|
9130
|
+
const spread = ring2.kind === 2 ? t : ring2.kind === 1 ? 1 - (1 - t) ** 4 : 1 - (1 - t) ** 2;
|
|
9131
|
+
ring2.radius = ring2.startRadius + (ring2.maxRadius - ring2.startRadius) * spread;
|
|
9132
|
+
ring2.alpha = ring2.strength * (1 - t) * (ring2.kind === 1 ? 1 - t : 1);
|
|
9133
|
+
return ring2.age < ring2.life;
|
|
9134
|
+
}
|
|
9135
|
+
function ageFoam(foam, dt) {
|
|
9136
|
+
foam.age += dt;
|
|
9137
|
+
const t = Math.min(1, foam.age / foam.life);
|
|
9138
|
+
foam.radius = foam.startRadius + (foam.maxRadius - foam.startRadius) * (1 - (1 - t) ** 3);
|
|
9139
|
+
foam.alpha = t < 0.5 ? 0.85 : 0.85 * (1 - (t - 0.5) / 0.5);
|
|
9140
|
+
return foam.age < foam.life;
|
|
9141
|
+
}
|
|
9142
|
+
function ageColumn(column, dt) {
|
|
9143
|
+
if (column.delay > 0) {
|
|
9144
|
+
column.delay -= dt;
|
|
9145
|
+
column.height = 0;
|
|
9146
|
+
column.alpha = 0;
|
|
9147
|
+
return true;
|
|
9148
|
+
}
|
|
9149
|
+
column.age += dt;
|
|
9150
|
+
const t = column.age;
|
|
9151
|
+
const fall = Math.max(1e-3, column.life - column.rise);
|
|
9152
|
+
column.height = t < column.rise ? column.peak * (1 - (1 - t / column.rise) ** 2) : column.peak * Math.max(0, 1 - ((t - column.rise) / fall) ** 1.6);
|
|
9153
|
+
column.radius = column.baseRadius * (1 + (column.dome ? 0.4 : 1.2) * Math.min(1, t / column.life));
|
|
9154
|
+
const share = t / column.life;
|
|
9155
|
+
column.alpha = share < 0.6 ? 0.9 : 0.9 * Math.max(0, 1 - (share - 0.6) / 0.4);
|
|
9156
|
+
return t < column.life;
|
|
9157
|
+
}
|
|
9158
|
+
function ageBubble(bubble, dt) {
|
|
9159
|
+
if (bubble.delay > 0) {
|
|
9160
|
+
bubble.delay -= dt;
|
|
9161
|
+
bubble.alpha = 0;
|
|
9162
|
+
return true;
|
|
9163
|
+
}
|
|
9164
|
+
bubble.age += dt;
|
|
9165
|
+
bubble.y += bubble.rise * dt;
|
|
9166
|
+
bubble.size *= 1 + 0.15 * dt;
|
|
9167
|
+
bubble.alpha = 0.7 * (1 - bubble.age / bubble.life);
|
|
9168
|
+
return bubble.age < bubble.life && bubble.y < bubble.level - bubble.size;
|
|
9169
|
+
}
|
|
9170
|
+
function ageMist(mist, dt) {
|
|
9171
|
+
mist.age += dt;
|
|
9172
|
+
const keep = Math.exp(-MIST_DRAG * dt);
|
|
9173
|
+
mist.vx *= keep;
|
|
9174
|
+
mist.vy = mist.vy * keep - 0.15 * dt;
|
|
9175
|
+
mist.vz *= keep;
|
|
9176
|
+
mist.x += mist.vx * dt;
|
|
9177
|
+
mist.y += mist.vy * dt;
|
|
9178
|
+
mist.z += mist.vz * dt;
|
|
9179
|
+
mist.size *= 1 + 0.35 * dt;
|
|
9180
|
+
const t = mist.age / mist.life;
|
|
9181
|
+
mist.alpha = t < 0.15 ? t / 0.15 * 0.45 : 0.45 * (1 - (t - 0.15) / 0.85);
|
|
9182
|
+
return mist.age < mist.life;
|
|
9183
|
+
}
|
|
9184
|
+
function ageWave(wave, dt) {
|
|
9185
|
+
if (wave.delay > 0) {
|
|
9186
|
+
wave.delay -= dt;
|
|
9187
|
+
return true;
|
|
9188
|
+
}
|
|
9189
|
+
wave.age += dt;
|
|
9190
|
+
return wave.age < wave.life && wave.speed * wave.age < wave.reach + wave.width;
|
|
9191
|
+
}
|
|
9192
|
+
function stepWaterPools(pools, context) {
|
|
9193
|
+
const { dt } = context;
|
|
9194
|
+
pools.drops.compact(moveDrop, context);
|
|
9195
|
+
pools.rings.compact(ageRing, dt);
|
|
9196
|
+
pools.foam.compact(ageFoam, dt);
|
|
9197
|
+
pools.columns.compact(ageColumn, dt);
|
|
9198
|
+
pools.bubbles.compact(ageBubble, dt);
|
|
9199
|
+
pools.mist.compact(ageMist, dt);
|
|
9200
|
+
pools.waves.compact(ageWave, dt);
|
|
9201
|
+
}
|
|
9202
|
+
|
|
9203
|
+
// src/water/profiles.ts
|
|
9204
|
+
var WATER_SHOT_PROFILES = {
|
|
9205
|
+
rimfire: { speed: 350, columnHeight: 0.25, columnRadius: 0.02, drops: 8, dropSpeed: [0.9, 1.8], dropSize: 9e-3, ringRadius: 0.32, rings: 1, ringLife: 1.2, foamRadius: 0.06, foamLife: 0.7, slowing: 0.35, bubblesPerMetre: 20, ricochetBelowDeg: 9 },
|
|
9206
|
+
pistol: { speed: 360, columnHeight: 0.45, columnRadius: 0.035, drops: 14, dropSpeed: [1.2, 2.6], dropSize: 0.012, ringRadius: 0.45, rings: 2, ringLife: 1.4, foamRadius: 0.09, foamLife: 0.9, slowing: 0.55, bubblesPerMetre: 30, ricochetBelowDeg: 8 },
|
|
9207
|
+
magnum: { speed: 450, columnHeight: 0.7, columnRadius: 0.045, drops: 20, dropSpeed: [1.5, 3.2], dropSize: 0.014, ringRadius: 0.6, rings: 2, ringLife: 1.6, foamRadius: 0.12, foamLife: 1.1, slowing: 0.7, bubblesPerMetre: 30, ricochetBelowDeg: 7 },
|
|
9208
|
+
rifle: { speed: 800, columnHeight: 1.1, columnRadius: 0.03, drops: 26, dropSpeed: [2.5, 4.5], dropSize: 0.011, ringRadius: 0.7, rings: 3, ringLife: 1.6, foamRadius: 0.11, foamLife: 1, slowing: 0.35, bubblesPerMetre: 45, ricochetBelowDeg: 6 },
|
|
9209
|
+
battle_rifle: { speed: 850, columnHeight: 1.4, columnRadius: 0.035, drops: 30, dropSpeed: [2.8, 5], dropSize: 0.012, ringRadius: 0.85, rings: 3, ringLife: 1.8, foamRadius: 0.13, foamLife: 1.1, slowing: 0.45, bubblesPerMetre: 45, ricochetBelowDeg: 6 },
|
|
9210
|
+
sniper: { speed: 900, columnHeight: 2.2, columnRadius: 0.06, drops: 48, dropSpeed: [3.5, 6.5], dropSize: 0.016, ringRadius: 1.4, rings: 4, ringLife: 2.2, foamRadius: 0.22, foamLife: 1.6, slowing: 0.9, bubblesPerMetre: 50, ricochetBelowDeg: 5 },
|
|
9211
|
+
buckshot: { speed: 400, columnHeight: 0.28, columnRadius: 0.025, drops: 7, dropSpeed: [1, 2], dropSize: 0.01, ringRadius: 0.3, rings: 1, ringLife: 1.1, foamRadius: 0.13, foamLife: 1.3, slowing: 0.3, bubblesPerMetre: 25, ricochetBelowDeg: 9 },
|
|
9212
|
+
birdshot: { speed: 400, columnHeight: 0.1, columnRadius: 0.012, drops: 2, dropSpeed: [0.6, 1.2], dropSize: 6e-3, ringRadius: 0.14, rings: 1, ringLife: 0.8, foamRadius: 0.06, foamLife: 0.9, slowing: 0.08, bubblesPerMetre: 10, ricochetBelowDeg: 10 },
|
|
9213
|
+
slug: { speed: 460, columnHeight: 0.8, columnRadius: 0.07, drops: 24, dropSpeed: [1.6, 3], dropSize: 0.016, ringRadius: 0.75, rings: 2, ringLife: 1.7, foamRadius: 0.18, foamLife: 1.3, slowing: 0.8, bubblesPerMetre: 35, ricochetBelowDeg: 8 },
|
|
9214
|
+
arrow: { speed: 100, columnHeight: 0.18, columnRadius: 0.02, drops: 5, dropSpeed: [0.6, 1.2], dropSize: 0.01, ringRadius: 0.3, rings: 1, ringLife: 1.2, foamRadius: 0.05, foamLife: 0.6, slowing: 2.5, bubblesPerMetre: 6, ricochetBelowDeg: 4 },
|
|
9215
|
+
// a thrown thing the size of a grenade or a can falling in: a plop, a crown and wide rings, and it sinks
|
|
9216
|
+
object: { speed: 12, columnHeight: 0.5, columnRadius: 0.07, drops: 18, dropSpeed: [1, 2.4], dropSize: 0.015, ringRadius: 0.9, rings: 3, ringLife: 2, foamRadius: 0.14, foamLife: 1.2, slowing: 0.5, bubblesPerMetre: 25, ricochetBelowDeg: 3 },
|
|
9217
|
+
fragment: { speed: 600, columnHeight: 0.35, columnRadius: 0.02, drops: 6, dropSpeed: [1, 2.4], dropSize: 0.01, ringRadius: 0.3, rings: 1, ringLife: 1, foamRadius: 0.05, foamLife: 0.6, slowing: 0.15, bubblesPerMetre: 15, ricochetBelowDeg: 7 }
|
|
9218
|
+
};
|
|
9219
|
+
var WATER_SHOT_BY_CALIBER = {
|
|
9220
|
+
"22lr": "rimfire",
|
|
9221
|
+
"380acp": "pistol",
|
|
9222
|
+
"9x18": "pistol",
|
|
9223
|
+
"9x19": "pistol",
|
|
9224
|
+
"40sw": "pistol",
|
|
9225
|
+
"45acp": "pistol",
|
|
9226
|
+
"5_7x28": "pistol",
|
|
9227
|
+
"38spl": "pistol",
|
|
9228
|
+
"32acp": "pistol",
|
|
9229
|
+
"7_62x25": "pistol",
|
|
9230
|
+
"4_6x30": "pistol",
|
|
9231
|
+
"357mag": "magnum",
|
|
9232
|
+
"44mag": "magnum",
|
|
9233
|
+
"50ae": "magnum",
|
|
9234
|
+
"45_70_bp": "magnum",
|
|
9235
|
+
"12ga_00buck": "buckshot",
|
|
9236
|
+
"20ga_buck": "buckshot",
|
|
9237
|
+
"12ga_birdshot": "birdshot",
|
|
9238
|
+
"12ga_slug": "slug",
|
|
9239
|
+
"5_56x45": "rifle",
|
|
9240
|
+
"5_45x39": "rifle",
|
|
9241
|
+
"7_62x39": "rifle",
|
|
9242
|
+
"30_30": "rifle",
|
|
9243
|
+
"9x39": "rifle",
|
|
9244
|
+
"7_62x51": "battle_rifle",
|
|
9245
|
+
"7_62x54r": "battle_rifle",
|
|
9246
|
+
"30_06": "battle_rifle",
|
|
9247
|
+
"7_92x57": "battle_rifle",
|
|
9248
|
+
"300wm": "battle_rifle",
|
|
9249
|
+
"338lapua": "sniper",
|
|
9250
|
+
"408cheytac": "sniper",
|
|
9251
|
+
"50bmg": "sniper",
|
|
9252
|
+
arrow: "arrow",
|
|
9253
|
+
crossbow_bolt: "arrow"
|
|
9254
|
+
};
|
|
9255
|
+
function waterShotClassOf(round2) {
|
|
9256
|
+
const joules = 0.5 * (round2.grams / 1e3) * round2.speed * round2.speed;
|
|
9257
|
+
if (round2.speed < 150) return "arrow";
|
|
9258
|
+
if (round2.pellet) return round2.grams < 0.5 ? "birdshot" : "buckshot";
|
|
9259
|
+
if ((round2.diameter ?? 0) >= 15) return "slug";
|
|
9260
|
+
if (joules >= 6e3) return "sniper";
|
|
9261
|
+
if (joules >= 2800) return "battle_rifle";
|
|
9262
|
+
if (joules >= 1200) return "rifle";
|
|
9263
|
+
if (joules >= 900) return "magnum";
|
|
9264
|
+
return joules < 200 ? "rimfire" : "pistol";
|
|
9265
|
+
}
|
|
9266
|
+
var WATER_BLAST_KINDS = {
|
|
9267
|
+
blast: { brisance: 1, columnWidth: 1, fragments: 0, mist: 1, fireballUnderwater: false },
|
|
9268
|
+
fragmentation: { brisance: 0.9, columnWidth: 1, fragments: 16, mist: 1, fireballUnderwater: false },
|
|
9269
|
+
shaped_charge: { brisance: 0.8, columnWidth: 0.6, fragments: 6, mist: 0.8, fireballUnderwater: false },
|
|
9270
|
+
directional: { brisance: 0.7, columnWidth: 0.9, fragments: 24, mist: 0.8, fireballUnderwater: false },
|
|
9271
|
+
fuel: { brisance: 0.25, columnWidth: 1.4, fragments: 4, mist: 2.2, fireballUnderwater: false },
|
|
9272
|
+
incendiary: { brisance: 0.05, columnWidth: 1.2, fragments: 0, mist: 1.5, fireballUnderwater: false },
|
|
9273
|
+
flash: { brisance: 0.1, columnWidth: 1, fragments: 0, mist: 0.6, fireballUnderwater: false }
|
|
9274
|
+
};
|
|
9275
|
+
var WATER_BLASTS = {
|
|
9276
|
+
m67: { tnt: 0.24, kind: "fragmentation" },
|
|
9277
|
+
pipe_bomb: { tnt: 0.15, kind: "fragmentation" },
|
|
9278
|
+
m79_40mm: { tnt: 0.045, kind: "fragmentation" },
|
|
9279
|
+
vog_25: { tnt: 0.045, kind: "fragmentation" },
|
|
9280
|
+
dynamite: { tnt: 0.25, kind: "blast" },
|
|
9281
|
+
c4: { tnt: 0.76, kind: "blast" },
|
|
9282
|
+
semtex: { tnt: 0.83, kind: "blast" },
|
|
9283
|
+
claymore: { tnt: 0.9, kind: "directional" },
|
|
9284
|
+
m72_66mm: { tnt: 0.45, kind: "shaped_charge" },
|
|
9285
|
+
at4_84mm: { tnt: 0.7, kind: "shaped_charge" },
|
|
9286
|
+
pg7v: { tnt: 0.45, kind: "shaped_charge" },
|
|
9287
|
+
carl_gustaf_84mm: { tnt: 0.7, kind: "shaped_charge" },
|
|
9288
|
+
propane_p13: { tnt: 1.5, kind: "fuel" },
|
|
9289
|
+
fuel_barrel: { tnt: 1, kind: "fuel" },
|
|
9290
|
+
car_fuel_tank: { tnt: 0.5, kind: "fuel" },
|
|
9291
|
+
fuel_pump: { tnt: 0.5, kind: "fuel" },
|
|
9292
|
+
fuel_station_tank: { tnt: 20, kind: "fuel" },
|
|
9293
|
+
molotov: { tnt: 0.02, kind: "incendiary" },
|
|
9294
|
+
flashbang: { tnt: 0.01, kind: "flash" }
|
|
9295
|
+
};
|
|
9296
|
+
function resolveWaterShotProfile(profile, table = WATER_SHOT_PROFILES) {
|
|
9297
|
+
if (typeof profile !== "string") return profile;
|
|
9298
|
+
return table[profile] ?? WATER_SHOT_PROFILES.pistol;
|
|
9299
|
+
}
|
|
9300
|
+
function patchWaterShotProfiles(base, changes) {
|
|
9301
|
+
const out = { ...base };
|
|
9302
|
+
for (const [id, change] of Object.entries(changes)) {
|
|
9303
|
+
if (change === null) delete out[id];
|
|
9304
|
+
else out[id] = { ...base[id] ?? WATER_SHOT_PROFILES.pistol, ...change };
|
|
9305
|
+
}
|
|
9306
|
+
return out;
|
|
9307
|
+
}
|
|
9308
|
+
|
|
9309
|
+
// src/water/plan.ts
|
|
9310
|
+
var DEGREES = 180 / Math.PI;
|
|
9311
|
+
var SPENT_SPEED = 15;
|
|
9312
|
+
var DEFAULT_DEPTH = 2;
|
|
9313
|
+
var RICOCHET_SPEED_SHARE = 0.6;
|
|
9314
|
+
var RICOCHET_YAW_DEG = 6;
|
|
9315
|
+
var BLAST_COLUMN_PER_QUARTIC_KG = 10;
|
|
9316
|
+
var AIRBURST_SCALED_HEIGHT = 2.5;
|
|
9317
|
+
var BEST_SCALED_DEPTH = 0.6;
|
|
9318
|
+
var DEEP_FALL = 1.6;
|
|
9319
|
+
var UNDERWATER_SCALED_DEPTH = 0.15;
|
|
9320
|
+
var clamp5 = (value, low, high) => Math.min(high, Math.max(low, value));
|
|
9321
|
+
function planWaterShot(params, random, table) {
|
|
9322
|
+
const profile = resolveWaterShotProfile(params.profile, table);
|
|
9323
|
+
const [dx, dy, dz] = params.direction;
|
|
9324
|
+
const sine = clamp5(-dy, 0, 1);
|
|
9325
|
+
const angleDeg = Math.asin(sine) * DEGREES;
|
|
9326
|
+
const speed = params.speed ?? profile.speed;
|
|
9327
|
+
const strength = clamp5(speed / profile.speed, 0.3, 1.25);
|
|
9328
|
+
const flat = Math.hypot(dx, dz) || 1;
|
|
9329
|
+
const forward = [dx / flat, dz / flat];
|
|
9330
|
+
const ricochet = angleDeg < profile.ricochetBelowDeg ? skipOff(params.direction, angleDeg, random) : null;
|
|
9331
|
+
const lean = (1 - sine) * (ricochet ? 1.2 : 0.6);
|
|
9332
|
+
const columnHeight = profile.columnHeight * strength * (ricochet ? 0.35 : 0.35 + 0.65 * sine);
|
|
9333
|
+
const depth = params.depth ?? DEFAULT_DEPTH;
|
|
9334
|
+
const trail = ricochet ? null : trailUnder(params, profile, speed, depth, sine);
|
|
9335
|
+
return {
|
|
9336
|
+
profile,
|
|
9337
|
+
angleDeg,
|
|
9338
|
+
ricochet,
|
|
9339
|
+
columnHeight,
|
|
9340
|
+
columnRadius: profile.columnRadius * Math.sqrt(strength),
|
|
9341
|
+
tilt: [forward[0] * lean, forward[1] * lean],
|
|
9342
|
+
drops: Math.round(profile.drops * strength),
|
|
9343
|
+
ringRadius: profile.ringRadius * Math.sqrt(strength),
|
|
9344
|
+
rings: profile.rings,
|
|
9345
|
+
foamRadius: profile.foamRadius * (ricochet ? 1.4 : 1),
|
|
9346
|
+
trailEnd: trail?.end ?? params.point,
|
|
9347
|
+
trailLength: trail?.length ?? 0,
|
|
9348
|
+
bedSpeed: trail?.bedSpeed ?? 0
|
|
9349
|
+
};
|
|
9350
|
+
}
|
|
9351
|
+
function skipOff(direction, angleDeg, random) {
|
|
9352
|
+
const yaw = random.between(-RICOCHET_YAW_DEG, RICOCHET_YAW_DEG) / DEGREES;
|
|
9353
|
+
const cos2 = Math.cos(yaw);
|
|
9354
|
+
const sin2 = Math.sin(yaw);
|
|
9355
|
+
const [dx, dy, dz] = direction;
|
|
9356
|
+
const up = Math.abs(dy) * (0.5 + 0.3 * random.next());
|
|
9357
|
+
const x = dx * cos2 - dz * sin2;
|
|
9358
|
+
const z = dx * sin2 + dz * cos2;
|
|
9359
|
+
const length = Math.hypot(x, up, z) || 1;
|
|
9360
|
+
return { direction: [x / length, up / length, z / length], speedShare: RICOCHET_SPEED_SHARE * (1 - angleDeg / 30) };
|
|
9361
|
+
}
|
|
9362
|
+
function trailUnder(params, profile, speed, depth, sine) {
|
|
9363
|
+
const spentAfter = profile.slowing * Math.log(Math.max(1, speed / SPENT_SPEED));
|
|
9364
|
+
const toBed = sine > 1e-3 ? depth / sine : Infinity;
|
|
9365
|
+
const length = Math.min(spentAfter, toBed);
|
|
9366
|
+
const [px, py, pz] = params.point;
|
|
9367
|
+
const [dx, dy, dz] = params.direction;
|
|
9368
|
+
const bedSpeed = toBed <= spentAfter ? speed * Math.exp(-toBed / profile.slowing) : 0;
|
|
9369
|
+
return { end: [px + dx * length, py + dy * length, pz + dz * length], length, bedSpeed };
|
|
9370
|
+
}
|
|
9371
|
+
function resolveWaterBlast(params) {
|
|
9372
|
+
const known = params.explosive ? WATER_BLASTS[params.explosive] : void 0;
|
|
9373
|
+
const tnt = Math.max(1e-3, params.tnt ?? known?.tnt ?? 0.25);
|
|
9374
|
+
const kindId = params.kind ?? known?.kind ?? "blast";
|
|
9375
|
+
const kind = WATER_BLAST_KINDS[kindId] ?? WATER_BLAST_KINDS.blast;
|
|
9376
|
+
return { tnt, kind };
|
|
9377
|
+
}
|
|
9378
|
+
function planWaterBlast(params) {
|
|
9379
|
+
const { tnt, kind } = resolveWaterBlast(params);
|
|
9380
|
+
const scale = Math.cbrt(tnt);
|
|
9381
|
+
const quartic = Math.sqrt(Math.sqrt(tnt));
|
|
9382
|
+
const burstDepth = params.level - params.point[1];
|
|
9383
|
+
const scaledDepth = burstDepth / scale;
|
|
9384
|
+
const airburst = -scaledDepth > AIRBURST_SCALED_HEIGHT;
|
|
9385
|
+
const underwater = scaledDepth > UNDERWATER_SCALED_DEPTH && !kind.fireballUnderwater;
|
|
9386
|
+
const surface = scaledDepth <= 0 ? Math.max(0, 1 + scaledDepth / AIRBURST_SCALED_HEIGHT) : 1;
|
|
9387
|
+
const depthShape = scaledDepth <= 0 ? 0.6 * surface : scaledDepth <= BEST_SCALED_DEPTH ? 0.6 + 0.4 * (scaledDepth / BEST_SCALED_DEPTH) : Math.exp(-(scaledDepth - BEST_SCALED_DEPTH) / DEEP_FALL);
|
|
9388
|
+
const shallow = clamp5(0.35 + params.depth / (1.2 * scale), 0.35, 1);
|
|
9389
|
+
const power = kind.brisance;
|
|
9390
|
+
const columnHeight = airburst ? 0 : BLAST_COLUMN_PER_QUARTIC_KG * quartic * power * depthShape * shallow;
|
|
9391
|
+
const domed = scaledDepth > 0 && !airburst;
|
|
9392
|
+
const domeRadius = domed ? 1.6 * scale * Math.cbrt(power) : 0;
|
|
9393
|
+
const fragments = scaledDepth < UNDERWATER_SCALED_DEPTH ? kind.fragments : 0;
|
|
9394
|
+
return {
|
|
9395
|
+
tnt,
|
|
9396
|
+
kind,
|
|
9397
|
+
burstDepth,
|
|
9398
|
+
underwater,
|
|
9399
|
+
airburst,
|
|
9400
|
+
columnHeight,
|
|
9401
|
+
columnRadius: 0.35 * scale * kind.columnWidth * (1 + 0.5 * clamp5(scaledDepth, 0, 1)),
|
|
9402
|
+
domeRadius,
|
|
9403
|
+
domeHeight: domed ? domeRadius * 0.6 * (scaledDepth < 1 ? 1 : Math.exp(1 - scaledDepth)) : 0,
|
|
9404
|
+
shockRadius: (scaledDepth >= 0 ? 5 : 4 * surface) * scale,
|
|
9405
|
+
waveAmplitude: 0.12 * scale * power * (scaledDepth >= 0 ? 1 : surface) * shallow,
|
|
9406
|
+
waveSpeed: 2.5 + 1.5 * scale,
|
|
9407
|
+
drops: airburst ? Math.round(20 * scale) : Math.round((60 + 140 * scale) * Math.max(0.3, depthShape) * Math.max(0.3, power)),
|
|
9408
|
+
mist: Math.round((6 + 10 * scale) * kind.mist * (airburst ? 0.4 : 1)),
|
|
9409
|
+
fragments,
|
|
9410
|
+
foamRadius: 2.5 * scale * Math.max(0.4, Math.cbrt(power)) * (airburst ? 0.3 : 1),
|
|
9411
|
+
bubbles: scaledDepth > 0 ? Math.round(30 + 50 * scale) : 0
|
|
9412
|
+
};
|
|
9413
|
+
}
|
|
9414
|
+
|
|
9415
|
+
// src/water/records.ts
|
|
9416
|
+
var WATER_LIMITS = { drops: 700, rings: 220, foam: 60, columns: 32, bubbles: 500, mist: 90, waves: 16 };
|
|
9417
|
+
function createWaterPools(limits) {
|
|
9418
|
+
return {
|
|
9419
|
+
drops: new OrderedPool(limits.drops, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, size: 0, age: 0, life: 0, level: 0 })),
|
|
9420
|
+
rings: new OrderedPool(limits.rings, () => ({ x: 0, y: 0, z: 0, kind: 0, radius: 0, startRadius: 0, maxRadius: 0, delay: 0, age: 0, life: 0, strength: 0, alpha: 0 })),
|
|
9421
|
+
foam: new OrderedPool(limits.foam, () => ({ x: 0, y: 0, z: 0, radius: 0, startRadius: 0, maxRadius: 0, age: 0, life: 0, alpha: 0 })),
|
|
9422
|
+
columns: new OrderedPool(limits.columns, () => ({ x: 0, y: 0, z: 0, dome: false, peak: 0, baseRadius: 0, tiltX: 0, tiltZ: 0, rise: 0, delay: 0, age: 0, life: 0, height: 0, radius: 0, alpha: 0 })),
|
|
9423
|
+
bubbles: new OrderedPool(limits.bubbles, () => ({ x: 0, y: 0, z: 0, size: 0, rise: 0, delay: 0, age: 0, life: 0, level: 0, alpha: 0 })),
|
|
9424
|
+
mist: new OrderedPool(limits.mist, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, size: 0, age: 0, life: 0, alpha: 0 })),
|
|
9425
|
+
waves: new OrderedPool(limits.waves, () => ({ x: 0, z: 0, speed: 0, amplitude: 0, width: 0, reach: 0, delay: 0, age: 0, life: 0 }))
|
|
9426
|
+
};
|
|
9427
|
+
}
|
|
9428
|
+
|
|
9429
|
+
// src/water/spawn.ts
|
|
9430
|
+
var TRAIL_BUBBLES_MAX = 40;
|
|
9431
|
+
var BLAST_FOAM_LIFE = 8;
|
|
9432
|
+
var BLAST_WAVE_CRESTS = 3;
|
|
9433
|
+
var BLAST_WAVE_GAP = 0.35;
|
|
9434
|
+
var BLAST_WAVE_LIFE = 6;
|
|
9435
|
+
var BLAST_SIDE_JETS = 4;
|
|
9436
|
+
function addRing(context, spec) {
|
|
9437
|
+
const ring2 = context.pools.rings.acquire();
|
|
9438
|
+
ring2.x = spec.x;
|
|
9439
|
+
ring2.y = spec.y;
|
|
9440
|
+
ring2.z = spec.z;
|
|
9441
|
+
ring2.kind = spec.kind;
|
|
9442
|
+
ring2.startRadius = spec.start;
|
|
9443
|
+
ring2.radius = spec.start;
|
|
9444
|
+
ring2.maxRadius = Math.max(spec.start, Math.min(spec.max, context.reach(spec.x, spec.z, spec.max)));
|
|
9445
|
+
ring2.delay = spec.delay;
|
|
9446
|
+
ring2.age = 0;
|
|
9447
|
+
ring2.life = spec.life;
|
|
9448
|
+
ring2.strength = spec.strength;
|
|
9449
|
+
ring2.alpha = 0;
|
|
9450
|
+
}
|
|
9451
|
+
function addFoam(context, at3, radius, life) {
|
|
9452
|
+
const foam = context.pools.foam.acquire();
|
|
9453
|
+
foam.x = at3[0];
|
|
9454
|
+
foam.y = at3[1];
|
|
9455
|
+
foam.z = at3[2];
|
|
9456
|
+
foam.maxRadius = Math.min(radius, Math.max(0.05, context.reach(at3[0], at3[2], radius)));
|
|
9457
|
+
foam.startRadius = foam.maxRadius * 0.35;
|
|
9458
|
+
foam.radius = foam.startRadius;
|
|
9459
|
+
foam.age = 0;
|
|
9460
|
+
foam.life = life;
|
|
9461
|
+
foam.alpha = 0.85;
|
|
9462
|
+
}
|
|
9463
|
+
function addColumn(context, spec) {
|
|
9464
|
+
if (spec.peak < 0.02) return;
|
|
9465
|
+
const column = context.pools.columns.acquire();
|
|
9466
|
+
column.x = spec.at[0];
|
|
9467
|
+
column.y = spec.at[1];
|
|
9468
|
+
column.z = spec.at[2];
|
|
9469
|
+
column.dome = spec.dome;
|
|
9470
|
+
column.peak = spec.peak;
|
|
9471
|
+
column.baseRadius = spec.radius;
|
|
9472
|
+
column.tiltX = spec.tilt[0];
|
|
9473
|
+
column.tiltZ = spec.tilt[1];
|
|
9474
|
+
const flight = Math.sqrt(2 * spec.peak / WATER_GRAVITY);
|
|
9475
|
+
column.rise = spec.rise ?? Math.max(0.06, flight * 0.6);
|
|
9476
|
+
column.life = column.rise + Math.max(0.2, flight * 1.3) + 0.15;
|
|
9477
|
+
column.delay = spec.delay;
|
|
9478
|
+
column.age = 0;
|
|
9479
|
+
column.height = 0;
|
|
9480
|
+
column.radius = spec.radius;
|
|
9481
|
+
column.alpha = 0;
|
|
9482
|
+
}
|
|
9483
|
+
function addDrop(context, spec) {
|
|
9484
|
+
const drop = context.pools.drops.acquire();
|
|
9485
|
+
drop.x = spec.at[0];
|
|
9486
|
+
drop.y = spec.at[1];
|
|
9487
|
+
drop.z = spec.at[2];
|
|
9488
|
+
drop.vx = spec.velocity[0];
|
|
9489
|
+
drop.vy = spec.velocity[1];
|
|
9490
|
+
drop.vz = spec.velocity[2];
|
|
9491
|
+
drop.size = spec.size;
|
|
9492
|
+
drop.level = spec.level;
|
|
9493
|
+
drop.age = 0;
|
|
9494
|
+
drop.life = 6;
|
|
9495
|
+
}
|
|
9496
|
+
function addBubble(context, at3, level, delay, size) {
|
|
9497
|
+
const { random } = context;
|
|
9498
|
+
const bubble = context.pools.bubbles.acquire();
|
|
9499
|
+
bubble.x = at3[0];
|
|
9500
|
+
bubble.y = at3[1];
|
|
9501
|
+
bubble.z = at3[2];
|
|
9502
|
+
bubble.size = size;
|
|
9503
|
+
bubble.rise = random.between(0.2, 0.45);
|
|
9504
|
+
bubble.delay = delay;
|
|
9505
|
+
bubble.age = 0;
|
|
9506
|
+
bubble.life = random.between(0.8, 2.2);
|
|
9507
|
+
bubble.level = level;
|
|
9508
|
+
bubble.alpha = 0;
|
|
9509
|
+
}
|
|
9510
|
+
function spawnShot(context, point, plan) {
|
|
9511
|
+
const { random, detail } = context;
|
|
9512
|
+
const [x, y, z] = point;
|
|
9513
|
+
const profile = plan.profile;
|
|
9514
|
+
addColumn(context, { at: point, peak: plan.columnHeight, radius: plan.columnRadius, tilt: plan.tilt, dome: false, delay: 0 });
|
|
9515
|
+
const drops = Math.round(plan.drops * detail);
|
|
9516
|
+
const steep = plan.ricochet ? 0.3 : 0.4 + 0.6 * Math.sin(plan.angleDeg * Math.PI / 180);
|
|
9517
|
+
for (let index = 0; index < drops; index++) {
|
|
9518
|
+
const angle = random.next() * Math.PI * 2;
|
|
9519
|
+
const speed = random.between(profile.dropSpeed[0], profile.dropSpeed[1]);
|
|
9520
|
+
const out = speed * random.between(0.2, 0.55);
|
|
9521
|
+
const lean = speed * random.between(0.3, 0.9);
|
|
9522
|
+
addDrop(context, {
|
|
9523
|
+
at: [x + Math.cos(angle) * plan.columnRadius, y, z + Math.sin(angle) * plan.columnRadius],
|
|
9524
|
+
velocity: [Math.cos(angle) * out + plan.tilt[0] * lean, speed * steep * random.between(0.7, 1), Math.sin(angle) * out + plan.tilt[1] * lean],
|
|
9525
|
+
size: profile.dropSize * random.between(0.6, 1.4),
|
|
9526
|
+
level: y
|
|
9527
|
+
});
|
|
9528
|
+
}
|
|
9529
|
+
for (let index = 0; index < plan.rings; index++) {
|
|
9530
|
+
addRing(context, { x, y, z, kind: 0, start: plan.columnRadius, max: plan.ringRadius * (1 - index * 0.22), life: profile.ringLife * (1 - index * 0.15), delay: index * 0.12, strength: 0.6 });
|
|
9531
|
+
}
|
|
9532
|
+
if (plan.ricochet) {
|
|
9533
|
+
for (let step = 1; step <= 2; step++) {
|
|
9534
|
+
const sx = x + plan.tilt[0] * 0.3 * step;
|
|
9535
|
+
const sz = z + plan.tilt[1] * 0.3 * step;
|
|
9536
|
+
addRing(context, { x: sx, y, z: sz, kind: 0, start: plan.columnRadius, max: plan.ringRadius * 0.6, life: profile.ringLife * 0.8, delay: 0.02 * step, strength: 0.45 });
|
|
9537
|
+
}
|
|
9538
|
+
}
|
|
9539
|
+
addFoam(context, point, plan.foamRadius, profile.foamLife);
|
|
9540
|
+
spawnTrail(context, point, plan);
|
|
9541
|
+
}
|
|
9542
|
+
function spawnTrail(context, point, plan) {
|
|
9543
|
+
if (plan.trailLength <= 0) return;
|
|
9544
|
+
const { random } = context;
|
|
9545
|
+
const count = Math.min(TRAIL_BUBBLES_MAX, Math.round(plan.profile.bubblesPerMetre * plan.trailLength * context.detail));
|
|
9546
|
+
const [ex, ey, ez] = plan.trailEnd;
|
|
9547
|
+
for (let index = 0; index < count; index++) {
|
|
9548
|
+
const along = random.next() ** 1.6;
|
|
9549
|
+
const jitter = 0.01 + 0.02 * along;
|
|
9550
|
+
const at3 = [point[0] + (ex - point[0]) * along + random.between(-jitter, jitter), point[1] + (ey - point[1]) * along, point[2] + (ez - point[2]) * along + random.between(-jitter, jitter)];
|
|
9551
|
+
addBubble(context, at3, point[1], along * 0.05, random.between(3e-3, 0.01));
|
|
9552
|
+
}
|
|
9553
|
+
}
|
|
9554
|
+
function spawnBlast(context, point, level, plan) {
|
|
9555
|
+
const { random, detail } = context;
|
|
9556
|
+
const surface = [point[0], level, point[2]];
|
|
9557
|
+
const scale = Math.cbrt(plan.tnt);
|
|
9558
|
+
addColumn(context, { at: surface, peak: plan.columnHeight, radius: plan.columnRadius, tilt: [0, 0], dome: false, delay: plan.domeRadius > 0 ? 0.08 : 0 });
|
|
9559
|
+
for (let index = 0; index < BLAST_SIDE_JETS && plan.columnHeight > 0; index++) {
|
|
9560
|
+
const angle = index / BLAST_SIDE_JETS * Math.PI * 2 + random.next();
|
|
9561
|
+
const off = plan.columnRadius * random.between(0.6, 1.1);
|
|
9562
|
+
const lean = random.between(0.1, 0.25);
|
|
9563
|
+
addColumn(context, { at: [surface[0] + Math.cos(angle) * off, level, surface[2] + Math.sin(angle) * off], peak: plan.columnHeight * random.between(0.45, 0.75), radius: plan.columnRadius * 0.45, tilt: [Math.cos(angle) * lean, Math.sin(angle) * lean], dome: false, delay: 0.05 + random.next() * 0.08 });
|
|
9564
|
+
}
|
|
9565
|
+
if (plan.domeRadius > 0) addColumn(context, { at: surface, peak: plan.domeHeight, radius: plan.domeRadius, tilt: [0, 0], dome: true, delay: 0, rise: 0.25 });
|
|
9566
|
+
addRing(context, { x: surface[0], y: level, z: surface[2], kind: 1, start: 0.2, max: plan.shockRadius, life: 0.45, delay: 0, strength: 0.95 });
|
|
9567
|
+
spawnWaves(context, surface, plan);
|
|
9568
|
+
spawnRain(context, surface, plan, detail);
|
|
9569
|
+
spawnSpray(context, surface, plan, scale);
|
|
9570
|
+
addFoam(context, surface, plan.foamRadius, BLAST_FOAM_LIFE);
|
|
9571
|
+
const bubbles = Math.round(plan.bubbles * detail);
|
|
9572
|
+
for (let index = 0; index < bubbles; index++) {
|
|
9573
|
+
const at3 = [point[0] + random.between(-0.5, 0.5) * scale, Math.min(level - 0.02, point[1] + random.between(-0.2, 0.3) * scale), point[2] + random.between(-0.5, 0.5) * scale];
|
|
9574
|
+
addBubble(context, at3, level, random.next() * 1.2, random.between(0.01, 0.04) * Math.max(1, scale));
|
|
9575
|
+
}
|
|
9576
|
+
}
|
|
9577
|
+
function spawnWaves(context, surface, plan) {
|
|
9578
|
+
if (plan.waveAmplitude <= 0) return;
|
|
9579
|
+
const reach = context.reach(surface[0], surface[2], plan.waveSpeed * BLAST_WAVE_LIFE);
|
|
9580
|
+
for (let crest = 0; crest < BLAST_WAVE_CRESTS; crest++) {
|
|
9581
|
+
const wave = context.pools.waves.acquire();
|
|
9582
|
+
wave.x = surface[0];
|
|
9583
|
+
wave.z = surface[2];
|
|
9584
|
+
wave.speed = plan.waveSpeed;
|
|
9585
|
+
wave.amplitude = plan.waveAmplitude * (1 - crest * 0.3);
|
|
9586
|
+
wave.width = 0.25 + 0.3 * Math.cbrt(plan.tnt);
|
|
9587
|
+
wave.reach = reach;
|
|
9588
|
+
wave.delay = crest * BLAST_WAVE_GAP;
|
|
9589
|
+
wave.age = 0;
|
|
9590
|
+
wave.life = BLAST_WAVE_LIFE;
|
|
9591
|
+
addRing(context, { x: surface[0], y: surface[1], z: surface[2], kind: 2, start: 0.1, max: plan.waveSpeed * BLAST_WAVE_LIFE, life: BLAST_WAVE_LIFE, delay: wave.delay, strength: 0.5 * (1 - crest * 0.3) });
|
|
9592
|
+
}
|
|
9593
|
+
}
|
|
9594
|
+
function spawnRain(context, surface, plan, detail) {
|
|
9595
|
+
const { random } = context;
|
|
9596
|
+
const drops = Math.round(plan.drops * detail);
|
|
9597
|
+
const top = Math.max(0.5, plan.columnHeight);
|
|
9598
|
+
const launch = Math.sqrt(2 * WATER_GRAVITY * top);
|
|
9599
|
+
const scale = Math.cbrt(plan.tnt);
|
|
9600
|
+
for (let index = 0; index < drops; index++) {
|
|
9601
|
+
const angle = random.next() * Math.PI * 2;
|
|
9602
|
+
const out = random.between(0.4, 3) * scale;
|
|
9603
|
+
const r = random.next() * plan.columnRadius;
|
|
9604
|
+
addDrop(context, {
|
|
9605
|
+
at: [surface[0] + Math.cos(angle) * r, surface[1] + random.next() * top * 0.2, surface[2] + Math.sin(angle) * r],
|
|
9606
|
+
velocity: [Math.cos(angle) * out, launch * random.between(0.45, 1.02), Math.sin(angle) * out],
|
|
9607
|
+
size: random.between(0.012, 0.035),
|
|
9608
|
+
level: surface[1]
|
|
9609
|
+
});
|
|
9610
|
+
}
|
|
9611
|
+
}
|
|
9612
|
+
function spawnSpray(context, surface, plan, scale) {
|
|
9613
|
+
const { random } = context;
|
|
9614
|
+
const top = Math.max(0.4, plan.columnHeight);
|
|
9615
|
+
for (let index = 0; index < plan.mist; index++) {
|
|
9616
|
+
const mist = context.pools.mist.acquire();
|
|
9617
|
+
const angle = random.next() * Math.PI * 2;
|
|
9618
|
+
const r = random.next() * (plan.columnRadius + 0.5 * scale);
|
|
9619
|
+
mist.x = surface[0] + Math.cos(angle) * r;
|
|
9620
|
+
mist.y = surface[1] + random.next() * top * 0.6;
|
|
9621
|
+
mist.z = surface[2] + Math.sin(angle) * r;
|
|
9622
|
+
const out = random.between(0.5, 1.8) * scale;
|
|
9623
|
+
mist.vx = Math.cos(angle) * out;
|
|
9624
|
+
mist.vy = random.between(0.3, 1);
|
|
9625
|
+
mist.vz = Math.sin(angle) * out;
|
|
9626
|
+
mist.size = random.between(0.4, 1.2) * scale;
|
|
9627
|
+
mist.age = 0;
|
|
9628
|
+
mist.life = random.between(2.5, 4.5);
|
|
9629
|
+
mist.alpha = 0;
|
|
9630
|
+
}
|
|
9631
|
+
}
|
|
9632
|
+
|
|
9633
|
+
// src/water/effects.ts
|
|
9634
|
+
var STEP_LIMIT = 0.05;
|
|
9635
|
+
var SHORE_DIRECTIONS = 8;
|
|
9636
|
+
var SHORE_HALVINGS = 5;
|
|
9637
|
+
var SAME_WATER = 0.2;
|
|
9638
|
+
var DROP_RING_SHARE = 0.75;
|
|
9639
|
+
var WAVE_PUSH = 2;
|
|
9640
|
+
function createWaterEffects(options = {}) {
|
|
9641
|
+
const limits = { ...WATER_LIMITS, ...options.limits };
|
|
9642
|
+
const pools = createWaterPools(limits);
|
|
9643
|
+
const random = lehmer(options.seed ?? 1);
|
|
9644
|
+
const lod = options.lod ?? LOD_GAME;
|
|
9645
|
+
const camera2 = [0, 0, 0];
|
|
9646
|
+
let hasCamera = false;
|
|
9647
|
+
const reach = (x, z, limit) => {
|
|
9648
|
+
const levelAt = options.levelAt;
|
|
9649
|
+
if (!levelAt) return limit;
|
|
9650
|
+
const here = levelAt(x, z);
|
|
9651
|
+
if (here === null) return 0;
|
|
9652
|
+
const step = Math.max(0.05, limit / 10);
|
|
9653
|
+
const isWater = (cos2, sin2, distance) => {
|
|
9654
|
+
const level = levelAt(x + cos2 * distance, z + sin2 * distance);
|
|
9655
|
+
return level !== null && Math.abs(level - here) <= SAME_WATER;
|
|
9656
|
+
};
|
|
9657
|
+
let nearest = limit;
|
|
9658
|
+
for (let index = 0; index < SHORE_DIRECTIONS; index++) {
|
|
9659
|
+
const angle = index / SHORE_DIRECTIONS * Math.PI * 2;
|
|
9660
|
+
const cos2 = Math.cos(angle);
|
|
9661
|
+
const sin2 = Math.sin(angle);
|
|
9662
|
+
for (let distance = step; distance < nearest; distance += step) {
|
|
9663
|
+
if (isWater(cos2, sin2, distance)) continue;
|
|
9664
|
+
let wet = distance - step;
|
|
9665
|
+
let dry = distance;
|
|
9666
|
+
for (let halving = 0; halving < SHORE_HALVINGS; halving++) {
|
|
9667
|
+
const middle = (wet + dry) / 2;
|
|
9668
|
+
if (isWater(cos2, sin2, middle)) wet = middle;
|
|
9669
|
+
else dry = middle;
|
|
9670
|
+
}
|
|
9671
|
+
nearest = Math.min(nearest, wet);
|
|
9672
|
+
break;
|
|
9673
|
+
}
|
|
9674
|
+
}
|
|
9675
|
+
return nearest;
|
|
9676
|
+
};
|
|
9677
|
+
const detailAt = (point, radius) => hasCamera ? lodScale(lod, Math.hypot(point[0] - camera2[0], point[1] - camera2[1], point[2] - camera2[2]), radius) : 1;
|
|
9678
|
+
const contextAt = (point, radius) => ({ pools, random, detail: detailAt(point, radius), reach });
|
|
9679
|
+
const motion = {
|
|
9680
|
+
dt: 0,
|
|
9681
|
+
landed: (drop) => {
|
|
9682
|
+
if (pools.rings.count >= limits.rings * DROP_RING_SHARE) return;
|
|
9683
|
+
const level = options.levelAt ? options.levelAt(drop.x, drop.z) : drop.level;
|
|
9684
|
+
if (level === null || Math.abs(level - drop.level) > SAME_WATER) return;
|
|
9685
|
+
addRing({ pools, random, detail: 1, reach }, { x: drop.x, y: level, z: drop.z, kind: 0, start: drop.size, max: 0.04 + drop.size * 6, life: 0.5, delay: 0, strength: 0.35 });
|
|
9686
|
+
}
|
|
9687
|
+
};
|
|
9688
|
+
const shot = (params) => {
|
|
9689
|
+
const plan = planWaterShot(params, random, options.profiles);
|
|
9690
|
+
spawnShot(contextAt(params.point, plan.ringRadius), params.point, plan);
|
|
9691
|
+
return plan;
|
|
9692
|
+
};
|
|
9693
|
+
const pepper = (params, plan) => {
|
|
9694
|
+
const spread = 1.5 + 3 * Math.cbrt(plan.tnt);
|
|
9695
|
+
for (let index = 0; index < plan.fragments; index++) {
|
|
9696
|
+
const angle = random.next() * Math.PI * 2;
|
|
9697
|
+
const distance = random.between(0.6, spread);
|
|
9698
|
+
const x = params.point[0] + Math.cos(angle) * distance;
|
|
9699
|
+
const z = params.point[2] + Math.sin(angle) * distance;
|
|
9700
|
+
const level = options.levelAt ? options.levelAt(x, z) : params.level;
|
|
9701
|
+
if (level === null || Math.abs(level - params.level) > SAME_WATER) continue;
|
|
9702
|
+
const fall = random.between(0.4, 1);
|
|
9703
|
+
const length = Math.hypot(Math.cos(angle), fall, Math.sin(angle));
|
|
9704
|
+
const point = [x, level, z];
|
|
9705
|
+
const fragment = planWaterShot({ point, direction: [Math.cos(angle) / length, -fall / length, Math.sin(angle) / length], profile: "fragment", depth: params.depth }, random, options.profiles);
|
|
9706
|
+
spawnShot(contextAt(point, fragment.ringRadius), point, fragment);
|
|
9707
|
+
}
|
|
9708
|
+
};
|
|
9709
|
+
const blast = (params) => {
|
|
9710
|
+
const plan = planWaterBlast(params);
|
|
9711
|
+
spawnBlast(contextAt(params.point, plan.shockRadius), params.point, params.level, plan);
|
|
9712
|
+
pepper(params, plan);
|
|
9713
|
+
return plan;
|
|
9714
|
+
};
|
|
9715
|
+
const waveAt = (x, z) => {
|
|
9716
|
+
let height = 0;
|
|
9717
|
+
let pushX = 0;
|
|
9718
|
+
let pushZ = 0;
|
|
9719
|
+
for (const wave of pools.waves.items) {
|
|
9720
|
+
if (wave.delay > 0) continue;
|
|
9721
|
+
const dx = x - wave.x;
|
|
9722
|
+
const dz = z - wave.z;
|
|
9723
|
+
const r = Math.hypot(dx, dz);
|
|
9724
|
+
if (r > wave.reach) continue;
|
|
9725
|
+
const off = (r - wave.speed * wave.age) / wave.width;
|
|
9726
|
+
if (Math.abs(off) > 3) continue;
|
|
9727
|
+
const crest = wave.amplitude * Math.exp(-off * off) * (1 - wave.age / wave.life) / Math.sqrt(Math.max(1, r));
|
|
9728
|
+
height += crest;
|
|
9729
|
+
if (r > 1e-3) {
|
|
9730
|
+
const push = crest * wave.speed * WAVE_PUSH;
|
|
9731
|
+
pushX += dx / r * push;
|
|
9732
|
+
pushZ += dz / r * push;
|
|
9733
|
+
}
|
|
9734
|
+
}
|
|
9735
|
+
return { height, push: [pushX, pushZ] };
|
|
9736
|
+
};
|
|
9737
|
+
return {
|
|
9738
|
+
shot,
|
|
9739
|
+
blast,
|
|
9740
|
+
update(dt) {
|
|
9741
|
+
let left = Math.max(0, dt);
|
|
9742
|
+
while (left > 1e-6) {
|
|
9743
|
+
motion.dt = Math.min(STEP_LIMIT, left);
|
|
9744
|
+
stepWaterPools(pools, motion);
|
|
9745
|
+
left -= motion.dt;
|
|
9746
|
+
}
|
|
9747
|
+
},
|
|
9748
|
+
setCamera(position) {
|
|
9749
|
+
camera2[0] = position[0];
|
|
9750
|
+
camera2[1] = position[1];
|
|
9751
|
+
camera2[2] = position[2];
|
|
9752
|
+
hasCamera = true;
|
|
9753
|
+
},
|
|
9754
|
+
waveAt,
|
|
9755
|
+
drops: pools.drops.items,
|
|
9756
|
+
rings: pools.rings.items,
|
|
9757
|
+
foam: pools.foam.items,
|
|
9758
|
+
columns: pools.columns.items,
|
|
9759
|
+
bubbles: pools.bubbles.items,
|
|
9760
|
+
mist: pools.mist.items,
|
|
9761
|
+
waves: pools.waves.items,
|
|
9762
|
+
limits,
|
|
9763
|
+
stats: () => ({ drops: pools.drops.count, rings: pools.rings.count, foam: pools.foam.count, columns: pools.columns.count, bubbles: pools.bubbles.count, mist: pools.mist.count, waves: pools.waves.count }),
|
|
9764
|
+
clear() {
|
|
9765
|
+
for (const pool of Object.values(pools)) pool.clear();
|
|
9766
|
+
}
|
|
9767
|
+
};
|
|
9768
|
+
}
|
|
9039
9769
|
return __toCommonJS(index_exports);
|
|
9040
9770
|
})();
|
|
9041
9771
|
//# sourceMappingURL=index.global.js.map
|