@adatechnology/game-destruction-three 0.24.2 → 0.24.4
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 +291 -135
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +92 -41
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
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,9 +7864,14 @@ 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);
|
|
7871
|
+
}
|
|
7872
|
+
function withMaterial(entry, material) {
|
|
7873
|
+
if (!entry.includes("{material}")) return entry;
|
|
7874
|
+
return material ? entry.replace("{material}", material) : void 0;
|
|
7831
7875
|
}
|
|
7832
7876
|
var DEGREES = 180 / Math.PI;
|
|
7833
7877
|
|
|
@@ -9204,7 +9248,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9204
9248
|
uTime: { value: 0 }
|
|
9205
9249
|
};
|
|
9206
9250
|
const puffs = createPuffLayer(THREE, pools.puffs, uniforms);
|
|
9207
|
-
const
|
|
9251
|
+
const sparks2 = createSparkLayer(THREE, pools.sparks);
|
|
9208
9252
|
const glows = createGlowLayer(THREE, pools.glows);
|
|
9209
9253
|
const rockGeometry = new THREE.DodecahedronGeometry(0.5, 0);
|
|
9210
9254
|
const plateGeometry = new THREE.BoxGeometry(1, 1, 1);
|
|
@@ -9213,7 +9257,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9213
9257
|
const sprites = createSpriteLayer(THREE, world.sprites(), options.pointScale ?? 700);
|
|
9214
9258
|
const lights = createLightLayer(THREE, pools.lights, options.lightScale ?? Math.PI, options.lights);
|
|
9215
9259
|
const marks = createMarkLayer(THREE, { ground: pools.ground, ...world.hostGroundAt ? { heightAt: world.hostGroundAt } : {}, createCanvas: options.createCanvas, rockGeometry, plateGeometry, ...options.markLimits });
|
|
9216
|
-
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);
|
|
9217
9261
|
const stopMarks = world.onMarks((event) => marks.handle(event));
|
|
9218
9262
|
const overlay = options.overlay ? createScreenOverlay(options.overlay) : void 0;
|
|
9219
9263
|
let drawCalls = 0;
|
|
@@ -9222,7 +9266,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9222
9266
|
const layerOn = /* @__PURE__ */ new Map();
|
|
9223
9267
|
const layerObjects = () => ({
|
|
9224
9268
|
puffs: [puffs.mesh],
|
|
9225
|
-
sparks: [
|
|
9269
|
+
sparks: [sparks2.mesh],
|
|
9226
9270
|
glows: [glows.mesh],
|
|
9227
9271
|
debris: [chunks.rocks, chunks.plates],
|
|
9228
9272
|
shock: [shocks.group],
|
|
@@ -9250,7 +9294,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9250
9294
|
}
|
|
9251
9295
|
function syncAll() {
|
|
9252
9296
|
lastDrawn.puffs = puffs.sync();
|
|
9253
|
-
lastDrawn.sparks =
|
|
9297
|
+
lastDrawn.sparks = sparks2.sync();
|
|
9254
9298
|
lastDrawn.glows = glows.sync();
|
|
9255
9299
|
lastDrawn.chunks = chunks.sync();
|
|
9256
9300
|
lastDrawn.shocks = shocks.sync();
|
|
@@ -9351,7 +9395,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9351
9395
|
stopMarks();
|
|
9352
9396
|
overlay?.dispose();
|
|
9353
9397
|
workshopLayers?.dispose();
|
|
9354
|
-
for (const layer22 of [puffs,
|
|
9398
|
+
for (const layer22 of [puffs, sparks2, glows, chunks, shocks, lights, marks, sprites]) layer22.dispose();
|
|
9355
9399
|
rockGeometry.dispose();
|
|
9356
9400
|
plateGeometry.dispose();
|
|
9357
9401
|
options.scene.remove(root);
|
|
@@ -12990,6 +13034,70 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
12990
13034
|
}
|
|
12991
13035
|
];
|
|
12992
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
|
+
}
|
|
12993
13101
|
|
|
12994
13102
|
// src/spec.ts
|
|
12995
13103
|
function containsOf(value) {
|
|
@@ -13198,6 +13306,48 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
13198
13306
|
return SURFACE_BY_KEY.find(([key]) => key.test(keys))?.[1];
|
|
13199
13307
|
}
|
|
13200
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
|
+
|
|
13201
13351
|
// src/heat.ts
|
|
13202
13352
|
var STOPS = [
|
|
13203
13353
|
[450, 0],
|
|
@@ -14475,7 +14625,6 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
14475
14625
|
var STEEL_DENSITY = 7850;
|
|
14476
14626
|
var CHIP_DECAL_EDGE = 0.05;
|
|
14477
14627
|
var WOOD_RIM = 1.5;
|
|
14478
|
-
var IMPACT_TAGS = ["metal", "glass", "wood"];
|
|
14479
14628
|
var GLOW_FROM_C = 430;
|
|
14480
14629
|
var MIN_DRAWN_CRACK_WIDTH = 4e-3;
|
|
14481
14630
|
var SETTLEMENT_CRACK_COLOR = 2827296;
|
|
@@ -14629,11 +14778,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
14629
14778
|
return impactKey(def);
|
|
14630
14779
|
}
|
|
14631
14780
|
}
|
|
14632
|
-
function fallbackColor(
|
|
14633
|
-
|
|
14634
|
-
if (def?.visual?.transparent) return 10473696;
|
|
14635
|
-
const h = hashString(id);
|
|
14636
|
-
return mixHex(7035464, 10130568, h % 100 / 100);
|
|
14781
|
+
function fallbackColor(def) {
|
|
14782
|
+
return debrisColor(def);
|
|
14637
14783
|
}
|
|
14638
14784
|
function materialsOf2(m) {
|
|
14639
14785
|
return Array.isArray(m) ? m : [m];
|
|
@@ -14707,6 +14853,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
14707
14853
|
__publicField(this, "ground");
|
|
14708
14854
|
__publicField(this, "pieceSys");
|
|
14709
14855
|
__publicField(this, "cages");
|
|
14856
|
+
__publicField(this, "hitPoints", new HitPoints());
|
|
14710
14857
|
__publicField(this, "active", /* @__PURE__ */ new Map());
|
|
14711
14858
|
__publicField(this, "fires", /* @__PURE__ */ new Map());
|
|
14712
14859
|
/** Primed parts burning in the effects world until they go off: their burn loop ends when they are put out. */
|
|
@@ -14918,6 +15065,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
14918
15065
|
this.restore(objectId);
|
|
14919
15066
|
this.pieceSys.remove(objectId);
|
|
14920
15067
|
this.bounds.delete(objectId);
|
|
15068
|
+
this.hitPoints.forget(objectId);
|
|
14921
15069
|
}
|
|
14922
15070
|
// ----------------------------------------------------------------------------------------------------------------------------------
|
|
14923
15071
|
// Pieces
|
|
@@ -15374,6 +15522,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15374
15522
|
}
|
|
15375
15523
|
apply(ev) {
|
|
15376
15524
|
this.staticDirty.add(ev.object);
|
|
15525
|
+
this.hitPoints.note(ev, this.time);
|
|
15377
15526
|
if (ev.type === "fracture" || ev.type === "detach" || ev.type === "collapse" || ev.type === "burnout" || ev.type === "destroyed") this.broken.add(ev.object);
|
|
15378
15527
|
switch (ev.type) {
|
|
15379
15528
|
case "damage":
|
|
@@ -15421,7 +15570,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15421
15570
|
if (pv) this.settlement.finish(pv);
|
|
15422
15571
|
}
|
|
15423
15572
|
this.splitLoose(ev.object);
|
|
15424
|
-
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] ?? ""));
|
|
15425
15574
|
else this.vfx.burst("dust", this.rootPoint(ev.object), [0, 1, 0], clamp6(Math.round(ev.mass / 4), 4, 24), 0.8);
|
|
15426
15575
|
break;
|
|
15427
15576
|
}
|
|
@@ -15462,7 +15611,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15462
15611
|
else this.dropCage(ev.object, ev.part);
|
|
15463
15612
|
if (ev.bars.length > 0) {
|
|
15464
15613
|
const [a, b] = ev.bars[0];
|
|
15465
|
-
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));
|
|
15466
15615
|
}
|
|
15467
15616
|
break;
|
|
15468
15617
|
case "extinguish": {
|
|
@@ -15502,7 +15651,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15502
15651
|
const b = this.bounds.get(ev.object);
|
|
15503
15652
|
const pv = b?.parts.get(ev.part);
|
|
15504
15653
|
const def = this.world.materials.get(ev.material);
|
|
15505
|
-
const color = (pv && this.partColor(pv, def)) ?? fallbackColor(
|
|
15654
|
+
const color = (pv && this.partColor(pv, def)) ?? fallbackColor(def);
|
|
15506
15655
|
let tag = this.homeTags.indexOf(ev.object) + 1;
|
|
15507
15656
|
if (tag === 0) tag = this.homeTags.push(ev.object);
|
|
15508
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 });
|
|
@@ -15589,7 +15738,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15589
15738
|
const tint = this.visuals.vertexTint(mv);
|
|
15590
15739
|
return tint ? c.clone().multiply(tint).getHex() : c.getHex();
|
|
15591
15740
|
}
|
|
15592
|
-
return def ? fallbackColor(def
|
|
15741
|
+
return def ? fallbackColor(def) : null;
|
|
15593
15742
|
}
|
|
15594
15743
|
debrisOptions(kind, objectId, partId, material) {
|
|
15595
15744
|
const pv = this.partVis(objectId, partId);
|
|
@@ -15598,7 +15747,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15598
15747
|
if ((kind === "dust" || kind === "chips") && def?.visual?.innerColor !== void 0) return { color: def.visual.innerColor };
|
|
15599
15748
|
if (kind === "fibers" || kind === "leaves") {
|
|
15600
15749
|
if (def?.visual?.innerColor !== void 0) return { color: def.visual.innerColor };
|
|
15601
|
-
const c = pv ? this.visuals.baseColorHex(pv.meshes[0]
|
|
15750
|
+
const c = pv && pv.meshes[0] ? this.visuals.baseColorHex(pv.meshes[0]) : -1;
|
|
15602
15751
|
return c >= 0 ? { color: c } : void 0;
|
|
15603
15752
|
}
|
|
15604
15753
|
if (kind === "dust" || kind === "chips") {
|
|
@@ -15644,22 +15793,23 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15644
15793
|
if (!b || !pv) return;
|
|
15645
15794
|
const def = this.world.materials.get(pv.material);
|
|
15646
15795
|
const n = this.worldDir(b, ev.hole.normal);
|
|
15796
|
+
const look = debrisLook(def, "shot");
|
|
15647
15797
|
const draw = (point, normal) => {
|
|
15648
15798
|
const wp = new this.THREE.Vector3(point[0], point[1], point[2]);
|
|
15649
15799
|
const mv = this.nearestMesh(pv, wp);
|
|
15650
15800
|
if (!mv) return;
|
|
15651
|
-
if (
|
|
15801
|
+
if (look.mark === "star_crack") {
|
|
15652
15802
|
const seed = hashNumbers(ev.time, point[0], point[1], point[2]);
|
|
15653
15803
|
this.visuals.addCrack(mv, wp, normal, 7, Math.max(0.05, ev.hole.diameter * 5), 15267071, seed);
|
|
15654
15804
|
} else {
|
|
15655
|
-
const fresh =
|
|
15805
|
+
const fresh = look.mark === "splintered_hole" ? def?.visual?.innerColor : void 0;
|
|
15656
15806
|
if (fresh !== void 0) this.visuals.addSpall(mv, wp, normal, Math.max(6e-3, ev.hole.diameter * WOOD_RIM), fresh);
|
|
15657
15807
|
this.visuals.addHole(mv, wp, normal, ev.hole.diameter);
|
|
15658
15808
|
}
|
|
15659
15809
|
};
|
|
15660
15810
|
draw(ev.worldPoint, n);
|
|
15661
15811
|
if (ev.hole.through && ev.exitPoint) draw(ev.exitPoint, n.clone().negate());
|
|
15662
|
-
if (
|
|
15812
|
+
if (look.sparks) this.vfx.burst("sparks", ev.worldPoint, [n.x, n.y, n.z], 6, 3.5);
|
|
15663
15813
|
if (ev.powder) {
|
|
15664
15814
|
const puff3 = { color: ev.powder.color, size: 0.6, life: 1.6, alpha: 1.3 };
|
|
15665
15815
|
this.vfx.burst("dust", ev.worldPoint, [n.x, n.y, n.z], this.low ? 5 : 10, 0.7, puff3);
|
|
@@ -15701,19 +15851,21 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15701
15851
|
const side = point[axis2] >= (box.min[axis2] + box.max[axis2]) / 2 ? 1 : -1;
|
|
15702
15852
|
return new this.THREE.Vector3(axis2 === "x" ? side : 0, axis2 === "y" ? side : 0, axis2 === "z" ? side : 0);
|
|
15703
15853
|
}
|
|
15704
|
-
/** The material an impact effect is chosen by: the tags of the material (`metal`, `glass`, `wood`), else stone and the like are `concrete`. */
|
|
15705
|
-
impactMaterial(def) {
|
|
15706
|
-
for (const tag of IMPACT_TAGS) if (def?.tags?.includes(tag)) return tag;
|
|
15707
|
-
return "concrete";
|
|
15708
|
-
}
|
|
15709
15854
|
/**
|
|
15710
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.
|
|
15711
|
-
* 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.
|
|
15712
15858
|
*/
|
|
15713
|
-
playEvent(event, point) {
|
|
15714
|
-
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);
|
|
15715
15861
|
if (!id) return false;
|
|
15716
|
-
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);
|
|
15717
15869
|
}
|
|
15718
15870
|
/** A coat came off: a patch in the colour of the core under it, below the bullet holes and cracks. */
|
|
15719
15871
|
onSpall(ev) {
|
|
@@ -15725,11 +15877,12 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15725
15877
|
const def = this.world.materials.get(pv.material);
|
|
15726
15878
|
const normal = this.faceNormal(mv, wp);
|
|
15727
15879
|
const core = def?.visual?.innerColor;
|
|
15728
|
-
|
|
15729
|
-
|
|
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);
|
|
15730
15883
|
if (core !== void 0) this.trickleFrom(ev.point, [normal.x, normal.y, normal.z], core, mv);
|
|
15731
15884
|
if (mv.mesh.userData.drawnSpalls?.includes(ev.part)) return;
|
|
15732
|
-
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));
|
|
15733
15886
|
}
|
|
15734
15887
|
/**
|
|
15735
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
|
|
@@ -15772,17 +15925,18 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15772
15925
|
* (cutting the wall's faces) is not drawn yet: it needs the per-vertex binding of the house renderer.
|
|
15773
15926
|
*/
|
|
15774
15927
|
onStage(ev) {
|
|
15775
|
-
const played = this.playEvent({ kind: "stage", stage: ev.stage }, ev.opening?.center ?? this.rootPoint(ev.object));
|
|
15776
|
-
if (!ev.fragments || !ev.opening) return;
|
|
15777
15928
|
const pv = this.partVis(ev.object, ev.part);
|
|
15778
15929
|
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
15779
|
-
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);
|
|
15780
15934
|
const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments;
|
|
15781
15935
|
const step = this.low ? 2 : 1;
|
|
15782
15936
|
for (let i = 0; i < ev.fragments.length; i += step) {
|
|
15783
15937
|
const fr = ev.fragments[i];
|
|
15784
15938
|
const fdef = this.world.materials.get(fr.material);
|
|
15785
|
-
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);
|
|
15786
15940
|
}
|
|
15787
15941
|
if (!played) this.vfx.burst("dust", ev.opening.center, [0, 1, 0], 14, 1.2, { color });
|
|
15788
15942
|
this.impactSound(pv?.material ?? "", ev.opening.center, 0.8, ev.blow);
|
|
@@ -15795,11 +15949,11 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15795
15949
|
onChip(ev) {
|
|
15796
15950
|
const pv = this.partVis(ev.object, ev.part);
|
|
15797
15951
|
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
15798
|
-
const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(
|
|
15952
|
+
const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(def);
|
|
15799
15953
|
const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments;
|
|
15800
15954
|
for (const fr of ev.fragments) {
|
|
15801
15955
|
const fdef = this.world.materials.get(fr.material);
|
|
15802
|
-
const tone =
|
|
15956
|
+
const tone = fragmentTone(fdef, fr, fdef === def ? color : fallbackColor(fdef));
|
|
15803
15957
|
this.fragments.spawn(fr, this.fragments.materialFor(fr.material, tone, false), ev.object, maxAlive);
|
|
15804
15958
|
}
|
|
15805
15959
|
if (def?.visual?.innerColor !== void 0 || pv?.material === "concrete" || pv?.material === "brick") {
|
|
@@ -15823,7 +15977,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15823
15977
|
const pv = b?.parts.get(ev.part);
|
|
15824
15978
|
const matId = pv?.material || (ev.fragments[0]?.material ?? "");
|
|
15825
15979
|
const def = this.world.materials.get(matId);
|
|
15826
|
-
let color = fallbackColor(
|
|
15980
|
+
let color = fallbackColor(def);
|
|
15827
15981
|
let opacity = 0.5;
|
|
15828
15982
|
const transparent = def?.visual?.transparent === true;
|
|
15829
15983
|
if (pv) {
|
|
@@ -15837,23 +15991,25 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15837
15991
|
this.loosenIfFootless(ev.object);
|
|
15838
15992
|
const up = [0, 1, 0];
|
|
15839
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;
|
|
15840
15996
|
switch (ev.style) {
|
|
15841
15997
|
case "shatter":
|
|
15842
15998
|
this.vfx.burst("shards", ev.point, up, 18 * sizeK, 3);
|
|
15843
15999
|
break;
|
|
15844
16000
|
case "crumble":
|
|
15845
|
-
this.vfx.burst("dust", ev.point, up, 16 * sizeK, 1.2,
|
|
15846
|
-
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 });
|
|
15847
16003
|
break;
|
|
15848
16004
|
case "splinter":
|
|
15849
|
-
this.vfx.burst("splinters", ev.point, up, 14 * sizeK, 3);
|
|
15850
|
-
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);
|
|
15851
16007
|
break;
|
|
15852
16008
|
case "tear":
|
|
15853
|
-
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 });
|
|
15854
16010
|
break;
|
|
15855
16011
|
case "snap":
|
|
15856
|
-
this.vfx.burst("chips", ev.point, up, 8 * sizeK, 3);
|
|
16012
|
+
this.vfx.burst("chips", ev.point, up, 8 * sizeK, 3, { color: look.color });
|
|
15857
16013
|
break;
|
|
15858
16014
|
default:
|
|
15859
16015
|
this.vfx.burst("sparks", ev.point, up, 10, 4);
|
|
@@ -15871,7 +16027,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15871
16027
|
}
|
|
15872
16028
|
const fr = ev.fragments[i];
|
|
15873
16029
|
const fdef = this.world.materials.get(fr.material);
|
|
15874
|
-
const tone =
|
|
16030
|
+
const tone = fragmentTone(fdef, fr, fdef === look.def || !fdef ? look.color : fallbackColor(fdef));
|
|
15875
16031
|
const mat = this.fragments.materialFor(fr.material, tone, look.transparent || fdef?.visual?.transparent === true, look.opacity);
|
|
15876
16032
|
this.fragments.spawn(fr, mat, ev.object, maxAlive);
|
|
15877
16033
|
}
|
|
@@ -16394,7 +16550,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16394
16550
|
const s = bb.getSize(new this.THREE.Vector3());
|
|
16395
16551
|
const footprint = Math.sqrt(Math.max(s.x * s.z, 1e-4));
|
|
16396
16552
|
if (reason === "melted") {
|
|
16397
|
-
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);
|
|
16398
16554
|
} else {
|
|
16399
16555
|
this.ground.add("ash", c.x, c.z, clamp6(footprint * 0.35, 0.04, 0.5), 1907224, objectId);
|
|
16400
16556
|
this.vfx.burst("ash", [c.x, bb.max.y, c.z], [0, 1, 0], 10, 0.8);
|
|
@@ -16557,8 +16713,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16557
16713
|
}
|
|
16558
16714
|
ownedVfxParticles() {
|
|
16559
16715
|
if (!this.ownVfx) return 0;
|
|
16560
|
-
const { puffs, sparks, glows, chunks } = this.vfx.stats();
|
|
16561
|
-
return puffs +
|
|
16716
|
+
const { puffs, sparks: sparks2, glows, chunks } = this.vfx.stats();
|
|
16717
|
+
return puffs + sparks2 + glows + chunks;
|
|
16562
16718
|
}
|
|
16563
16719
|
warmUpProbes() {
|
|
16564
16720
|
this.releaseWarmProbes();
|