@adatechnology/game-destruction-three 0.24.1 → 0.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +329 -134
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +93 -40
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -3718,66 +3718,58 @@ var GameDestructionThree = (() => {
|
|
|
3718
3718
|
])
|
|
3719
3719
|
]
|
|
3720
3720
|
};
|
|
3721
|
+
var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
|
|
3722
|
+
var DEBRIS_COLOR_VARIABLE = "debrisColor";
|
|
3723
|
+
var DUST_COLOR_VARIABLE = "dustColor";
|
|
3724
|
+
var FAMILIES = {
|
|
3725
|
+
wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
|
|
3726
|
+
masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
|
|
3727
|
+
glass: { debris: 11061464, dust: 12572386, piece: [0.04, 4e-3, 0.04], spin: 14, cloud: 0.25, sparks: false, glints: true },
|
|
3728
|
+
metal: { debris: 9080726, dust: 9078138, piece: [0.04, 6e-3, 0.03], spin: 8, cloud: 0.15, sparks: true, glints: false },
|
|
3729
|
+
soft: { debris: 10130568, dust: 11578014, piece: [0.025, 4e-3, 0.02], spin: 6, cloud: 0.3, sparks: false, glints: false },
|
|
3730
|
+
soil: { debris: 8022613, dust: 9075298, piece: [0.03, 0.025, 0.03], spin: 3, cloud: 1, sparks: false, glints: false }
|
|
3731
|
+
};
|
|
3732
|
+
var ORIGIN = [0, 0, 0];
|
|
3721
3733
|
var FACING4 = [0, 0, 1];
|
|
3722
3734
|
var UP11 = [0, 1, 0];
|
|
3723
|
-
var
|
|
3724
|
-
var
|
|
3725
|
-
var
|
|
3726
|
-
var
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
var muzzleEffect = (weapon) => ({
|
|
3735
|
-
id: `muzzle_${weapon}`,
|
|
3736
|
-
pageId: `event:muzzle_${weapon}`,
|
|
3737
|
-
team: "weapons",
|
|
3738
|
-
budget: { particles: 60, lights: 1 },
|
|
3739
|
-
loop: 2.4,
|
|
3740
|
-
timeline: [call2("muzzle", weapon, ORIGIN, FORWARD4)]
|
|
3741
|
-
});
|
|
3742
|
-
var casingEffect = (id, type) => ({
|
|
3743
|
-
id,
|
|
3744
|
-
pageId: `event:${id}`,
|
|
3745
|
-
team: "weapons",
|
|
3746
|
-
budget: { debris: 1 },
|
|
3747
|
-
loop: 2,
|
|
3748
|
-
timeline: [call2("casing", ORIGIN, type)]
|
|
3749
|
-
});
|
|
3750
|
-
var EVENT_EFFECTS = [
|
|
3751
|
-
...IMPACT_MATERIALS.map(impactEffect),
|
|
3752
|
-
...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
|
|
3753
|
-
casingEffect("casing_brass", ""),
|
|
3754
|
-
casingEffect("casing_shell", "shell"),
|
|
3755
|
-
casingEffect("casing_50", "50"),
|
|
3756
|
-
{
|
|
3757
|
-
// door_stages (W856-871): the dust a blow shakes loose from the frame and the splinters.
|
|
3758
|
-
id: "stage_crack",
|
|
3759
|
-
pageId: "event:stage_crack",
|
|
3735
|
+
var grow = (piece, factor) => [piece[0] * factor, piece[1] * factor, piece[2] * factor];
|
|
3736
|
+
var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
|
|
3737
|
+
var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
|
|
3738
|
+
var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
|
|
3739
|
+
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 })] : [];
|
|
3740
|
+
function stageCrack(family) {
|
|
3741
|
+
const look = FAMILIES[family];
|
|
3742
|
+
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 })];
|
|
3743
|
+
return {
|
|
3744
|
+
id: `stage_crack_${family}`,
|
|
3745
|
+
pageId: `event:stage_crack_${family}`,
|
|
3760
3746
|
team: "destruction",
|
|
3761
|
-
budget: { particles:
|
|
3747
|
+
budget: { particles: 16, debris: 6 },
|
|
3762
3748
|
loop: 2,
|
|
3763
3749
|
timeline: [
|
|
3764
|
-
|
|
3765
|
-
|
|
3750
|
+
...dust,
|
|
3751
|
+
...sparks(look, 8),
|
|
3752
|
+
...glints(look, 4),
|
|
3753
|
+
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 }))
|
|
3766
3754
|
]
|
|
3767
|
-
}
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3755
|
+
};
|
|
3756
|
+
}
|
|
3757
|
+
function breachDust(family) {
|
|
3758
|
+
const look = FAMILIES[family];
|
|
3759
|
+
return {
|
|
3760
|
+
id: `breach_dust_${family}`,
|
|
3761
|
+
pageId: `event:breach_dust_${family}`,
|
|
3772
3762
|
team: "destruction",
|
|
3773
3763
|
budget: { particles: 90, debris: 16 },
|
|
3774
3764
|
loop: 5,
|
|
3775
3765
|
timeline: [
|
|
3776
3766
|
screen({ add: { shake: 0.25 } }),
|
|
3777
|
-
|
|
3778
|
-
|
|
3767
|
+
...sparks(look, 14),
|
|
3768
|
+
...glints(look, 20),
|
|
3769
|
+
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 }),
|
|
3770
|
+
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 })),
|
|
3779
3771
|
repeat(
|
|
3780
|
-
scaled(60),
|
|
3772
|
+
scaled(Math.round(60 * look.cloud)),
|
|
3781
3773
|
spawn("normal", local("angle", rnd(0, 6.283), {
|
|
3782
3774
|
p: [rnd(-1.4, 1.4), 0.2, rnd(-0.6, 0.4)],
|
|
3783
3775
|
dir: vnorm([cos(variable("angle")), 0.3, sin(variable("angle"))]),
|
|
@@ -3787,27 +3779,30 @@ var GameDestructionThree = (() => {
|
|
|
3787
3779
|
life: [2.5, 4.5],
|
|
3788
3780
|
size: [0.6, 1],
|
|
3789
3781
|
grow: 3,
|
|
3790
|
-
c0:
|
|
3782
|
+
c0: dustTone(look),
|
|
3791
3783
|
c1: 4867648,
|
|
3792
3784
|
a: 0.45,
|
|
3793
3785
|
fi: 0.12
|
|
3794
3786
|
}))
|
|
3795
3787
|
)
|
|
3796
3788
|
]
|
|
3797
|
-
}
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3789
|
+
};
|
|
3790
|
+
}
|
|
3791
|
+
function collapseDust(family) {
|
|
3792
|
+
const look = FAMILIES[family];
|
|
3793
|
+
return {
|
|
3794
|
+
id: `collapse_dust_${family}`,
|
|
3795
|
+
pageId: `event:collapse_dust_${family}`,
|
|
3802
3796
|
team: "destruction",
|
|
3803
3797
|
budget: { particles: 350, debris: 26 },
|
|
3804
3798
|
loop: 8,
|
|
3805
3799
|
timeline: [
|
|
3806
3800
|
screen({ add: { shake: 0.45 } }),
|
|
3807
|
-
|
|
3808
|
-
repeat(
|
|
3801
|
+
...sparks(look, 20),
|
|
3802
|
+
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 })),
|
|
3803
|
+
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 })),
|
|
3809
3804
|
repeat(
|
|
3810
|
-
scaled(70),
|
|
3805
|
+
scaled(Math.round(70 * look.cloud)),
|
|
3811
3806
|
spawn("normal", local("angle", rnd(-0.4, 3.5), {
|
|
3812
3807
|
p: [rnd(-2, 2), 0.2, rnd(-0.5, 0.5)],
|
|
3813
3808
|
dir: vnorm([mul(cos(variable("angle")), 0.6), 0.25, sin(variable("angle"))]),
|
|
@@ -3817,14 +3812,66 @@ var GameDestructionThree = (() => {
|
|
|
3817
3812
|
life: [3, 6],
|
|
3818
3813
|
size: [0.7, 1.2],
|
|
3819
3814
|
grow: 3,
|
|
3820
|
-
c0:
|
|
3815
|
+
c0: dustTone(look),
|
|
3821
3816
|
c1: 4867648,
|
|
3822
3817
|
a: 0.5,
|
|
3823
3818
|
fi: 0.12
|
|
3824
3819
|
}))
|
|
3825
3820
|
)
|
|
3826
3821
|
]
|
|
3827
|
-
}
|
|
3822
|
+
};
|
|
3823
|
+
}
|
|
3824
|
+
var MASONRY = FAMILIES.masonry;
|
|
3825
|
+
var REBAR_EXPOSE = {
|
|
3826
|
+
id: "rebar_expose",
|
|
3827
|
+
pageId: "event:rebar_expose",
|
|
3828
|
+
team: "destruction",
|
|
3829
|
+
budget: { particles: 24, debris: 8 },
|
|
3830
|
+
loop: 2,
|
|
3831
|
+
timeline: [
|
|
3832
|
+
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 })),
|
|
3833
|
+
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 }),
|
|
3834
|
+
call2("rust_at", ORIGIN, 6)
|
|
3835
|
+
]
|
|
3836
|
+
};
|
|
3837
|
+
var MATERIAL_EVENT_EFFECTS = [
|
|
3838
|
+
...DEBRIS_EFFECT_FAMILIES.flatMap((family) => [stageCrack(family), breachDust(family), collapseDust(family)]),
|
|
3839
|
+
REBAR_EXPOSE
|
|
3840
|
+
];
|
|
3841
|
+
var FACING5 = [0, 0, 1];
|
|
3842
|
+
var ORIGIN2 = [0, 0, 0];
|
|
3843
|
+
var FORWARD4 = [0, 0, -1];
|
|
3844
|
+
var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
|
|
3845
|
+
var impactEffect = (material) => ({
|
|
3846
|
+
id: `impact_${material}`,
|
|
3847
|
+
pageId: `event:impact_${material}`,
|
|
3848
|
+
team: "weapons",
|
|
3849
|
+
budget: { particles: 40, decals: 1 },
|
|
3850
|
+
loop: 2,
|
|
3851
|
+
timeline: [call2("impact", material, ORIGIN2, FACING5, 1, 0)]
|
|
3852
|
+
});
|
|
3853
|
+
var muzzleEffect = (weapon) => ({
|
|
3854
|
+
id: `muzzle_${weapon}`,
|
|
3855
|
+
pageId: `event:muzzle_${weapon}`,
|
|
3856
|
+
team: "weapons",
|
|
3857
|
+
budget: { particles: 60, lights: 1 },
|
|
3858
|
+
loop: 2.4,
|
|
3859
|
+
timeline: [call2("muzzle", weapon, ORIGIN2, FORWARD4)]
|
|
3860
|
+
});
|
|
3861
|
+
var casingEffect = (id, type) => ({
|
|
3862
|
+
id,
|
|
3863
|
+
pageId: `event:${id}`,
|
|
3864
|
+
team: "weapons",
|
|
3865
|
+
budget: { debris: 1 },
|
|
3866
|
+
loop: 2,
|
|
3867
|
+
timeline: [call2("casing", ORIGIN2, type)]
|
|
3868
|
+
});
|
|
3869
|
+
var EVENT_EFFECTS = [
|
|
3870
|
+
...IMPACT_MATERIALS.map(impactEffect),
|
|
3871
|
+
...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
|
|
3872
|
+
casingEffect("casing_brass", ""),
|
|
3873
|
+
casingEffect("casing_shell", "shell"),
|
|
3874
|
+
casingEffect("casing_50", "50"),
|
|
3828
3875
|
{
|
|
3829
3876
|
// shopfront_glass (W846-855): the pane coming down as shards, the flash of the glints and the pale dust.
|
|
3830
3877
|
id: "glass_burst",
|
|
@@ -3836,21 +3883,13 @@ var GameDestructionThree = (() => {
|
|
|
3836
3883
|
screen({ add: { shake: 0.08 } }),
|
|
3837
3884
|
repeat(
|
|
3838
3885
|
scaled(75),
|
|
3839
|
-
debris({ p:
|
|
3886
|
+
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 })
|
|
3840
3887
|
),
|
|
3841
|
-
burst("add", 30, { p:
|
|
3888
|
+
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 }),
|
|
3842
3889
|
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 })
|
|
3843
3890
|
]
|
|
3844
3891
|
},
|
|
3845
|
-
|
|
3846
|
-
// The chips macro the page uses on wood (W849) plus rust (`rustAt`), for rebar laid bare in concrete.
|
|
3847
|
-
id: "rebar_expose",
|
|
3848
|
-
pageId: "event:rebar_expose",
|
|
3849
|
-
team: "destruction",
|
|
3850
|
-
budget: { particles: 20, debris: 8 },
|
|
3851
|
-
loop: 2,
|
|
3852
|
-
timeline: [call2("chips", ORIGIN, UP11, 8, 0.9), call2("rust_at", ORIGIN, 6)]
|
|
3853
|
-
}
|
|
3892
|
+
...MATERIAL_EVENT_EFFECTS
|
|
3854
3893
|
];
|
|
3855
3894
|
var PI = Math.PI;
|
|
3856
3895
|
var SMOKE = { color: 9079430, width: 10, height: 8, gravity: -0.08, drag: 2.2, growth: 2.1 };
|
|
@@ -3861,7 +3900,7 @@ var GameDestructionThree = (() => {
|
|
|
3861
3900
|
var FLASH_OPACITY = 0.95;
|
|
3862
3901
|
var FLAME_COLORS = [16742946, 16760896, 13121050, 16773296];
|
|
3863
3902
|
var FLAME_ADDITIVE = 3;
|
|
3864
|
-
var
|
|
3903
|
+
var ORIGIN3 = [0, 0, 0];
|
|
3865
3904
|
var SIZE = variable("size");
|
|
3866
3905
|
var FLASH_SCALE = variable("flash");
|
|
3867
3906
|
var fallback = (name, defaultValue) => ite(ne(variable(name), void 0), variable(name), defaultValue);
|
|
@@ -3909,7 +3948,7 @@ var GameDestructionThree = (() => {
|
|
|
3909
3948
|
grow: 2.2
|
|
3910
3949
|
})
|
|
3911
3950
|
];
|
|
3912
|
-
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:
|
|
3951
|
+
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 });
|
|
3913
3952
|
var MUZZLE_FLASH2 = {
|
|
3914
3953
|
id: "viewmodel_muzzle_flash",
|
|
3915
3954
|
pageId: "event:viewmodel_muzzle_flash",
|
|
@@ -3936,7 +3975,7 @@ var GameDestructionThree = (() => {
|
|
|
3936
3975
|
repeat(4, append("angles", add(div(mul(INDEX, PI), 2), mul(rand(), 0.6)))),
|
|
3937
3976
|
set("roll", mul(rand(), PI)),
|
|
3938
3977
|
when(gt(FLASH_SCALE, 0), [
|
|
3939
|
-
flash(
|
|
3978
|
+
flash(ORIGIN3, 16756832, mul(4, SIZE, FLASH_SCALE), FLASH_SECONDS, mul(2, SIZE, FLASH_SCALE), true, true),
|
|
3940
3979
|
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),
|
|
3941
3980
|
repeat(
|
|
3942
3981
|
4,
|
|
@@ -3956,7 +3995,7 @@ var GameDestructionThree = (() => {
|
|
|
3956
3995
|
repeat(
|
|
3957
3996
|
variable("puffs"),
|
|
3958
3997
|
puff2(
|
|
3959
|
-
|
|
3998
|
+
ORIGIN3,
|
|
3960
3999
|
[add(variable("drift"), mul(rand(), variable("driftSpread"))), add(variable("rise"), mul(rand(), variable("riseSpread"))), mul(sub(rand(), 0.5), variable("sideSpread"))],
|
|
3961
4000
|
[0, 0, 0],
|
|
3962
4001
|
mul(variable("radius"), SIZE),
|
|
@@ -3973,7 +4012,7 @@ var GameDestructionThree = (() => {
|
|
|
3973
4012
|
team: "weapons",
|
|
3974
4013
|
budget: { particles: 1 },
|
|
3975
4014
|
loop: 0.1,
|
|
3976
|
-
timeline: [puff2(
|
|
4015
|
+
timeline: [puff2(ORIGIN3, void 0, [variable("vx"), variable("vy"), variable("vz")], variable("radius"), variable("life"), variable("opacity"))]
|
|
3977
4016
|
};
|
|
3978
4017
|
var BACKBLAST = {
|
|
3979
4018
|
id: "launcher_backblast",
|
|
@@ -3982,8 +4021,8 @@ var GameDestructionThree = (() => {
|
|
|
3982
4021
|
budget: { particles: 40 },
|
|
3983
4022
|
loop: 0.1,
|
|
3984
4023
|
timeline: [
|
|
3985
|
-
repeat(26, puff2(
|
|
3986
|
-
repeat(14, ...flameBit(
|
|
4024
|
+
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)),
|
|
4025
|
+
repeat(14, ...flameBit(ORIGIN3, [neg(add(2, mul(rand(), 2))), 0, 0], [wide(1), wide(0.6), wide(1)], 0.02, 0.25))
|
|
3987
4026
|
]
|
|
3988
4027
|
};
|
|
3989
4028
|
var FLAME_JET = {
|
|
@@ -4102,7 +4141,7 @@ var GameDestructionThree = (() => {
|
|
|
4102
4141
|
}
|
|
4103
4142
|
var COLUMNS = 6;
|
|
4104
4143
|
var ROWS = 5;
|
|
4105
|
-
var
|
|
4144
|
+
var ORIGIN4 = [-2.2, 0, 2.6];
|
|
4106
4145
|
var BLOCK_SIZE = [0.5, 0.44, 0.25];
|
|
4107
4146
|
var OBJECT_ID_DRAWS2 = 4;
|
|
4108
4147
|
var FLOOR2 = 0.13;
|
|
@@ -4145,7 +4184,7 @@ var GameDestructionThree = (() => {
|
|
|
4145
4184
|
const chipScale = random.between(0.8, 1.3) * scale;
|
|
4146
4185
|
for (let draw = 0; draw < OBJECT_ID_DRAWS2; draw++) random.next();
|
|
4147
4186
|
best.holes.push({ x: offsetX, y: offsetY, scale, chipTurn, chipScale });
|
|
4148
|
-
impact(host.engine, "concrete", [
|
|
4187
|
+
impact(host.engine, "concrete", [ORIGIN4[0] + x, y, ORIGIN4[2] + 0.13], [0, 0, 1], 0.8);
|
|
4149
4188
|
} else if (action === "collapse") {
|
|
4150
4189
|
const { x, y } = args;
|
|
4151
4190
|
for (const block of blocks) {
|
|
@@ -4195,7 +4234,7 @@ var GameDestructionThree = (() => {
|
|
|
4195
4234
|
}
|
|
4196
4235
|
};
|
|
4197
4236
|
}
|
|
4198
|
-
var
|
|
4237
|
+
var ORIGIN5 = [5.6, 0, 0.8];
|
|
4199
4238
|
var MAX_TILT = 0.25;
|
|
4200
4239
|
function createCarBehavior() {
|
|
4201
4240
|
let y = 0;
|
|
@@ -4228,7 +4267,7 @@ var GameDestructionThree = (() => {
|
|
|
4228
4267
|
}
|
|
4229
4268
|
},
|
|
4230
4269
|
query(_host, name, args) {
|
|
4231
|
-
if (name === "position") return [
|
|
4270
|
+
if (name === "position") return [ORIGIN5[0], y, ORIGIN5[2]];
|
|
4232
4271
|
if (name === "point") {
|
|
4233
4272
|
const [x, py, z] = args;
|
|
4234
4273
|
const point = carPoint(x, py, z);
|
|
@@ -5100,7 +5139,7 @@ var GameDestructionThree = (() => {
|
|
|
5100
5139
|
this.index = previous;
|
|
5101
5140
|
}
|
|
5102
5141
|
};
|
|
5103
|
-
var
|
|
5142
|
+
var ORIGIN6 = [0, 0, 0];
|
|
5104
5143
|
var DEFAULT_HEADING = [0, 0, -1];
|
|
5105
5144
|
var DEFAULT_MAX_INSTANCES = 48;
|
|
5106
5145
|
var ENDLESS_SECONDS = 60;
|
|
@@ -5177,7 +5216,7 @@ var GameDestructionThree = (() => {
|
|
|
5177
5216
|
random: playOptions.seed !== void 0 ? streamOf(playOptions.seed) : void 0,
|
|
5178
5217
|
follow: playOptions.follow,
|
|
5179
5218
|
origin: point,
|
|
5180
|
-
anchor: def.anchor ??
|
|
5219
|
+
anchor: def.anchor ?? ORIGIN6,
|
|
5181
5220
|
yaw: yawOf(heading, playOptions.direction),
|
|
5182
5221
|
orientation: playOptions.orientation,
|
|
5183
5222
|
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
|
|
@@ -7815,9 +7854,9 @@ var GameDestructionThree = (() => {
|
|
|
7815
7854
|
}
|
|
7816
7855
|
var event_effects_default = {
|
|
7817
7856
|
spall: "impact_{material}",
|
|
7818
|
-
stage: { "1": "
|
|
7857
|
+
stage: { "1": "stage_crack_{material}", "2": "breach_dust_{material}", "3": "collapse_dust_{material}" },
|
|
7819
7858
|
expose: "rebar_expose",
|
|
7820
|
-
collapse: "
|
|
7859
|
+
collapse: "collapse_dust_{material}",
|
|
7821
7860
|
explode: "explosion",
|
|
7822
7861
|
fracture: { glass: "glass_burst" }
|
|
7823
7862
|
};
|
|
@@ -7825,10 +7864,16 @@ var GameDestructionThree = (() => {
|
|
|
7825
7864
|
function effectForEvent(event, map = EVENT_EFFECTS_MAP) {
|
|
7826
7865
|
const entry = map[event.kind];
|
|
7827
7866
|
if (entry === void 0) return void 0;
|
|
7828
|
-
if (typeof entry === "string") return
|
|
7867
|
+
if (typeof entry === "string") return withMaterial(entry, event.material);
|
|
7829
7868
|
const key = event.stage !== void 0 ? String(event.stage) : event.material;
|
|
7830
|
-
|
|
7869
|
+
const chosen = key === void 0 ? void 0 : entry[key];
|
|
7870
|
+
return chosen === void 0 ? void 0 : withMaterial(chosen, event.material);
|
|
7831
7871
|
}
|
|
7872
|
+
function withMaterial(entry, material) {
|
|
7873
|
+
if (!entry.includes("{material}")) return entry;
|
|
7874
|
+
return material ? entry.replace("{material}", material) : void 0;
|
|
7875
|
+
}
|
|
7876
|
+
var DEGREES = 180 / Math.PI;
|
|
7832
7877
|
|
|
7833
7878
|
// ../game-render-three/dist/index.js
|
|
7834
7879
|
var DEFAULT_ANGLE = Math.PI / 3;
|
|
@@ -9203,7 +9248,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9203
9248
|
uTime: { value: 0 }
|
|
9204
9249
|
};
|
|
9205
9250
|
const puffs = createPuffLayer(THREE, pools.puffs, uniforms);
|
|
9206
|
-
const
|
|
9251
|
+
const sparks2 = createSparkLayer(THREE, pools.sparks);
|
|
9207
9252
|
const glows = createGlowLayer(THREE, pools.glows);
|
|
9208
9253
|
const rockGeometry = new THREE.DodecahedronGeometry(0.5, 0);
|
|
9209
9254
|
const plateGeometry = new THREE.BoxGeometry(1, 1, 1);
|
|
@@ -9212,7 +9257,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9212
9257
|
const sprites = createSpriteLayer(THREE, world.sprites(), options.pointScale ?? 700);
|
|
9213
9258
|
const lights = createLightLayer(THREE, pools.lights, options.lightScale ?? Math.PI, options.lights);
|
|
9214
9259
|
const marks = createMarkLayer(THREE, { ground: pools.ground, ...world.hostGroundAt ? { heightAt: world.hostGroundAt } : {}, createCanvas: options.createCanvas, rockGeometry, plateGeometry, ...options.markLimits });
|
|
9215
|
-
root.add(puffs.mesh,
|
|
9260
|
+
root.add(puffs.mesh, sparks2.mesh, glows.mesh, chunks.rocks, chunks.plates, shocks.group, lights.group, sprites.additive, sprites.normal, marks.group);
|
|
9216
9261
|
const stopMarks = world.onMarks((event) => marks.handle(event));
|
|
9217
9262
|
const overlay = options.overlay ? createScreenOverlay(options.overlay) : void 0;
|
|
9218
9263
|
let drawCalls = 0;
|
|
@@ -9221,7 +9266,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9221
9266
|
const layerOn = /* @__PURE__ */ new Map();
|
|
9222
9267
|
const layerObjects = () => ({
|
|
9223
9268
|
puffs: [puffs.mesh],
|
|
9224
|
-
sparks: [
|
|
9269
|
+
sparks: [sparks2.mesh],
|
|
9225
9270
|
glows: [glows.mesh],
|
|
9226
9271
|
debris: [chunks.rocks, chunks.plates],
|
|
9227
9272
|
shock: [shocks.group],
|
|
@@ -9249,7 +9294,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9249
9294
|
}
|
|
9250
9295
|
function syncAll() {
|
|
9251
9296
|
lastDrawn.puffs = puffs.sync();
|
|
9252
|
-
lastDrawn.sparks =
|
|
9297
|
+
lastDrawn.sparks = sparks2.sync();
|
|
9253
9298
|
lastDrawn.glows = glows.sync();
|
|
9254
9299
|
lastDrawn.chunks = chunks.sync();
|
|
9255
9300
|
lastDrawn.shocks = shocks.sync();
|
|
@@ -9350,7 +9395,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9350
9395
|
stopMarks();
|
|
9351
9396
|
overlay?.dispose();
|
|
9352
9397
|
workshopLayers?.dispose();
|
|
9353
|
-
for (const layer22 of [puffs,
|
|
9398
|
+
for (const layer22 of [puffs, sparks2, glows, chunks, shocks, lights, marks, sprites]) layer22.dispose();
|
|
9354
9399
|
rockGeometry.dispose();
|
|
9355
9400
|
plateGeometry.dispose();
|
|
9356
9401
|
options.scene.remove(root);
|
|
@@ -9359,6 +9404,42 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9359
9404
|
}
|
|
9360
9405
|
var LIGHT_BUDGET = EVENT_BUDGET.blastLights + EVENT_BUDGET.fireLights;
|
|
9361
9406
|
|
|
9407
|
+
// ../game-vfx-three/dist/index.js
|
|
9408
|
+
var NOISE = `float wHash(vec2 p){return fract(sin(dot(p,vec2(12.9898,78.233)))*43758.5453);}
|
|
9409
|
+
float wNoise(vec2 p){vec2 i=floor(p);vec2 f=fract(p);f=f*f*(3.-2.*f);return mix(mix(wHash(i),wHash(i+vec2(1.,0.)),f.x),mix(wHash(i+vec2(0.,1.)),wHash(i+vec2(1.,1.)),f.x),f.y);}`;
|
|
9410
|
+
var OUTPUT = `
|
|
9411
|
+
#include <tonemapping_fragment>
|
|
9412
|
+
#include <colorspace_fragment>`;
|
|
9413
|
+
var WATER_SURFACE_FRAGMENT = `uniform vec3 uFoam;varying vec2 vU;varying vec3 vD;${NOISE}
|
|
9414
|
+
void main(){float r=length(vU);if(r>1.)discard;float a=atan(vU.y,vU.x);float kind=vD.y;float s=vD.z;float m;
|
|
9415
|
+
if(kind>2.5){float n=wNoise(vU*7.+s*13.)*.6+wNoise(vU*19.-s*7.)*.4;m=smoothstep(1.,.55,r)*smoothstep(.25,.6,n);}
|
|
9416
|
+
else{float w=kind>1.5?.16:kind>.5?.05:.09;float band=smoothstep(1.,1.-w,r)*smoothstep(1.-w*3.,1.-w,r);float broken=kind>.5?1.:.65+.35*wNoise(vec2(a*5.+s*20.,s));m=band*broken;}
|
|
9417
|
+
float alpha=m*vD.x;if(alpha<.004)discard;gl_FragColor=vec4(uFoam,alpha);${OUTPUT}
|
|
9418
|
+
}`;
|
|
9419
|
+
var WATER_SPRITE_FRAGMENT = `uniform vec3 uFoam;uniform vec3 uDeep;varying vec2 vU;varying vec3 vD;${NOISE}
|
|
9420
|
+
void main(){float r=length(vU);if(r>1.)discard;float kind=vD.y;float m;vec3 c=uFoam;
|
|
9421
|
+
if(kind>1.5){m=exp(-r*r*3.)*(.75+.25*wNoise(vU*3.+vD.z*9.));}
|
|
9422
|
+
else if(kind>.5){m=smoothstep(.55,.85,r)*smoothstep(1.,.88,r)+.25*smoothstep(.5,.2,length(vU-vec2(-.3,.3)));c=mix(uDeep,uFoam,.8);}
|
|
9423
|
+
else{m=smoothstep(1.,.6,r);c=mix(uDeep,uFoam,.55+.45*smoothstep(.2,.8,1.-length(vU-vec2(-.3,.35))));}
|
|
9424
|
+
float alpha=m*vD.x;if(alpha<.004)discard;gl_FragColor=vec4(c,alpha);${OUTPUT}
|
|
9425
|
+
}`;
|
|
9426
|
+
var WATER_COLUMN_VERTEX = `attribute vec4 aP;attribute vec4 aD;attribute vec2 aK;varying float vY;varying float vA;varying vec2 vK;varying float vF;${NOISE}
|
|
9427
|
+
void main(){vY=position.y;float ang=atan(position.z,position.x);vK=aK;
|
|
9428
|
+
float dome=aK.x;float s=aK.y;float h=position.y;
|
|
9429
|
+
float jag=.8+.4*wNoise(vec2(ang*3.+s*17.,h*4.+s));
|
|
9430
|
+
float flare=dome>.5?1.:(.55+.9*h*h)*jag;
|
|
9431
|
+
vec3 p=vec3(position.x*aP.w*flare,position.y*aD.x,position.z*aP.w*flare);
|
|
9432
|
+
p.x+=aD.z*aD.x*h*h;p.z+=aD.w*aD.x*h*h;
|
|
9433
|
+
vec3 w=aP.xyz+p;vec3 n=normalize(vec3(position.x,dome>.5?position.y:.25,position.z));
|
|
9434
|
+
vec3 v=normalize(cameraPosition-w);vF=abs(dot(n,v));
|
|
9435
|
+
vA=aD.y;gl_Position=projectionMatrix*viewMatrix*vec4(w,1.);}`;
|
|
9436
|
+
var WATER_COLUMN_FRAGMENT = `uniform vec3 uFoam;uniform vec3 uDeep;varying float vY;varying float vA;varying vec2 vK;varying float vF;${NOISE}
|
|
9437
|
+
void main(){float dome=vK.x;float s=vK.y;
|
|
9438
|
+
float streak=wNoise(vec2(gl_FragCoord.x*.05+s*31.,vY*6.+s));
|
|
9439
|
+
float body=dome>.5?mix(.95,.5,vY)*(.6+.4*(1.-vF)):(1.-smoothstep(.55,1.,vY))*(.45+.55*streak)*(.55+.45*(1.-vF*.6));
|
|
9440
|
+
vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)discard;gl_FragColor=vec4(c,alpha);${OUTPUT}
|
|
9441
|
+
}`;
|
|
9442
|
+
|
|
9362
9443
|
// src/fitted-boxes.ts
|
|
9363
9444
|
var SLICE_LENGTH = 0.12;
|
|
9364
9445
|
var MAX_SLICES = 12;
|
|
@@ -9852,6 +9933,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9852
9933
|
rouse(f) {
|
|
9853
9934
|
f.asleep = false;
|
|
9854
9935
|
f.rest = 0;
|
|
9936
|
+
f.floor = null;
|
|
9855
9937
|
f.mesh.matrixAutoUpdate = true;
|
|
9856
9938
|
}
|
|
9857
9939
|
/** What lies inside the disc looks at the ground again: it was dug or heaped under it. */
|
|
@@ -9897,6 +9979,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9897
9979
|
if (!f.asleep || f.dying) continue;
|
|
9898
9980
|
const e = this.m.makeRotationFromQuaternion(f.mesh.quaternion).elements;
|
|
9899
9981
|
const ext = Math.abs(e[1]) * f.half.x + Math.abs(e[5]) * f.half.y + Math.abs(e[9]) * f.half.z;
|
|
9982
|
+
f.floor = null;
|
|
9900
9983
|
if (f.mesh.position.y - ext > this.floorUnder(f) + SUPPORT_GAP) this.rouse(f);
|
|
9901
9984
|
}
|
|
9902
9985
|
}
|
|
@@ -12951,6 +13034,70 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12951
13034
|
}
|
|
12952
13035
|
];
|
|
12953
13036
|
var SHIPPED = structuredClone(assemblies_default);
|
|
13037
|
+
var FAMILY_COLORS = {
|
|
13038
|
+
wood: { debris: 11569754, dust: 11901556 },
|
|
13039
|
+
masonry: { debris: 10197652, dust: 11052187 },
|
|
13040
|
+
glass: { debris: 11061464, dust: 12572386 },
|
|
13041
|
+
metal: { debris: 9080726, dust: void 0 },
|
|
13042
|
+
soft: { debris: 10130568, dust: void 0 },
|
|
13043
|
+
soil: { debris: 8022613, dust: 9075298 }
|
|
13044
|
+
};
|
|
13045
|
+
var MARKS = { wood: "splintered_hole", masonry: "crater", glass: "star_crack", metal: "dent", soft: "torn_hole", soil: "pit" };
|
|
13046
|
+
var IMPACTS = { wood: "wood", masonry: "concrete", glass: "glass", metal: "metal", soft: void 0, soil: void 0 };
|
|
13047
|
+
var FAMILY_DEBRIS = { wood: "splinters", masonry: "chips", glass: "shards", metal: "sparks", soil: "dust" };
|
|
13048
|
+
var STYLE_DEBRIS = { shatter: "shards", crumble: "chips", splinter: "splinters", tear: "fibers", snap: "chips", none: "sparks" };
|
|
13049
|
+
var FRACTURE_FAMILY = { none: "metal", shatter: "glass", splinter: "wood", crumble: "masonry", tear: "soft", snap: "soft" };
|
|
13050
|
+
function debrisFamily(def) {
|
|
13051
|
+
const tags = def?.tags ?? [];
|
|
13052
|
+
if (tags.includes("metal")) return "metal";
|
|
13053
|
+
if (tags.includes("glass") || def?.visual?.transparent) return "glass";
|
|
13054
|
+
if (tags.includes("wood") || def?.penetrationClass === "wood") return "wood";
|
|
13055
|
+
if (tags.includes("soil")) return "soil";
|
|
13056
|
+
if (tags.includes("masonry") || tags.includes("ceramic")) return "masonry";
|
|
13057
|
+
return FRACTURE_FAMILY[def?.fracture ?? "tear"];
|
|
13058
|
+
}
|
|
13059
|
+
function debrisColor(def, partColor) {
|
|
13060
|
+
const family = debrisFamily(def);
|
|
13061
|
+
if (def?.visual?.innerColor !== void 0) return def.visual.innerColor;
|
|
13062
|
+
if (def?.visual?.unitColor !== void 0) return def.visual.unitColor;
|
|
13063
|
+
if (partColor !== void 0 && family !== "metal" && family !== "glass") return partColor;
|
|
13064
|
+
return FAMILY_COLORS[family].debris;
|
|
13065
|
+
}
|
|
13066
|
+
function fragmentTone(def, face, partColor) {
|
|
13067
|
+
if (face.unit && def?.visual?.unitColor !== void 0) return def.visual.unitColor;
|
|
13068
|
+
if (face.inner && def?.visual?.innerColor !== void 0) return def.visual.innerColor;
|
|
13069
|
+
return partColor ?? FAMILY_COLORS[debrisFamily(def)].debris;
|
|
13070
|
+
}
|
|
13071
|
+
function dustColor(def, partColor) {
|
|
13072
|
+
const family = debrisFamily(def);
|
|
13073
|
+
const base = FAMILY_COLORS[family].dust;
|
|
13074
|
+
if (base === void 0) return void 0;
|
|
13075
|
+
if (family === "glass") return base;
|
|
13076
|
+
return mix(debrisColor(def, partColor), 14210252, 0.3);
|
|
13077
|
+
}
|
|
13078
|
+
function debrisKindOf(def, family, event, style) {
|
|
13079
|
+
if (event === "fracture") return STYLE_DEBRIS[style ?? def?.fracture ?? "crumble"];
|
|
13080
|
+
if (event === "shot") return def?.hitDebris ?? (family === "soft" ? "chips" : FAMILY_DEBRIS[family]);
|
|
13081
|
+
if (event === "stage2" || event === "stage3" || event === "explosion" || event === "collapse") return def?.breakDebris ?? "dust";
|
|
13082
|
+
if (family === "soft") return def?.hitDebris ?? "chips";
|
|
13083
|
+
return FAMILY_DEBRIS[family];
|
|
13084
|
+
}
|
|
13085
|
+
function debrisLook(def, event, options = {}) {
|
|
13086
|
+
const family = debrisFamily(def);
|
|
13087
|
+
return {
|
|
13088
|
+
family,
|
|
13089
|
+
debris: debrisKindOf(def, family, event, options.style),
|
|
13090
|
+
color: debrisColor(def, options.partColor),
|
|
13091
|
+
dust: dustColor(def, options.partColor),
|
|
13092
|
+
mark: MARKS[family],
|
|
13093
|
+
sparks: family === "metal",
|
|
13094
|
+
impact: IMPACTS[family]
|
|
13095
|
+
};
|
|
13096
|
+
}
|
|
13097
|
+
function mix(a, b, t) {
|
|
13098
|
+
const channel = (shift) => Math.round((a >> shift & 255) * (1 - t) + (b >> shift & 255) * t) << shift;
|
|
13099
|
+
return channel(16) | channel(8) | channel(0);
|
|
13100
|
+
}
|
|
12954
13101
|
|
|
12955
13102
|
// src/spec.ts
|
|
12956
13103
|
function containsOf(value) {
|
|
@@ -13159,6 +13306,48 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
13159
13306
|
return SURFACE_BY_KEY.find(([key]) => key.test(keys))?.[1];
|
|
13160
13307
|
}
|
|
13161
13308
|
|
|
13309
|
+
// src/debris-events.ts
|
|
13310
|
+
var HIT_POINT_SECONDS = 1;
|
|
13311
|
+
function familyPlay(def, partColor) {
|
|
13312
|
+
const dust = dustColor(def, partColor);
|
|
13313
|
+
return {
|
|
13314
|
+
material: debrisFamily(def),
|
|
13315
|
+
values: { [DEBRIS_COLOR_VARIABLE]: debrisColor(def, partColor), ...dust !== void 0 ? { [DUST_COLOR_VARIABLE]: dust } : {} }
|
|
13316
|
+
};
|
|
13317
|
+
}
|
|
13318
|
+
function pointOf(ev) {
|
|
13319
|
+
switch (ev.type) {
|
|
13320
|
+
case "hole":
|
|
13321
|
+
case "crack":
|
|
13322
|
+
return ev.worldPoint;
|
|
13323
|
+
case "spall":
|
|
13324
|
+
case "debris":
|
|
13325
|
+
return ev.point;
|
|
13326
|
+
case "chip":
|
|
13327
|
+
return ev.center;
|
|
13328
|
+
default:
|
|
13329
|
+
return void 0;
|
|
13330
|
+
}
|
|
13331
|
+
}
|
|
13332
|
+
var HitPoints = class {
|
|
13333
|
+
constructor() {
|
|
13334
|
+
__publicField(this, "points", /* @__PURE__ */ new Map());
|
|
13335
|
+
}
|
|
13336
|
+
note(ev, time) {
|
|
13337
|
+
const point = pointOf(ev);
|
|
13338
|
+
if (!point || !("part" in ev)) return;
|
|
13339
|
+
this.points.set(`${ev.object}|${ev.part}`, { point, time });
|
|
13340
|
+
}
|
|
13341
|
+
/** The last hit on the part, if it was recent. */
|
|
13342
|
+
of(objectId, partId, time) {
|
|
13343
|
+
const hit = this.points.get(`${objectId}|${partId}`);
|
|
13344
|
+
return hit && time - hit.time <= HIT_POINT_SECONDS ? hit.point : void 0;
|
|
13345
|
+
}
|
|
13346
|
+
forget(objectId) {
|
|
13347
|
+
for (const key of this.points.keys()) if (key.startsWith(`${objectId}|`)) this.points.delete(key);
|
|
13348
|
+
}
|
|
13349
|
+
};
|
|
13350
|
+
|
|
13162
13351
|
// src/heat.ts
|
|
13163
13352
|
var STOPS = [
|
|
13164
13353
|
[450, 0],
|
|
@@ -14436,7 +14625,6 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
14436
14625
|
var STEEL_DENSITY = 7850;
|
|
14437
14626
|
var CHIP_DECAL_EDGE = 0.05;
|
|
14438
14627
|
var WOOD_RIM = 1.5;
|
|
14439
|
-
var IMPACT_TAGS = ["metal", "glass", "wood"];
|
|
14440
14628
|
var GLOW_FROM_C = 430;
|
|
14441
14629
|
var MIN_DRAWN_CRACK_WIDTH = 4e-3;
|
|
14442
14630
|
var SETTLEMENT_CRACK_COLOR = 2827296;
|
|
@@ -14590,11 +14778,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
14590
14778
|
return impactKey(def);
|
|
14591
14779
|
}
|
|
14592
14780
|
}
|
|
14593
|
-
function fallbackColor(
|
|
14594
|
-
|
|
14595
|
-
if (def?.visual?.transparent) return 10473696;
|
|
14596
|
-
const h = hashString(id);
|
|
14597
|
-
return mixHex(7035464, 10130568, h % 100 / 100);
|
|
14781
|
+
function fallbackColor(def) {
|
|
14782
|
+
return debrisColor(def);
|
|
14598
14783
|
}
|
|
14599
14784
|
function materialsOf2(m) {
|
|
14600
14785
|
return Array.isArray(m) ? m : [m];
|
|
@@ -14668,6 +14853,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
14668
14853
|
__publicField(this, "ground");
|
|
14669
14854
|
__publicField(this, "pieceSys");
|
|
14670
14855
|
__publicField(this, "cages");
|
|
14856
|
+
__publicField(this, "hitPoints", new HitPoints());
|
|
14671
14857
|
__publicField(this, "active", /* @__PURE__ */ new Map());
|
|
14672
14858
|
__publicField(this, "fires", /* @__PURE__ */ new Map());
|
|
14673
14859
|
/** Primed parts burning in the effects world until they go off: their burn loop ends when they are put out. */
|
|
@@ -14879,6 +15065,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
14879
15065
|
this.restore(objectId);
|
|
14880
15066
|
this.pieceSys.remove(objectId);
|
|
14881
15067
|
this.bounds.delete(objectId);
|
|
15068
|
+
this.hitPoints.forget(objectId);
|
|
14882
15069
|
}
|
|
14883
15070
|
// ----------------------------------------------------------------------------------------------------------------------------------
|
|
14884
15071
|
// Pieces
|
|
@@ -15335,6 +15522,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15335
15522
|
}
|
|
15336
15523
|
apply(ev) {
|
|
15337
15524
|
this.staticDirty.add(ev.object);
|
|
15525
|
+
this.hitPoints.note(ev, this.time);
|
|
15338
15526
|
if (ev.type === "fracture" || ev.type === "detach" || ev.type === "collapse" || ev.type === "burnout" || ev.type === "destroyed") this.broken.add(ev.object);
|
|
15339
15527
|
switch (ev.type) {
|
|
15340
15528
|
case "damage":
|
|
@@ -15382,7 +15570,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15382
15570
|
if (pv) this.settlement.finish(pv);
|
|
15383
15571
|
}
|
|
15384
15572
|
this.splitLoose(ev.object);
|
|
15385
|
-
if (!furniture || ev.mass >= COLLAPSE_CLOUD_KG) this.playEvent({ kind: "collapse" }, this.rootPoint(ev.object));
|
|
15573
|
+
if (!furniture || ev.mass >= COLLAPSE_CLOUD_KG) this.playEvent({ kind: "collapse" }, this.rootPoint(ev.object), this.partPlay(ev.object, ev.parts[0] ?? ""));
|
|
15386
15574
|
else this.vfx.burst("dust", this.rootPoint(ev.object), [0, 1, 0], clamp6(Math.round(ev.mass / 4), 4, 24), 0.8);
|
|
15387
15575
|
break;
|
|
15388
15576
|
}
|
|
@@ -15423,7 +15611,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15423
15611
|
else this.dropCage(ev.object, ev.part);
|
|
15424
15612
|
if (ev.bars.length > 0) {
|
|
15425
15613
|
const [a, b] = ev.bars[0];
|
|
15426
|
-
this.playEvent({ kind: "expose" }, [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2]);
|
|
15614
|
+
this.playEvent({ kind: "expose" }, [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2], this.partPlay(ev.object, ev.part));
|
|
15427
15615
|
}
|
|
15428
15616
|
break;
|
|
15429
15617
|
case "extinguish": {
|
|
@@ -15463,7 +15651,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15463
15651
|
const b = this.bounds.get(ev.object);
|
|
15464
15652
|
const pv = b?.parts.get(ev.part);
|
|
15465
15653
|
const def = this.world.materials.get(ev.material);
|
|
15466
|
-
const color = (pv && this.partColor(pv, def)) ?? fallbackColor(
|
|
15654
|
+
const color = (pv && this.partColor(pv, def)) ?? fallbackColor(def);
|
|
15467
15655
|
let tag = this.homeTags.indexOf(ev.object) + 1;
|
|
15468
15656
|
if (tag === 0) tag = this.homeTags.push(ev.object);
|
|
15469
15657
|
this.vfx.spawn("drips", ev.point, [(this.rng() - 0.5) * 0.1, -0.1, (this.rng() - 0.5) * 0.1], { color, tag, owner: this.owner });
|
|
@@ -15550,7 +15738,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15550
15738
|
const tint = this.visuals.vertexTint(mv);
|
|
15551
15739
|
return tint ? c.clone().multiply(tint).getHex() : c.getHex();
|
|
15552
15740
|
}
|
|
15553
|
-
return def ? fallbackColor(def
|
|
15741
|
+
return def ? fallbackColor(def) : null;
|
|
15554
15742
|
}
|
|
15555
15743
|
debrisOptions(kind, objectId, partId, material) {
|
|
15556
15744
|
const pv = this.partVis(objectId, partId);
|
|
@@ -15605,22 +15793,23 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15605
15793
|
if (!b || !pv) return;
|
|
15606
15794
|
const def = this.world.materials.get(pv.material);
|
|
15607
15795
|
const n = this.worldDir(b, ev.hole.normal);
|
|
15796
|
+
const look = debrisLook(def, "shot");
|
|
15608
15797
|
const draw = (point, normal) => {
|
|
15609
15798
|
const wp = new this.THREE.Vector3(point[0], point[1], point[2]);
|
|
15610
15799
|
const mv = this.nearestMesh(pv, wp);
|
|
15611
15800
|
if (!mv) return;
|
|
15612
|
-
if (
|
|
15801
|
+
if (look.mark === "star_crack") {
|
|
15613
15802
|
const seed = hashNumbers(ev.time, point[0], point[1], point[2]);
|
|
15614
15803
|
this.visuals.addCrack(mv, wp, normal, 7, Math.max(0.05, ev.hole.diameter * 5), 15267071, seed);
|
|
15615
15804
|
} else {
|
|
15616
|
-
const fresh =
|
|
15805
|
+
const fresh = look.mark === "splintered_hole" ? def?.visual?.innerColor : void 0;
|
|
15617
15806
|
if (fresh !== void 0) this.visuals.addSpall(mv, wp, normal, Math.max(6e-3, ev.hole.diameter * WOOD_RIM), fresh);
|
|
15618
15807
|
this.visuals.addHole(mv, wp, normal, ev.hole.diameter);
|
|
15619
15808
|
}
|
|
15620
15809
|
};
|
|
15621
15810
|
draw(ev.worldPoint, n);
|
|
15622
15811
|
if (ev.hole.through && ev.exitPoint) draw(ev.exitPoint, n.clone().negate());
|
|
15623
|
-
if (
|
|
15812
|
+
if (look.sparks) this.vfx.burst("sparks", ev.worldPoint, [n.x, n.y, n.z], 6, 3.5);
|
|
15624
15813
|
if (ev.powder) {
|
|
15625
15814
|
const puff3 = { color: ev.powder.color, size: 0.6, life: 1.6, alpha: 1.3 };
|
|
15626
15815
|
this.vfx.burst("dust", ev.worldPoint, [n.x, n.y, n.z], this.low ? 5 : 10, 0.7, puff3);
|
|
@@ -15662,19 +15851,21 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15662
15851
|
const side = point[axis2] >= (box.min[axis2] + box.max[axis2]) / 2 ? 1 : -1;
|
|
15663
15852
|
return new this.THREE.Vector3(axis2 === "x" ? side : 0, axis2 === "y" ? side : 0, axis2 === "z" ? side : 0);
|
|
15664
15853
|
}
|
|
15665
|
-
/** The material an impact effect is chosen by: the tags of the material (`metal`, `glass`, `wood`), else stone and the like are `concrete`. */
|
|
15666
|
-
impactMaterial(def) {
|
|
15667
|
-
for (const tag of IMPACT_TAGS) if (def?.tags?.includes(tag)) return tag;
|
|
15668
|
-
return "concrete";
|
|
15669
|
-
}
|
|
15670
15854
|
/**
|
|
15671
15855
|
* Plays the effect the event map names for a destruction event (`data/event-effects.json` of `game-vfx`, or `RendererOptions.eventEffects`) at a point.
|
|
15672
|
-
* Answers whether one played, so the caller can
|
|
15856
|
+
* `play` gives the family of the material (the map's `{material}`) and the colours of its debris and dust. Answers whether one played, so the caller can
|
|
15857
|
+
* leave out the burst it replaces.
|
|
15673
15858
|
*/
|
|
15674
|
-
playEvent(event, point) {
|
|
15675
|
-
const id = effectForEvent(event, this.o.eventEffects ?? EVENT_EFFECTS_MAP);
|
|
15859
|
+
playEvent(event, point, play) {
|
|
15860
|
+
const id = effectForEvent(play && event.material === void 0 ? { ...event, material: play.material } : event, this.o.eventEffects ?? EVENT_EFFECTS_MAP);
|
|
15676
15861
|
if (!id) return false;
|
|
15677
|
-
return this.vfx.play(id, point, { seed: hashNumbers(point[0], point[1], point[2], this.time) }) !== null;
|
|
15862
|
+
return this.vfx.play(id, point, { seed: hashNumbers(point[0], point[1], point[2], this.time), ...play ? { values: play.values } : {} }) !== null;
|
|
15863
|
+
}
|
|
15864
|
+
/** The family and colours of a part's material, for the effects of the event map. */
|
|
15865
|
+
partPlay(objectId, partId) {
|
|
15866
|
+
const pv = this.partVis(objectId, partId);
|
|
15867
|
+
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
15868
|
+
return familyPlay(def, pv ? this.partColor(pv, def) ?? void 0 : void 0);
|
|
15678
15869
|
}
|
|
15679
15870
|
/** A coat came off: a patch in the colour of the core under it, below the bullet holes and cracks. */
|
|
15680
15871
|
onSpall(ev) {
|
|
@@ -15686,11 +15877,12 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15686
15877
|
const def = this.world.materials.get(pv.material);
|
|
15687
15878
|
const normal = this.faceNormal(mv, wp);
|
|
15688
15879
|
const core = def?.visual?.innerColor;
|
|
15689
|
-
|
|
15690
|
-
|
|
15880
|
+
const look = debrisLook(def, "spall", { partColor: this.partColor(pv, def) ?? void 0 });
|
|
15881
|
+
if (core !== void 0 || look.impact === void 0) this.vfx.burst(look.debris, ev.point, [normal.x, normal.y, normal.z], 5, 2.5, { color: look.color });
|
|
15882
|
+
else this.playEvent({ kind: "spall", material: look.impact }, ev.point);
|
|
15691
15883
|
if (core !== void 0) this.trickleFrom(ev.point, [normal.x, normal.y, normal.z], core, mv);
|
|
15692
15884
|
if (mv.mesh.userData.drawnSpalls?.includes(ev.part)) return;
|
|
15693
|
-
this.visuals.addSpall(mv, wp, normal, Math.sqrt(ev.area / Math.PI), core ?? fallbackColor(
|
|
15885
|
+
this.visuals.addSpall(mv, wp, normal, Math.sqrt(ev.area / Math.PI), core ?? fallbackColor(def));
|
|
15694
15886
|
}
|
|
15695
15887
|
/**
|
|
15696
15888
|
* Grit and dust go on falling from where a blow broke a hard face (masonry, concrete, wood) for `TRICKLE_SECONDS`, a pinch at a time and less and
|
|
@@ -15733,17 +15925,18 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15733
15925
|
* (cutting the wall's faces) is not drawn yet: it needs the per-vertex binding of the house renderer.
|
|
15734
15926
|
*/
|
|
15735
15927
|
onStage(ev) {
|
|
15736
|
-
const played = this.playEvent({ kind: "stage", stage: ev.stage }, ev.opening?.center ?? this.rootPoint(ev.object));
|
|
15737
|
-
if (!ev.fragments || !ev.opening) return;
|
|
15738
15928
|
const pv = this.partVis(ev.object, ev.part);
|
|
15739
15929
|
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
15740
|
-
const
|
|
15930
|
+
const at3 = ev.opening?.center ?? this.hitPoints.of(ev.object, ev.part, this.time) ?? this.rootPoint(ev.object);
|
|
15931
|
+
const played = this.playEvent({ kind: "stage", stage: ev.stage }, at3, this.partPlay(ev.object, ev.part));
|
|
15932
|
+
if (!ev.fragments || !ev.opening) return;
|
|
15933
|
+
const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(def);
|
|
15741
15934
|
const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments;
|
|
15742
15935
|
const step = this.low ? 2 : 1;
|
|
15743
15936
|
for (let i = 0; i < ev.fragments.length; i += step) {
|
|
15744
15937
|
const fr = ev.fragments[i];
|
|
15745
15938
|
const fdef = this.world.materials.get(fr.material);
|
|
15746
|
-
this.fragments.spawn(fr, this.fragments.materialFor(fr.material, fdef === def || !fdef ? color : fallbackColor(
|
|
15939
|
+
this.fragments.spawn(fr, this.fragments.materialFor(fr.material, fdef === def || !fdef ? color : fallbackColor(fdef), false), ev.object, maxAlive);
|
|
15747
15940
|
}
|
|
15748
15941
|
if (!played) this.vfx.burst("dust", ev.opening.center, [0, 1, 0], 14, 1.2, { color });
|
|
15749
15942
|
this.impactSound(pv?.material ?? "", ev.opening.center, 0.8, ev.blow);
|
|
@@ -15756,11 +15949,11 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15756
15949
|
onChip(ev) {
|
|
15757
15950
|
const pv = this.partVis(ev.object, ev.part);
|
|
15758
15951
|
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
15759
|
-
const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(
|
|
15952
|
+
const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(def);
|
|
15760
15953
|
const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments;
|
|
15761
15954
|
for (const fr of ev.fragments) {
|
|
15762
15955
|
const fdef = this.world.materials.get(fr.material);
|
|
15763
|
-
const tone =
|
|
15956
|
+
const tone = fragmentTone(fdef, fr, fdef === def ? color : fallbackColor(fdef));
|
|
15764
15957
|
this.fragments.spawn(fr, this.fragments.materialFor(fr.material, tone, false), ev.object, maxAlive);
|
|
15765
15958
|
}
|
|
15766
15959
|
if (def?.visual?.innerColor !== void 0 || pv?.material === "concrete" || pv?.material === "brick") {
|
|
@@ -15784,7 +15977,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15784
15977
|
const pv = b?.parts.get(ev.part);
|
|
15785
15978
|
const matId = pv?.material || (ev.fragments[0]?.material ?? "");
|
|
15786
15979
|
const def = this.world.materials.get(matId);
|
|
15787
|
-
let color = fallbackColor(
|
|
15980
|
+
let color = fallbackColor(def);
|
|
15788
15981
|
let opacity = 0.5;
|
|
15789
15982
|
const transparent = def?.visual?.transparent === true;
|
|
15790
15983
|
if (pv) {
|
|
@@ -15798,23 +15991,25 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15798
15991
|
this.loosenIfFootless(ev.object);
|
|
15799
15992
|
const up = [0, 1, 0];
|
|
15800
15993
|
const sizeK = clamp6(ev.fragments.length / 10, 0.5, 2);
|
|
15994
|
+
const look = debrisLook(def, "fracture", { style: ev.style, partColor: color });
|
|
15995
|
+
const dust = look.dust !== void 0 ? { color: look.dust } : void 0;
|
|
15801
15996
|
switch (ev.style) {
|
|
15802
15997
|
case "shatter":
|
|
15803
15998
|
this.vfx.burst("shards", ev.point, up, 18 * sizeK, 3);
|
|
15804
15999
|
break;
|
|
15805
16000
|
case "crumble":
|
|
15806
|
-
this.vfx.burst("dust", ev.point, up, 16 * sizeK, 1.2,
|
|
15807
|
-
this.vfx.burst("chips", ev.point, up, 6, 3);
|
|
16001
|
+
this.vfx.burst("dust", ev.point, up, 16 * sizeK, 1.2, dust);
|
|
16002
|
+
this.vfx.burst(look.family === "glass" ? "shards" : "chips", ev.point, up, 6, 3, { color: look.color });
|
|
15808
16003
|
break;
|
|
15809
16004
|
case "splinter":
|
|
15810
|
-
this.vfx.burst("splinters", ev.point, up, 14 * sizeK, 3);
|
|
15811
|
-
this.vfx.burst("dust", ev.point, up, 5, 0.8,
|
|
16005
|
+
this.vfx.burst("splinters", ev.point, up, 14 * sizeK, 3, { color: look.color });
|
|
16006
|
+
this.vfx.burst("dust", ev.point, up, 5, 0.8, dust);
|
|
15812
16007
|
break;
|
|
15813
16008
|
case "tear":
|
|
15814
|
-
this.vfx.burst("fibers", ev.point, up, 12 * sizeK, 1.6, { color:
|
|
16009
|
+
this.vfx.burst("fibers", ev.point, up, 12 * sizeK, 1.6, { color: look.color });
|
|
15815
16010
|
break;
|
|
15816
16011
|
case "snap":
|
|
15817
|
-
this.vfx.burst("chips", ev.point, up, 8 * sizeK, 3);
|
|
16012
|
+
this.vfx.burst("chips", ev.point, up, 8 * sizeK, 3, { color: look.color });
|
|
15818
16013
|
break;
|
|
15819
16014
|
default:
|
|
15820
16015
|
this.vfx.burst("sparks", ev.point, up, 10, 4);
|
|
@@ -15832,7 +16027,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15832
16027
|
}
|
|
15833
16028
|
const fr = ev.fragments[i];
|
|
15834
16029
|
const fdef = this.world.materials.get(fr.material);
|
|
15835
|
-
const tone =
|
|
16030
|
+
const tone = fragmentTone(fdef, fr, fdef === look.def || !fdef ? look.color : fallbackColor(fdef));
|
|
15836
16031
|
const mat = this.fragments.materialFor(fr.material, tone, look.transparent || fdef?.visual?.transparent === true, look.opacity);
|
|
15837
16032
|
this.fragments.spawn(fr, mat, ev.object, maxAlive);
|
|
15838
16033
|
}
|
|
@@ -16355,7 +16550,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
16355
16550
|
const s = bb.getSize(new this.THREE.Vector3());
|
|
16356
16551
|
const footprint = Math.sqrt(Math.max(s.x * s.z, 1e-4));
|
|
16357
16552
|
if (reason === "melted") {
|
|
16358
|
-
this.ground.add("puddle", c.x, c.z, clamp6(footprint * 0.55, 0.05, 1), this.partColor(pv, def) ?? fallbackColor(
|
|
16553
|
+
this.ground.add("puddle", c.x, c.z, clamp6(footprint * 0.55, 0.05, 1), this.partColor(pv, def) ?? fallbackColor(def), objectId);
|
|
16359
16554
|
} else {
|
|
16360
16555
|
this.ground.add("ash", c.x, c.z, clamp6(footprint * 0.35, 0.04, 0.5), 1907224, objectId);
|
|
16361
16556
|
this.vfx.burst("ash", [c.x, bb.max.y, c.z], [0, 1, 0], 10, 0.8);
|
|
@@ -16518,8 +16713,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
16518
16713
|
}
|
|
16519
16714
|
ownedVfxParticles() {
|
|
16520
16715
|
if (!this.ownVfx) return 0;
|
|
16521
|
-
const { puffs, sparks, glows, chunks } = this.vfx.stats();
|
|
16522
|
-
return puffs +
|
|
16716
|
+
const { puffs, sparks: sparks2, glows, chunks } = this.vfx.stats();
|
|
16717
|
+
return puffs + sparks2 + glows + chunks;
|
|
16523
16718
|
}
|
|
16524
16719
|
warmUpProbes() {
|
|
16525
16720
|
this.releaseWarmProbes();
|