@adatechnology/game-vehicles 0.6.17 → 0.6.18
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 +45 -7
- package/dist/index.global.js +451 -101
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +338 -101
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -24,8 +24,12 @@ var GameVehicles = (() => {
|
|
|
24
24
|
var index_exports = {};
|
|
25
25
|
__export(index_exports, {
|
|
26
26
|
ARMOUR_LEVELS: () => ARMOUR_LEVELS,
|
|
27
|
+
CABIN_CATEGORIES: () => CABIN_CATEGORIES,
|
|
27
28
|
CABIN_LEAK: () => CABIN_LEAK,
|
|
29
|
+
CABIN_MINIMUMS: () => CABIN_MINIMUMS,
|
|
30
|
+
CABIN_SOURCE: () => CABIN_SOURCE,
|
|
28
31
|
CRASH_RULES: () => CRASH_RULES,
|
|
32
|
+
ENTRY_DUCK_FACTOR: () => ENTRY_DUCK_FACTOR,
|
|
29
33
|
JOINT_RULES: () => JOINT_RULES,
|
|
30
34
|
LEGACY_STATES: () => LEGACY_STATES,
|
|
31
35
|
LEGACY_ZONE_IDS: () => LEGACY_ZONE_IDS,
|
|
@@ -35,6 +39,7 @@ var GameVehicles = (() => {
|
|
|
35
39
|
buildVehicleModel: () => buildVehicleModel,
|
|
36
40
|
cabinBoxOf: () => cabinBoxOf,
|
|
37
41
|
cabinEnclosure: () => cabinEnclosure,
|
|
42
|
+
cabinMinimumOf: () => cabinMinimumOf,
|
|
38
43
|
clamp: () => clamp,
|
|
39
44
|
crackedGlassMaterial: () => crackedGlassMaterial,
|
|
40
45
|
crashDeltaV: () => crashDeltaV,
|
|
@@ -63,7 +68,7 @@ var GameVehicles = (() => {
|
|
|
63
68
|
wrapThreeForLod: () => wrapThreeForLod
|
|
64
69
|
});
|
|
65
70
|
|
|
66
|
-
// ../game-shapes/dist/chunk-
|
|
71
|
+
// ../game-shapes/dist/chunk-E3X7UDDV.js
|
|
67
72
|
function canonicalJson(value) {
|
|
68
73
|
if (value === null) return "null";
|
|
69
74
|
if (typeof value === "number") return Object.is(value, -0) ? "-0" : Number.isFinite(value) ? String(value) : JSON.stringify(String(value));
|
|
@@ -1455,6 +1460,76 @@ var GameVehicles = (() => {
|
|
|
1455
1460
|
|
|
1456
1461
|
// ../game-contracts/dist/index.js
|
|
1457
1462
|
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
1463
|
+
var NEAREST = 0.3;
|
|
1464
|
+
function sideOnImpulse(tnt, distance, nearest = NEAREST) {
|
|
1465
|
+
if (!(tnt > 0)) return 0;
|
|
1466
|
+
const w3 = Math.cbrt(tnt);
|
|
1467
|
+
const z = Math.max(distance, nearest) / w3;
|
|
1468
|
+
const near = z / 0.23 * (z / 0.23);
|
|
1469
|
+
const far = z / 1.55;
|
|
1470
|
+
const scaled = 0.067 * Math.sqrt(1 + near * near) / (z * z * Math.cbrt(1 + far * far * far));
|
|
1471
|
+
return scaled * w3 * 100;
|
|
1472
|
+
}
|
|
1473
|
+
var ATMOSPHERE = 101325;
|
|
1474
|
+
function sideOnOverpressure(tnt, distance, nearest = NEAREST) {
|
|
1475
|
+
if (!(tnt > 0)) return 0;
|
|
1476
|
+
const z = Math.max(distance, nearest) / Math.cbrt(tnt);
|
|
1477
|
+
const ratio = 808 * (1 + (z / 4.5) ** 2) / (Math.sqrt(1 + (z / 0.048) ** 2) * Math.sqrt(1 + (z / 0.32) ** 2) * Math.sqrt(1 + (z / 1.35) ** 2));
|
|
1478
|
+
return ratio * ATMOSPHERE;
|
|
1479
|
+
}
|
|
1480
|
+
var CHARGE_RADIUS = 1.3;
|
|
1481
|
+
var CHARGE_SECONDS = 0.01;
|
|
1482
|
+
var CHARGE_FLUX = 15e5;
|
|
1483
|
+
var DOSE_PER_DEGREE = 300;
|
|
1484
|
+
function chargeFireball(tnt) {
|
|
1485
|
+
const cube = Math.cbrt(Math.max(0, tnt));
|
|
1486
|
+
return { radius: CHARGE_RADIUS * cube, seconds: CHARGE_SECONDS * cube, flux: CHARGE_FLUX };
|
|
1487
|
+
}
|
|
1488
|
+
function fireballDose(fireball, distance) {
|
|
1489
|
+
const share = distance <= fireball.radius ? 1 : (fireball.radius / distance) ** 2;
|
|
1490
|
+
return fireball.flux * fireball.seconds * share;
|
|
1491
|
+
}
|
|
1492
|
+
function ignitionDose(ignitionC, ambientC = 20) {
|
|
1493
|
+
return DOSE_PER_DEGREE * Math.max(1, ignitionC - ambientC);
|
|
1494
|
+
}
|
|
1495
|
+
var ATMOSPHERE2 = 101325;
|
|
1496
|
+
var NEAREST_SCALED = 0.2;
|
|
1497
|
+
var LOADED_MARGIN = 0.15;
|
|
1498
|
+
var TNT_JOULES = 4184e3;
|
|
1499
|
+
var SHOCK_COUPLING = 0.04;
|
|
1500
|
+
var SHOCK_SCALED = 0.6;
|
|
1501
|
+
function reflectedLoad(tnt, distance) {
|
|
1502
|
+
if (!(tnt > 0)) return { pressure: 0, impulse: 0 };
|
|
1503
|
+
const cube = Math.cbrt(tnt);
|
|
1504
|
+
const nearest = NEAREST_SCALED * cube;
|
|
1505
|
+
const side2 = sideOnOverpressure(tnt, distance, nearest);
|
|
1506
|
+
const z = Math.max(distance, nearest) / cube;
|
|
1507
|
+
const pressure = 2 * side2 * (7 * ATMOSPHERE2 + 4 * side2) / (7 * ATMOSPHERE2 + side2);
|
|
1508
|
+
const impulse = sideOnImpulse(tnt, distance, nearest) * (2 + 4 / (1 + z * z));
|
|
1509
|
+
return { pressure, impulse };
|
|
1510
|
+
}
|
|
1511
|
+
function waveWork(input) {
|
|
1512
|
+
const load = reflectedLoad(input.tnt, input.distance);
|
|
1513
|
+
const reach = Math.min(1, Math.max(0, input.reach));
|
|
1514
|
+
const pressure = load.pressure * reach;
|
|
1515
|
+
if (!(input.area > 0) || !(input.mass > 0) || pressure <= 0) return { energy: 0, shock: 0, pressure, loaded: 0 };
|
|
1516
|
+
const loaded = Math.min(input.area, Math.PI * (input.distance + LOADED_MARGIN) ** 2);
|
|
1517
|
+
const mass = input.mass * (loaded / input.area);
|
|
1518
|
+
const impulse = load.impulse * reach * loaded;
|
|
1519
|
+
const impulsive = impulse * impulse / (2 * mass);
|
|
1520
|
+
const quasiStatic = pressure * loaded * Math.max(input.thickness, 1e-4);
|
|
1521
|
+
return { energy: Math.min(impulsive, quasiStatic), shock: shockWork(input), pressure, loaded };
|
|
1522
|
+
}
|
|
1523
|
+
function shockWork(input) {
|
|
1524
|
+
const cube = Math.cbrt(input.tnt);
|
|
1525
|
+
if (!(cube > 0) || !(input.area > 0)) return 0;
|
|
1526
|
+
const z = Math.max(input.distance, 0) / cube;
|
|
1527
|
+
const radius = Math.cbrt(3 * input.tnt / (4 * Math.PI * 1600));
|
|
1528
|
+
const share = Math.min(0.5, input.area / (4 * Math.PI * (input.distance + radius) ** 2));
|
|
1529
|
+
const falloff = 1 + z / SHOCK_SCALED * (z / SHOCK_SCALED);
|
|
1530
|
+
const reach = Math.min(1, Math.max(0, input.reach));
|
|
1531
|
+
return SHOCK_COUPLING * input.tnt * TNT_JOULES * share * reach * reach / (falloff * falloff);
|
|
1532
|
+
}
|
|
1458
1533
|
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
1459
1534
|
var DEFAULT_IGNITION_RULES = {
|
|
1460
1535
|
fillCurve: [
|
|
@@ -1502,15 +1577,40 @@ var GameVehicles = (() => {
|
|
|
1502
1577
|
var DEFERRED_QUEUE_ID = {
|
|
1503
1578
|
DESTRUCTION_EVENTS: "destruction.events",
|
|
1504
1579
|
BREACH_PAINT: "floorplan.breach-paint",
|
|
1580
|
+
BREACH_CUT: "floorplan.breach-cut",
|
|
1505
1581
|
AUDIO_VOICES: "audio.voices",
|
|
1506
|
-
VEHICLE_CREASE: "vehicles.crease"
|
|
1582
|
+
VEHICLE_CREASE: "vehicles.crease",
|
|
1583
|
+
AUDIO_OCCLUSION: "audio.occlusion",
|
|
1584
|
+
FLUID_FILM: "fluids.film",
|
|
1585
|
+
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
1586
|
+
SETTLED_BATCH: "destruction.settled-batch",
|
|
1587
|
+
STATIC_BATCH: "render.static-batch",
|
|
1588
|
+
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
1589
|
+
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
1590
|
+
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
1591
|
+
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
1507
1592
|
};
|
|
1508
1593
|
var DEFERRED_PRIORITY = {
|
|
1509
1594
|
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
1510
|
-
|
|
1595
|
+
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
1596
|
+
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
1597
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
1511
1598
|
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
1512
|
-
[DEFERRED_QUEUE_ID.
|
|
1599
|
+
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
1600
|
+
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
1601
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
1602
|
+
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
1603
|
+
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
1604
|
+
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1605
|
+
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1606
|
+
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1607
|
+
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
1608
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
1513
1609
|
};
|
|
1610
|
+
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
1611
|
+
function drainDetached(queue, budgetMs, clock = () => performance.now()) {
|
|
1612
|
+
return queue.run(clock() + budgetMs, clock);
|
|
1613
|
+
}
|
|
1514
1614
|
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
1515
1615
|
var warnedKeys = () => {
|
|
1516
1616
|
const holder = globalThis;
|
|
@@ -1574,6 +1674,27 @@ var GameVehicles = (() => {
|
|
|
1574
1674
|
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
1575
1675
|
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
1576
1676
|
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
1677
|
+
var WORKER_KIND_ID = {
|
|
1678
|
+
GROUND_TILES: "destruction.ground-tiles",
|
|
1679
|
+
CROWD_PHYSICS: "crowd.physics",
|
|
1680
|
+
PIECE_BOXES: "destruction.piece-boxes",
|
|
1681
|
+
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
1682
|
+
SHAPES_GENERATE: "shapes.generate",
|
|
1683
|
+
WORLD_REGION: "world.region"
|
|
1684
|
+
};
|
|
1685
|
+
var WORKER_KIND_DEFAULTS = {
|
|
1686
|
+
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
1687
|
+
[WORKER_KIND_ID.CROWD_PHYSICS]: { lane: "sim", priority: 250, latencyFrames: 1, late: "sync" },
|
|
1688
|
+
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
1689
|
+
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
1690
|
+
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
1691
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
|
|
1692
|
+
};
|
|
1693
|
+
|
|
1694
|
+
// ../game-shapes/dist/index.js
|
|
1695
|
+
var SAME_COLOUR = 1 / 512;
|
|
1696
|
+
var SAME_FACING = 1 - 1e-6;
|
|
1697
|
+
var PARALLEL = Math.cos(2 * Math.PI / 180);
|
|
1577
1698
|
|
|
1578
1699
|
// ../game-shapes-three/dist/index.js
|
|
1579
1700
|
var UV_BEFORE_NORMAL = /* @__PURE__ */ new Set(["LatheGeometry", "ExtrudeGeometry"]);
|
|
@@ -2594,7 +2715,7 @@ var GameVehicles = (() => {
|
|
|
2594
2715
|
ti.boxes[j + 3 + k] = Math.max(P[a + k], P[b + k], P[c + k]);
|
|
2595
2716
|
}
|
|
2596
2717
|
}
|
|
2597
|
-
function advance(geo, ti, deadline) {
|
|
2718
|
+
function advance(geo, ti, deadline, clock) {
|
|
2598
2719
|
const total = blockCount(ti.triangles);
|
|
2599
2720
|
while (ti.builtBlocks < total) {
|
|
2600
2721
|
const block = ti.builtBlocks;
|
|
@@ -2602,7 +2723,7 @@ var GameVehicles = (() => {
|
|
|
2602
2723
|
for (let t = block * TRI_BLOCK; t < t1; t++) boxTriangle(geo, ti, t);
|
|
2603
2724
|
boxBlock(ti, block);
|
|
2604
2725
|
ti.builtBlocks++;
|
|
2605
|
-
if (deadline !== Infinity &&
|
|
2726
|
+
if (deadline !== Infinity && clock() >= deadline) break;
|
|
2606
2727
|
}
|
|
2607
2728
|
return ti.builtBlocks === total;
|
|
2608
2729
|
}
|
|
@@ -2626,14 +2747,14 @@ var GameVehicles = (() => {
|
|
|
2626
2747
|
if (!supports(geo)) return void 0;
|
|
2627
2748
|
let ti = cache.get(geo);
|
|
2628
2749
|
if (!ti || !isCurrent(geo, ti)) ti = start(geo);
|
|
2629
|
-
advance(geo, ti, Infinity);
|
|
2750
|
+
advance(geo, ti, Infinity, performance.now.bind(performance));
|
|
2630
2751
|
return ti;
|
|
2631
2752
|
}
|
|
2632
|
-
function warmTriIndex(geo, deadline) {
|
|
2753
|
+
function warmTriIndex(geo, deadline, clock = performance.now.bind(performance)) {
|
|
2633
2754
|
if (!supports(geo)) return true;
|
|
2634
2755
|
let ti = cache.get(geo);
|
|
2635
2756
|
if (!ti || !isCurrent(geo, ti)) ti = start(geo);
|
|
2636
|
-
return advance(geo, ti, deadline);
|
|
2757
|
+
return advance(geo, ti, deadline, clock);
|
|
2637
2758
|
}
|
|
2638
2759
|
function storeTriIndex(geo, boxes) {
|
|
2639
2760
|
const ti = start(geo);
|
|
@@ -2677,7 +2798,7 @@ var GameVehicles = (() => {
|
|
|
2677
2798
|
if (shared && isCurrent(geo, shared) && shared.builtBlocks === blockCount(shared.triangles)) return shared;
|
|
2678
2799
|
let ti = rayCache.get(geo);
|
|
2679
2800
|
if (!ti || !isCurrent(geo, ti)) ti = start(geo, rayCache);
|
|
2680
|
-
advance(geo, ti, Infinity);
|
|
2801
|
+
advance(geo, ti, Infinity, performance.now.bind(performance));
|
|
2681
2802
|
return ti;
|
|
2682
2803
|
}
|
|
2683
2804
|
var BLOCK_SLACK = 1e-6;
|
|
@@ -2970,9 +3091,9 @@ var GameVehicles = (() => {
|
|
|
2970
3091
|
const cs = Math.cos(deg * PI / 180);
|
|
2971
3092
|
let phase = 0;
|
|
2972
3093
|
let at = 0;
|
|
2973
|
-
function hashSlice(deadline) {
|
|
3094
|
+
function hashSlice(deadline, clock) {
|
|
2974
3095
|
for (; at < n; at++) {
|
|
2975
|
-
if ((at & 1023) === 0 &&
|
|
3096
|
+
if ((at & 1023) === 0 && clock() > deadline) return false;
|
|
2976
3097
|
const x = Math.round(P[3 * at] * 2e3) | 0;
|
|
2977
3098
|
const y = Math.round(P[3 * at + 1] * 2e3) | 0;
|
|
2978
3099
|
const z = Math.round(P[3 * at + 2] * 2e3) | 0;
|
|
@@ -3001,9 +3122,9 @@ var GameVehicles = (() => {
|
|
|
3001
3122
|
members = new Int32Array(n);
|
|
3002
3123
|
for (let i = 0; i < n; i++) members[fill[groupOf[i]]++] = i / 3 | 0;
|
|
3003
3124
|
}
|
|
3004
|
-
function smoothSlice(deadline) {
|
|
3125
|
+
function smoothSlice(deadline, clock) {
|
|
3005
3126
|
for (; at < n; at++) {
|
|
3006
|
-
if ((at & 1023) === 0 &&
|
|
3127
|
+
if ((at & 1023) === 0 && clock() > deadline) return false;
|
|
3007
3128
|
const fi = (at / 3 | 0) * 3;
|
|
3008
3129
|
const g = groupOf[at];
|
|
3009
3130
|
let sx = 0;
|
|
@@ -3029,16 +3150,16 @@ var GameVehicles = (() => {
|
|
|
3029
3150
|
}
|
|
3030
3151
|
return true;
|
|
3031
3152
|
}
|
|
3032
|
-
function step(deadline) {
|
|
3153
|
+
function step(deadline, clock = performance.now.bind(performance)) {
|
|
3033
3154
|
if (latestCrease.get(geo) !== token) return true;
|
|
3034
3155
|
if (phase === 0) {
|
|
3035
|
-
if (!hashSlice(deadline)) return false;
|
|
3156
|
+
if (!hashSlice(deadline, clock)) return false;
|
|
3036
3157
|
gather();
|
|
3037
3158
|
phase = 1;
|
|
3038
3159
|
at = 0;
|
|
3039
3160
|
}
|
|
3040
3161
|
if (phase === 1) {
|
|
3041
|
-
const done = smoothSlice(deadline);
|
|
3162
|
+
const done = smoothSlice(deadline, clock);
|
|
3042
3163
|
if (deadline !== Infinity) normal.needsUpdate = true;
|
|
3043
3164
|
if (!done) return false;
|
|
3044
3165
|
phase = 2;
|
|
@@ -7835,15 +7956,32 @@ var GameVehicles = (() => {
|
|
|
7835
7956
|
const m = c.meta;
|
|
7836
7957
|
return new V3(m.front - 0.6, (m.clearance || 0.3) + 0.3, 0);
|
|
7837
7958
|
}
|
|
7959
|
+
function worldPointOf(c, local) {
|
|
7960
|
+
c.vehicle.updateWorldMatrix(true, false);
|
|
7961
|
+
const wp = local.clone().applyMatrix4(c.vehicle.matrixWorld);
|
|
7962
|
+
return [wp.x, wp.y, wp.z];
|
|
7963
|
+
}
|
|
7964
|
+
function startVehicleFire(c, local, radius, life) {
|
|
7965
|
+
const effects = kit.effects?.();
|
|
7966
|
+
if (!effects) return false;
|
|
7967
|
+
const handle = effects.play({ effect: "volumetric_fire", point: worldPointOf(c, local), values: { radius, life } });
|
|
7968
|
+
if (handle != null) {
|
|
7969
|
+
c.vfxHandles = c.vfxHandles || [];
|
|
7970
|
+
c.vfxHandles.push(handle);
|
|
7971
|
+
}
|
|
7972
|
+
return true;
|
|
7973
|
+
}
|
|
7838
7974
|
kit.explode = function(c, o) {
|
|
7839
7975
|
o = o || {};
|
|
7840
7976
|
if (c.blast || c.exploded) return false;
|
|
7841
7977
|
const fuse = o.now ? 0 : o.delay != null ? o.delay : 3 + c.rand() * 5;
|
|
7842
|
-
c.blast = { phase: "fire", t: 0, T: fuse };
|
|
7978
|
+
c.blast = { phase: "fire", t: 0, T: fuse, skipBlastEffect: !!o.skipBlastEffect };
|
|
7843
7979
|
if (fuse > 0) {
|
|
7844
7980
|
const ep = enginePos(c);
|
|
7845
|
-
|
|
7846
|
-
|
|
7981
|
+
if (!startVehicleFire(c, ep.clone().add(new V3(0, 0.25, 0)), 0.55, fuse + 2)) {
|
|
7982
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.25, 0)), "fire", { rate: 10, s: 0.9 });
|
|
7983
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.6, 0)), "black", { rate: 6, s: 1.2 });
|
|
7984
|
+
}
|
|
7847
7985
|
I.hurtEngine(c, 0.1);
|
|
7848
7986
|
}
|
|
7849
7987
|
if (c.hood) c.hood.target = 0;
|
|
@@ -7861,8 +7999,10 @@ var GameVehicles = (() => {
|
|
|
7861
7999
|
return p.kind === "fuel_tank";
|
|
7862
8000
|
});
|
|
7863
8001
|
const tp = tk ? tk.pos.clone() : enginePos(c);
|
|
7864
|
-
|
|
7865
|
-
|
|
8002
|
+
if (!startVehicleFire(c, tp.clone().setY(Math.max(0.15, tp.y)), 0.65, 25)) {
|
|
8003
|
+
kit.addEmitter(c, tp.clone().setY(Math.max(0.15, tp.y)), "fire", { rate: 12, s: 1.1 });
|
|
8004
|
+
kit.addEmitter(c, tp.clone().setY(tp.y + 0.8), "black", { rate: 5, s: 1.4 });
|
|
8005
|
+
}
|
|
7866
8006
|
return "fire";
|
|
7867
8007
|
}
|
|
7868
8008
|
return null;
|
|
@@ -7969,42 +8109,51 @@ var GameVehicles = (() => {
|
|
|
7969
8109
|
c.emitters = c.emitters.filter(function(e) {
|
|
7970
8110
|
return e.kind !== "exhaust";
|
|
7971
8111
|
});
|
|
7972
|
-
const
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8112
|
+
const effects = kit.effects?.();
|
|
8113
|
+
if (effects) {
|
|
8114
|
+
if (!B.skipBlastEffect) {
|
|
8115
|
+
c.effects.updateWorldMatrix(true, false);
|
|
8116
|
+
const worldCen = cen.clone().applyMatrix4(c.effects.matrixWorld);
|
|
8117
|
+
effects.play({ effect: big ? "fuel_station_tank" : "car_fuel_tank", point: [worldCen.x, worldCen.y, worldCen.z], values: {} });
|
|
8118
|
+
}
|
|
8119
|
+
} else {
|
|
8120
|
+
const fl = new THREE.Sprite(
|
|
8121
|
+
new THREE.SpriteMaterial({
|
|
8122
|
+
map: I.glowTexture(),
|
|
8123
|
+
color: 16767392,
|
|
8124
|
+
blending: THREE.AdditiveBlending,
|
|
8125
|
+
transparent: true,
|
|
8126
|
+
depthWrite: false,
|
|
8127
|
+
fog: false
|
|
8128
|
+
})
|
|
8129
|
+
);
|
|
8130
|
+
fl.raycast = function() {
|
|
8131
|
+
};
|
|
8132
|
+
fl.position.copy(cen);
|
|
8133
|
+
fl.scale.setScalar(0.1);
|
|
8134
|
+
c.effects.add(fl);
|
|
8135
|
+
B.flash = fl;
|
|
8136
|
+
const sw = new THREE.Mesh(new THREE.RingGeometry(0.8, 1, 64), boomMat("#ffcf8a", 0.6, true));
|
|
8137
|
+
sw.rotation.x = -PI / 2;
|
|
8138
|
+
sw.position.set(cen.x, 0.07, cen.z);
|
|
8139
|
+
c.effects.add(sw);
|
|
8140
|
+
B.shock = sw;
|
|
8141
|
+
const k = big ? 1.8 : 1;
|
|
8142
|
+
for (let i = 0; i < (big ? 70 : 46); i++) {
|
|
8143
|
+
const d = new V3(c.rand() - 0.5, c.rand() * 0.9, c.rand() - 0.5).normalize();
|
|
8144
|
+
kit.spawn(c, "fire", cen.clone().addScaledVector(d, 0.3), d.multiplyScalar((2.5 + c.rand() * 4) * k), {
|
|
8145
|
+
s: (1 + c.rand() * 1.4) * k,
|
|
8146
|
+
life: 0.8 + c.rand() * 0.7
|
|
8147
|
+
});
|
|
8148
|
+
}
|
|
8149
|
+
for (let j = 0; j < (big ? 30 : 18); j++) {
|
|
8150
|
+
const d2 = new V3(c.rand() - 0.5, 0.4 + c.rand(), c.rand() - 0.5).normalize();
|
|
8151
|
+
kit.spawn(c, "smoke", cen.clone().addScaledVector(d2, 0.6), d2.multiplyScalar(1.5 + c.rand() * 2), {
|
|
8152
|
+
variant: "black",
|
|
8153
|
+
s: (1.4 + c.rand()) * k,
|
|
8154
|
+
life: 4 + c.rand() * 2
|
|
8155
|
+
});
|
|
8156
|
+
}
|
|
8008
8157
|
}
|
|
8009
8158
|
I.burst(c, "spark", cen, 40, { speed: 7, spread: 1.6 });
|
|
8010
8159
|
I.burst(c, "scrap", cen, 14, {
|
|
@@ -8017,7 +8166,7 @@ var GameVehicles = (() => {
|
|
|
8017
8166
|
const G = gm2.userData.glass;
|
|
8018
8167
|
if (!G || G.broken || !gm2.visible || !gm2.parent) return;
|
|
8019
8168
|
if (G.type === "laminated") {
|
|
8020
|
-
for (let
|
|
8169
|
+
for (let k = 0; k < 3; k++) I.crackGlass(c, gm2, I.glassPt ? I.glassPt(c, gm2, c.rand) : gm2.position.clone(), 1.2);
|
|
8021
8170
|
return;
|
|
8022
8171
|
}
|
|
8023
8172
|
I.shatterGlass(c, gm2, 1.4, new V3(0, 1, 0));
|
|
@@ -8043,14 +8192,19 @@ var GameVehicles = (() => {
|
|
|
8043
8192
|
c.emitters.forEach(function(e) {
|
|
8044
8193
|
if (e.kind === "fire") e.rate = Math.min(e.rate, 7);
|
|
8045
8194
|
});
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8195
|
+
if (effects) {
|
|
8196
|
+
startVehicleFire(c, ep.clone().add(new V3(0, 0.15, 0)), 0.55, 30);
|
|
8197
|
+
startVehicleFire(c, new V3(((m.front || 1) + (m.rear || -1)) / 2, (m.clearance || 0.3) + 0.35, 0), 0.45, 25);
|
|
8198
|
+
} else {
|
|
8199
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.15, 0)), "fire", { rate: 8, s: 0.8 });
|
|
8200
|
+
kit.addEmitter(c, new V3(((m.front || 1) + (m.rear || -1)) / 2, (m.clearance || 0.3) + 0.35, 0), "fire", { rate: 6, s: 0.7 });
|
|
8201
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.9, 0)), "black", { rate: 4, s: 1.4 });
|
|
8202
|
+
}
|
|
8049
8203
|
c.parts.forEach(function(p) {
|
|
8050
8204
|
if (p.kind === "glass" || p.kind === "headlight" || p.kind === "taillight" || p.kind === "hood") p.done = true;
|
|
8051
8205
|
});
|
|
8052
8206
|
c.log.push({ kind: "explosion", label: kit.t(big ? "blast.tank_explosion" : "blast.explosion") });
|
|
8053
|
-
if (big) bigBoomFx(c);
|
|
8207
|
+
if (big && !effects) bigBoomFx(c);
|
|
8054
8208
|
}
|
|
8055
8209
|
function tickBoom(c, dt) {
|
|
8056
8210
|
const B = c.blast;
|
|
@@ -12845,6 +12999,11 @@ var GameVehicles = (() => {
|
|
|
12845
12999
|
return c;
|
|
12846
13000
|
}
|
|
12847
13001
|
kit.dispose = function(c) {
|
|
13002
|
+
if (Array.isArray(c.vfxHandles) && c.vfxHandles.length > 0) {
|
|
13003
|
+
const effects = kit.effects?.();
|
|
13004
|
+
for (const handle of c.vfxHandles) effects?.stop?.(handle);
|
|
13005
|
+
c.vfxHandles = [];
|
|
13006
|
+
}
|
|
12848
13007
|
const shared = Object.values(I.PARTICLE_GEOMETRIES);
|
|
12849
13008
|
c.root.traverse(function(o) {
|
|
12850
13009
|
if (o.isSprite) {
|
|
@@ -13794,6 +13953,7 @@ var GameVehicles = (() => {
|
|
|
13794
13953
|
|
|
13795
13954
|
// src/destructible/visual.ts
|
|
13796
13955
|
var HOLE_DECAL_SCALE = 2.4;
|
|
13956
|
+
var HOLE_BATCH_CAPACITY = 64;
|
|
13797
13957
|
var DOOR_DEPTH = 0.07;
|
|
13798
13958
|
var DOOR_SKIN_DEPTH = 0.09;
|
|
13799
13959
|
var DOOR_FLOOR_DEPTH = 0.2;
|
|
@@ -13945,7 +14105,25 @@ var GameVehicles = (() => {
|
|
|
13945
14105
|
__publicField(this, "holdFrame", -1);
|
|
13946
14106
|
/** Normal smoothing still running, by mesh: a mesh cut again gets a new task and the old one is dropped. */
|
|
13947
14107
|
__publicField(this, "smoothing", /* @__PURE__ */ new Map());
|
|
14108
|
+
/** The bullet holes of one carrier and material, drawn as one instanced batch each (a door full of holes still draws as one). */
|
|
14109
|
+
__publicField(this, "holes", /* @__PURE__ */ new Map());
|
|
13948
14110
|
__publicField(this, "hood");
|
|
14111
|
+
/** What `pump` drains when no shared queue owns the smoothing: the same steps, timed by `drainDetached`. */
|
|
14112
|
+
__publicField(this, "pumpQueue", {
|
|
14113
|
+
id: DEFERRED_QUEUE_ID.VEHICLE_CREASE,
|
|
14114
|
+
pending: () => this.smoothing.size + (this.warming ? 1 : 0),
|
|
14115
|
+
run: (deadline, clock) => {
|
|
14116
|
+
let ran = 0;
|
|
14117
|
+
for (const [msh, task] of this.smoothing) {
|
|
14118
|
+
if (msh.geometry !== task.geo || task.step(deadline, clock)) this.smoothing.delete(msh);
|
|
14119
|
+
ran++;
|
|
14120
|
+
if (clock() >= deadline) return ran;
|
|
14121
|
+
}
|
|
14122
|
+
this.warmIndexes(deadline, clock);
|
|
14123
|
+
return ran + 1;
|
|
14124
|
+
},
|
|
14125
|
+
flush: () => this.finishAll()
|
|
14126
|
+
});
|
|
13949
14127
|
;
|
|
13950
14128
|
c.smoothLater = (mesh2) => this.smoothLater(mesh2);
|
|
13951
14129
|
this.kit = kit;
|
|
@@ -14874,19 +15052,44 @@ var GameVehicles = (() => {
|
|
|
14874
15052
|
const pane = part?.role === "glass" ? this.panesOf(part).find((g) => g.visible) : void 0;
|
|
14875
15053
|
if (part?.role === "glass" && (!pane || pane.userData.glass?.broken)) return;
|
|
14876
15054
|
const radius = Math.max(6e-3, diameter / 2) * HOLE_DECAL_SCALE;
|
|
14877
|
-
const m = new THREE.Mesh(holeDiscGeometry(THREE), holeMaterial(this.kit, part?.material ?? "steel"));
|
|
14878
|
-
m.scale.set(radius, radius, 1);
|
|
14879
15055
|
const n = new THREE.Vector3(...normal);
|
|
14880
|
-
m.position.set(...point).addScaledVector(n, 3e-3);
|
|
14881
|
-
this.c.vehicle.add(m);
|
|
14882
|
-
m.lookAt(this.c.vehicle.localToWorld(m.position.clone().add(n)));
|
|
14883
|
-
m.userData.decal = true;
|
|
14884
|
-
m.userData.noFollow = true;
|
|
14885
|
-
m.renderOrder = 3;
|
|
14886
|
-
m.raycast = () => {
|
|
14887
|
-
};
|
|
14888
15056
|
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);
|
|
14889
|
-
|
|
15057
|
+
const parent = carrier ?? this.c.vehicle;
|
|
15058
|
+
const material = holeMaterial(this.kit, part?.material ?? "steel");
|
|
15059
|
+
const key = `${parent.uuid}|${material.uuid}`;
|
|
15060
|
+
let batches = this.holes.get(key);
|
|
15061
|
+
let batch = batches?.[batches.length - 1];
|
|
15062
|
+
if (!batch || batch.count >= HOLE_BATCH_CAPACITY) {
|
|
15063
|
+
batch = new THREE.InstancedMesh(holeDiscGeometry(THREE), material, HOLE_BATCH_CAPACITY);
|
|
15064
|
+
batch.count = 0;
|
|
15065
|
+
batch.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|
|
15066
|
+
batch.castShadow = false;
|
|
15067
|
+
batch.receiveShadow = false;
|
|
15068
|
+
batch.userData.decal = true;
|
|
15069
|
+
batch.userData.noFollow = true;
|
|
15070
|
+
batch.renderOrder = 3;
|
|
15071
|
+
batch.raycast = () => {
|
|
15072
|
+
};
|
|
15073
|
+
batch.frustumCulled = false;
|
|
15074
|
+
parent.add(batch);
|
|
15075
|
+
if (!batches) {
|
|
15076
|
+
batches = [];
|
|
15077
|
+
this.holes.set(key, batches);
|
|
15078
|
+
}
|
|
15079
|
+
batches.push(batch);
|
|
15080
|
+
}
|
|
15081
|
+
const at = this.c.vehicle.localToWorld(new THREE.Vector3(...point).addScaledVector(n, 3e-3));
|
|
15082
|
+
const toward = this.c.vehicle.localToWorld(new THREE.Vector3(...point).addScaledVector(n, 1.003));
|
|
15083
|
+
const pose = new THREE.Object3D();
|
|
15084
|
+
pose.position.copy(at);
|
|
15085
|
+
pose.scale.set(radius, radius, 1);
|
|
15086
|
+
pose.lookAt(toward);
|
|
15087
|
+
pose.updateMatrix();
|
|
15088
|
+
parent.updateWorldMatrix(true, false);
|
|
15089
|
+
const instance = new THREE.Matrix4().copy(parent.matrixWorld).invert().multiply(pose.matrix);
|
|
15090
|
+
batch.setMatrixAt(batch.count, instance);
|
|
15091
|
+
batch.count += 1;
|
|
15092
|
+
batch.instanceMatrix.needsUpdate = true;
|
|
14890
15093
|
}
|
|
14891
15094
|
/** The door or lid a hinge group stands for. */
|
|
14892
15095
|
/** 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. */
|
|
@@ -15039,12 +15242,7 @@ var GameVehicles = (() => {
|
|
|
15039
15242
|
}
|
|
15040
15243
|
if (this.queued) return;
|
|
15041
15244
|
if (!this.smoothing.size && !this.warming) return;
|
|
15042
|
-
|
|
15043
|
-
for (const [msh, task] of this.smoothing) {
|
|
15044
|
-
if (msh.geometry !== task.geo || task.step(deadline)) this.smoothing.delete(msh);
|
|
15045
|
-
if (performance.now() >= deadline) return;
|
|
15046
|
-
}
|
|
15047
|
-
this.warmIndexes(deadline);
|
|
15245
|
+
drainDetached(this.pumpQueue, budgetMs);
|
|
15048
15246
|
}
|
|
15049
15247
|
setQueued(isQueued) {
|
|
15050
15248
|
this.queued = isQueued;
|
|
@@ -15060,24 +15258,24 @@ var GameVehicles = (() => {
|
|
|
15060
15258
|
return this.smoothing.size + (this.warming ? 1 : 0);
|
|
15061
15259
|
}
|
|
15062
15260
|
/** One slice of the pending work, for the shared queue. */
|
|
15063
|
-
runStep(deadline) {
|
|
15261
|
+
runStep(deadline, clock) {
|
|
15064
15262
|
const next = this.smoothing.entries().next();
|
|
15065
15263
|
if (!next.done) {
|
|
15066
15264
|
const [msh, task] = next.value;
|
|
15067
|
-
if (msh.geometry !== task.geo || task.step(deadline)) this.smoothing.delete(msh);
|
|
15265
|
+
if (msh.geometry !== task.geo || task.step(deadline, clock)) this.smoothing.delete(msh);
|
|
15068
15266
|
return true;
|
|
15069
15267
|
}
|
|
15070
15268
|
if (!this.warming) return false;
|
|
15071
|
-
this.warmIndexes(deadline);
|
|
15269
|
+
this.warmIndexes(deadline, clock);
|
|
15072
15270
|
return true;
|
|
15073
15271
|
}
|
|
15074
15272
|
finishAll() {
|
|
15075
15273
|
while (this.runStep(Infinity)) ;
|
|
15076
15274
|
}
|
|
15077
15275
|
/** Measures the triangles of the heavy body meshes once, a slice per frame, so the first panel torn off finds them ready (see `triIndexOf`). */
|
|
15078
|
-
warmIndexes(deadline) {
|
|
15276
|
+
warmIndexes(deadline, clock) {
|
|
15079
15277
|
if (!this.warming) return;
|
|
15080
|
-
this.warming = this.warming.filter((msh) => !warmTriIndex(msh.geometry, deadline));
|
|
15278
|
+
this.warming = this.warming.filter((msh) => !warmTriIndex(msh.geometry, deadline, clock));
|
|
15081
15279
|
if (!this.warming.length) this.warming = null;
|
|
15082
15280
|
}
|
|
15083
15281
|
/** Moves the panel of a lost zone out of the body (the kit's torn-off look). */
|
|
@@ -15329,9 +15527,12 @@ var GameVehicles = (() => {
|
|
|
15329
15527
|
rim: 4
|
|
15330
15528
|
};
|
|
15331
15529
|
var BLUNT = { steel: 0.8, aluminium: 1, glass: 1.5, plastic: 1.2, rubber: 0.3 };
|
|
15530
|
+
var SHIELDED_REACH = 0.25;
|
|
15531
|
+
var DENSITY = { steel: 7850, aluminium: 2700, glass: 2500, plastic: 1100, rubber: 1100, wood_hard: 750, fabric: 400 };
|
|
15332
15532
|
var SHIELDED = /* @__PURE__ */ new Set(["engine", "gearbox", "frame", "radiator", "fuel_tank", "oil_pan", "battery", "alternator", "brakes", "steering", "shocks"]);
|
|
15333
15533
|
var AMBIENT = 20;
|
|
15334
15534
|
var FLAME = 700;
|
|
15535
|
+
var FIREBALL_NOTICE = 0.05;
|
|
15335
15536
|
var STEEL_MM = { panel: 0.8, door: 1.6, hood: 0.8, lid: 0.8, roof: 0.8, fender: 0.8, pillar: 2, frame: 4, rim: 3, engine: 40, gearbox: 25, fuel_tank: 1, radiator: 1, battery: 2, brakes: 10, steering: 8, shocks: 6, oil_pan: 2, alternator: 4, hitch: 8, other: 2 };
|
|
15336
15537
|
var ARMOUR_STEEL_MM = { IIIA: 4, III: 7 };
|
|
15337
15538
|
var SOFT_LEAD = 0.8;
|
|
@@ -15587,8 +15788,9 @@ var GameVehicles = (() => {
|
|
|
15587
15788
|
for (const j of js) if (!j.open && (j.def.a === d.id || j.def.b === d.id)) openJoint(j, "part_lost", out);
|
|
15588
15789
|
recomputeGroups();
|
|
15589
15790
|
};
|
|
15590
|
-
const damage = (p,
|
|
15591
|
-
if (p.lost || !(
|
|
15791
|
+
const damage = (p, hitAmount, dtype, source, out, cause, pieces = 1) => {
|
|
15792
|
+
if (p.lost || !(hitAmount > 0)) return;
|
|
15793
|
+
const amount = pieces > 1 ? Math.min(hitAmount * pieces, Math.max(hitAmount, p.hp)) : hitAmount;
|
|
15592
15794
|
const before = p.hp;
|
|
15593
15795
|
const crumples = dtype === "blunt" && CRUMPLES.has(p.def.role) && (p.def.material === "steel" || p.def.material === "aluminium");
|
|
15594
15796
|
const punctures = dtype === "ballistic" && p.def.role === "tyre";
|
|
@@ -15695,16 +15897,30 @@ var GameVehicles = (() => {
|
|
|
15695
15897
|
if (l?.pud && l.fluid === "fuel") I.igniteFuel(c, l.pud);
|
|
15696
15898
|
}
|
|
15697
15899
|
};
|
|
15698
|
-
const burningBlast = (centreLocal, radius, energy, source, out) => {
|
|
15900
|
+
const burningBlast = (centreLocal, radius, energy, source, out, tnt = energy * DEFAULT_BLAST_IMPULSE.tntPerJoule) => {
|
|
15901
|
+
let tank = 0;
|
|
15699
15902
|
for (const d of model.parts) {
|
|
15700
15903
|
const p = ps.get(d.id);
|
|
15701
15904
|
if (p.lost) continue;
|
|
15702
15905
|
const dist = distToBox(d, centreLocal);
|
|
15703
15906
|
if (dist > radius) continue;
|
|
15704
|
-
const
|
|
15705
|
-
|
|
15706
|
-
damage(p,
|
|
15907
|
+
const work = waveOn(d, centreLocal, dist, tnt);
|
|
15908
|
+
if (d.role === "fuel_tank") tank = work;
|
|
15909
|
+
damage(p, work * (BLUNT[d.material] ?? 1), "explosive", source, out);
|
|
15707
15910
|
}
|
|
15911
|
+
return tank;
|
|
15912
|
+
};
|
|
15913
|
+
const waveOn = (d, centreLocal, dist, tnt) => {
|
|
15914
|
+
const [sx, sy, sz] = d.box.size;
|
|
15915
|
+
const toward = new V3(centreLocal.x - d.box.center[0], centreLocal.y - d.box.center[1], centreLocal.z - d.box.center[2]);
|
|
15916
|
+
const length = toward.length();
|
|
15917
|
+
if (length > 1e-6) toward.multiplyScalar(1 / length);
|
|
15918
|
+
else toward.set(0, 1, 0);
|
|
15919
|
+
const area3 = Math.abs(toward.x) * sy * sz + Math.abs(toward.y) * sx * sz + Math.abs(toward.z) * sx * sy;
|
|
15920
|
+
const face = Math.max(sx * sy, sx * sz, sy * sz, 1e-6);
|
|
15921
|
+
const thickness = Math.min(Math.min(sx, sy, sz), d.mass / ((DENSITY[d.material] ?? 1e3) * face));
|
|
15922
|
+
const wave = waveWork({ tnt, distance: dist, reach: SHIELDED.has(d.role) ? SHIELDED_REACH : 1, area: area3, mass: Math.max(d.mass, 0.05), thickness });
|
|
15923
|
+
return wave.energy + wave.shock;
|
|
15708
15924
|
};
|
|
15709
15925
|
const explode = (tank, source, out) => {
|
|
15710
15926
|
if (exploded) return;
|
|
@@ -15714,7 +15930,7 @@ var GameVehicles = (() => {
|
|
|
15714
15930
|
out.push(ev({ type: "explode", part: d.id, point: toWorld(d.box.center), energy: spec.energy, radius: spec.radius, ..."effect" in spec && spec.effect !== void 0 ? { effect: spec.effect } : {} }));
|
|
15715
15931
|
tank.liters = 0;
|
|
15716
15932
|
leaks.delete(d.id);
|
|
15717
|
-
if (vis) kit.explode(c, { delay: 0.6 });
|
|
15933
|
+
if (vis) kit.explode(c, { delay: 0.6, skipBlastEffect: true });
|
|
15718
15934
|
else c.blast = c.blast ?? { phase: "fire", t: 0, T: 0.6 };
|
|
15719
15935
|
lose(tank, "broken", out);
|
|
15720
15936
|
burningBlast(centreOf(d), spec.radius, spec.energy, source, out);
|
|
@@ -15808,6 +16024,7 @@ var GameVehicles = (() => {
|
|
|
15808
16024
|
const d = p.def;
|
|
15809
16025
|
const E = h.energy ?? 0;
|
|
15810
16026
|
const cal = h.caliber ?? 9;
|
|
16027
|
+
const pieces = h.pieces ?? 1;
|
|
15811
16028
|
const dir = dirToLocal(h.direction ?? [0, 0, -1]).normalize();
|
|
15812
16029
|
const n = h.normal ? dirToLocal(h.normal).normalize() : normalOf(d, v);
|
|
15813
16030
|
const res = resist(d, p);
|
|
@@ -15818,7 +16035,7 @@ var GameVehicles = (() => {
|
|
|
15818
16035
|
if (metal && !through && cosInc < 0.3 && E > 40) {
|
|
15819
16036
|
const refl = dir.clone().addScaledVector(n, -2 * dir.dot(n));
|
|
15820
16037
|
out.push(ev({ type: "ricochet", part: d.id, point: worldPoint, direction: r3(dirToWorld(refl)), energy: r2(E * 0.4) }));
|
|
15821
|
-
damage(p, E * 0.05, "ballistic", h.source, out, worldPoint);
|
|
16038
|
+
damage(p, E * 0.05, "ballistic", h.source, out, worldPoint, pieces);
|
|
15822
16039
|
vis?.spark([v.x, v.y, v.z], [refl.x, refl.y, refl.z], 6);
|
|
15823
16040
|
return;
|
|
15824
16041
|
}
|
|
@@ -15849,13 +16066,13 @@ var GameVehicles = (() => {
|
|
|
15849
16066
|
const crack = { point: r3(fromVehicle(v, M)), normal: r3(fromVehicle(n, new THREE.Matrix4().extractRotation(M))), length: r2(0.15 + force * 0.35), rays: 6 + Math.round(force * 6) };
|
|
15850
16067
|
p.cracks.push(crack);
|
|
15851
16068
|
out.push(ev({ type: "crack", part: d.id, crack, worldPoint }));
|
|
15852
|
-
damage(p, E * (armourLevel && !through ? armourLevel.glassTakes : 0.5), "ballistic", h.source, out, worldPoint);
|
|
15853
|
-
} else damage(p, laminated ? E * 0.5 : p.hp, "ballistic", h.source, out, worldPoint);
|
|
16069
|
+
damage(p, E * (armourLevel && !through ? armourLevel.glassTakes : 0.5), "ballistic", h.source, out, worldPoint, pieces);
|
|
16070
|
+
} else damage(p, laminated ? E * 0.5 : p.hp, "ballistic", h.source, out, worldPoint, laminated ? pieces : 1);
|
|
15854
16071
|
break;
|
|
15855
16072
|
}
|
|
15856
16073
|
case "rubber": {
|
|
15857
16074
|
push(through);
|
|
15858
|
-
damage(p, E * 0.4, "ballistic", h.source, out, worldPoint);
|
|
16075
|
+
damage(p, E * 0.4, "ballistic", h.source, out, worldPoint, pieces);
|
|
15859
16076
|
if (through && !p.lost && !p.flat) {
|
|
15860
16077
|
if (E >= TYRE_BURST_JOULES || cal >= TYRE_BURST_CALIBER) deflate(p, 1);
|
|
15861
16078
|
else p.airLoss += TYRE_LEAK_PER_MM2 * Math.PI * (cal / 2) ** 2;
|
|
@@ -15872,7 +16089,7 @@ var GameVehicles = (() => {
|
|
|
15872
16089
|
vis?.spark([v.x, v.y, v.z], [dir.x, dir.y, dir.z], through ? 4 : 8);
|
|
15873
16090
|
let amount = through ? E * 0.6 : E * 0.25;
|
|
15874
16091
|
if (through && (d.role === "battery" || d.role === "alternator")) amount = Math.max(amount, p.hp * 0.65);
|
|
15875
|
-
damage(p, amount, "ballistic", h.source, out, worldPoint);
|
|
16092
|
+
damage(p, amount, "ballistic", h.source, out, worldPoint, pieces);
|
|
15876
16093
|
if (through && d.role === "fuel_tank") rollIgnition(p, h, metal, out);
|
|
15877
16094
|
}
|
|
15878
16095
|
}
|
|
@@ -15943,12 +16160,12 @@ var GameVehicles = (() => {
|
|
|
15943
16160
|
const nearest = Math.min(...model.parts.map((d) => distToBox(d, v)));
|
|
15944
16161
|
if (nearest > radius) return;
|
|
15945
16162
|
if (vis && E >= 3e3) kit.impact(c, v.clone().addScaledVector(dir, -0.1).setY(clamp(v.y, 0.3, 1.2)), dir, clamp(0.4 + E / 6e4, 0.4, 1.4), { noStain: true });
|
|
15946
|
-
burningBlast(v, radius, E, h.source, out);
|
|
16163
|
+
const tankWork = burningBlast(v, radius, E, h.source, out, h.tnt);
|
|
15947
16164
|
const tank = [...ps.values()].find((q) => q.def.role === "fuel_tank" && !q.lost);
|
|
15948
16165
|
if (tank && !exploded) {
|
|
15949
16166
|
const dist = distToBox(tank.def, v);
|
|
15950
16167
|
if (dist <= radius) {
|
|
15951
|
-
const verdict = kit.blastDamage(c,
|
|
16168
|
+
const verdict = kit.blastDamage(c, tankWork);
|
|
15952
16169
|
if (verdict === "explosion") explode(tank, h.source, out);
|
|
15953
16170
|
else if (verdict === "fire") {
|
|
15954
16171
|
light(tank, out);
|
|
@@ -15956,7 +16173,14 @@ var GameVehicles = (() => {
|
|
|
15956
16173
|
}
|
|
15957
16174
|
}
|
|
15958
16175
|
}
|
|
15959
|
-
|
|
16176
|
+
const fireball = h.fireball ?? chargeFireball(E * DEFAULT_BLAST_IMPULSE.tntPerJoule);
|
|
16177
|
+
for (const d of model.parts) {
|
|
16178
|
+
const p = ps.get(d.id);
|
|
16179
|
+
if (p.lost || !d.ignitionC) continue;
|
|
16180
|
+
const needed = ignitionDose(d.ignitionC, AMBIENT);
|
|
16181
|
+
const share = Math.min(1, fireballDose(fireball, distToBox(d, v)) / needed);
|
|
16182
|
+
if (share >= FIREBALL_NOTICE) p.temp = Math.max(p.temp, AMBIENT + (d.ignitionC + 1 - AMBIENT) * share);
|
|
16183
|
+
}
|
|
15960
16184
|
};
|
|
15961
16185
|
const fireHit = (h, out) => {
|
|
15962
16186
|
sync();
|
|
@@ -16352,6 +16576,7 @@ var GameVehicles = (() => {
|
|
|
16352
16576
|
joints: js.map((j) => [j.def.id, j.hp, j.progress, j.open, j.by ?? null])
|
|
16353
16577
|
}),
|
|
16354
16578
|
partName: (pid) => ps.get(pid)?.def.name ?? pid,
|
|
16579
|
+
objectsOf: (pid) => vis?.objectsOf(pid) ?? [],
|
|
16355
16580
|
status: computeStatus,
|
|
16356
16581
|
animations: () => createVehicleClips(model, vis, kit, c),
|
|
16357
16582
|
crumple: (point, direction, depth) => {
|
|
@@ -16467,7 +16692,7 @@ var GameVehicles = (() => {
|
|
|
16467
16692
|
if (ran > 0 && clock() >= deadline) break;
|
|
16468
16693
|
const work = tracked[cursor % tracked.length];
|
|
16469
16694
|
cursor = (cursor + 1) % tracked.length;
|
|
16470
|
-
if (work.pendingUnits(lastFrame) > 0 && work.runStep(deadline)) {
|
|
16695
|
+
if (work.pendingUnits(lastFrame) > 0 && work.runStep(deadline, clock)) {
|
|
16471
16696
|
ran++;
|
|
16472
16697
|
skipped = 0;
|
|
16473
16698
|
} else skipped++;
|
|
@@ -16612,6 +16837,131 @@ var GameVehicles = (() => {
|
|
|
16612
16837
|
leak
|
|
16613
16838
|
};
|
|
16614
16839
|
}
|
|
16840
|
+
|
|
16841
|
+
// src/data/cabin.json
|
|
16842
|
+
var cabin_default = {
|
|
16843
|
+
source: "Spec 012 (R6, T0.2) \u2014 SAE J1100 interior packaging & ISO 7250-1 / NASA-STD-3000 adult anthropometry (1.80 m seated height = 0.936 m, buttock-knee = 0.612 m, shoulder = 0.468 m)",
|
|
16844
|
+
entryDuckFactor: 0.44,
|
|
16845
|
+
categories: {
|
|
16846
|
+
passenger_car: {
|
|
16847
|
+
frontHeadroomMetres: 0.95,
|
|
16848
|
+
rearHeadroomMetres: 0.9,
|
|
16849
|
+
frontLegroomMetres: 0.62,
|
|
16850
|
+
widthMetres: 0.52,
|
|
16851
|
+
door: { widthMetres: 0.65, heightMetres: 0.8 }
|
|
16852
|
+
},
|
|
16853
|
+
suv_pickup: {
|
|
16854
|
+
frontHeadroomMetres: 0.98,
|
|
16855
|
+
rearHeadroomMetres: 0.93,
|
|
16856
|
+
frontLegroomMetres: 0.64,
|
|
16857
|
+
widthMetres: 0.54,
|
|
16858
|
+
door: { widthMetres: 0.7, heightMetres: 0.82 }
|
|
16859
|
+
},
|
|
16860
|
+
van: {
|
|
16861
|
+
frontHeadroomMetres: 1.05,
|
|
16862
|
+
rearHeadroomMetres: 1.05,
|
|
16863
|
+
frontLegroomMetres: 0.65,
|
|
16864
|
+
widthMetres: 0.54,
|
|
16865
|
+
door: { widthMetres: 0.75, heightMetres: 0.95 }
|
|
16866
|
+
},
|
|
16867
|
+
truck: {
|
|
16868
|
+
frontHeadroomMetres: 1,
|
|
16869
|
+
rearHeadroomMetres: 1,
|
|
16870
|
+
frontLegroomMetres: 0.62,
|
|
16871
|
+
widthMetres: 0.52,
|
|
16872
|
+
door: { widthMetres: 0.65, heightMetres: 0.85 }
|
|
16873
|
+
},
|
|
16874
|
+
bus: {
|
|
16875
|
+
frontHeadroomMetres: 1.2,
|
|
16876
|
+
rearHeadroomMetres: 1.2,
|
|
16877
|
+
frontLegroomMetres: 0.62,
|
|
16878
|
+
widthMetres: 0.5,
|
|
16879
|
+
door: { widthMetres: 0.7, heightMetres: 1.75 }
|
|
16880
|
+
},
|
|
16881
|
+
agricultural: {
|
|
16882
|
+
frontHeadroomMetres: 1.05,
|
|
16883
|
+
rearHeadroomMetres: null,
|
|
16884
|
+
frontLegroomMetres: 0.62,
|
|
16885
|
+
widthMetres: 0.52,
|
|
16886
|
+
door: { widthMetres: 0.65, heightMetres: 0.9 }
|
|
16887
|
+
},
|
|
16888
|
+
military_light: {
|
|
16889
|
+
frontHeadroomMetres: 0.95,
|
|
16890
|
+
rearHeadroomMetres: 0.92,
|
|
16891
|
+
frontLegroomMetres: 0.62,
|
|
16892
|
+
widthMetres: 0.5,
|
|
16893
|
+
door: { widthMetres: 0.6, heightMetres: 0.8 }
|
|
16894
|
+
},
|
|
16895
|
+
military_armored: {
|
|
16896
|
+
frontHeadroomMetres: 0.88,
|
|
16897
|
+
rearHeadroomMetres: 0.88,
|
|
16898
|
+
frontLegroomMetres: 0.58,
|
|
16899
|
+
widthMetres: 0.46,
|
|
16900
|
+
door: { widthMetres: 0.5, heightMetres: 0.55 }
|
|
16901
|
+
},
|
|
16902
|
+
open_vehicle: {
|
|
16903
|
+
frontHeadroomMetres: null,
|
|
16904
|
+
rearHeadroomMetres: null,
|
|
16905
|
+
frontLegroomMetres: null,
|
|
16906
|
+
widthMetres: null,
|
|
16907
|
+
door: null
|
|
16908
|
+
},
|
|
16909
|
+
boat_cabin: {
|
|
16910
|
+
frontHeadroomMetres: 1.05,
|
|
16911
|
+
rearHeadroomMetres: 1.05,
|
|
16912
|
+
frontLegroomMetres: 0.62,
|
|
16913
|
+
widthMetres: 0.52,
|
|
16914
|
+
door: { widthMetres: 0.6, heightMetres: 0.9 }
|
|
16915
|
+
},
|
|
16916
|
+
aircraft_enclosed: {
|
|
16917
|
+
frontHeadroomMetres: 0.95,
|
|
16918
|
+
rearHeadroomMetres: 0.92,
|
|
16919
|
+
frontLegroomMetres: 0.62,
|
|
16920
|
+
widthMetres: 0.48,
|
|
16921
|
+
door: { widthMetres: 0.55, heightMetres: 0.8 }
|
|
16922
|
+
}
|
|
16923
|
+
}
|
|
16924
|
+
};
|
|
16925
|
+
|
|
16926
|
+
// src/cabin.ts
|
|
16927
|
+
var CABIN_CATEGORIES = [
|
|
16928
|
+
"passenger_car",
|
|
16929
|
+
"suv_pickup",
|
|
16930
|
+
"van",
|
|
16931
|
+
"truck",
|
|
16932
|
+
"bus",
|
|
16933
|
+
"agricultural",
|
|
16934
|
+
"military_light",
|
|
16935
|
+
"military_armored",
|
|
16936
|
+
"open_vehicle",
|
|
16937
|
+
"boat_cabin",
|
|
16938
|
+
"aircraft_enclosed"
|
|
16939
|
+
];
|
|
16940
|
+
var toClearance = (value) => value === null ? Number.POSITIVE_INFINITY : value;
|
|
16941
|
+
var toCabinMinimum = (category, raw) => {
|
|
16942
|
+
if (category === "open_vehicle") {
|
|
16943
|
+
return {
|
|
16944
|
+
frontHeadroomMetres: Number.POSITIVE_INFINITY,
|
|
16945
|
+
rearHeadroomMetres: Number.POSITIVE_INFINITY,
|
|
16946
|
+
frontLegroomMetres: Number.POSITIVE_INFINITY,
|
|
16947
|
+
widthMetres: Number.POSITIVE_INFINITY,
|
|
16948
|
+
door: void 0
|
|
16949
|
+
};
|
|
16950
|
+
}
|
|
16951
|
+
return {
|
|
16952
|
+
frontHeadroomMetres: toClearance(raw.frontHeadroomMetres),
|
|
16953
|
+
rearHeadroomMetres: raw.rearHeadroomMetres === null ? void 0 : raw.rearHeadroomMetres,
|
|
16954
|
+
frontLegroomMetres: toClearance(raw.frontLegroomMetres),
|
|
16955
|
+
widthMetres: toClearance(raw.widthMetres),
|
|
16956
|
+
door: raw.door === null ? void 0 : { widthMetres: raw.door.widthMetres, heightMetres: raw.door.heightMetres }
|
|
16957
|
+
};
|
|
16958
|
+
};
|
|
16959
|
+
var CABIN_SOURCE = cabin_default.source;
|
|
16960
|
+
var ENTRY_DUCK_FACTOR = cabin_default.entryDuckFactor;
|
|
16961
|
+
var CABIN_MINIMUMS = Object.fromEntries(
|
|
16962
|
+
CABIN_CATEGORIES.map((category) => [category, toCabinMinimum(category, cabin_default.categories[category])])
|
|
16963
|
+
);
|
|
16964
|
+
var cabinMinimumOf = (category) => CABIN_MINIMUMS[category];
|
|
16615
16965
|
return __toCommonJS(index_exports);
|
|
16616
16966
|
})();
|
|
16617
16967
|
//# sourceMappingURL=index.global.js.map
|