@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.js
CHANGED
|
@@ -3680,67 +3680,59 @@ var COUGH_AND_BREATH = {
|
|
|
3680
3680
|
]
|
|
3681
3681
|
};
|
|
3682
3682
|
|
|
3683
|
-
// src/effects/events.ts
|
|
3683
|
+
// src/effects/material-events.ts
|
|
3684
|
+
var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
|
|
3685
|
+
var DEBRIS_COLOR_VARIABLE = "debrisColor";
|
|
3686
|
+
var DUST_COLOR_VARIABLE = "dustColor";
|
|
3687
|
+
var FAMILIES = {
|
|
3688
|
+
wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
|
|
3689
|
+
masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
|
|
3690
|
+
glass: { debris: 11061464, dust: 12572386, piece: [0.04, 4e-3, 0.04], spin: 14, cloud: 0.25, sparks: false, glints: true },
|
|
3691
|
+
metal: { debris: 9080726, dust: 9078138, piece: [0.04, 6e-3, 0.03], spin: 8, cloud: 0.15, sparks: true, glints: false },
|
|
3692
|
+
soft: { debris: 10130568, dust: 11578014, piece: [0.025, 4e-3, 0.02], spin: 6, cloud: 0.3, sparks: false, glints: false },
|
|
3693
|
+
soil: { debris: 8022613, dust: 9075298, piece: [0.03, 0.025, 0.03], spin: 3, cloud: 1, sparks: false, glints: false }
|
|
3694
|
+
};
|
|
3695
|
+
var ORIGIN = [0, 0, 0];
|
|
3684
3696
|
var FACING4 = [0, 0, 1];
|
|
3685
3697
|
var UP11 = [0, 1, 0];
|
|
3686
|
-
var
|
|
3687
|
-
var
|
|
3688
|
-
var
|
|
3689
|
-
var
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
}
|
|
3697
|
-
var muzzleEffect = (weapon) => ({
|
|
3698
|
-
id: `muzzle_${weapon}`,
|
|
3699
|
-
pageId: `event:muzzle_${weapon}`,
|
|
3700
|
-
team: "weapons",
|
|
3701
|
-
budget: { particles: 60, lights: 1 },
|
|
3702
|
-
loop: 2.4,
|
|
3703
|
-
timeline: [call2("muzzle", weapon, ORIGIN, FORWARD4)]
|
|
3704
|
-
});
|
|
3705
|
-
var casingEffect = (id, type) => ({
|
|
3706
|
-
id,
|
|
3707
|
-
pageId: `event:${id}`,
|
|
3708
|
-
team: "weapons",
|
|
3709
|
-
budget: { debris: 1 },
|
|
3710
|
-
loop: 2,
|
|
3711
|
-
timeline: [call2("casing", ORIGIN, type)]
|
|
3712
|
-
});
|
|
3713
|
-
var EVENT_EFFECTS = [
|
|
3714
|
-
...IMPACT_MATERIALS.map(impactEffect),
|
|
3715
|
-
...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
|
|
3716
|
-
casingEffect("casing_brass", ""),
|
|
3717
|
-
casingEffect("casing_shell", "shell"),
|
|
3718
|
-
casingEffect("casing_50", "50"),
|
|
3719
|
-
{
|
|
3720
|
-
// door_stages (W856-871): the dust a blow shakes loose from the frame and the splinters.
|
|
3721
|
-
id: "stage_crack",
|
|
3722
|
-
pageId: "event:stage_crack",
|
|
3698
|
+
var grow = (piece, factor) => [piece[0] * factor, piece[1] * factor, piece[2] * factor];
|
|
3699
|
+
var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
|
|
3700
|
+
var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
|
|
3701
|
+
var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
|
|
3702
|
+
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 })] : [];
|
|
3703
|
+
function stageCrack(family) {
|
|
3704
|
+
const look = FAMILIES[family];
|
|
3705
|
+
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 })];
|
|
3706
|
+
return {
|
|
3707
|
+
id: `stage_crack_${family}`,
|
|
3708
|
+
pageId: `event:stage_crack_${family}`,
|
|
3723
3709
|
team: "destruction",
|
|
3724
|
-
budget: { particles:
|
|
3710
|
+
budget: { particles: 16, debris: 6 },
|
|
3725
3711
|
loop: 2,
|
|
3726
3712
|
timeline: [
|
|
3727
|
-
|
|
3728
|
-
|
|
3713
|
+
...dust,
|
|
3714
|
+
...sparks(look, 8),
|
|
3715
|
+
...glints(look, 4),
|
|
3716
|
+
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 }))
|
|
3729
3717
|
]
|
|
3730
|
-
}
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3718
|
+
};
|
|
3719
|
+
}
|
|
3720
|
+
function breachDust(family) {
|
|
3721
|
+
const look = FAMILIES[family];
|
|
3722
|
+
return {
|
|
3723
|
+
id: `breach_dust_${family}`,
|
|
3724
|
+
pageId: `event:breach_dust_${family}`,
|
|
3735
3725
|
team: "destruction",
|
|
3736
3726
|
budget: { particles: 90, debris: 16 },
|
|
3737
3727
|
loop: 5,
|
|
3738
3728
|
timeline: [
|
|
3739
3729
|
screen({ add: { shake: 0.25 } }),
|
|
3740
|
-
|
|
3741
|
-
|
|
3730
|
+
...sparks(look, 14),
|
|
3731
|
+
...glints(look, 20),
|
|
3732
|
+
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 }),
|
|
3733
|
+
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 })),
|
|
3742
3734
|
repeat(
|
|
3743
|
-
scaled(60),
|
|
3735
|
+
scaled(Math.round(60 * look.cloud)),
|
|
3744
3736
|
spawn("normal", local("angle", rnd(0, 6.283), {
|
|
3745
3737
|
p: [rnd(-1.4, 1.4), 0.2, rnd(-0.6, 0.4)],
|
|
3746
3738
|
dir: vnorm([cos(variable("angle")), 0.3, sin(variable("angle"))]),
|
|
@@ -3750,27 +3742,30 @@ var EVENT_EFFECTS = [
|
|
|
3750
3742
|
life: [2.5, 4.5],
|
|
3751
3743
|
size: [0.6, 1],
|
|
3752
3744
|
grow: 3,
|
|
3753
|
-
c0:
|
|
3745
|
+
c0: dustTone(look),
|
|
3754
3746
|
c1: 4867648,
|
|
3755
3747
|
a: 0.45,
|
|
3756
3748
|
fi: 0.12
|
|
3757
3749
|
}))
|
|
3758
3750
|
)
|
|
3759
3751
|
]
|
|
3760
|
-
}
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3752
|
+
};
|
|
3753
|
+
}
|
|
3754
|
+
function collapseDust(family) {
|
|
3755
|
+
const look = FAMILIES[family];
|
|
3756
|
+
return {
|
|
3757
|
+
id: `collapse_dust_${family}`,
|
|
3758
|
+
pageId: `event:collapse_dust_${family}`,
|
|
3765
3759
|
team: "destruction",
|
|
3766
3760
|
budget: { particles: 350, debris: 26 },
|
|
3767
3761
|
loop: 8,
|
|
3768
3762
|
timeline: [
|
|
3769
3763
|
screen({ add: { shake: 0.45 } }),
|
|
3770
|
-
|
|
3771
|
-
repeat(
|
|
3764
|
+
...sparks(look, 20),
|
|
3765
|
+
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 })),
|
|
3766
|
+
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 })),
|
|
3772
3767
|
repeat(
|
|
3773
|
-
scaled(70),
|
|
3768
|
+
scaled(Math.round(70 * look.cloud)),
|
|
3774
3769
|
spawn("normal", local("angle", rnd(-0.4, 3.5), {
|
|
3775
3770
|
p: [rnd(-2, 2), 0.2, rnd(-0.5, 0.5)],
|
|
3776
3771
|
dir: vnorm([mul(cos(variable("angle")), 0.6), 0.25, sin(variable("angle"))]),
|
|
@@ -3780,14 +3775,68 @@ var EVENT_EFFECTS = [
|
|
|
3780
3775
|
life: [3, 6],
|
|
3781
3776
|
size: [0.7, 1.2],
|
|
3782
3777
|
grow: 3,
|
|
3783
|
-
c0:
|
|
3778
|
+
c0: dustTone(look),
|
|
3784
3779
|
c1: 4867648,
|
|
3785
3780
|
a: 0.5,
|
|
3786
3781
|
fi: 0.12
|
|
3787
3782
|
}))
|
|
3788
3783
|
)
|
|
3789
3784
|
]
|
|
3790
|
-
}
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
var MASONRY = FAMILIES.masonry;
|
|
3788
|
+
var REBAR_EXPOSE = {
|
|
3789
|
+
id: "rebar_expose",
|
|
3790
|
+
pageId: "event:rebar_expose",
|
|
3791
|
+
team: "destruction",
|
|
3792
|
+
budget: { particles: 24, debris: 8 },
|
|
3793
|
+
loop: 2,
|
|
3794
|
+
timeline: [
|
|
3795
|
+
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 })),
|
|
3796
|
+
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 }),
|
|
3797
|
+
call2("rust_at", ORIGIN, 6)
|
|
3798
|
+
]
|
|
3799
|
+
};
|
|
3800
|
+
var MATERIAL_EVENT_EFFECTS = [
|
|
3801
|
+
...DEBRIS_EFFECT_FAMILIES.flatMap((family) => [stageCrack(family), breachDust(family), collapseDust(family)]),
|
|
3802
|
+
REBAR_EXPOSE
|
|
3803
|
+
];
|
|
3804
|
+
|
|
3805
|
+
// src/effects/events.ts
|
|
3806
|
+
var FACING5 = [0, 0, 1];
|
|
3807
|
+
var ORIGIN2 = [0, 0, 0];
|
|
3808
|
+
var FORWARD4 = [0, 0, -1];
|
|
3809
|
+
var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
|
|
3810
|
+
var impactEffect = (material) => ({
|
|
3811
|
+
id: `impact_${material}`,
|
|
3812
|
+
pageId: `event:impact_${material}`,
|
|
3813
|
+
team: "weapons",
|
|
3814
|
+
budget: { particles: 40, decals: 1 },
|
|
3815
|
+
loop: 2,
|
|
3816
|
+
timeline: [call2("impact", material, ORIGIN2, FACING5, 1, 0)]
|
|
3817
|
+
});
|
|
3818
|
+
var muzzleEffect = (weapon) => ({
|
|
3819
|
+
id: `muzzle_${weapon}`,
|
|
3820
|
+
pageId: `event:muzzle_${weapon}`,
|
|
3821
|
+
team: "weapons",
|
|
3822
|
+
budget: { particles: 60, lights: 1 },
|
|
3823
|
+
loop: 2.4,
|
|
3824
|
+
timeline: [call2("muzzle", weapon, ORIGIN2, FORWARD4)]
|
|
3825
|
+
});
|
|
3826
|
+
var casingEffect = (id, type) => ({
|
|
3827
|
+
id,
|
|
3828
|
+
pageId: `event:${id}`,
|
|
3829
|
+
team: "weapons",
|
|
3830
|
+
budget: { debris: 1 },
|
|
3831
|
+
loop: 2,
|
|
3832
|
+
timeline: [call2("casing", ORIGIN2, type)]
|
|
3833
|
+
});
|
|
3834
|
+
var EVENT_EFFECTS = [
|
|
3835
|
+
...IMPACT_MATERIALS.map(impactEffect),
|
|
3836
|
+
...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
|
|
3837
|
+
casingEffect("casing_brass", ""),
|
|
3838
|
+
casingEffect("casing_shell", "shell"),
|
|
3839
|
+
casingEffect("casing_50", "50"),
|
|
3791
3840
|
{
|
|
3792
3841
|
// shopfront_glass (W846-855): the pane coming down as shards, the flash of the glints and the pale dust.
|
|
3793
3842
|
id: "glass_burst",
|
|
@@ -3799,21 +3848,13 @@ var EVENT_EFFECTS = [
|
|
|
3799
3848
|
screen({ add: { shake: 0.08 } }),
|
|
3800
3849
|
repeat(
|
|
3801
3850
|
scaled(75),
|
|
3802
|
-
debris({ p:
|
|
3851
|
+
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 })
|
|
3803
3852
|
),
|
|
3804
|
-
burst("add", 30, { p:
|
|
3853
|
+
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 }),
|
|
3805
3854
|
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 })
|
|
3806
3855
|
]
|
|
3807
3856
|
},
|
|
3808
|
-
|
|
3809
|
-
// The chips macro the page uses on wood (W849) plus rust (`rustAt`), for rebar laid bare in concrete.
|
|
3810
|
-
id: "rebar_expose",
|
|
3811
|
-
pageId: "event:rebar_expose",
|
|
3812
|
-
team: "destruction",
|
|
3813
|
-
budget: { particles: 20, debris: 8 },
|
|
3814
|
-
loop: 2,
|
|
3815
|
-
timeline: [call2("chips", ORIGIN, UP11, 8, 0.9), call2("rust_at", ORIGIN, 6)]
|
|
3816
|
-
}
|
|
3857
|
+
...MATERIAL_EVENT_EFFECTS
|
|
3817
3858
|
];
|
|
3818
3859
|
|
|
3819
3860
|
// src/effects/weapons/viewmodel.ts
|
|
@@ -3826,7 +3867,7 @@ var FLASH_RAMP = [0.6, 0.9];
|
|
|
3826
3867
|
var FLASH_OPACITY = 0.95;
|
|
3827
3868
|
var FLAME_COLORS = [16742946, 16760896, 13121050, 16773296];
|
|
3828
3869
|
var FLAME_ADDITIVE = 3;
|
|
3829
|
-
var
|
|
3870
|
+
var ORIGIN3 = [0, 0, 0];
|
|
3830
3871
|
var SIZE = variable("size");
|
|
3831
3872
|
var FLASH_SCALE = variable("flash");
|
|
3832
3873
|
var fallback = (name, defaultValue) => ite(ne(variable(name), void 0), variable(name), defaultValue);
|
|
@@ -3874,7 +3915,7 @@ var flameBit = (point, velocity, world, radius, life) => [
|
|
|
3874
3915
|
grow: 2.2
|
|
3875
3916
|
})
|
|
3876
3917
|
];
|
|
3877
|
-
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:
|
|
3918
|
+
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 });
|
|
3878
3919
|
var MUZZLE_FLASH2 = {
|
|
3879
3920
|
id: "viewmodel_muzzle_flash",
|
|
3880
3921
|
pageId: "event:viewmodel_muzzle_flash",
|
|
@@ -3901,7 +3942,7 @@ var MUZZLE_FLASH2 = {
|
|
|
3901
3942
|
repeat(4, append("angles", add(div(mul(INDEX, PI), 2), mul(rand(), 0.6)))),
|
|
3902
3943
|
set("roll", mul(rand(), PI)),
|
|
3903
3944
|
when(gt(FLASH_SCALE, 0), [
|
|
3904
|
-
flash(
|
|
3945
|
+
flash(ORIGIN3, 16756832, mul(4, SIZE, FLASH_SCALE), FLASH_SECONDS, mul(2, SIZE, FLASH_SCALE), true, true),
|
|
3905
3946
|
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),
|
|
3906
3947
|
repeat(
|
|
3907
3948
|
4,
|
|
@@ -3921,7 +3962,7 @@ var MUZZLE_FLASH2 = {
|
|
|
3921
3962
|
repeat(
|
|
3922
3963
|
variable("puffs"),
|
|
3923
3964
|
puff2(
|
|
3924
|
-
|
|
3965
|
+
ORIGIN3,
|
|
3925
3966
|
[add(variable("drift"), mul(rand(), variable("driftSpread"))), add(variable("rise"), mul(rand(), variable("riseSpread"))), mul(sub(rand(), 0.5), variable("sideSpread"))],
|
|
3926
3967
|
[0, 0, 0],
|
|
3927
3968
|
mul(variable("radius"), SIZE),
|
|
@@ -3938,7 +3979,7 @@ var SMOKE_PUFF = {
|
|
|
3938
3979
|
team: "weapons",
|
|
3939
3980
|
budget: { particles: 1 },
|
|
3940
3981
|
loop: 0.1,
|
|
3941
|
-
timeline: [puff2(
|
|
3982
|
+
timeline: [puff2(ORIGIN3, void 0, [variable("vx"), variable("vy"), variable("vz")], variable("radius"), variable("life"), variable("opacity"))]
|
|
3942
3983
|
};
|
|
3943
3984
|
var BACKBLAST = {
|
|
3944
3985
|
id: "launcher_backblast",
|
|
@@ -3947,8 +3988,8 @@ var BACKBLAST = {
|
|
|
3947
3988
|
budget: { particles: 40 },
|
|
3948
3989
|
loop: 0.1,
|
|
3949
3990
|
timeline: [
|
|
3950
|
-
repeat(26, puff2(
|
|
3951
|
-
repeat(14, ...flameBit(
|
|
3991
|
+
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)),
|
|
3992
|
+
repeat(14, ...flameBit(ORIGIN3, [neg(add(2, mul(rand(), 2))), 0, 0], [wide(1), wide(0.6), wide(1)], 0.02, 0.25))
|
|
3952
3993
|
]
|
|
3953
3994
|
};
|
|
3954
3995
|
var FLAME_JET = {
|
|
@@ -4087,7 +4128,7 @@ function impact(engine, material, point, normal, scale = 1, age = 0) {
|
|
|
4087
4128
|
// src/effects/behaviors/blocks.ts
|
|
4088
4129
|
var COLUMNS = 6;
|
|
4089
4130
|
var ROWS = 5;
|
|
4090
|
-
var
|
|
4131
|
+
var ORIGIN4 = [-2.2, 0, 2.6];
|
|
4091
4132
|
var BLOCK_SIZE = [0.5, 0.44, 0.25];
|
|
4092
4133
|
var OBJECT_ID_DRAWS2 = 4;
|
|
4093
4134
|
var FLOOR2 = 0.13;
|
|
@@ -4130,7 +4171,7 @@ function createBlocksBehavior() {
|
|
|
4130
4171
|
const chipScale = random.between(0.8, 1.3) * scale;
|
|
4131
4172
|
for (let draw = 0; draw < OBJECT_ID_DRAWS2; draw++) random.next();
|
|
4132
4173
|
best.holes.push({ x: offsetX, y: offsetY, scale, chipTurn, chipScale });
|
|
4133
|
-
impact(host.engine, "concrete", [
|
|
4174
|
+
impact(host.engine, "concrete", [ORIGIN4[0] + x, y, ORIGIN4[2] + 0.13], [0, 0, 1], 0.8);
|
|
4134
4175
|
} else if (action === "collapse") {
|
|
4135
4176
|
const { x, y } = args;
|
|
4136
4177
|
for (const block of blocks) {
|
|
@@ -4182,7 +4223,7 @@ function createBlocksBehavior() {
|
|
|
4182
4223
|
}
|
|
4183
4224
|
|
|
4184
4225
|
// src/effects/behaviors/car.ts
|
|
4185
|
-
var
|
|
4226
|
+
var ORIGIN5 = [5.6, 0, 0.8];
|
|
4186
4227
|
var MAX_TILT = 0.25;
|
|
4187
4228
|
function createCarBehavior() {
|
|
4188
4229
|
let y = 0;
|
|
@@ -4215,7 +4256,7 @@ function createCarBehavior() {
|
|
|
4215
4256
|
}
|
|
4216
4257
|
},
|
|
4217
4258
|
query(_host, name, args) {
|
|
4218
|
-
if (name === "position") return [
|
|
4259
|
+
if (name === "position") return [ORIGIN5[0], y, ORIGIN5[2]];
|
|
4219
4260
|
if (name === "point") {
|
|
4220
4261
|
const [x, py, z] = args;
|
|
4221
4262
|
const point = carPoint(x, py, z);
|
|
@@ -5120,7 +5161,7 @@ var EffectInstance = class {
|
|
|
5120
5161
|
};
|
|
5121
5162
|
|
|
5122
5163
|
// src/effects/player.ts
|
|
5123
|
-
var
|
|
5164
|
+
var ORIGIN6 = [0, 0, 0];
|
|
5124
5165
|
var DEFAULT_HEADING = [0, 0, -1];
|
|
5125
5166
|
var DEFAULT_MAX_INSTANCES = 48;
|
|
5126
5167
|
var ENDLESS_SECONDS = 60;
|
|
@@ -5197,7 +5238,7 @@ function createEffectPlayer(options) {
|
|
|
5197
5238
|
random: playOptions.seed !== void 0 ? streamOf(playOptions.seed) : void 0,
|
|
5198
5239
|
follow: playOptions.follow,
|
|
5199
5240
|
origin: point,
|
|
5200
|
-
anchor: def.anchor ??
|
|
5241
|
+
anchor: def.anchor ?? ORIGIN6,
|
|
5201
5242
|
yaw: yawOf(heading, playOptions.direction),
|
|
5202
5243
|
orientation: playOptions.orientation,
|
|
5203
5244
|
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
|
|
@@ -7896,9 +7937,9 @@ function createVfx(options = {}) {
|
|
|
7896
7937
|
// src/data/event-effects.json
|
|
7897
7938
|
var event_effects_default = {
|
|
7898
7939
|
spall: "impact_{material}",
|
|
7899
|
-
stage: { "1": "
|
|
7940
|
+
stage: { "1": "stage_crack_{material}", "2": "breach_dust_{material}", "3": "collapse_dust_{material}" },
|
|
7900
7941
|
expose: "rebar_expose",
|
|
7901
|
-
collapse: "
|
|
7942
|
+
collapse: "collapse_dust_{material}",
|
|
7902
7943
|
explode: "explosion",
|
|
7903
7944
|
fracture: { glass: "glass_burst" }
|
|
7904
7945
|
};
|
|
@@ -7908,9 +7949,14 @@ var EVENT_EFFECTS_MAP = event_effects_default;
|
|
|
7908
7949
|
function effectForEvent(event, map = EVENT_EFFECTS_MAP) {
|
|
7909
7950
|
const entry = map[event.kind];
|
|
7910
7951
|
if (entry === void 0) return void 0;
|
|
7911
|
-
if (typeof entry === "string") return
|
|
7952
|
+
if (typeof entry === "string") return withMaterial(entry, event.material);
|
|
7912
7953
|
const key = event.stage !== void 0 ? String(event.stage) : event.material;
|
|
7913
|
-
|
|
7954
|
+
const chosen = key === void 0 ? void 0 : entry[key];
|
|
7955
|
+
return chosen === void 0 ? void 0 : withMaterial(chosen, event.material);
|
|
7956
|
+
}
|
|
7957
|
+
function withMaterial(entry, material) {
|
|
7958
|
+
if (!entry.includes("{material}")) return entry;
|
|
7959
|
+
return material ? entry.replace("{material}", material) : void 0;
|
|
7914
7960
|
}
|
|
7915
7961
|
|
|
7916
7962
|
// src/locales/en.ts
|
|
@@ -8958,8 +9004,679 @@ function createGroundField(options = {}) {
|
|
|
8958
9004
|
reset
|
|
8959
9005
|
};
|
|
8960
9006
|
}
|
|
9007
|
+
|
|
9008
|
+
// src/water/motion.ts
|
|
9009
|
+
var WATER_GRAVITY = 9.81;
|
|
9010
|
+
var DROP_DRAG = 0.25;
|
|
9011
|
+
var MIST_DRAG = 1.2;
|
|
9012
|
+
function moveDrop(drop, context) {
|
|
9013
|
+
const { dt } = context;
|
|
9014
|
+
drop.age += dt;
|
|
9015
|
+
const keep = Math.exp(-DROP_DRAG * dt);
|
|
9016
|
+
drop.vx *= keep;
|
|
9017
|
+
drop.vz *= keep;
|
|
9018
|
+
drop.vy = drop.vy * keep - WATER_GRAVITY * dt;
|
|
9019
|
+
drop.x += drop.vx * dt;
|
|
9020
|
+
drop.y += drop.vy * dt;
|
|
9021
|
+
drop.z += drop.vz * dt;
|
|
9022
|
+
if (drop.vy < 0 && drop.y <= drop.level) {
|
|
9023
|
+
context.landed(drop);
|
|
9024
|
+
return false;
|
|
9025
|
+
}
|
|
9026
|
+
return drop.age < drop.life;
|
|
9027
|
+
}
|
|
9028
|
+
function ageRing(ring2, dt) {
|
|
9029
|
+
if (ring2.delay > 0) {
|
|
9030
|
+
ring2.delay -= dt;
|
|
9031
|
+
ring2.alpha = 0;
|
|
9032
|
+
return true;
|
|
9033
|
+
}
|
|
9034
|
+
ring2.age += dt;
|
|
9035
|
+
const t = Math.min(1, ring2.age / ring2.life);
|
|
9036
|
+
const spread = ring2.kind === 2 ? t : ring2.kind === 1 ? 1 - (1 - t) ** 4 : 1 - (1 - t) ** 2;
|
|
9037
|
+
ring2.radius = ring2.startRadius + (ring2.maxRadius - ring2.startRadius) * spread;
|
|
9038
|
+
ring2.alpha = ring2.strength * (1 - t) * (ring2.kind === 1 ? 1 - t : 1);
|
|
9039
|
+
return ring2.age < ring2.life;
|
|
9040
|
+
}
|
|
9041
|
+
function ageFoam(foam, dt) {
|
|
9042
|
+
foam.age += dt;
|
|
9043
|
+
const t = Math.min(1, foam.age / foam.life);
|
|
9044
|
+
foam.radius = foam.startRadius + (foam.maxRadius - foam.startRadius) * (1 - (1 - t) ** 3);
|
|
9045
|
+
foam.alpha = t < 0.5 ? 0.85 : 0.85 * (1 - (t - 0.5) / 0.5);
|
|
9046
|
+
return foam.age < foam.life;
|
|
9047
|
+
}
|
|
9048
|
+
function ageColumn(column, dt) {
|
|
9049
|
+
if (column.delay > 0) {
|
|
9050
|
+
column.delay -= dt;
|
|
9051
|
+
column.height = 0;
|
|
9052
|
+
column.alpha = 0;
|
|
9053
|
+
return true;
|
|
9054
|
+
}
|
|
9055
|
+
column.age += dt;
|
|
9056
|
+
const t = column.age;
|
|
9057
|
+
const fall = Math.max(1e-3, column.life - column.rise);
|
|
9058
|
+
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);
|
|
9059
|
+
column.radius = column.baseRadius * (1 + (column.dome ? 0.4 : 1.2) * Math.min(1, t / column.life));
|
|
9060
|
+
const share = t / column.life;
|
|
9061
|
+
column.alpha = share < 0.6 ? 0.9 : 0.9 * Math.max(0, 1 - (share - 0.6) / 0.4);
|
|
9062
|
+
return t < column.life;
|
|
9063
|
+
}
|
|
9064
|
+
function ageBubble(bubble, dt) {
|
|
9065
|
+
if (bubble.delay > 0) {
|
|
9066
|
+
bubble.delay -= dt;
|
|
9067
|
+
bubble.alpha = 0;
|
|
9068
|
+
return true;
|
|
9069
|
+
}
|
|
9070
|
+
bubble.age += dt;
|
|
9071
|
+
bubble.y += bubble.rise * dt;
|
|
9072
|
+
bubble.size *= 1 + 0.15 * dt;
|
|
9073
|
+
bubble.alpha = 0.7 * (1 - bubble.age / bubble.life);
|
|
9074
|
+
return bubble.age < bubble.life && bubble.y < bubble.level - bubble.size;
|
|
9075
|
+
}
|
|
9076
|
+
function ageMist(mist, dt) {
|
|
9077
|
+
mist.age += dt;
|
|
9078
|
+
const keep = Math.exp(-MIST_DRAG * dt);
|
|
9079
|
+
mist.vx *= keep;
|
|
9080
|
+
mist.vy = mist.vy * keep - 0.15 * dt;
|
|
9081
|
+
mist.vz *= keep;
|
|
9082
|
+
mist.x += mist.vx * dt;
|
|
9083
|
+
mist.y += mist.vy * dt;
|
|
9084
|
+
mist.z += mist.vz * dt;
|
|
9085
|
+
mist.size *= 1 + 0.35 * dt;
|
|
9086
|
+
const t = mist.age / mist.life;
|
|
9087
|
+
mist.alpha = t < 0.15 ? t / 0.15 * 0.45 : 0.45 * (1 - (t - 0.15) / 0.85);
|
|
9088
|
+
return mist.age < mist.life;
|
|
9089
|
+
}
|
|
9090
|
+
function ageWave(wave, dt) {
|
|
9091
|
+
if (wave.delay > 0) {
|
|
9092
|
+
wave.delay -= dt;
|
|
9093
|
+
return true;
|
|
9094
|
+
}
|
|
9095
|
+
wave.age += dt;
|
|
9096
|
+
return wave.age < wave.life && wave.speed * wave.age < wave.reach + wave.width;
|
|
9097
|
+
}
|
|
9098
|
+
function stepWaterPools(pools, context) {
|
|
9099
|
+
const { dt } = context;
|
|
9100
|
+
pools.drops.compact(moveDrop, context);
|
|
9101
|
+
pools.rings.compact(ageRing, dt);
|
|
9102
|
+
pools.foam.compact(ageFoam, dt);
|
|
9103
|
+
pools.columns.compact(ageColumn, dt);
|
|
9104
|
+
pools.bubbles.compact(ageBubble, dt);
|
|
9105
|
+
pools.mist.compact(ageMist, dt);
|
|
9106
|
+
pools.waves.compact(ageWave, dt);
|
|
9107
|
+
}
|
|
9108
|
+
|
|
9109
|
+
// src/water/profiles.ts
|
|
9110
|
+
var WATER_SHOT_PROFILES = {
|
|
9111
|
+
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 },
|
|
9112
|
+
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 },
|
|
9113
|
+
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 },
|
|
9114
|
+
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 },
|
|
9115
|
+
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 },
|
|
9116
|
+
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 },
|
|
9117
|
+
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 },
|
|
9118
|
+
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 },
|
|
9119
|
+
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 },
|
|
9120
|
+
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 },
|
|
9121
|
+
// a thrown thing the size of a grenade or a can falling in: a plop, a crown and wide rings, and it sinks
|
|
9122
|
+
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 },
|
|
9123
|
+
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 }
|
|
9124
|
+
};
|
|
9125
|
+
var WATER_SHOT_BY_CALIBER = {
|
|
9126
|
+
"22lr": "rimfire",
|
|
9127
|
+
"380acp": "pistol",
|
|
9128
|
+
"9x18": "pistol",
|
|
9129
|
+
"9x19": "pistol",
|
|
9130
|
+
"40sw": "pistol",
|
|
9131
|
+
"45acp": "pistol",
|
|
9132
|
+
"5_7x28": "pistol",
|
|
9133
|
+
"38spl": "pistol",
|
|
9134
|
+
"32acp": "pistol",
|
|
9135
|
+
"7_62x25": "pistol",
|
|
9136
|
+
"4_6x30": "pistol",
|
|
9137
|
+
"357mag": "magnum",
|
|
9138
|
+
"44mag": "magnum",
|
|
9139
|
+
"50ae": "magnum",
|
|
9140
|
+
"45_70_bp": "magnum",
|
|
9141
|
+
"12ga_00buck": "buckshot",
|
|
9142
|
+
"20ga_buck": "buckshot",
|
|
9143
|
+
"12ga_birdshot": "birdshot",
|
|
9144
|
+
"12ga_slug": "slug",
|
|
9145
|
+
"5_56x45": "rifle",
|
|
9146
|
+
"5_45x39": "rifle",
|
|
9147
|
+
"7_62x39": "rifle",
|
|
9148
|
+
"30_30": "rifle",
|
|
9149
|
+
"9x39": "rifle",
|
|
9150
|
+
"7_62x51": "battle_rifle",
|
|
9151
|
+
"7_62x54r": "battle_rifle",
|
|
9152
|
+
"30_06": "battle_rifle",
|
|
9153
|
+
"7_92x57": "battle_rifle",
|
|
9154
|
+
"300wm": "battle_rifle",
|
|
9155
|
+
"338lapua": "sniper",
|
|
9156
|
+
"408cheytac": "sniper",
|
|
9157
|
+
"50bmg": "sniper",
|
|
9158
|
+
arrow: "arrow",
|
|
9159
|
+
crossbow_bolt: "arrow"
|
|
9160
|
+
};
|
|
9161
|
+
function waterShotClassOf(round2) {
|
|
9162
|
+
const joules = 0.5 * (round2.grams / 1e3) * round2.speed * round2.speed;
|
|
9163
|
+
if (round2.speed < 150) return "arrow";
|
|
9164
|
+
if (round2.pellet) return round2.grams < 0.5 ? "birdshot" : "buckshot";
|
|
9165
|
+
if ((round2.diameter ?? 0) >= 15) return "slug";
|
|
9166
|
+
if (joules >= 6e3) return "sniper";
|
|
9167
|
+
if (joules >= 2800) return "battle_rifle";
|
|
9168
|
+
if (joules >= 1200) return "rifle";
|
|
9169
|
+
if (joules >= 900) return "magnum";
|
|
9170
|
+
return joules < 200 ? "rimfire" : "pistol";
|
|
9171
|
+
}
|
|
9172
|
+
var WATER_BLAST_KINDS = {
|
|
9173
|
+
blast: { brisance: 1, columnWidth: 1, fragments: 0, mist: 1, fireballUnderwater: false },
|
|
9174
|
+
fragmentation: { brisance: 0.9, columnWidth: 1, fragments: 16, mist: 1, fireballUnderwater: false },
|
|
9175
|
+
shaped_charge: { brisance: 0.8, columnWidth: 0.6, fragments: 6, mist: 0.8, fireballUnderwater: false },
|
|
9176
|
+
directional: { brisance: 0.7, columnWidth: 0.9, fragments: 24, mist: 0.8, fireballUnderwater: false },
|
|
9177
|
+
fuel: { brisance: 0.25, columnWidth: 1.4, fragments: 4, mist: 2.2, fireballUnderwater: false },
|
|
9178
|
+
incendiary: { brisance: 0.05, columnWidth: 1.2, fragments: 0, mist: 1.5, fireballUnderwater: false },
|
|
9179
|
+
flash: { brisance: 0.1, columnWidth: 1, fragments: 0, mist: 0.6, fireballUnderwater: false }
|
|
9180
|
+
};
|
|
9181
|
+
var WATER_BLASTS = {
|
|
9182
|
+
m67: { tnt: 0.24, kind: "fragmentation" },
|
|
9183
|
+
pipe_bomb: { tnt: 0.15, kind: "fragmentation" },
|
|
9184
|
+
m79_40mm: { tnt: 0.045, kind: "fragmentation" },
|
|
9185
|
+
vog_25: { tnt: 0.045, kind: "fragmentation" },
|
|
9186
|
+
dynamite: { tnt: 0.25, kind: "blast" },
|
|
9187
|
+
c4: { tnt: 0.76, kind: "blast" },
|
|
9188
|
+
semtex: { tnt: 0.83, kind: "blast" },
|
|
9189
|
+
claymore: { tnt: 0.9, kind: "directional" },
|
|
9190
|
+
m72_66mm: { tnt: 0.45, kind: "shaped_charge" },
|
|
9191
|
+
at4_84mm: { tnt: 0.7, kind: "shaped_charge" },
|
|
9192
|
+
pg7v: { tnt: 0.45, kind: "shaped_charge" },
|
|
9193
|
+
carl_gustaf_84mm: { tnt: 0.7, kind: "shaped_charge" },
|
|
9194
|
+
propane_p13: { tnt: 1.5, kind: "fuel" },
|
|
9195
|
+
fuel_barrel: { tnt: 1, kind: "fuel" },
|
|
9196
|
+
car_fuel_tank: { tnt: 0.5, kind: "fuel" },
|
|
9197
|
+
fuel_pump: { tnt: 0.5, kind: "fuel" },
|
|
9198
|
+
fuel_station_tank: { tnt: 20, kind: "fuel" },
|
|
9199
|
+
molotov: { tnt: 0.02, kind: "incendiary" },
|
|
9200
|
+
flashbang: { tnt: 0.01, kind: "flash" }
|
|
9201
|
+
};
|
|
9202
|
+
function resolveWaterShotProfile(profile, table = WATER_SHOT_PROFILES) {
|
|
9203
|
+
if (typeof profile !== "string") return profile;
|
|
9204
|
+
return table[profile] ?? WATER_SHOT_PROFILES.pistol;
|
|
9205
|
+
}
|
|
9206
|
+
function patchWaterShotProfiles(base, changes) {
|
|
9207
|
+
const out = { ...base };
|
|
9208
|
+
for (const [id, change] of Object.entries(changes)) {
|
|
9209
|
+
if (change === null) delete out[id];
|
|
9210
|
+
else out[id] = { ...base[id] ?? WATER_SHOT_PROFILES.pistol, ...change };
|
|
9211
|
+
}
|
|
9212
|
+
return out;
|
|
9213
|
+
}
|
|
9214
|
+
|
|
9215
|
+
// src/water/plan.ts
|
|
9216
|
+
var DEGREES = 180 / Math.PI;
|
|
9217
|
+
var SPENT_SPEED = 15;
|
|
9218
|
+
var DEFAULT_DEPTH = 2;
|
|
9219
|
+
var RICOCHET_SPEED_SHARE = 0.6;
|
|
9220
|
+
var RICOCHET_YAW_DEG = 6;
|
|
9221
|
+
var BLAST_COLUMN_PER_QUARTIC_KG = 10;
|
|
9222
|
+
var AIRBURST_SCALED_HEIGHT = 2.5;
|
|
9223
|
+
var BEST_SCALED_DEPTH = 0.6;
|
|
9224
|
+
var DEEP_FALL = 1.6;
|
|
9225
|
+
var UNDERWATER_SCALED_DEPTH = 0.15;
|
|
9226
|
+
var clamp5 = (value, low, high) => Math.min(high, Math.max(low, value));
|
|
9227
|
+
function planWaterShot(params, random, table) {
|
|
9228
|
+
const profile = resolveWaterShotProfile(params.profile, table);
|
|
9229
|
+
const [dx, dy, dz] = params.direction;
|
|
9230
|
+
const sine = clamp5(-dy, 0, 1);
|
|
9231
|
+
const angleDeg = Math.asin(sine) * DEGREES;
|
|
9232
|
+
const speed = params.speed ?? profile.speed;
|
|
9233
|
+
const strength = clamp5(speed / profile.speed, 0.3, 1.25);
|
|
9234
|
+
const flat = Math.hypot(dx, dz) || 1;
|
|
9235
|
+
const forward = [dx / flat, dz / flat];
|
|
9236
|
+
const ricochet = angleDeg < profile.ricochetBelowDeg ? skipOff(params.direction, angleDeg, random) : null;
|
|
9237
|
+
const lean = (1 - sine) * (ricochet ? 1.2 : 0.6);
|
|
9238
|
+
const columnHeight = profile.columnHeight * strength * (ricochet ? 0.35 : 0.35 + 0.65 * sine);
|
|
9239
|
+
const depth = params.depth ?? DEFAULT_DEPTH;
|
|
9240
|
+
const trail = ricochet ? null : trailUnder(params, profile, speed, depth, sine);
|
|
9241
|
+
return {
|
|
9242
|
+
profile,
|
|
9243
|
+
angleDeg,
|
|
9244
|
+
ricochet,
|
|
9245
|
+
columnHeight,
|
|
9246
|
+
columnRadius: profile.columnRadius * Math.sqrt(strength),
|
|
9247
|
+
tilt: [forward[0] * lean, forward[1] * lean],
|
|
9248
|
+
drops: Math.round(profile.drops * strength),
|
|
9249
|
+
ringRadius: profile.ringRadius * Math.sqrt(strength),
|
|
9250
|
+
rings: profile.rings,
|
|
9251
|
+
foamRadius: profile.foamRadius * (ricochet ? 1.4 : 1),
|
|
9252
|
+
trailEnd: trail?.end ?? params.point,
|
|
9253
|
+
trailLength: trail?.length ?? 0,
|
|
9254
|
+
bedSpeed: trail?.bedSpeed ?? 0
|
|
9255
|
+
};
|
|
9256
|
+
}
|
|
9257
|
+
function skipOff(direction, angleDeg, random) {
|
|
9258
|
+
const yaw = random.between(-RICOCHET_YAW_DEG, RICOCHET_YAW_DEG) / DEGREES;
|
|
9259
|
+
const cos2 = Math.cos(yaw);
|
|
9260
|
+
const sin2 = Math.sin(yaw);
|
|
9261
|
+
const [dx, dy, dz] = direction;
|
|
9262
|
+
const up = Math.abs(dy) * (0.5 + 0.3 * random.next());
|
|
9263
|
+
const x = dx * cos2 - dz * sin2;
|
|
9264
|
+
const z = dx * sin2 + dz * cos2;
|
|
9265
|
+
const length = Math.hypot(x, up, z) || 1;
|
|
9266
|
+
return { direction: [x / length, up / length, z / length], speedShare: RICOCHET_SPEED_SHARE * (1 - angleDeg / 30) };
|
|
9267
|
+
}
|
|
9268
|
+
function trailUnder(params, profile, speed, depth, sine) {
|
|
9269
|
+
const spentAfter = profile.slowing * Math.log(Math.max(1, speed / SPENT_SPEED));
|
|
9270
|
+
const toBed = sine > 1e-3 ? depth / sine : Infinity;
|
|
9271
|
+
const length = Math.min(spentAfter, toBed);
|
|
9272
|
+
const [px, py, pz] = params.point;
|
|
9273
|
+
const [dx, dy, dz] = params.direction;
|
|
9274
|
+
const bedSpeed = toBed <= spentAfter ? speed * Math.exp(-toBed / profile.slowing) : 0;
|
|
9275
|
+
return { end: [px + dx * length, py + dy * length, pz + dz * length], length, bedSpeed };
|
|
9276
|
+
}
|
|
9277
|
+
function resolveWaterBlast(params) {
|
|
9278
|
+
const known = params.explosive ? WATER_BLASTS[params.explosive] : void 0;
|
|
9279
|
+
const tnt = Math.max(1e-3, params.tnt ?? known?.tnt ?? 0.25);
|
|
9280
|
+
const kindId = params.kind ?? known?.kind ?? "blast";
|
|
9281
|
+
const kind = WATER_BLAST_KINDS[kindId] ?? WATER_BLAST_KINDS.blast;
|
|
9282
|
+
return { tnt, kind };
|
|
9283
|
+
}
|
|
9284
|
+
function planWaterBlast(params) {
|
|
9285
|
+
const { tnt, kind } = resolveWaterBlast(params);
|
|
9286
|
+
const scale = Math.cbrt(tnt);
|
|
9287
|
+
const quartic = Math.sqrt(Math.sqrt(tnt));
|
|
9288
|
+
const burstDepth = params.level - params.point[1];
|
|
9289
|
+
const scaledDepth = burstDepth / scale;
|
|
9290
|
+
const airburst = -scaledDepth > AIRBURST_SCALED_HEIGHT;
|
|
9291
|
+
const underwater = scaledDepth > UNDERWATER_SCALED_DEPTH && !kind.fireballUnderwater;
|
|
9292
|
+
const surface = scaledDepth <= 0 ? Math.max(0, 1 + scaledDepth / AIRBURST_SCALED_HEIGHT) : 1;
|
|
9293
|
+
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);
|
|
9294
|
+
const shallow = clamp5(0.35 + params.depth / (1.2 * scale), 0.35, 1);
|
|
9295
|
+
const power = kind.brisance;
|
|
9296
|
+
const columnHeight = airburst ? 0 : BLAST_COLUMN_PER_QUARTIC_KG * quartic * power * depthShape * shallow;
|
|
9297
|
+
const domed = scaledDepth > 0 && !airburst;
|
|
9298
|
+
const domeRadius = domed ? 1.6 * scale * Math.cbrt(power) : 0;
|
|
9299
|
+
const fragments = scaledDepth < UNDERWATER_SCALED_DEPTH ? kind.fragments : 0;
|
|
9300
|
+
return {
|
|
9301
|
+
tnt,
|
|
9302
|
+
kind,
|
|
9303
|
+
burstDepth,
|
|
9304
|
+
underwater,
|
|
9305
|
+
airburst,
|
|
9306
|
+
columnHeight,
|
|
9307
|
+
columnRadius: 0.35 * scale * kind.columnWidth * (1 + 0.5 * clamp5(scaledDepth, 0, 1)),
|
|
9308
|
+
domeRadius,
|
|
9309
|
+
domeHeight: domed ? domeRadius * 0.6 * (scaledDepth < 1 ? 1 : Math.exp(1 - scaledDepth)) : 0,
|
|
9310
|
+
shockRadius: (scaledDepth >= 0 ? 5 : 4 * surface) * scale,
|
|
9311
|
+
waveAmplitude: 0.12 * scale * power * (scaledDepth >= 0 ? 1 : surface) * shallow,
|
|
9312
|
+
waveSpeed: 2.5 + 1.5 * scale,
|
|
9313
|
+
drops: airburst ? Math.round(20 * scale) : Math.round((60 + 140 * scale) * Math.max(0.3, depthShape) * Math.max(0.3, power)),
|
|
9314
|
+
mist: Math.round((6 + 10 * scale) * kind.mist * (airburst ? 0.4 : 1)),
|
|
9315
|
+
fragments,
|
|
9316
|
+
foamRadius: 2.5 * scale * Math.max(0.4, Math.cbrt(power)) * (airburst ? 0.3 : 1),
|
|
9317
|
+
bubbles: scaledDepth > 0 ? Math.round(30 + 50 * scale) : 0
|
|
9318
|
+
};
|
|
9319
|
+
}
|
|
9320
|
+
|
|
9321
|
+
// src/water/records.ts
|
|
9322
|
+
var WATER_LIMITS = { drops: 700, rings: 220, foam: 60, columns: 32, bubbles: 500, mist: 90, waves: 16 };
|
|
9323
|
+
function createWaterPools(limits) {
|
|
9324
|
+
return {
|
|
9325
|
+
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 })),
|
|
9326
|
+
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 })),
|
|
9327
|
+
foam: new OrderedPool(limits.foam, () => ({ x: 0, y: 0, z: 0, radius: 0, startRadius: 0, maxRadius: 0, age: 0, life: 0, alpha: 0 })),
|
|
9328
|
+
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 })),
|
|
9329
|
+
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 })),
|
|
9330
|
+
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 })),
|
|
9331
|
+
waves: new OrderedPool(limits.waves, () => ({ x: 0, z: 0, speed: 0, amplitude: 0, width: 0, reach: 0, delay: 0, age: 0, life: 0 }))
|
|
9332
|
+
};
|
|
9333
|
+
}
|
|
9334
|
+
|
|
9335
|
+
// src/water/spawn.ts
|
|
9336
|
+
var TRAIL_BUBBLES_MAX = 40;
|
|
9337
|
+
var BLAST_FOAM_LIFE = 8;
|
|
9338
|
+
var BLAST_WAVE_CRESTS = 3;
|
|
9339
|
+
var BLAST_WAVE_GAP = 0.35;
|
|
9340
|
+
var BLAST_WAVE_LIFE = 6;
|
|
9341
|
+
var BLAST_SIDE_JETS = 4;
|
|
9342
|
+
function addRing(context, spec) {
|
|
9343
|
+
const ring2 = context.pools.rings.acquire();
|
|
9344
|
+
ring2.x = spec.x;
|
|
9345
|
+
ring2.y = spec.y;
|
|
9346
|
+
ring2.z = spec.z;
|
|
9347
|
+
ring2.kind = spec.kind;
|
|
9348
|
+
ring2.startRadius = spec.start;
|
|
9349
|
+
ring2.radius = spec.start;
|
|
9350
|
+
ring2.maxRadius = Math.max(spec.start, Math.min(spec.max, context.reach(spec.x, spec.z, spec.max)));
|
|
9351
|
+
ring2.delay = spec.delay;
|
|
9352
|
+
ring2.age = 0;
|
|
9353
|
+
ring2.life = spec.life;
|
|
9354
|
+
ring2.strength = spec.strength;
|
|
9355
|
+
ring2.alpha = 0;
|
|
9356
|
+
}
|
|
9357
|
+
function addFoam(context, at3, radius, life) {
|
|
9358
|
+
const foam = context.pools.foam.acquire();
|
|
9359
|
+
foam.x = at3[0];
|
|
9360
|
+
foam.y = at3[1];
|
|
9361
|
+
foam.z = at3[2];
|
|
9362
|
+
foam.maxRadius = Math.min(radius, Math.max(0.05, context.reach(at3[0], at3[2], radius)));
|
|
9363
|
+
foam.startRadius = foam.maxRadius * 0.35;
|
|
9364
|
+
foam.radius = foam.startRadius;
|
|
9365
|
+
foam.age = 0;
|
|
9366
|
+
foam.life = life;
|
|
9367
|
+
foam.alpha = 0.85;
|
|
9368
|
+
}
|
|
9369
|
+
function addColumn(context, spec) {
|
|
9370
|
+
if (spec.peak < 0.02) return;
|
|
9371
|
+
const column = context.pools.columns.acquire();
|
|
9372
|
+
column.x = spec.at[0];
|
|
9373
|
+
column.y = spec.at[1];
|
|
9374
|
+
column.z = spec.at[2];
|
|
9375
|
+
column.dome = spec.dome;
|
|
9376
|
+
column.peak = spec.peak;
|
|
9377
|
+
column.baseRadius = spec.radius;
|
|
9378
|
+
column.tiltX = spec.tilt[0];
|
|
9379
|
+
column.tiltZ = spec.tilt[1];
|
|
9380
|
+
const flight = Math.sqrt(2 * spec.peak / WATER_GRAVITY);
|
|
9381
|
+
column.rise = spec.rise ?? Math.max(0.06, flight * 0.6);
|
|
9382
|
+
column.life = column.rise + Math.max(0.2, flight * 1.3) + 0.15;
|
|
9383
|
+
column.delay = spec.delay;
|
|
9384
|
+
column.age = 0;
|
|
9385
|
+
column.height = 0;
|
|
9386
|
+
column.radius = spec.radius;
|
|
9387
|
+
column.alpha = 0;
|
|
9388
|
+
}
|
|
9389
|
+
function addDrop(context, spec) {
|
|
9390
|
+
const drop = context.pools.drops.acquire();
|
|
9391
|
+
drop.x = spec.at[0];
|
|
9392
|
+
drop.y = spec.at[1];
|
|
9393
|
+
drop.z = spec.at[2];
|
|
9394
|
+
drop.vx = spec.velocity[0];
|
|
9395
|
+
drop.vy = spec.velocity[1];
|
|
9396
|
+
drop.vz = spec.velocity[2];
|
|
9397
|
+
drop.size = spec.size;
|
|
9398
|
+
drop.level = spec.level;
|
|
9399
|
+
drop.age = 0;
|
|
9400
|
+
drop.life = 6;
|
|
9401
|
+
}
|
|
9402
|
+
function addBubble(context, at3, level, delay, size) {
|
|
9403
|
+
const { random } = context;
|
|
9404
|
+
const bubble = context.pools.bubbles.acquire();
|
|
9405
|
+
bubble.x = at3[0];
|
|
9406
|
+
bubble.y = at3[1];
|
|
9407
|
+
bubble.z = at3[2];
|
|
9408
|
+
bubble.size = size;
|
|
9409
|
+
bubble.rise = random.between(0.2, 0.45);
|
|
9410
|
+
bubble.delay = delay;
|
|
9411
|
+
bubble.age = 0;
|
|
9412
|
+
bubble.life = random.between(0.8, 2.2);
|
|
9413
|
+
bubble.level = level;
|
|
9414
|
+
bubble.alpha = 0;
|
|
9415
|
+
}
|
|
9416
|
+
function spawnShot(context, point, plan) {
|
|
9417
|
+
const { random, detail } = context;
|
|
9418
|
+
const [x, y, z] = point;
|
|
9419
|
+
const profile = plan.profile;
|
|
9420
|
+
addColumn(context, { at: point, peak: plan.columnHeight, radius: plan.columnRadius, tilt: plan.tilt, dome: false, delay: 0 });
|
|
9421
|
+
const drops = Math.round(plan.drops * detail);
|
|
9422
|
+
const steep = plan.ricochet ? 0.3 : 0.4 + 0.6 * Math.sin(plan.angleDeg * Math.PI / 180);
|
|
9423
|
+
for (let index = 0; index < drops; index++) {
|
|
9424
|
+
const angle = random.next() * Math.PI * 2;
|
|
9425
|
+
const speed = random.between(profile.dropSpeed[0], profile.dropSpeed[1]);
|
|
9426
|
+
const out = speed * random.between(0.2, 0.55);
|
|
9427
|
+
const lean = speed * random.between(0.3, 0.9);
|
|
9428
|
+
addDrop(context, {
|
|
9429
|
+
at: [x + Math.cos(angle) * plan.columnRadius, y, z + Math.sin(angle) * plan.columnRadius],
|
|
9430
|
+
velocity: [Math.cos(angle) * out + plan.tilt[0] * lean, speed * steep * random.between(0.7, 1), Math.sin(angle) * out + plan.tilt[1] * lean],
|
|
9431
|
+
size: profile.dropSize * random.between(0.6, 1.4),
|
|
9432
|
+
level: y
|
|
9433
|
+
});
|
|
9434
|
+
}
|
|
9435
|
+
for (let index = 0; index < plan.rings; index++) {
|
|
9436
|
+
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 });
|
|
9437
|
+
}
|
|
9438
|
+
if (plan.ricochet) {
|
|
9439
|
+
for (let step = 1; step <= 2; step++) {
|
|
9440
|
+
const sx = x + plan.tilt[0] * 0.3 * step;
|
|
9441
|
+
const sz = z + plan.tilt[1] * 0.3 * step;
|
|
9442
|
+
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 });
|
|
9443
|
+
}
|
|
9444
|
+
}
|
|
9445
|
+
addFoam(context, point, plan.foamRadius, profile.foamLife);
|
|
9446
|
+
spawnTrail(context, point, plan);
|
|
9447
|
+
}
|
|
9448
|
+
function spawnTrail(context, point, plan) {
|
|
9449
|
+
if (plan.trailLength <= 0) return;
|
|
9450
|
+
const { random } = context;
|
|
9451
|
+
const count = Math.min(TRAIL_BUBBLES_MAX, Math.round(plan.profile.bubblesPerMetre * plan.trailLength * context.detail));
|
|
9452
|
+
const [ex, ey, ez] = plan.trailEnd;
|
|
9453
|
+
for (let index = 0; index < count; index++) {
|
|
9454
|
+
const along = random.next() ** 1.6;
|
|
9455
|
+
const jitter = 0.01 + 0.02 * along;
|
|
9456
|
+
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)];
|
|
9457
|
+
addBubble(context, at3, point[1], along * 0.05, random.between(3e-3, 0.01));
|
|
9458
|
+
}
|
|
9459
|
+
}
|
|
9460
|
+
function spawnBlast(context, point, level, plan) {
|
|
9461
|
+
const { random, detail } = context;
|
|
9462
|
+
const surface = [point[0], level, point[2]];
|
|
9463
|
+
const scale = Math.cbrt(plan.tnt);
|
|
9464
|
+
addColumn(context, { at: surface, peak: plan.columnHeight, radius: plan.columnRadius, tilt: [0, 0], dome: false, delay: plan.domeRadius > 0 ? 0.08 : 0 });
|
|
9465
|
+
for (let index = 0; index < BLAST_SIDE_JETS && plan.columnHeight > 0; index++) {
|
|
9466
|
+
const angle = index / BLAST_SIDE_JETS * Math.PI * 2 + random.next();
|
|
9467
|
+
const off = plan.columnRadius * random.between(0.6, 1.1);
|
|
9468
|
+
const lean = random.between(0.1, 0.25);
|
|
9469
|
+
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 });
|
|
9470
|
+
}
|
|
9471
|
+
if (plan.domeRadius > 0) addColumn(context, { at: surface, peak: plan.domeHeight, radius: plan.domeRadius, tilt: [0, 0], dome: true, delay: 0, rise: 0.25 });
|
|
9472
|
+
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 });
|
|
9473
|
+
spawnWaves(context, surface, plan);
|
|
9474
|
+
spawnRain(context, surface, plan, detail);
|
|
9475
|
+
spawnSpray(context, surface, plan, scale);
|
|
9476
|
+
addFoam(context, surface, plan.foamRadius, BLAST_FOAM_LIFE);
|
|
9477
|
+
const bubbles = Math.round(plan.bubbles * detail);
|
|
9478
|
+
for (let index = 0; index < bubbles; index++) {
|
|
9479
|
+
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];
|
|
9480
|
+
addBubble(context, at3, level, random.next() * 1.2, random.between(0.01, 0.04) * Math.max(1, scale));
|
|
9481
|
+
}
|
|
9482
|
+
}
|
|
9483
|
+
function spawnWaves(context, surface, plan) {
|
|
9484
|
+
if (plan.waveAmplitude <= 0) return;
|
|
9485
|
+
const reach = context.reach(surface[0], surface[2], plan.waveSpeed * BLAST_WAVE_LIFE);
|
|
9486
|
+
for (let crest = 0; crest < BLAST_WAVE_CRESTS; crest++) {
|
|
9487
|
+
const wave = context.pools.waves.acquire();
|
|
9488
|
+
wave.x = surface[0];
|
|
9489
|
+
wave.z = surface[2];
|
|
9490
|
+
wave.speed = plan.waveSpeed;
|
|
9491
|
+
wave.amplitude = plan.waveAmplitude * (1 - crest * 0.3);
|
|
9492
|
+
wave.width = 0.25 + 0.3 * Math.cbrt(plan.tnt);
|
|
9493
|
+
wave.reach = reach;
|
|
9494
|
+
wave.delay = crest * BLAST_WAVE_GAP;
|
|
9495
|
+
wave.age = 0;
|
|
9496
|
+
wave.life = BLAST_WAVE_LIFE;
|
|
9497
|
+
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) });
|
|
9498
|
+
}
|
|
9499
|
+
}
|
|
9500
|
+
function spawnRain(context, surface, plan, detail) {
|
|
9501
|
+
const { random } = context;
|
|
9502
|
+
const drops = Math.round(plan.drops * detail);
|
|
9503
|
+
const top = Math.max(0.5, plan.columnHeight);
|
|
9504
|
+
const launch = Math.sqrt(2 * WATER_GRAVITY * top);
|
|
9505
|
+
const scale = Math.cbrt(plan.tnt);
|
|
9506
|
+
for (let index = 0; index < drops; index++) {
|
|
9507
|
+
const angle = random.next() * Math.PI * 2;
|
|
9508
|
+
const out = random.between(0.4, 3) * scale;
|
|
9509
|
+
const r = random.next() * plan.columnRadius;
|
|
9510
|
+
addDrop(context, {
|
|
9511
|
+
at: [surface[0] + Math.cos(angle) * r, surface[1] + random.next() * top * 0.2, surface[2] + Math.sin(angle) * r],
|
|
9512
|
+
velocity: [Math.cos(angle) * out, launch * random.between(0.45, 1.02), Math.sin(angle) * out],
|
|
9513
|
+
size: random.between(0.012, 0.035),
|
|
9514
|
+
level: surface[1]
|
|
9515
|
+
});
|
|
9516
|
+
}
|
|
9517
|
+
}
|
|
9518
|
+
function spawnSpray(context, surface, plan, scale) {
|
|
9519
|
+
const { random } = context;
|
|
9520
|
+
const top = Math.max(0.4, plan.columnHeight);
|
|
9521
|
+
for (let index = 0; index < plan.mist; index++) {
|
|
9522
|
+
const mist = context.pools.mist.acquire();
|
|
9523
|
+
const angle = random.next() * Math.PI * 2;
|
|
9524
|
+
const r = random.next() * (plan.columnRadius + 0.5 * scale);
|
|
9525
|
+
mist.x = surface[0] + Math.cos(angle) * r;
|
|
9526
|
+
mist.y = surface[1] + random.next() * top * 0.6;
|
|
9527
|
+
mist.z = surface[2] + Math.sin(angle) * r;
|
|
9528
|
+
const out = random.between(0.5, 1.8) * scale;
|
|
9529
|
+
mist.vx = Math.cos(angle) * out;
|
|
9530
|
+
mist.vy = random.between(0.3, 1);
|
|
9531
|
+
mist.vz = Math.sin(angle) * out;
|
|
9532
|
+
mist.size = random.between(0.4, 1.2) * scale;
|
|
9533
|
+
mist.age = 0;
|
|
9534
|
+
mist.life = random.between(2.5, 4.5);
|
|
9535
|
+
mist.alpha = 0;
|
|
9536
|
+
}
|
|
9537
|
+
}
|
|
9538
|
+
|
|
9539
|
+
// src/water/effects.ts
|
|
9540
|
+
var STEP_LIMIT = 0.05;
|
|
9541
|
+
var SHORE_DIRECTIONS = 8;
|
|
9542
|
+
var SHORE_HALVINGS = 5;
|
|
9543
|
+
var SAME_WATER = 0.2;
|
|
9544
|
+
var DROP_RING_SHARE = 0.75;
|
|
9545
|
+
var WAVE_PUSH = 2;
|
|
9546
|
+
function createWaterEffects(options = {}) {
|
|
9547
|
+
const limits = { ...WATER_LIMITS, ...options.limits };
|
|
9548
|
+
const pools = createWaterPools(limits);
|
|
9549
|
+
const random = lehmer(options.seed ?? 1);
|
|
9550
|
+
const lod = options.lod ?? LOD_GAME;
|
|
9551
|
+
const camera2 = [0, 0, 0];
|
|
9552
|
+
let hasCamera = false;
|
|
9553
|
+
const reach = (x, z, limit) => {
|
|
9554
|
+
const levelAt = options.levelAt;
|
|
9555
|
+
if (!levelAt) return limit;
|
|
9556
|
+
const here = levelAt(x, z);
|
|
9557
|
+
if (here === null) return 0;
|
|
9558
|
+
const step = Math.max(0.05, limit / 10);
|
|
9559
|
+
const isWater = (cos2, sin2, distance) => {
|
|
9560
|
+
const level = levelAt(x + cos2 * distance, z + sin2 * distance);
|
|
9561
|
+
return level !== null && Math.abs(level - here) <= SAME_WATER;
|
|
9562
|
+
};
|
|
9563
|
+
let nearest = limit;
|
|
9564
|
+
for (let index = 0; index < SHORE_DIRECTIONS; index++) {
|
|
9565
|
+
const angle = index / SHORE_DIRECTIONS * Math.PI * 2;
|
|
9566
|
+
const cos2 = Math.cos(angle);
|
|
9567
|
+
const sin2 = Math.sin(angle);
|
|
9568
|
+
for (let distance = step; distance < nearest; distance += step) {
|
|
9569
|
+
if (isWater(cos2, sin2, distance)) continue;
|
|
9570
|
+
let wet = distance - step;
|
|
9571
|
+
let dry = distance;
|
|
9572
|
+
for (let halving = 0; halving < SHORE_HALVINGS; halving++) {
|
|
9573
|
+
const middle = (wet + dry) / 2;
|
|
9574
|
+
if (isWater(cos2, sin2, middle)) wet = middle;
|
|
9575
|
+
else dry = middle;
|
|
9576
|
+
}
|
|
9577
|
+
nearest = Math.min(nearest, wet);
|
|
9578
|
+
break;
|
|
9579
|
+
}
|
|
9580
|
+
}
|
|
9581
|
+
return nearest;
|
|
9582
|
+
};
|
|
9583
|
+
const detailAt = (point, radius) => hasCamera ? lodScale(lod, Math.hypot(point[0] - camera2[0], point[1] - camera2[1], point[2] - camera2[2]), radius) : 1;
|
|
9584
|
+
const contextAt = (point, radius) => ({ pools, random, detail: detailAt(point, radius), reach });
|
|
9585
|
+
const motion = {
|
|
9586
|
+
dt: 0,
|
|
9587
|
+
landed: (drop) => {
|
|
9588
|
+
if (pools.rings.count >= limits.rings * DROP_RING_SHARE) return;
|
|
9589
|
+
const level = options.levelAt ? options.levelAt(drop.x, drop.z) : drop.level;
|
|
9590
|
+
if (level === null || Math.abs(level - drop.level) > SAME_WATER) return;
|
|
9591
|
+
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 });
|
|
9592
|
+
}
|
|
9593
|
+
};
|
|
9594
|
+
const shot = (params) => {
|
|
9595
|
+
const plan = planWaterShot(params, random, options.profiles);
|
|
9596
|
+
spawnShot(contextAt(params.point, plan.ringRadius), params.point, plan);
|
|
9597
|
+
return plan;
|
|
9598
|
+
};
|
|
9599
|
+
const pepper = (params, plan) => {
|
|
9600
|
+
const spread = 1.5 + 3 * Math.cbrt(plan.tnt);
|
|
9601
|
+
for (let index = 0; index < plan.fragments; index++) {
|
|
9602
|
+
const angle = random.next() * Math.PI * 2;
|
|
9603
|
+
const distance = random.between(0.6, spread);
|
|
9604
|
+
const x = params.point[0] + Math.cos(angle) * distance;
|
|
9605
|
+
const z = params.point[2] + Math.sin(angle) * distance;
|
|
9606
|
+
const level = options.levelAt ? options.levelAt(x, z) : params.level;
|
|
9607
|
+
if (level === null || Math.abs(level - params.level) > SAME_WATER) continue;
|
|
9608
|
+
const fall = random.between(0.4, 1);
|
|
9609
|
+
const length = Math.hypot(Math.cos(angle), fall, Math.sin(angle));
|
|
9610
|
+
const point = [x, level, z];
|
|
9611
|
+
const fragment = planWaterShot({ point, direction: [Math.cos(angle) / length, -fall / length, Math.sin(angle) / length], profile: "fragment", depth: params.depth }, random, options.profiles);
|
|
9612
|
+
spawnShot(contextAt(point, fragment.ringRadius), point, fragment);
|
|
9613
|
+
}
|
|
9614
|
+
};
|
|
9615
|
+
const blast = (params) => {
|
|
9616
|
+
const plan = planWaterBlast(params);
|
|
9617
|
+
spawnBlast(contextAt(params.point, plan.shockRadius), params.point, params.level, plan);
|
|
9618
|
+
pepper(params, plan);
|
|
9619
|
+
return plan;
|
|
9620
|
+
};
|
|
9621
|
+
const waveAt = (x, z) => {
|
|
9622
|
+
let height = 0;
|
|
9623
|
+
let pushX = 0;
|
|
9624
|
+
let pushZ = 0;
|
|
9625
|
+
for (const wave of pools.waves.items) {
|
|
9626
|
+
if (wave.delay > 0) continue;
|
|
9627
|
+
const dx = x - wave.x;
|
|
9628
|
+
const dz = z - wave.z;
|
|
9629
|
+
const r = Math.hypot(dx, dz);
|
|
9630
|
+
if (r > wave.reach) continue;
|
|
9631
|
+
const off = (r - wave.speed * wave.age) / wave.width;
|
|
9632
|
+
if (Math.abs(off) > 3) continue;
|
|
9633
|
+
const crest = wave.amplitude * Math.exp(-off * off) * (1 - wave.age / wave.life) / Math.sqrt(Math.max(1, r));
|
|
9634
|
+
height += crest;
|
|
9635
|
+
if (r > 1e-3) {
|
|
9636
|
+
const push = crest * wave.speed * WAVE_PUSH;
|
|
9637
|
+
pushX += dx / r * push;
|
|
9638
|
+
pushZ += dz / r * push;
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9641
|
+
return { height, push: [pushX, pushZ] };
|
|
9642
|
+
};
|
|
9643
|
+
return {
|
|
9644
|
+
shot,
|
|
9645
|
+
blast,
|
|
9646
|
+
update(dt) {
|
|
9647
|
+
let left = Math.max(0, dt);
|
|
9648
|
+
while (left > 1e-6) {
|
|
9649
|
+
motion.dt = Math.min(STEP_LIMIT, left);
|
|
9650
|
+
stepWaterPools(pools, motion);
|
|
9651
|
+
left -= motion.dt;
|
|
9652
|
+
}
|
|
9653
|
+
},
|
|
9654
|
+
setCamera(position) {
|
|
9655
|
+
camera2[0] = position[0];
|
|
9656
|
+
camera2[1] = position[1];
|
|
9657
|
+
camera2[2] = position[2];
|
|
9658
|
+
hasCamera = true;
|
|
9659
|
+
},
|
|
9660
|
+
waveAt,
|
|
9661
|
+
drops: pools.drops.items,
|
|
9662
|
+
rings: pools.rings.items,
|
|
9663
|
+
foam: pools.foam.items,
|
|
9664
|
+
columns: pools.columns.items,
|
|
9665
|
+
bubbles: pools.bubbles.items,
|
|
9666
|
+
mist: pools.mist.items,
|
|
9667
|
+
waves: pools.waves.items,
|
|
9668
|
+
limits,
|
|
9669
|
+
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 }),
|
|
9670
|
+
clear() {
|
|
9671
|
+
for (const pool of Object.values(pools)) pool.clear();
|
|
9672
|
+
}
|
|
9673
|
+
};
|
|
9674
|
+
}
|
|
8961
9675
|
export {
|
|
8962
9676
|
AREA_CAP_GAME,
|
|
9677
|
+
DEBRIS_COLOR_VARIABLE,
|
|
9678
|
+
DEBRIS_EFFECT_FAMILIES,
|
|
9679
|
+
DUST_COLOR_VARIABLE,
|
|
8963
9680
|
EVENT_BUDGET,
|
|
8964
9681
|
EVENT_EFFECTS,
|
|
8965
9682
|
EVENT_EFFECTS_MAP,
|
|
@@ -8972,6 +9689,7 @@ export {
|
|
|
8972
9689
|
GAME_EFFECTS,
|
|
8973
9690
|
LOD_GAME,
|
|
8974
9691
|
LOD_LAB,
|
|
9692
|
+
MATERIAL_EVENT_EFFECTS,
|
|
8975
9693
|
MeshPool,
|
|
8976
9694
|
OrderedPool,
|
|
8977
9695
|
PROFILES,
|
|
@@ -8984,6 +9702,11 @@ export {
|
|
|
8984
9702
|
SpriteKindSystem,
|
|
8985
9703
|
VFX_LAYERS,
|
|
8986
9704
|
VIEWMODEL_EFFECTS,
|
|
9705
|
+
WATER_BLASTS,
|
|
9706
|
+
WATER_BLAST_KINDS,
|
|
9707
|
+
WATER_LIMITS,
|
|
9708
|
+
WATER_SHOT_BY_CALIBER,
|
|
9709
|
+
WATER_SHOT_PROFILES,
|
|
8987
9710
|
WORKSHOP_BEHAVIORS,
|
|
8988
9711
|
WORKSHOP_EFFECTS,
|
|
8989
9712
|
WORKSHOP_PUDDLES,
|
|
@@ -8996,6 +9719,7 @@ export {
|
|
|
8996
9719
|
createSchedule,
|
|
8997
9720
|
createScreenState,
|
|
8998
9721
|
createVfx,
|
|
9722
|
+
createWaterEffects,
|
|
8999
9723
|
createWorkshopBehaviors,
|
|
9000
9724
|
effectForEvent,
|
|
9001
9725
|
estimateCost,
|
|
@@ -9009,10 +9733,16 @@ export {
|
|
|
9009
9733
|
patchEffects,
|
|
9010
9734
|
patchExplosions,
|
|
9011
9735
|
patchSpriteKinds,
|
|
9736
|
+
patchWaterShotProfiles,
|
|
9737
|
+
planWaterBlast,
|
|
9738
|
+
planWaterShot,
|
|
9012
9739
|
resolveStrings,
|
|
9740
|
+
resolveWaterBlast,
|
|
9741
|
+
resolveWaterShotProfile,
|
|
9013
9742
|
slideAlong,
|
|
9014
9743
|
streamFor,
|
|
9015
9744
|
updateScreen,
|
|
9745
|
+
waterShotClassOf,
|
|
9016
9746
|
workshopGround
|
|
9017
9747
|
};
|
|
9018
9748
|
//# sourceMappingURL=index.js.map
|