@adatechnology/game-vehicles 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +58 -2
- package/dist/index.global.js +352 -87
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +351 -86
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.global.js
CHANGED
|
@@ -34,6 +34,8 @@ var GameVehicles = (() => {
|
|
|
34
34
|
ENTRY_DUCK_FACTOR: () => ENTRY_DUCK_FACTOR,
|
|
35
35
|
FLAT_PAD: () => FLAT_PAD,
|
|
36
36
|
FLOATING_AREA: () => FLOATING_AREA,
|
|
37
|
+
GOUGE_COS: () => GOUGE_COS,
|
|
38
|
+
HEAVY_CALIBER_MM: () => HEAVY_CALIBER_MM,
|
|
37
39
|
JOINT_RULES: () => JOINT_RULES,
|
|
38
40
|
LEGACY_STATES: () => LEGACY_STATES,
|
|
39
41
|
LEGACY_ZONE_IDS: () => LEGACY_ZONE_IDS,
|
|
@@ -42,6 +44,8 @@ var GameVehicles = (() => {
|
|
|
42
44
|
RAIN_MOVE_STEP: () => RAIN_MOVE_STEP,
|
|
43
45
|
RAIN_OPENING_DIAMETER: () => RAIN_OPENING_DIAMETER,
|
|
44
46
|
RAIN_TURN_STEP: () => RAIN_TURN_STEP,
|
|
47
|
+
RIFLE_ENERGY_DENSITY: () => RIFLE_ENERGY_DENSITY,
|
|
48
|
+
RIFLE_SPEED: () => RIFLE_SPEED,
|
|
45
49
|
SEED_SALTS: () => SEED_SALTS,
|
|
46
50
|
SMOKE_LOOKS: () => SMOKE_LOOKS,
|
|
47
51
|
SMOKE_WIND: () => SMOKE_WIND,
|
|
@@ -49,6 +53,7 @@ var GameVehicles = (() => {
|
|
|
49
53
|
armourLevelOf: () => armourLevelOf,
|
|
50
54
|
buildVehicleItem: () => buildVehicleItem,
|
|
51
55
|
buildVehicleModel: () => buildVehicleModel,
|
|
56
|
+
bulletHoleShape: () => bulletHoleShape,
|
|
52
57
|
cabinBoxOf: () => cabinBoxOf,
|
|
53
58
|
cabinEnclosure: () => cabinEnclosure,
|
|
54
59
|
cabinMinimumOf: () => cabinMinimumOf,
|
|
@@ -69,6 +74,7 @@ var GameVehicles = (() => {
|
|
|
69
74
|
engineBayVent: () => engineBayVent,
|
|
70
75
|
format: () => format,
|
|
71
76
|
hash: () => hash,
|
|
77
|
+
holeStyleOf: () => holeStyleOf,
|
|
72
78
|
hullOf: () => hullOf,
|
|
73
79
|
hullPlanKind: () => hullPlanKind,
|
|
74
80
|
hullVolume: () => hullVolume,
|
|
@@ -98,7 +104,7 @@ var GameVehicles = (() => {
|
|
|
98
104
|
wrapThreeForLod: () => wrapThreeForLod
|
|
99
105
|
});
|
|
100
106
|
|
|
101
|
-
// ../game-shapes/dist/chunk-
|
|
107
|
+
// ../game-shapes/dist/chunk-QETSTM6M.js
|
|
102
108
|
function canonicalJson(value) {
|
|
103
109
|
if (value === null) return "null";
|
|
104
110
|
if (typeof value === "number") return Object.is(value, -0) ? "-0" : Number.isFinite(value) ? String(value) : JSON.stringify(String(value));
|
|
@@ -4669,6 +4675,7 @@ var GameVehicles = (() => {
|
|
|
4669
4675
|
kit.halo = halo;
|
|
4670
4676
|
function lampKit(g, d, inner, lens, lensMat, refl) {
|
|
4671
4677
|
refl = refl || MATERIALS.reflector;
|
|
4678
|
+
let nProj = 0;
|
|
4672
4679
|
return {
|
|
4673
4680
|
housing: function(w, h, y, z, geoFn) {
|
|
4674
4681
|
const geo = roundedBoxGeometry(d, h, w, Math.min(0.03, h * 0.4));
|
|
@@ -4689,7 +4696,7 @@ var GameVehicles = (() => {
|
|
|
4689
4696
|
return m;
|
|
4690
4697
|
},
|
|
4691
4698
|
proj: function(y, z, r, mat) {
|
|
4692
|
-
const bz = gm(g, new THREE.CylinderGeometry(r * 1.3, r * 1.45, 0.03, 18), refl, d / 2 - 0.03, y, z);
|
|
4699
|
+
const bz = gm(g, new THREE.CylinderGeometry(r * 1.3, r * 1.45, 0.03, 18), refl, d / 2 - 0.03 - nProj++ * 2e-3, y, z);
|
|
4693
4700
|
bz.rotation.z = -PI / 2;
|
|
4694
4701
|
if (refl !== MATERIALS.reflector) inner.push(bz);
|
|
4695
4702
|
const e = gm(g, new THREE.SphereGeometry(r, 14, 10), mat, d / 2 - 0.022, y, z);
|
|
@@ -4869,10 +4876,10 @@ var GameVehicles = (() => {
|
|
|
4869
4876
|
(parent || c.vehicle).add(g);
|
|
4870
4877
|
const d1 = gm(g, new THREE.CylinderGeometry(r, r, 0.012, 24), MATERIALS.chrome);
|
|
4871
4878
|
d1.rotation.z = PI / 2;
|
|
4872
|
-
const d2 = gm(g, new THREE.CylinderGeometry(r * 0.78, r * 0.78, 0.
|
|
4879
|
+
const d2 = gm(g, new THREE.CylinderGeometry(r * 0.78, r * 0.78, 0.018, 24), MATERIALS.trim);
|
|
4873
4880
|
d2.rotation.z = PI / 2;
|
|
4874
|
-
gm(g, roundedBoxGeometry(0.
|
|
4875
|
-
gm(g, roundedBoxGeometry(0.
|
|
4881
|
+
gm(g, roundedBoxGeometry(0.024, r * 0.32, r * 1.4, 5e-3), MATERIALS.chrome);
|
|
4882
|
+
gm(g, roundedBoxGeometry(0.03, r * 1, r * 0.22, 5e-3), MATERIALS.chrome, 0, 0, r * 0.25).rotation.x = 0.5;
|
|
4876
4883
|
return g;
|
|
4877
4884
|
};
|
|
4878
4885
|
kit.grille = function(c, o) {
|
|
@@ -4925,7 +4932,7 @@ var GameVehicles = (() => {
|
|
|
4925
4932
|
g.children.forEach(function(m) {
|
|
4926
4933
|
m.castShadow = true;
|
|
4927
4934
|
});
|
|
4928
|
-
if (o.emblem !== false) kit.emblem(c, 0.05, st === "closed" ? h * 0.12 : 0, 0, Math.min(0.05, h * 0.3), g);
|
|
4935
|
+
if (o.emblem !== false) kit.emblem(c, 0.05 - (o.emblemBack ?? 0), st === "closed" ? h * 0.12 : 0, 0, Math.min(0.05, h * 0.3), g);
|
|
4929
4936
|
return g;
|
|
4930
4937
|
};
|
|
4931
4938
|
const shared = { lampGroup, gm, wedgeY, haloTex, glowTexture, haloMats, halo, lampKit };
|
|
@@ -5172,7 +5179,7 @@ var GameVehicles = (() => {
|
|
|
5172
5179
|
} else kit.seat(c, x, fl, 0, { w: zi * 2 - 0.1, n: r === 2 ? 2 : 3, mat: fab, back, lean, h: seatH * 0.95, role: "rear" });
|
|
5173
5180
|
const trimLen = Math.min(0.8, (o.rowPitch ?? 0.88) - 0.06);
|
|
5174
5181
|
[-1, 1].forEach(function(s) {
|
|
5175
|
-
c.roundBox(trimLen, belt - fl - 0.08, 0.035, 0.015, trim, x + 0.12, (belt + fl) / 2 + 0.02, s * (zi + 0.02));
|
|
5182
|
+
c.roundBox(trimLen, belt - fl - 0.08, 0.035, 0.015, trim, x + 0.12, (belt + fl) / 2 + 0.02, s * (zi + 0.02 + r % 2 * 2e-3));
|
|
5176
5183
|
c.roundBox(0.3, 0.05, 0.07, 0.02, fab, x + 0.16, fl + seatH + 0.16, s * (zi - 0.015));
|
|
5177
5184
|
c.roundBox(0.08, 0.025, 0.02, 8e-3, MATERIALS.chrome, x + 0.36, belt - 0.11, s * (zi - 5e-3));
|
|
5178
5185
|
});
|
|
@@ -5597,15 +5604,15 @@ var GameVehicles = (() => {
|
|
|
5597
5604
|
const cx = (x0 + x1) / 2;
|
|
5598
5605
|
const paint = c.paint(o.col || c.meta.color || "#666");
|
|
5599
5606
|
const out = {};
|
|
5600
|
-
c.roundBox(L, 0.03, 2 * zw, 0.01, MATERIALS.bay, cx, fl, 0);
|
|
5607
|
+
c.roundBox(L - 0.03, 0.03, 2 * zw, 0.01, MATERIALS.bay, cx + 0.015, fl, 0);
|
|
5601
5608
|
c.roundBox(0.03, H + 0.04, 2 * zw, 0.01, MATERIALS.bay, x0 + 0.015, fl + H / 2, 0);
|
|
5602
5609
|
[1, -1].forEach(function(s) {
|
|
5603
|
-
c.roundBox(L, H * 0.75, 0.03, 0.01, MATERIALS.bay,
|
|
5610
|
+
c.roundBox(L - 0.034, H * 0.75, 0.03, 0.01, MATERIALS.bay, x0 + 0.03 + (L - 0.034) / 2, fl + H * 0.37, s * zw);
|
|
5604
5611
|
});
|
|
5605
5612
|
const rx = x1 - 0.06;
|
|
5606
5613
|
const rh = H * 0.82;
|
|
5607
5614
|
const rad = c.roundBox(0.05, rh, zw * 1.5, 0.012, MATERIALS.radiator, rx, fl + rh / 2 + 0.02, 0);
|
|
5608
|
-
for (let f = 0; f < 6; f++) c.roundBox(0.
|
|
5615
|
+
for (let f = 0; f < 6; f++) c.roundBox(0.062, 6e-3, zw * 1.46, 2e-3, MATERIALS.steel, rx, fl + 0.06 + f * (rh - 0.06) / 6, 0);
|
|
5609
5616
|
c.roundBox(0.07, 0.04, zw * 1.5, 0.015, MATERIALS.plastic, rx, fl + rh + 0.03, 0);
|
|
5610
5617
|
out.rad = new V3(rx, fl + rh / 2, 0);
|
|
5611
5618
|
const fanR = Math.min(rh * 0.42, zw * 0.45);
|
|
@@ -5644,8 +5651,9 @@ var GameVehicles = (() => {
|
|
|
5644
5651
|
}
|
|
5645
5652
|
function battery(x, y, z, sc) {
|
|
5646
5653
|
sc = sc || 1;
|
|
5654
|
+
x = Math.max(x, x0 + 0.034 + 0.1 * sc);
|
|
5647
5655
|
c.roundBox(0.2 * sc, 0.15 * sc, 0.15 * sc, 0.015, makeMaterial("#1a1b1c", { roughness: 0.5 }), x, y, z);
|
|
5648
|
-
c.roundBox(0.2 * sc, 0.012, 0.15 * sc, 5e-3, makeMaterial("#2e3a6a", { roughness: 0.5 }), x, y + 0.04 * sc, z);
|
|
5656
|
+
c.roundBox(0.2 * sc + 8e-3, 0.012, 0.15 * sc + 8e-3, 5e-3, makeMaterial("#2e3a6a", { roughness: 0.5 }), x, y + 0.04 * sc, z);
|
|
5649
5657
|
c.cylinder(0.016, 0.018, 0.03, MATERIALS.postRed, x + 0.06 * sc, y + 0.09 * sc, z + 0.045 * sc);
|
|
5650
5658
|
c.cylinder(0.016, 0.018, 0.03, MATERIALS.postBlack, x + 0.06 * sc, y + 0.09 * sc, z - 0.045 * sc);
|
|
5651
5659
|
c.tube(
|
|
@@ -5664,7 +5672,7 @@ var GameVehicles = (() => {
|
|
|
5664
5672
|
reservoir(x0 + 0.12, uy - 0.04, -zw * 0.55, 0.07, 0.06, 0.07, MATERIALS.coolant, makeMaterial("#c9b26a", { roughness: 0.3 }), MATERIALS.yellow);
|
|
5665
5673
|
reservoir(x1 - 0.2, fl + H * 0.45, zw * 0.72, 0.12, 0.13, 0.1, MATERIALS.washer, makeMaterial("#3f8fc0", { roughness: 0.3 }), MATERIALS.capBlue);
|
|
5666
5674
|
c.roundBox(0.12, 0.07, 0.13, 0.015, MATERIALS.plastic, x0 + 0.18, uy - 0.02, -zw * 0.78);
|
|
5667
|
-
c.roundBox(0.
|
|
5675
|
+
c.roundBox(0.116, 6e-3, 0.126, 3e-3, MATERIALS.dark, x0 + 0.18, uy + 0.017, -zw * 0.78);
|
|
5668
5676
|
if (mot === "electric") {
|
|
5669
5677
|
const fx0 = x0 + L * 0.4;
|
|
5670
5678
|
const fx1 = x1 - 0.14;
|
|
@@ -5817,7 +5825,7 @@ var GameVehicles = (() => {
|
|
|
5817
5825
|
const afx = x1 - L * 0.32;
|
|
5818
5826
|
const afy = Math.min(top - 0.07, fl + H * 0.7);
|
|
5819
5827
|
c.roundBox(0.22, 0.1, 0.26, 0.03, MATERIALS.plastic, afx, afy, zw * 0.5);
|
|
5820
|
-
c.roundBox(0.
|
|
5828
|
+
c.roundBox(0.224, 0.012, 0.264, 4e-3, MATERIALS.dark, afx, afy + 0.01, zw * 0.5);
|
|
5821
5829
|
c.tube(
|
|
5822
5830
|
[
|
|
5823
5831
|
[afx - 0.11, afy, zw * 0.4],
|
|
@@ -6157,7 +6165,7 @@ var GameVehicles = (() => {
|
|
|
6157
6165
|
const gr = Object.assign({ style: "bars", w: W * 0.44, h: Math.max(0.08, hy - bumperY - 0.12) }, s.grille || {});
|
|
6158
6166
|
const gy = gr.y || (bumperY + hy) / 2 + 0.02;
|
|
6159
6167
|
const gx = I.profX(it, gy, true);
|
|
6160
|
-
kit.grille(c, { style: gr.style, x: gx + 0.
|
|
6168
|
+
kit.grille(c, { style: gr.style, x: gx + 0.027, y: gy, w: gr.w, h: gr.h, col: s.col, emblem: gr.emblem, emblemBack: gr.emblemBack });
|
|
6161
6169
|
} else kit.emblem(c, I.profX(it, hy + 0.02, true) + 0.055, hy + 0.02, 0, 0.04);
|
|
6162
6170
|
const tl = Object.assign({ style: "wrap", w: s.tailW || 0.3, h: s.tailH || 0.14, in: 0.05 }, s.tl || {});
|
|
6163
6171
|
const ty = tl.y || s.tailLightY || s.tailY - 0.05;
|
|
@@ -13190,8 +13198,8 @@ var GameVehicles = (() => {
|
|
|
13190
13198
|
};
|
|
13191
13199
|
}
|
|
13192
13200
|
kit.lodHiddenMaterials = function() {
|
|
13193
|
-
const
|
|
13194
|
-
return new Set(lod.hiddenMaterials.map((name) =>
|
|
13201
|
+
const materials2 = kit.materials;
|
|
13202
|
+
return new Set(lod.hiddenMaterials.map((name) => materials2[name]).filter(Boolean));
|
|
13195
13203
|
};
|
|
13196
13204
|
}
|
|
13197
13205
|
|
|
@@ -13522,6 +13530,52 @@ var GameVehicles = (() => {
|
|
|
13522
13530
|
return kit;
|
|
13523
13531
|
}
|
|
13524
13532
|
|
|
13533
|
+
// src/hole-shape.ts
|
|
13534
|
+
var GOUGE_COS = 0.45;
|
|
13535
|
+
var RIFLE_SPEED = 600;
|
|
13536
|
+
var RIFLE_ENERGY_DENSITY = 35;
|
|
13537
|
+
var HEAVY_CALIBER_MM = 12;
|
|
13538
|
+
var LONGEST_GOUGE = 4;
|
|
13539
|
+
var SHORTEST_GOUGE = 1.5;
|
|
13540
|
+
var SHEET_METALS = /* @__PURE__ */ new Set(["steel", "aluminium"]);
|
|
13541
|
+
function speedOf(input) {
|
|
13542
|
+
const mass = input.massGrams;
|
|
13543
|
+
if (!mass || mass <= 0 || input.energy <= 0) return void 0;
|
|
13544
|
+
return Math.sqrt(2 * input.energy / (mass / 1e3));
|
|
13545
|
+
}
|
|
13546
|
+
function isRifleRound(input) {
|
|
13547
|
+
const speed = speedOf(input);
|
|
13548
|
+
if (speed !== void 0) return speed >= RIFLE_SPEED;
|
|
13549
|
+
const area3 = Math.PI * (input.caliberMm / 2) ** 2;
|
|
13550
|
+
return area3 > 0 && input.energy / area3 >= RIFLE_ENERGY_DENSITY;
|
|
13551
|
+
}
|
|
13552
|
+
function holeStyleOf(input) {
|
|
13553
|
+
const sheet = SHEET_METALS.has(input.material);
|
|
13554
|
+
if (sheet && input.cosIncidence < GOUGE_COS) return "gouge";
|
|
13555
|
+
if (!input.through) return "dimple";
|
|
13556
|
+
if (input.caliberMm >= HEAVY_CALIBER_MM) return "ragged";
|
|
13557
|
+
return sheet && isRifleRound(input) ? "petalled" : "round";
|
|
13558
|
+
}
|
|
13559
|
+
function bulletHoleShape(input) {
|
|
13560
|
+
const style = holeStyleOf(input);
|
|
13561
|
+
const bore = Math.max(3e-3, input.boreDiameter);
|
|
13562
|
+
const caliber = input.caliberMm / 1e3;
|
|
13563
|
+
switch (style) {
|
|
13564
|
+
case "gouge": {
|
|
13565
|
+
const elongation = Math.min(LONGEST_GOUGE, Math.max(SHORTEST_GOUGE, 1 / Math.max(input.cosIncidence, 0.05)));
|
|
13566
|
+
return { style, boreDiameter: input.through ? bore * 0.6 : 0, markDiameter: caliber * 1.8, dentDepth: caliber * 0.12, elongation, petals: 0 };
|
|
13567
|
+
}
|
|
13568
|
+
case "dimple":
|
|
13569
|
+
return { style, boreDiameter: 0, markDiameter: caliber * 1.9, dentDepth: caliber * 0.25, elongation: 1, petals: 0 };
|
|
13570
|
+
case "ragged":
|
|
13571
|
+
return { style, boreDiameter: bore * 1.15, markDiameter: bore * 2.6, dentDepth: caliber * 0.35, elongation: 1, petals: 7 };
|
|
13572
|
+
case "petalled":
|
|
13573
|
+
return { style, boreDiameter: bore, markDiameter: bore * 3.4, dentDepth: caliber * 0.18, elongation: 1, petals: 5 };
|
|
13574
|
+
default:
|
|
13575
|
+
return { style, boreDiameter: bore, markDiameter: bore * 2.2, dentDepth: caliber * 0.15, elongation: 1, petals: 0 };
|
|
13576
|
+
}
|
|
13577
|
+
}
|
|
13578
|
+
|
|
13525
13579
|
// src/stray-lamps.ts
|
|
13526
13580
|
var END_DEPTH = 0.45;
|
|
13527
13581
|
var LAMP_EMISSIVE_MIN = 0.25;
|
|
@@ -13711,6 +13765,26 @@ var GameVehicles = (() => {
|
|
|
13711
13765
|
return meta.armored || meta.bullet ? "III" : null;
|
|
13712
13766
|
}
|
|
13713
13767
|
|
|
13768
|
+
// src/destructible/support-span.ts
|
|
13769
|
+
var SUPPORT_BAND_M = 0.12;
|
|
13770
|
+
function supportSpanOf(vehicle, inverse) {
|
|
13771
|
+
const boxes = [];
|
|
13772
|
+
vehicle.traverse((node) => {
|
|
13773
|
+
const mesh2 = node;
|
|
13774
|
+
if (!mesh2.isMesh || mesh2.userData.decal || !mesh2.geometry) return;
|
|
13775
|
+
mesh2.geometry.computeBoundingBox();
|
|
13776
|
+
const bounds = mesh2.geometry.boundingBox;
|
|
13777
|
+
if (!bounds) return;
|
|
13778
|
+
const box2 = bounds.clone().applyMatrix4(mesh2.matrixWorld).applyMatrix4(inverse);
|
|
13779
|
+
if (box2.isEmpty()) return;
|
|
13780
|
+
boxes.push({ minX: box2.min.x, maxX: box2.max.x, minY: box2.min.y });
|
|
13781
|
+
});
|
|
13782
|
+
if (boxes.length === 0) return void 0;
|
|
13783
|
+
const ground = Math.min(...boxes.map((box2) => box2.minY));
|
|
13784
|
+
const resting = boxes.filter((box2) => box2.minY <= ground + SUPPORT_BAND_M);
|
|
13785
|
+
return { rear: Math.min(...resting.map((box2) => box2.minX)), front: Math.max(...resting.map((box2) => box2.maxX)) };
|
|
13786
|
+
}
|
|
13787
|
+
|
|
13714
13788
|
// src/destructible/model.ts
|
|
13715
13789
|
var JOINT_RULES = {
|
|
13716
13790
|
hinge: { strength: 5e3, tools: ["wrench", "screwdriver"], seconds: 3 },
|
|
@@ -13990,12 +14064,15 @@ var GameVehicles = (() => {
|
|
|
13990
14064
|
}
|
|
13991
14065
|
if (!hubZone) {
|
|
13992
14066
|
const h = Math.max(0.15, belt - clearance);
|
|
14067
|
+
const box2 = floorPan({ center: [(F + R) / 2, clearance + h * 0.45, 0], size: [Math.max(0.4, L * 0.8), h * 0.7, Math.max(0.2, W * 0.9)] });
|
|
14068
|
+
const support = supportSpanOf(c.vehicle, inverse);
|
|
13993
14069
|
add({
|
|
13994
14070
|
id: hubId,
|
|
13995
14071
|
role: "frame",
|
|
13996
14072
|
name: t("mechanics.chassis"),
|
|
13997
14073
|
material: "steel",
|
|
13998
|
-
box:
|
|
14074
|
+
box: box2,
|
|
14075
|
+
...support ? { massCentre: [(support.front + support.rear) / 2, box2.center[1], box2.center[2]] } : {},
|
|
13999
14076
|
mass: mass * 0.25,
|
|
14000
14077
|
hp: 15e4 * armour,
|
|
14001
14078
|
visual: false,
|
|
@@ -14595,8 +14672,185 @@ var GameVehicles = (() => {
|
|
|
14595
14672
|
return [tub, seal];
|
|
14596
14673
|
}
|
|
14597
14674
|
|
|
14675
|
+
// src/destructible/hole-mark.ts
|
|
14676
|
+
var TEXTURE_SIZE = 128;
|
|
14677
|
+
var DISC_RINGS = [0, 0.18, 0.34, 0.5, 0.66, 0.82, 1];
|
|
14678
|
+
var DISC_SPOKES = 24;
|
|
14679
|
+
var BOWL_LEAN = 0.85;
|
|
14680
|
+
var BOWL_REACH = 0.9;
|
|
14681
|
+
var BARE = { steel: "#a9aeb2", aluminium: "#cfd3d6", plastic: "#d9d6cc", rubber: "#141414", glass: "#eef3f5" };
|
|
14682
|
+
var STEEL_BARE = "#a9aeb2";
|
|
14683
|
+
var PRIMER = "#7d8285";
|
|
14684
|
+
var PETAL_TIP = 0.62;
|
|
14685
|
+
var PETAL_WIDTH = 0.42;
|
|
14686
|
+
var PETAL_SHADE = "#6f7478";
|
|
14687
|
+
var BORE_SHARE = { round: 0.45, petalled: 0.3, ragged: 0.44, dimple: 0, gouge: 0.2 };
|
|
14688
|
+
var materials = /* @__PURE__ */ new WeakMap();
|
|
14689
|
+
var disc = null;
|
|
14690
|
+
function holeMarkGeometry(THREE) {
|
|
14691
|
+
if (disc) return disc;
|
|
14692
|
+
const positions = [];
|
|
14693
|
+
const normals = [];
|
|
14694
|
+
const uvs = [];
|
|
14695
|
+
for (const r of DISC_RINGS) {
|
|
14696
|
+
const spokes = r === 0 ? 1 : DISC_SPOKES;
|
|
14697
|
+
const lean = r > 0 && r < BOWL_REACH ? BOWL_LEAN * Math.sin(Math.PI * r / BOWL_REACH) / r : 0;
|
|
14698
|
+
for (let k = 0; k < spokes; k++) {
|
|
14699
|
+
const a = k / DISC_SPOKES * Math.PI * 2;
|
|
14700
|
+
const x = Math.cos(a) * r;
|
|
14701
|
+
const y = Math.sin(a) * r;
|
|
14702
|
+
const n = new THREE.Vector3(-x * lean, -y * lean, 1).normalize();
|
|
14703
|
+
positions.push(x, y, 0);
|
|
14704
|
+
normals.push(n.x, n.y, n.z);
|
|
14705
|
+
uvs.push(0.5 + x / 2, 0.5 + y / 2);
|
|
14706
|
+
}
|
|
14707
|
+
}
|
|
14708
|
+
const geometry = new THREE.BufferGeometry();
|
|
14709
|
+
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
|
|
14710
|
+
geometry.setAttribute("normal", new THREE.Float32BufferAttribute(normals, 3));
|
|
14711
|
+
geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2));
|
|
14712
|
+
geometry.setIndex(discIndices());
|
|
14713
|
+
disc = geometry;
|
|
14714
|
+
return geometry;
|
|
14715
|
+
}
|
|
14716
|
+
function discIndices() {
|
|
14717
|
+
const indices = [];
|
|
14718
|
+
const start2 = (ring2) => 1 + (ring2 - 1) * DISC_SPOKES;
|
|
14719
|
+
for (let k = 0; k < DISC_SPOKES; k++) indices.push(0, start2(1) + k, start2(1) + (k + 1) % DISC_SPOKES);
|
|
14720
|
+
for (let ring2 = 1; ring2 < DISC_RINGS.length - 1; ring2++) {
|
|
14721
|
+
for (let k = 0; k < DISC_SPOKES; k++) {
|
|
14722
|
+
const a = start2(ring2) + k;
|
|
14723
|
+
const b = start2(ring2) + (k + 1) % DISC_SPOKES;
|
|
14724
|
+
const c = start2(ring2 + 1) + k;
|
|
14725
|
+
const d = start2(ring2 + 1) + (k + 1) % DISC_SPOKES;
|
|
14726
|
+
indices.push(a, c, d, a, d, b);
|
|
14727
|
+
}
|
|
14728
|
+
}
|
|
14729
|
+
return indices;
|
|
14730
|
+
}
|
|
14731
|
+
function jagged(x, options) {
|
|
14732
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14733
|
+
x.beginPath();
|
|
14734
|
+
for (let i = 0; i <= options.points; i++) {
|
|
14735
|
+
const a = i / options.points * Math.PI * 2;
|
|
14736
|
+
const wobble = Math.sin(i * 12.9898 + options.seed * 78.233) * 43758.5453;
|
|
14737
|
+
const r = mid * options.radius * (1 - options.jag + 2 * options.jag * (wobble - Math.floor(wobble)));
|
|
14738
|
+
x.lineTo(mid + Math.cos(a) * r, mid + Math.sin(a) * r);
|
|
14739
|
+
}
|
|
14740
|
+
x.closePath();
|
|
14741
|
+
}
|
|
14742
|
+
function drawBore(x, share, bare) {
|
|
14743
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14744
|
+
const r = mid * share;
|
|
14745
|
+
const wall = x.createRadialGradient(mid, mid, 0, mid, mid, r);
|
|
14746
|
+
wall.addColorStop(0, "#000000");
|
|
14747
|
+
wall.addColorStop(0.6, "#050505");
|
|
14748
|
+
wall.addColorStop(1, "#2a2b2c");
|
|
14749
|
+
x.fillStyle = wall;
|
|
14750
|
+
x.beginPath();
|
|
14751
|
+
x.arc(mid, mid, r, 0, Math.PI * 2);
|
|
14752
|
+
x.fill();
|
|
14753
|
+
x.strokeStyle = bare;
|
|
14754
|
+
x.lineWidth = Math.max(1, mid * 0.05);
|
|
14755
|
+
x.beginPath();
|
|
14756
|
+
x.arc(mid, mid, r, 0, Math.PI * 2);
|
|
14757
|
+
x.stroke();
|
|
14758
|
+
}
|
|
14759
|
+
function drawPetals(x, share, petals) {
|
|
14760
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14761
|
+
x.fillStyle = PETAL_SHADE;
|
|
14762
|
+
for (let i = 0; i < petals; i++) {
|
|
14763
|
+
const a = i / petals * Math.PI * 2 + 0.4;
|
|
14764
|
+
const half = Math.PI / petals * PETAL_WIDTH;
|
|
14765
|
+
x.beginPath();
|
|
14766
|
+
x.moveTo(mid + Math.cos(a - half) * mid * share, mid + Math.sin(a - half) * mid * share);
|
|
14767
|
+
x.lineTo(mid + Math.cos(a) * mid * share * PETAL_TIP, mid + Math.sin(a) * mid * share * PETAL_TIP);
|
|
14768
|
+
x.lineTo(mid + Math.cos(a + half) * mid * share, mid + Math.sin(a + half) * mid * share);
|
|
14769
|
+
x.closePath();
|
|
14770
|
+
x.fill();
|
|
14771
|
+
}
|
|
14772
|
+
}
|
|
14773
|
+
function drawRing(x, material, style) {
|
|
14774
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14775
|
+
const bare = BARE[material] ?? STEEL_BARE;
|
|
14776
|
+
const share = BORE_SHARE[style];
|
|
14777
|
+
if (material === "steel" || material === "aluminium") {
|
|
14778
|
+
x.fillStyle = PRIMER;
|
|
14779
|
+
jagged(x, { radius: style === "petalled" ? 0.9 : 0.86, jag: 0.12, points: 22, seed: style.length });
|
|
14780
|
+
x.fill();
|
|
14781
|
+
}
|
|
14782
|
+
x.fillStyle = bare;
|
|
14783
|
+
jagged(x, { radius: Math.max(share + 0.18, style === "dimple" ? 0.55 : 0.6), jag: 0.08, points: 18, seed: style.length + 3 });
|
|
14784
|
+
x.fill();
|
|
14785
|
+
x.strokeStyle = "rgba(70, 72, 74, 0.55)";
|
|
14786
|
+
x.lineWidth = 1;
|
|
14787
|
+
for (let i = 0; i < 14; i++) {
|
|
14788
|
+
const a = i / 14 * Math.PI * 2 + 0.2;
|
|
14789
|
+
x.beginPath();
|
|
14790
|
+
x.moveTo(mid + Math.cos(a) * mid * (share + 0.05), mid + Math.sin(a) * mid * (share + 0.05));
|
|
14791
|
+
x.lineTo(mid + Math.cos(a) * mid * (share + 0.2), mid + Math.sin(a) * mid * (share + 0.2));
|
|
14792
|
+
x.stroke();
|
|
14793
|
+
}
|
|
14794
|
+
}
|
|
14795
|
+
function drawDimple(x) {
|
|
14796
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14797
|
+
const hollow = x.createRadialGradient(mid * 0.92, mid * 0.92, 0, mid, mid, mid * 0.4);
|
|
14798
|
+
hollow.addColorStop(0, "#3c3e40");
|
|
14799
|
+
hollow.addColorStop(1, "rgba(60, 62, 64, 0)");
|
|
14800
|
+
x.fillStyle = hollow;
|
|
14801
|
+
x.beginPath();
|
|
14802
|
+
x.arc(mid, mid, mid * 0.4, 0, Math.PI * 2);
|
|
14803
|
+
x.fill();
|
|
14804
|
+
}
|
|
14805
|
+
function drawCrease(x) {
|
|
14806
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14807
|
+
const crease = x.createLinearGradient(0, mid * 0.75, 0, mid * 1.25);
|
|
14808
|
+
crease.addColorStop(0, "rgba(20, 20, 20, 0)");
|
|
14809
|
+
crease.addColorStop(0.5, "#141414");
|
|
14810
|
+
crease.addColorStop(1, "rgba(20, 20, 20, 0)");
|
|
14811
|
+
x.fillStyle = crease;
|
|
14812
|
+
x.fillRect(mid * 0.15, mid * 0.75, mid * 1.7, mid * 0.5);
|
|
14813
|
+
}
|
|
14814
|
+
function drawMark(x, material, style) {
|
|
14815
|
+
const bare = BARE[material] ?? STEEL_BARE;
|
|
14816
|
+
const share = BORE_SHARE[style];
|
|
14817
|
+
drawRing(x, material, style);
|
|
14818
|
+
if (style === "dimple") return drawDimple(x);
|
|
14819
|
+
if (style === "gouge") drawCrease(x);
|
|
14820
|
+
drawBore(x, share, bare);
|
|
14821
|
+
if (style === "petalled") drawPetals(x, share, 5);
|
|
14822
|
+
if (style !== "ragged") return;
|
|
14823
|
+
x.fillStyle = "#030303";
|
|
14824
|
+
jagged(x, { radius: share, jag: 0.22, points: 11, seed: 7 });
|
|
14825
|
+
x.fill();
|
|
14826
|
+
drawPetals(x, share, 7);
|
|
14827
|
+
}
|
|
14828
|
+
function holeMarkMaterial(kit, material, style) {
|
|
14829
|
+
const key = kit;
|
|
14830
|
+
const cache2 = materials.get(key) ?? /* @__PURE__ */ new Map();
|
|
14831
|
+
materials.set(key, cache2);
|
|
14832
|
+
const id = `${material}|${style}`;
|
|
14833
|
+
const known = cache2.get(id);
|
|
14834
|
+
if (known) return known;
|
|
14835
|
+
const shared = kit._;
|
|
14836
|
+
const THREE = kit.THREE;
|
|
14837
|
+
const canvas = kit.document?.createElement?.("canvas");
|
|
14838
|
+
const context = canvas?.getContext?.("2d");
|
|
14839
|
+
let made = shared.MATERIALS.dark;
|
|
14840
|
+
if (canvas && context) {
|
|
14841
|
+
canvas.width = canvas.height = TEXTURE_SIZE;
|
|
14842
|
+
drawMark(context, material, style);
|
|
14843
|
+
const map = new THREE.CanvasTexture(canvas);
|
|
14844
|
+
const metal = material === "steel" || material === "aluminium";
|
|
14845
|
+
made = new THREE.MeshStandardMaterial({ map, transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -1, polygonOffsetUnits: -2, roughness: 0.5, metalness: metal ? 0.55 : 0 });
|
|
14846
|
+
}
|
|
14847
|
+
cache2.set(id, made);
|
|
14848
|
+
return made;
|
|
14849
|
+
}
|
|
14850
|
+
|
|
14598
14851
|
// src/destructible/visual.ts
|
|
14599
|
-
var
|
|
14852
|
+
var HOLE_LIFT = 1e-3;
|
|
14853
|
+
var HOLE_MIN_MARK = 4e-3;
|
|
14600
14854
|
var HOLE_BATCH_CAPACITY = 64;
|
|
14601
14855
|
var DOOR_DEPTH = 0.07;
|
|
14602
14856
|
var DOOR_SKIN_DEPTH = 0.09;
|
|
@@ -14619,7 +14873,6 @@ var GameVehicles = (() => {
|
|
|
14619
14873
|
var DOOR_SILL = 0.25;
|
|
14620
14874
|
var DOOR_STRIP_OVER = 0.05;
|
|
14621
14875
|
var DOOR_TOP_OVER_PANE = 0.03;
|
|
14622
|
-
var HOLE_TEXTURE_SIZE = 64;
|
|
14623
14876
|
var LAMP_BOX_MARGIN = 0.03;
|
|
14624
14877
|
var GLOW_MIN_EMISSIVE = 0.05;
|
|
14625
14878
|
var MIRROR_MIN_METALNESS = 0.8;
|
|
@@ -14672,46 +14925,6 @@ var GameVehicles = (() => {
|
|
|
14672
14925
|
var SIDEWALL_SHARE = 0.3;
|
|
14673
14926
|
var MIRROR_GLASS_MIN = 0.05;
|
|
14674
14927
|
var MIRROR_GLASS_COLOR = "#59636a";
|
|
14675
|
-
var HOLE_RIM = { steel: "#b7bcc0", aluminium: "#d3d6d8", plastic: "#d9d6cc", rubber: "#141414", glass: "#eef3f5" };
|
|
14676
|
-
var holeMaterials = /* @__PURE__ */ new WeakMap();
|
|
14677
|
-
var holeDisc = null;
|
|
14678
|
-
function holeDiscGeometry(THREE) {
|
|
14679
|
-
holeDisc = holeDisc ?? new THREE.CircleGeometry(1, 12);
|
|
14680
|
-
return holeDisc;
|
|
14681
|
-
}
|
|
14682
|
-
function holeMaterial(kit, material) {
|
|
14683
|
-
const key = kit;
|
|
14684
|
-
const cache2 = holeMaterials.get(key) ?? /* @__PURE__ */ new Map();
|
|
14685
|
-
holeMaterials.set(key, cache2);
|
|
14686
|
-
const known = cache2.get(material);
|
|
14687
|
-
if (known) return known;
|
|
14688
|
-
const I = kit._;
|
|
14689
|
-
const THREE = kit.THREE;
|
|
14690
|
-
const canvas = kit.document?.createElement?.("canvas");
|
|
14691
|
-
const x = canvas?.getContext?.("2d");
|
|
14692
|
-
let made = I.MATERIALS.dark;
|
|
14693
|
-
if (x) {
|
|
14694
|
-
canvas.width = canvas.height = HOLE_TEXTURE_SIZE;
|
|
14695
|
-
const mid = HOLE_TEXTURE_SIZE / 2;
|
|
14696
|
-
x.fillStyle = HOLE_RIM[material] ?? HOLE_RIM.steel;
|
|
14697
|
-
x.beginPath();
|
|
14698
|
-
for (let i = 0; i < 18; i++) {
|
|
14699
|
-
const a = i / 18 * Math.PI * 2;
|
|
14700
|
-
const r = mid * (i % 2 ? 0.98 : 0.76);
|
|
14701
|
-
x.lineTo(mid + Math.cos(a) * r, mid + Math.sin(a) * r);
|
|
14702
|
-
}
|
|
14703
|
-
x.closePath();
|
|
14704
|
-
x.fill();
|
|
14705
|
-
x.fillStyle = "#050505";
|
|
14706
|
-
x.beginPath();
|
|
14707
|
-
x.arc(mid, mid, mid * 0.42, 0, Math.PI * 2);
|
|
14708
|
-
x.fill();
|
|
14709
|
-
const map = new THREE.CanvasTexture(canvas);
|
|
14710
|
-
made = new THREE.MeshStandardMaterial({ map, transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -2, roughness: 0.55, metalness: material === "steel" || material === "aluminium" ? 0.6 : 0 });
|
|
14711
|
-
}
|
|
14712
|
-
cache2.set(material, made);
|
|
14713
|
-
return made;
|
|
14714
|
-
}
|
|
14715
14928
|
function isGlowing(material) {
|
|
14716
14929
|
const { emissive, emissiveIntensity } = material;
|
|
14717
14930
|
return !!emissive && (emissiveIntensity ?? 0) > 0 && emissive.r + emissive.g + emissive.b >= GLOW_MIN_EMISSIVE;
|
|
@@ -15744,31 +15957,24 @@ var GameVehicles = (() => {
|
|
|
15744
15957
|
this.extra.set(p.id, [g]);
|
|
15745
15958
|
}
|
|
15746
15959
|
// ---- marks -------------------------------------------------------------------------------------------------------------------------------
|
|
15747
|
-
/**
|
|
15748
|
-
|
|
15960
|
+
/**
|
|
15961
|
+
* A bullet mark lying on the panel at `point` (`c.vehicle` coordinates), facing out along `normal`: its look and size come from `shape` (`bulletHoleShape`), its
|
|
15962
|
+
* long axis lies along `along` (the round's path) over the panel, and it is a child of the part's carrier so it goes where the panel goes.
|
|
15963
|
+
*/
|
|
15964
|
+
holeDecal(point, normal, shape, part, along) {
|
|
15749
15965
|
const THREE = this.THREE;
|
|
15750
15966
|
const pane = part?.role === "glass" ? this.panesOf(part).find((g) => g.visible) : void 0;
|
|
15751
15967
|
if (part?.role === "glass" && (!pane || pane.userData.glass?.broken)) return;
|
|
15752
|
-
const
|
|
15753
|
-
const n = new THREE.Vector3(...normal);
|
|
15968
|
+
const across = Math.max(HOLE_MIN_MARK, shape.markDiameter) / 2;
|
|
15969
|
+
const n = new THREE.Vector3(...normal).normalize();
|
|
15754
15970
|
const carrier = (part && (this.plates.get(part.id) ?? (part.id === this.hood?.id ? this.c.hood?.piv : void 0))) ?? (pane && pane.parent !== this.c.vehicle ? pane.parent : null);
|
|
15755
15971
|
const parent = carrier ?? this.c.vehicle;
|
|
15756
|
-
const material =
|
|
15972
|
+
const material = holeMarkMaterial(this.kit, part?.material ?? "steel", shape.style);
|
|
15757
15973
|
const key = `${parent.uuid}|${material.uuid}`;
|
|
15758
15974
|
let batches = this.holes.get(key);
|
|
15759
15975
|
let batch = batches?.[batches.length - 1];
|
|
15760
15976
|
if (!batch || batch.count >= HOLE_BATCH_CAPACITY) {
|
|
15761
|
-
batch =
|
|
15762
|
-
batch.count = 0;
|
|
15763
|
-
batch.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|
|
15764
|
-
batch.castShadow = false;
|
|
15765
|
-
batch.receiveShadow = false;
|
|
15766
|
-
batch.userData.decal = true;
|
|
15767
|
-
batch.userData.noFollow = true;
|
|
15768
|
-
batch.renderOrder = 3;
|
|
15769
|
-
batch.raycast = () => {
|
|
15770
|
-
};
|
|
15771
|
-
batch.frustumCulled = false;
|
|
15977
|
+
batch = this.holeBatch(material);
|
|
15772
15978
|
parent.add(batch);
|
|
15773
15979
|
if (!batches) {
|
|
15774
15980
|
batches = [];
|
|
@@ -15776,19 +15982,33 @@ var GameVehicles = (() => {
|
|
|
15776
15982
|
}
|
|
15777
15983
|
batches.push(batch);
|
|
15778
15984
|
}
|
|
15779
|
-
const
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
pose.updateMatrix();
|
|
15985
|
+
const u = new THREE.Vector3(...along ?? [0, 0, 0]).addScaledVector(n, -new THREE.Vector3(...along ?? [0, 0, 0]).dot(n));
|
|
15986
|
+
if (u.lengthSq() < 1e-8) u.crossVectors(n, Math.abs(n.y) < 0.9 ? new THREE.Vector3(0, 1, 0) : new THREE.Vector3(1, 0, 0));
|
|
15987
|
+
u.normalize();
|
|
15988
|
+
const w = new THREE.Vector3().crossVectors(n, u);
|
|
15989
|
+
const at = new THREE.Vector3(...point).addScaledVector(n, HOLE_LIFT);
|
|
15990
|
+
const local = new THREE.Matrix4().makeBasis(u.multiplyScalar(across * shape.elongation), w.multiplyScalar(across), n).setPosition(at);
|
|
15786
15991
|
parent.updateWorldMatrix(true, false);
|
|
15787
|
-
const instance = new THREE.Matrix4().copy(parent.matrixWorld).invert().multiply(
|
|
15992
|
+
const instance = new THREE.Matrix4().copy(parent.matrixWorld).invert().multiply(this.c.vehicle.matrixWorld).multiply(local);
|
|
15788
15993
|
batch.setMatrixAt(batch.count, instance);
|
|
15789
15994
|
batch.count += 1;
|
|
15790
15995
|
batch.instanceMatrix.needsUpdate = true;
|
|
15791
15996
|
}
|
|
15997
|
+
/** A new batch of marks of one material (a door full of holes still draws as one). */
|
|
15998
|
+
holeBatch(material) {
|
|
15999
|
+
const batch = new this.THREE.InstancedMesh(holeMarkGeometry(this.THREE), material, HOLE_BATCH_CAPACITY);
|
|
16000
|
+
batch.count = 0;
|
|
16001
|
+
batch.instanceMatrix.setUsage(this.THREE.DynamicDrawUsage);
|
|
16002
|
+
batch.castShadow = false;
|
|
16003
|
+
batch.receiveShadow = false;
|
|
16004
|
+
batch.userData.decal = true;
|
|
16005
|
+
batch.userData.noFollow = true;
|
|
16006
|
+
batch.renderOrder = 3;
|
|
16007
|
+
batch.raycast = () => {
|
|
16008
|
+
};
|
|
16009
|
+
batch.frustumCulled = false;
|
|
16010
|
+
return batch;
|
|
16011
|
+
}
|
|
15792
16012
|
/** The door or lid a hinge group stands for. */
|
|
15793
16013
|
/** The part a separately drawn piece stands for (a mirror on the door, a battery under the hood), so a shot at it lands on that part. */
|
|
15794
16014
|
extraIdOf(o) {
|
|
@@ -16229,6 +16449,46 @@ var GameVehicles = (() => {
|
|
|
16229
16449
|
return clips;
|
|
16230
16450
|
}
|
|
16231
16451
|
|
|
16452
|
+
// src/destructible/mark-fit.ts
|
|
16453
|
+
var MARK_PROBE = 0.02;
|
|
16454
|
+
var MARK_FALL = 2e-3;
|
|
16455
|
+
var MARK_RISE = 15e-4;
|
|
16456
|
+
var MARK_RIM_SAMPLES = 12;
|
|
16457
|
+
var MARK_SHRINK = 0.7;
|
|
16458
|
+
var MARK_FIT_TRIES = 7;
|
|
16459
|
+
function createMarkFitter(deps) {
|
|
16460
|
+
const axesOf = (n, along) => {
|
|
16461
|
+
const u = along.clone().addScaledVector(n, -along.dot(n));
|
|
16462
|
+
if (u.lengthSq() < 1e-8) u.crossVectors(n, Math.abs(n.y) < 0.9 ? deps.vector(0, 1, 0) : deps.vector(1, 0, 0));
|
|
16463
|
+
u.normalize();
|
|
16464
|
+
return { u, w: deps.vector(0, 0, 0).crossVectors(n, u).normalize() };
|
|
16465
|
+
};
|
|
16466
|
+
const rimOnSurface = (at, axes, half) => {
|
|
16467
|
+
const inward = deps.dirToWorld(at.normal.clone().negate());
|
|
16468
|
+
for (let k = 0; k < MARK_RIM_SAMPLES; k++) {
|
|
16469
|
+
const a = k / MARK_RIM_SAMPLES * Math.PI * 2;
|
|
16470
|
+
const q = at.point.clone().addScaledVector(axes.u, Math.cos(a) * half.along).addScaledVector(axes.w, Math.sin(a) * half.across).addScaledVector(at.normal, MARK_PROBE);
|
|
16471
|
+
const hit = deps.surfaceRay({ origin: deps.toWorld(q), direction: inward, maxDistance: MARK_PROBE * 2 });
|
|
16472
|
+
const fall = hit ? hit.distance - MARK_PROBE : Infinity;
|
|
16473
|
+
if (fall > MARK_FALL || fall < -MARK_RISE) return false;
|
|
16474
|
+
}
|
|
16475
|
+
return true;
|
|
16476
|
+
};
|
|
16477
|
+
return (shape, at) => {
|
|
16478
|
+
const placed = { ...at, normal: at.normal.clone().normalize() };
|
|
16479
|
+
const axes = axesOf(placed.normal, at.along);
|
|
16480
|
+
let scale = 1;
|
|
16481
|
+
for (let tries = 0; tries < MARK_FIT_TRIES; tries++) {
|
|
16482
|
+
const across = shape.markDiameter / 2 * scale;
|
|
16483
|
+
if (rimOnSurface(placed, axes, { along: across * shape.elongation, across })) break;
|
|
16484
|
+
scale *= MARK_SHRINK;
|
|
16485
|
+
}
|
|
16486
|
+
if (scale === 1) return shape;
|
|
16487
|
+
const markDiameter = shape.markDiameter * scale;
|
|
16488
|
+
return { ...shape, markDiameter, boreDiameter: Math.min(shape.boreDiameter, markDiameter * 0.8) };
|
|
16489
|
+
};
|
|
16490
|
+
}
|
|
16491
|
+
|
|
16232
16492
|
// src/destructible/impl.ts
|
|
16233
16493
|
var RESIST = { steel: 380, aluminium: 220, glass: 90, plastic: 70, rubber: 120 };
|
|
16234
16494
|
var ROLE_RESIST = {
|
|
@@ -16744,6 +17004,8 @@ var GameVehicles = (() => {
|
|
|
16744
17004
|
if (near && igniteRand() < 1 - Math.exp(-chancePerSecond * dt)) light(tank, out);
|
|
16745
17005
|
};
|
|
16746
17006
|
const normalOf = (d, v) => faceNormal(d, v);
|
|
17007
|
+
const fitter = createMarkFitter({ vector: (x, y, z) => new V3(x, y, z), surfaceRay: (ray) => surfaceRay(ray), toWorld, dirToWorld });
|
|
17008
|
+
const fitMark = (v, n, shape, along) => vis ? fitter(shape, { point: v, normal: n, along }) : shape;
|
|
16747
17009
|
const ballistic = (h, out) => {
|
|
16748
17010
|
sync();
|
|
16749
17011
|
const M = toFrameMatrix();
|
|
@@ -16761,15 +17023,17 @@ var GameVehicles = (() => {
|
|
|
16761
17023
|
const cosInc = Math.abs(dir.dot(n));
|
|
16762
17024
|
const metal = d.material === "steel" || d.material === "aluminium";
|
|
16763
17025
|
const worldPoint = toWorld(v);
|
|
17026
|
+
const opens = (h.piercing ?? 1) < SOFT_LEAD ? EXPANDED_HOLE : 1;
|
|
17027
|
+
const holeDiam = Math.max(6e-3, cal / 1e3 * (d.material === "glass" ? 1.4 : 1) * opens);
|
|
17028
|
+
const shapeOf = (pierced) => bulletHoleShape({ caliberMm: cal, energy: E, ...h.mass !== void 0 ? { massGrams: h.mass } : {}, cosIncidence: cosInc, through: pierced, material: d.material, boreDiameter: holeDiam });
|
|
16764
17029
|
if (metal && !through && cosInc < 0.3 && E > 40) {
|
|
16765
17030
|
const refl = dir.clone().addScaledVector(n, -2 * dir.dot(n));
|
|
16766
17031
|
out.push(ev({ type: "ricochet", part: d.id, point: worldPoint, direction: r3(dirToWorld(refl)), energy: r2(E * 0.4) }));
|
|
16767
17032
|
damage(p, E * 0.05, "ballistic", h.source, out, worldPoint, pieces);
|
|
16768
17033
|
vis?.spark([v.x, v.y, v.z], [refl.x, refl.y, refl.z], 6);
|
|
17034
|
+
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z], fitMark(v, n, shapeOf(false), dir), d, [dir.x, dir.y, dir.z]);
|
|
16769
17035
|
return;
|
|
16770
17036
|
}
|
|
16771
|
-
const opens = (h.piercing ?? 1) < SOFT_LEAD ? EXPANDED_HOLE : 1;
|
|
16772
|
-
const holeDiam = Math.max(6e-3, cal / 1e3 * (d.material === "glass" ? 1.4 : 1) * opens);
|
|
16773
17037
|
const energyLeft = () => {
|
|
16774
17038
|
const metal2 = d.material === "steel" || d.material === "aluminium";
|
|
16775
17039
|
const mm = h.penetration?.steel;
|
|
@@ -16780,8 +17044,8 @@ var GameVehicles = (() => {
|
|
|
16780
17044
|
if (!hole) return;
|
|
16781
17045
|
const hp = { point: r3(fromVehicle(v, M)), normal: r3(fromVehicle(n, new THREE.Matrix4().extractRotation(M))), diameter: r2(holeDiam), through };
|
|
16782
17046
|
p.holes.push(hp);
|
|
16783
|
-
out.push(ev({ type: "hole", part: d.id, hole: hp, worldPoint, ...through ? { energyLeft: r2(energyLeft()) } : {}, ...through ? { exitPoint: add3(worldPoint, r3(dirToWorld(dir.clone().multiplyScalar(Math.max(0.02, Math.min(d.box.size[0], d.box.size[1], d.box.size[2])))))) } : {} }));
|
|
16784
|
-
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z],
|
|
17047
|
+
out.push(ev({ type: "hole", part: d.id, hole: hp, worldPoint, worldNormal: r3(dirToWorld(n.clone().normalize())), direction: r3(dirToWorld(dir)), ...through ? { energyLeft: r2(energyLeft()) } : {}, ...through ? { exitPoint: add3(worldPoint, r3(dirToWorld(dir.clone().multiplyScalar(Math.max(0.02, Math.min(d.box.size[0], d.box.size[1], d.box.size[2])))))) } : {} }));
|
|
17048
|
+
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z], d.material === "glass" ? shapeOf(through) : fitMark(v, n, shapeOf(through), dir), d, [dir.x, dir.y, dir.z]);
|
|
16785
17049
|
if (d.role === "mirror") vis?.shatterMirror(d.id);
|
|
16786
17050
|
startLeak(p, v, cal, out, dir);
|
|
16787
17051
|
};
|
|
@@ -16814,6 +17078,7 @@ var GameVehicles = (() => {
|
|
|
16814
17078
|
const dent = { point: r3(fromVehicle(v, M)), normal: r3(fromVehicle(n, new THREE.Matrix4().extractRotation(M))), radius: r2(Math.max(0.02, holeDiam * 2)), depth: r2(Math.min(0.03, E / 6e4 + 2e-3)) };
|
|
16815
17079
|
p.dents.push(dent);
|
|
16816
17080
|
out.push(ev({ type: "dent", part: d.id, dent, worldPoint }));
|
|
17081
|
+
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z], fitMark(v, n, shapeOf(false), dir), d, [dir.x, dir.y, dir.z]);
|
|
16817
17082
|
}
|
|
16818
17083
|
vis?.spark([v.x, v.y, v.z], [dir.x, dir.y, dir.z], through ? 4 : 8);
|
|
16819
17084
|
let amount = through ? E * 0.6 : E * 0.25;
|