@adatechnology/game-vehicles 0.6.17 → 0.6.19
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 +112 -7
- package/dist/index.global.js +574 -133
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +461 -133
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -24,17 +24,26 @@ 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,
|
|
36
|
+
PLUME_PUFFS: () => PLUME_PUFFS,
|
|
32
37
|
SEED_SALTS: () => SEED_SALTS,
|
|
38
|
+
SMOKE_LOOKS: () => SMOKE_LOOKS,
|
|
39
|
+
SMOKE_WIND: () => SMOKE_WIND,
|
|
40
|
+
SmokeCause: () => SmokeCause,
|
|
33
41
|
armourLevelOf: () => armourLevelOf,
|
|
34
42
|
buildVehicleItem: () => buildVehicleItem,
|
|
35
43
|
buildVehicleModel: () => buildVehicleModel,
|
|
36
44
|
cabinBoxOf: () => cabinBoxOf,
|
|
37
45
|
cabinEnclosure: () => cabinEnclosure,
|
|
46
|
+
cabinMinimumOf: () => cabinMinimumOf,
|
|
38
47
|
clamp: () => clamp,
|
|
39
48
|
crackedGlassMaterial: () => crackedGlassMaterial,
|
|
40
49
|
crashDeltaV: () => crashDeltaV,
|
|
@@ -46,6 +55,7 @@ var GameVehicles = (() => {
|
|
|
46
55
|
createVehicleKit: () => createVehicleKit,
|
|
47
56
|
defaultDamageableKinds: () => defaultDamageableKinds,
|
|
48
57
|
defaultLodSettings: () => defaultLodSettings,
|
|
58
|
+
engineBayVent: () => engineBayVent,
|
|
49
59
|
format: () => format,
|
|
50
60
|
hash: () => hash,
|
|
51
61
|
legacyGlassId: () => legacyGlassId,
|
|
@@ -56,6 +66,9 @@ var GameVehicles = (() => {
|
|
|
56
66
|
registerLocale: () => registerLocale,
|
|
57
67
|
resolveStrings: () => resolveStrings,
|
|
58
68
|
rng: () => rng,
|
|
69
|
+
smokeCauseOfEmitter: () => smokeCauseOfEmitter,
|
|
70
|
+
smokePuff: () => smokePuff,
|
|
71
|
+
smokeRate: () => smokeRate,
|
|
59
72
|
smooth: () => smooth,
|
|
60
73
|
strHash: () => strHash,
|
|
61
74
|
strayLampsOf: () => strayLampsOf,
|
|
@@ -63,7 +76,7 @@ var GameVehicles = (() => {
|
|
|
63
76
|
wrapThreeForLod: () => wrapThreeForLod
|
|
64
77
|
});
|
|
65
78
|
|
|
66
|
-
// ../game-shapes/dist/chunk-
|
|
79
|
+
// ../game-shapes/dist/chunk-E3X7UDDV.js
|
|
67
80
|
function canonicalJson(value) {
|
|
68
81
|
if (value === null) return "null";
|
|
69
82
|
if (typeof value === "number") return Object.is(value, -0) ? "-0" : Number.isFinite(value) ? String(value) : JSON.stringify(String(value));
|
|
@@ -1455,6 +1468,76 @@ var GameVehicles = (() => {
|
|
|
1455
1468
|
|
|
1456
1469
|
// ../game-contracts/dist/index.js
|
|
1457
1470
|
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
1471
|
+
var NEAREST = 0.3;
|
|
1472
|
+
function sideOnImpulse(tnt, distance, nearest = NEAREST) {
|
|
1473
|
+
if (!(tnt > 0)) return 0;
|
|
1474
|
+
const w3 = Math.cbrt(tnt);
|
|
1475
|
+
const z = Math.max(distance, nearest) / w3;
|
|
1476
|
+
const near = z / 0.23 * (z / 0.23);
|
|
1477
|
+
const far = z / 1.55;
|
|
1478
|
+
const scaled = 0.067 * Math.sqrt(1 + near * near) / (z * z * Math.cbrt(1 + far * far * far));
|
|
1479
|
+
return scaled * w3 * 100;
|
|
1480
|
+
}
|
|
1481
|
+
var ATMOSPHERE = 101325;
|
|
1482
|
+
function sideOnOverpressure(tnt, distance, nearest = NEAREST) {
|
|
1483
|
+
if (!(tnt > 0)) return 0;
|
|
1484
|
+
const z = Math.max(distance, nearest) / Math.cbrt(tnt);
|
|
1485
|
+
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));
|
|
1486
|
+
return ratio * ATMOSPHERE;
|
|
1487
|
+
}
|
|
1488
|
+
var CHARGE_RADIUS = 1.3;
|
|
1489
|
+
var CHARGE_SECONDS = 0.01;
|
|
1490
|
+
var CHARGE_FLUX = 15e5;
|
|
1491
|
+
var DOSE_PER_DEGREE = 300;
|
|
1492
|
+
function chargeFireball(tnt) {
|
|
1493
|
+
const cube = Math.cbrt(Math.max(0, tnt));
|
|
1494
|
+
return { radius: CHARGE_RADIUS * cube, seconds: CHARGE_SECONDS * cube, flux: CHARGE_FLUX };
|
|
1495
|
+
}
|
|
1496
|
+
function fireballDose(fireball, distance) {
|
|
1497
|
+
const share = distance <= fireball.radius ? 1 : (fireball.radius / distance) ** 2;
|
|
1498
|
+
return fireball.flux * fireball.seconds * share;
|
|
1499
|
+
}
|
|
1500
|
+
function ignitionDose(ignitionC, ambientC = 20) {
|
|
1501
|
+
return DOSE_PER_DEGREE * Math.max(1, ignitionC - ambientC);
|
|
1502
|
+
}
|
|
1503
|
+
var ATMOSPHERE2 = 101325;
|
|
1504
|
+
var NEAREST_SCALED = 0.2;
|
|
1505
|
+
var LOADED_MARGIN = 0.15;
|
|
1506
|
+
var TNT_JOULES = 4184e3;
|
|
1507
|
+
var SHOCK_COUPLING = 0.04;
|
|
1508
|
+
var SHOCK_SCALED = 0.6;
|
|
1509
|
+
function reflectedLoad(tnt, distance) {
|
|
1510
|
+
if (!(tnt > 0)) return { pressure: 0, impulse: 0 };
|
|
1511
|
+
const cube = Math.cbrt(tnt);
|
|
1512
|
+
const nearest = NEAREST_SCALED * cube;
|
|
1513
|
+
const side2 = sideOnOverpressure(tnt, distance, nearest);
|
|
1514
|
+
const z = Math.max(distance, nearest) / cube;
|
|
1515
|
+
const pressure = 2 * side2 * (7 * ATMOSPHERE2 + 4 * side2) / (7 * ATMOSPHERE2 + side2);
|
|
1516
|
+
const impulse = sideOnImpulse(tnt, distance, nearest) * (2 + 4 / (1 + z * z));
|
|
1517
|
+
return { pressure, impulse };
|
|
1518
|
+
}
|
|
1519
|
+
function waveWork(input) {
|
|
1520
|
+
const load = reflectedLoad(input.tnt, input.distance);
|
|
1521
|
+
const reach = Math.min(1, Math.max(0, input.reach));
|
|
1522
|
+
const pressure = load.pressure * reach;
|
|
1523
|
+
if (!(input.area > 0) || !(input.mass > 0) || pressure <= 0) return { energy: 0, shock: 0, pressure, loaded: 0 };
|
|
1524
|
+
const loaded = Math.min(input.area, Math.PI * (input.distance + LOADED_MARGIN) ** 2);
|
|
1525
|
+
const mass = input.mass * (loaded / input.area);
|
|
1526
|
+
const impulse = load.impulse * reach * loaded;
|
|
1527
|
+
const impulsive = impulse * impulse / (2 * mass);
|
|
1528
|
+
const quasiStatic = pressure * loaded * Math.max(input.thickness, 1e-4);
|
|
1529
|
+
return { energy: Math.min(impulsive, quasiStatic), shock: shockWork(input), pressure, loaded };
|
|
1530
|
+
}
|
|
1531
|
+
function shockWork(input) {
|
|
1532
|
+
const cube = Math.cbrt(input.tnt);
|
|
1533
|
+
if (!(cube > 0) || !(input.area > 0)) return 0;
|
|
1534
|
+
const z = Math.max(input.distance, 0) / cube;
|
|
1535
|
+
const radius = Math.cbrt(3 * input.tnt / (4 * Math.PI * 1600));
|
|
1536
|
+
const share = Math.min(0.5, input.area / (4 * Math.PI * (input.distance + radius) ** 2));
|
|
1537
|
+
const falloff = 1 + z / SHOCK_SCALED * (z / SHOCK_SCALED);
|
|
1538
|
+
const reach = Math.min(1, Math.max(0, input.reach));
|
|
1539
|
+
return SHOCK_COUPLING * input.tnt * TNT_JOULES * share * reach * reach / (falloff * falloff);
|
|
1540
|
+
}
|
|
1458
1541
|
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
1459
1542
|
var DEFAULT_IGNITION_RULES = {
|
|
1460
1543
|
fillCurve: [
|
|
@@ -1502,15 +1585,40 @@ var GameVehicles = (() => {
|
|
|
1502
1585
|
var DEFERRED_QUEUE_ID = {
|
|
1503
1586
|
DESTRUCTION_EVENTS: "destruction.events",
|
|
1504
1587
|
BREACH_PAINT: "floorplan.breach-paint",
|
|
1588
|
+
BREACH_CUT: "floorplan.breach-cut",
|
|
1505
1589
|
AUDIO_VOICES: "audio.voices",
|
|
1506
|
-
VEHICLE_CREASE: "vehicles.crease"
|
|
1590
|
+
VEHICLE_CREASE: "vehicles.crease",
|
|
1591
|
+
AUDIO_OCCLUSION: "audio.occlusion",
|
|
1592
|
+
FLUID_FILM: "fluids.film",
|
|
1593
|
+
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
1594
|
+
SETTLED_BATCH: "destruction.settled-batch",
|
|
1595
|
+
STATIC_BATCH: "render.static-batch",
|
|
1596
|
+
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
1597
|
+
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
1598
|
+
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
1599
|
+
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
1507
1600
|
};
|
|
1508
1601
|
var DEFERRED_PRIORITY = {
|
|
1509
1602
|
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
1510
|
-
|
|
1603
|
+
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
1604
|
+
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
1605
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
1511
1606
|
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
1512
|
-
[DEFERRED_QUEUE_ID.
|
|
1607
|
+
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
1608
|
+
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
1609
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
1610
|
+
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
1611
|
+
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
1612
|
+
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1613
|
+
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1614
|
+
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
1615
|
+
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
1616
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
1513
1617
|
};
|
|
1618
|
+
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
1619
|
+
function drainDetached(queue, budgetMs, clock = () => performance.now()) {
|
|
1620
|
+
return queue.run(clock() + budgetMs, clock);
|
|
1621
|
+
}
|
|
1514
1622
|
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
1515
1623
|
var warnedKeys = () => {
|
|
1516
1624
|
const holder = globalThis;
|
|
@@ -1574,6 +1682,27 @@ var GameVehicles = (() => {
|
|
|
1574
1682
|
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
1575
1683
|
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
1576
1684
|
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
1685
|
+
var WORKER_KIND_ID = {
|
|
1686
|
+
GROUND_TILES: "destruction.ground-tiles",
|
|
1687
|
+
CROWD_PHYSICS: "crowd.physics",
|
|
1688
|
+
PIECE_BOXES: "destruction.piece-boxes",
|
|
1689
|
+
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
1690
|
+
SHAPES_GENERATE: "shapes.generate",
|
|
1691
|
+
WORLD_REGION: "world.region"
|
|
1692
|
+
};
|
|
1693
|
+
var WORKER_KIND_DEFAULTS = {
|
|
1694
|
+
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
1695
|
+
[WORKER_KIND_ID.CROWD_PHYSICS]: { lane: "sim", priority: 250, latencyFrames: 1, late: "sync" },
|
|
1696
|
+
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
1697
|
+
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
1698
|
+
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
1699
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1702
|
+
// ../game-shapes/dist/index.js
|
|
1703
|
+
var SAME_COLOUR = 1 / 512;
|
|
1704
|
+
var SAME_FACING = 1 - 1e-6;
|
|
1705
|
+
var PARALLEL = Math.cos(2 * Math.PI / 180);
|
|
1577
1706
|
|
|
1578
1707
|
// ../game-shapes-three/dist/index.js
|
|
1579
1708
|
var UV_BEFORE_NORMAL = /* @__PURE__ */ new Set(["LatheGeometry", "ExtrudeGeometry"]);
|
|
@@ -2594,7 +2723,7 @@ var GameVehicles = (() => {
|
|
|
2594
2723
|
ti.boxes[j + 3 + k] = Math.max(P[a + k], P[b + k], P[c + k]);
|
|
2595
2724
|
}
|
|
2596
2725
|
}
|
|
2597
|
-
function advance(geo, ti, deadline) {
|
|
2726
|
+
function advance(geo, ti, deadline, clock) {
|
|
2598
2727
|
const total = blockCount(ti.triangles);
|
|
2599
2728
|
while (ti.builtBlocks < total) {
|
|
2600
2729
|
const block = ti.builtBlocks;
|
|
@@ -2602,7 +2731,7 @@ var GameVehicles = (() => {
|
|
|
2602
2731
|
for (let t = block * TRI_BLOCK; t < t1; t++) boxTriangle(geo, ti, t);
|
|
2603
2732
|
boxBlock(ti, block);
|
|
2604
2733
|
ti.builtBlocks++;
|
|
2605
|
-
if (deadline !== Infinity &&
|
|
2734
|
+
if (deadline !== Infinity && clock() >= deadline) break;
|
|
2606
2735
|
}
|
|
2607
2736
|
return ti.builtBlocks === total;
|
|
2608
2737
|
}
|
|
@@ -2626,14 +2755,14 @@ var GameVehicles = (() => {
|
|
|
2626
2755
|
if (!supports(geo)) return void 0;
|
|
2627
2756
|
let ti = cache.get(geo);
|
|
2628
2757
|
if (!ti || !isCurrent(geo, ti)) ti = start(geo);
|
|
2629
|
-
advance(geo, ti, Infinity);
|
|
2758
|
+
advance(geo, ti, Infinity, performance.now.bind(performance));
|
|
2630
2759
|
return ti;
|
|
2631
2760
|
}
|
|
2632
|
-
function warmTriIndex(geo, deadline) {
|
|
2761
|
+
function warmTriIndex(geo, deadline, clock = performance.now.bind(performance)) {
|
|
2633
2762
|
if (!supports(geo)) return true;
|
|
2634
2763
|
let ti = cache.get(geo);
|
|
2635
2764
|
if (!ti || !isCurrent(geo, ti)) ti = start(geo);
|
|
2636
|
-
return advance(geo, ti, deadline);
|
|
2765
|
+
return advance(geo, ti, deadline, clock);
|
|
2637
2766
|
}
|
|
2638
2767
|
function storeTriIndex(geo, boxes) {
|
|
2639
2768
|
const ti = start(geo);
|
|
@@ -2677,7 +2806,7 @@ var GameVehicles = (() => {
|
|
|
2677
2806
|
if (shared && isCurrent(geo, shared) && shared.builtBlocks === blockCount(shared.triangles)) return shared;
|
|
2678
2807
|
let ti = rayCache.get(geo);
|
|
2679
2808
|
if (!ti || !isCurrent(geo, ti)) ti = start(geo, rayCache);
|
|
2680
|
-
advance(geo, ti, Infinity);
|
|
2809
|
+
advance(geo, ti, Infinity, performance.now.bind(performance));
|
|
2681
2810
|
return ti;
|
|
2682
2811
|
}
|
|
2683
2812
|
var BLOCK_SLACK = 1e-6;
|
|
@@ -2970,9 +3099,9 @@ var GameVehicles = (() => {
|
|
|
2970
3099
|
const cs = Math.cos(deg * PI / 180);
|
|
2971
3100
|
let phase = 0;
|
|
2972
3101
|
let at = 0;
|
|
2973
|
-
function hashSlice(deadline) {
|
|
3102
|
+
function hashSlice(deadline, clock) {
|
|
2974
3103
|
for (; at < n; at++) {
|
|
2975
|
-
if ((at & 1023) === 0 &&
|
|
3104
|
+
if ((at & 1023) === 0 && clock() > deadline) return false;
|
|
2976
3105
|
const x = Math.round(P[3 * at] * 2e3) | 0;
|
|
2977
3106
|
const y = Math.round(P[3 * at + 1] * 2e3) | 0;
|
|
2978
3107
|
const z = Math.round(P[3 * at + 2] * 2e3) | 0;
|
|
@@ -3001,9 +3130,9 @@ var GameVehicles = (() => {
|
|
|
3001
3130
|
members = new Int32Array(n);
|
|
3002
3131
|
for (let i = 0; i < n; i++) members[fill[groupOf[i]]++] = i / 3 | 0;
|
|
3003
3132
|
}
|
|
3004
|
-
function smoothSlice(deadline) {
|
|
3133
|
+
function smoothSlice(deadline, clock) {
|
|
3005
3134
|
for (; at < n; at++) {
|
|
3006
|
-
if ((at & 1023) === 0 &&
|
|
3135
|
+
if ((at & 1023) === 0 && clock() > deadline) return false;
|
|
3007
3136
|
const fi = (at / 3 | 0) * 3;
|
|
3008
3137
|
const g = groupOf[at];
|
|
3009
3138
|
let sx = 0;
|
|
@@ -3029,16 +3158,16 @@ var GameVehicles = (() => {
|
|
|
3029
3158
|
}
|
|
3030
3159
|
return true;
|
|
3031
3160
|
}
|
|
3032
|
-
function step(deadline) {
|
|
3161
|
+
function step(deadline, clock = performance.now.bind(performance)) {
|
|
3033
3162
|
if (latestCrease.get(geo) !== token) return true;
|
|
3034
3163
|
if (phase === 0) {
|
|
3035
|
-
if (!hashSlice(deadline)) return false;
|
|
3164
|
+
if (!hashSlice(deadline, clock)) return false;
|
|
3036
3165
|
gather();
|
|
3037
3166
|
phase = 1;
|
|
3038
3167
|
at = 0;
|
|
3039
3168
|
}
|
|
3040
3169
|
if (phase === 1) {
|
|
3041
|
-
const done = smoothSlice(deadline);
|
|
3170
|
+
const done = smoothSlice(deadline, clock);
|
|
3042
3171
|
if (deadline !== Infinity) normal.needsUpdate = true;
|
|
3043
3172
|
if (!done) return false;
|
|
3044
3173
|
phase = 2;
|
|
@@ -6003,6 +6132,51 @@ var GameVehicles = (() => {
|
|
|
6003
6132
|
return shared;
|
|
6004
6133
|
}
|
|
6005
6134
|
|
|
6135
|
+
// src/engine-smoke.ts
|
|
6136
|
+
var SmokeCause = { STEAM: "steam", OIL: "oil", FIRE: "fire" };
|
|
6137
|
+
var SMOKE_LOOKS = {
|
|
6138
|
+
[SmokeCause.STEAM]: { color: 14870248, alpha: 0.18 },
|
|
6139
|
+
[SmokeCause.OIL]: { color: 11120306, alpha: 0.2 },
|
|
6140
|
+
[SmokeCause.FIRE]: { color: 2302756, alpha: 0.3 }
|
|
6141
|
+
};
|
|
6142
|
+
var CAUSE_OF_EMITTER = { white: SmokeCause.STEAM, oil: SmokeCause.OIL, black: SmokeCause.FIRE };
|
|
6143
|
+
var smokeCauseOfEmitter = (kind) => CAUSE_OF_EMITTER[kind];
|
|
6144
|
+
var RATE_AT_NO_DAMAGE = 0.25;
|
|
6145
|
+
var RATE_AT_WRECK = 1;
|
|
6146
|
+
function smokeRate(baseRate, damage) {
|
|
6147
|
+
const level = Math.min(1, Math.max(0, damage));
|
|
6148
|
+
return baseRate * (RATE_AT_NO_DAMAGE + (RATE_AT_WRECK - RATE_AT_NO_DAMAGE) * level);
|
|
6149
|
+
}
|
|
6150
|
+
var PLUME_PUFFS = 3;
|
|
6151
|
+
var SMOKE_WIND = [-0.45, 0, 0.16];
|
|
6152
|
+
var LIFT = { [SmokeCause.STEAM]: 0.5, [SmokeCause.OIL]: 0.45, [SmokeCause.FIRE]: 0.6 };
|
|
6153
|
+
var DRAG = 0.4;
|
|
6154
|
+
var VENT_CLEARANCE = 0.08;
|
|
6155
|
+
var VENT_SPREAD = 0.18;
|
|
6156
|
+
var jitter = (random, span) => (random() - 0.5) * 2 * span;
|
|
6157
|
+
function smokePuff(params) {
|
|
6158
|
+
const { cause, scale, random } = params;
|
|
6159
|
+
const wind = params.wind ?? SMOKE_WIND;
|
|
6160
|
+
const look = SMOKE_LOOKS[cause];
|
|
6161
|
+
const isFire = cause === SmokeCause.FIRE;
|
|
6162
|
+
return {
|
|
6163
|
+
offset: [jitter(random, VENT_SPREAD * scale), random() * 0.05, jitter(random, VENT_SPREAD * scale)],
|
|
6164
|
+
velocity: [wind[0] + jitter(random, 0.22), 0.55 + random() * 0.5, wind[2] + jitter(random, 0.22)],
|
|
6165
|
+
size: (isFire ? 0.2 : 0.14) * scale * (0.8 + random() * 0.4),
|
|
6166
|
+
growth: (isFire ? 6 : 5) + random() * 2,
|
|
6167
|
+
life: (isFire ? 3.4 : 2.6) + random() * 1.2,
|
|
6168
|
+
color: look.color,
|
|
6169
|
+
alpha: look.alpha * (0.8 + random() * 0.4),
|
|
6170
|
+
lift: LIFT[cause],
|
|
6171
|
+
drag: DRAG
|
|
6172
|
+
};
|
|
6173
|
+
}
|
|
6174
|
+
function engineBayVent(box2) {
|
|
6175
|
+
const [cx, cy, cz] = box2.center;
|
|
6176
|
+
const [sx, sy] = box2.size;
|
|
6177
|
+
return [cx + sx * 0.15, cy + sy / 2 + VENT_CLEARANCE, cz];
|
|
6178
|
+
}
|
|
6179
|
+
|
|
6006
6180
|
// src/routed-particles.ts
|
|
6007
6181
|
var ROUTED_PARTICLE_TYPES = { smoke: "particle_puff", dust: "particle_puff", fire: "particle_glow" };
|
|
6008
6182
|
var PUFF_LOOKS = {
|
|
@@ -6022,7 +6196,7 @@ var GameVehicles = (() => {
|
|
|
6022
6196
|
const life = input.life ?? LIFE[type] ?? 99;
|
|
6023
6197
|
const size = (input.size ?? 1) * (input.grow ?? 1);
|
|
6024
6198
|
const isFire = type === "fire";
|
|
6025
|
-
const growth = isFire ? 1 : (SMOKE_START_SCALE + 1.5 * (1 - Math.exp(-life * 1.1)) + life * 0.12) / SMOKE_START_SCALE;
|
|
6199
|
+
const growth = input.growth ?? (isFire ? 1 : (SMOKE_START_SCALE + 1.5 * (1 - Math.exp(-life * 1.1)) + life * 0.12) / SMOKE_START_SCALE);
|
|
6026
6200
|
return {
|
|
6027
6201
|
effect: ROUTED_PARTICLE_TYPES[type],
|
|
6028
6202
|
point: input.position,
|
|
@@ -6031,12 +6205,12 @@ var GameVehicles = (() => {
|
|
|
6031
6205
|
vy: input.velocity[1],
|
|
6032
6206
|
vz: input.velocity[2],
|
|
6033
6207
|
life,
|
|
6034
|
-
size: isFire ? size * 0.85 : size * SMOKE_START_SCALE,
|
|
6208
|
+
size: input.growth !== void 0 ? size : isFire ? size * 0.85 : size * SMOKE_START_SCALE,
|
|
6035
6209
|
grow: growth,
|
|
6036
6210
|
color: input.color ?? (isFire ? FIRE_COLOR : look[0]),
|
|
6037
6211
|
alpha: input.alpha ?? look[1],
|
|
6038
|
-
gravity: isFire ? 0 : type === "dust" ? 0 : -0.08,
|
|
6039
|
-
drag: type === "dust" ? 2.5 : isFire ? 1.5 : 0.9
|
|
6212
|
+
gravity: input.gravity ?? (isFire ? 0 : type === "dust" ? 0 : -0.08),
|
|
6213
|
+
drag: input.drag ?? (type === "dust" ? 2.5 : isFire ? 1.5 : 0.9)
|
|
6040
6214
|
}
|
|
6041
6215
|
};
|
|
6042
6216
|
}
|
|
@@ -6189,7 +6363,10 @@ var GameVehicles = (() => {
|
|
|
6189
6363
|
...o.op != null ? { alpha: o.op } : {},
|
|
6190
6364
|
...o.s ? { size: o.s } : {},
|
|
6191
6365
|
...o.life ? { life: o.life } : {},
|
|
6192
|
-
...o.grow ? { grow: o.grow } : {}
|
|
6366
|
+
...o.grow ? { grow: o.grow } : {},
|
|
6367
|
+
...o.growth ? { growth: o.growth } : {},
|
|
6368
|
+
...o.lift != null ? { gravity: -o.lift } : {},
|
|
6369
|
+
...o.drag != null ? { drag: o.drag } : {}
|
|
6193
6370
|
})
|
|
6194
6371
|
);
|
|
6195
6372
|
return null;
|
|
@@ -6244,7 +6421,8 @@ var GameVehicles = (() => {
|
|
|
6244
6421
|
r: o.r || 0.01,
|
|
6245
6422
|
spin: (c.rand() - 0.5) * 1.2,
|
|
6246
6423
|
ph: c.rand() * 6.28,
|
|
6247
|
-
grow: o.grow || 1
|
|
6424
|
+
grow: o.grow || 1,
|
|
6425
|
+
growth: o.growth || 0
|
|
6248
6426
|
};
|
|
6249
6427
|
c.particles.push(P);
|
|
6250
6428
|
return P;
|
|
@@ -6285,7 +6463,7 @@ var GameVehicles = (() => {
|
|
|
6285
6463
|
m.position.addScaledVector(P.v, dt);
|
|
6286
6464
|
m.position.x += Math.sin(P.age * 1.7 + P.ph) * 0.08 * dt;
|
|
6287
6465
|
m.position.z += Math.cos(P.age * 1.3 + P.ph) * 0.08 * dt;
|
|
6288
|
-
const gs = P.s0 * P.grow * (0.18 + 1.5 * (1 - Math.exp(-P.age * 1.1)) + P.age * 0.12);
|
|
6466
|
+
const gs = P.growth ? P.s0 * (1 + (P.growth - 1) * t) : P.s0 * P.grow * (0.18 + 1.5 * (1 - Math.exp(-P.age * 1.1)) + P.age * 0.12);
|
|
6289
6467
|
m.scale.set(gs, gs, 1);
|
|
6290
6468
|
m.material.rotation += P.spin * dt;
|
|
6291
6469
|
m.material.opacity = P.op * Math.min(1, P.age / 0.3);
|
|
@@ -6361,7 +6539,8 @@ var GameVehicles = (() => {
|
|
|
6361
6539
|
acc: 0,
|
|
6362
6540
|
s: o.s || 1,
|
|
6363
6541
|
dir: o.dir || null,
|
|
6364
|
-
gap: 0
|
|
6542
|
+
gap: 0,
|
|
6543
|
+
...o.damage ? { damage: o.damage } : {}
|
|
6365
6544
|
};
|
|
6366
6545
|
c.emitters.push(e);
|
|
6367
6546
|
return e;
|
|
@@ -6373,7 +6552,31 @@ var GameVehicles = (() => {
|
|
|
6373
6552
|
return ["#141414", 0.66];
|
|
6374
6553
|
}
|
|
6375
6554
|
kit.exhaustLook = exhaustLook;
|
|
6555
|
+
function spawnSmokePuff(c, cause, scale, vent) {
|
|
6556
|
+
for (let k = 0; k < PLUME_PUFFS; k++) {
|
|
6557
|
+
const puff = smokePuff({ cause, scale, random: c.rand });
|
|
6558
|
+
const at = vent.clone().add(c.dirToEffects(new V3(puff.offset[0], puff.offset[1], puff.offset[2])));
|
|
6559
|
+
kit.spawn(c, "smoke", at, new V3(puff.velocity[0], puff.velocity[1], puff.velocity[2]), {
|
|
6560
|
+
col: puff.color,
|
|
6561
|
+
op: puff.alpha,
|
|
6562
|
+
s: puff.size,
|
|
6563
|
+
life: puff.life,
|
|
6564
|
+
growth: puff.growth,
|
|
6565
|
+
lift: puff.lift,
|
|
6566
|
+
drag: puff.drag
|
|
6567
|
+
});
|
|
6568
|
+
}
|
|
6569
|
+
}
|
|
6570
|
+
function spawnOwnSmokePuff(c, e, p) {
|
|
6571
|
+
const black = e.kind === "black" || e.kind === "oil";
|
|
6572
|
+
kit.spawn(c, "smoke", p, new V3((c.rand() - 0.5) * 0.2, black ? 0.9 + c.rand() * 0.3 : 1.1 + c.rand() * 0.3, (c.rand() - 0.5) * 0.2), {
|
|
6573
|
+
variant: black ? "black" : "steam",
|
|
6574
|
+
s: (black ? 0.75 : 0.6) * e.s * (0.8 + c.rand() * 0.4),
|
|
6575
|
+
life: black ? 3.2 : 2
|
|
6576
|
+
});
|
|
6577
|
+
}
|
|
6376
6578
|
function tickEmit(c, dt) {
|
|
6579
|
+
const plume = !!kit.effects?.();
|
|
6377
6580
|
c.emitters.forEach(function(e) {
|
|
6378
6581
|
if (e.kind === "exhaust") {
|
|
6379
6582
|
const h = c.engineHealth == null ? 1 : c.engineHealth;
|
|
@@ -6384,7 +6587,7 @@ var GameVehicles = (() => {
|
|
|
6384
6587
|
if (e.gap > 0) return;
|
|
6385
6588
|
}
|
|
6386
6589
|
}
|
|
6387
|
-
e.acc += e.rate * dt;
|
|
6590
|
+
e.acc += (plume && e.damage ? smokeRate(e.rate, e.damage()) : e.rate) * dt;
|
|
6388
6591
|
while (e.acc >= 1) {
|
|
6389
6592
|
e.acc -= 1;
|
|
6390
6593
|
const p = e.world ? e.p.clone() : c.toEffects(e.p);
|
|
@@ -6397,8 +6600,10 @@ var GameVehicles = (() => {
|
|
|
6397
6600
|
s: (0.45 + c.rand() * 0.45) * e.s,
|
|
6398
6601
|
life: 0.55 + c.rand() * 0.35
|
|
6399
6602
|
});
|
|
6400
|
-
if (c.rand() < 0.45)
|
|
6401
|
-
|
|
6603
|
+
if (c.rand() < 0.45) {
|
|
6604
|
+
if (plume) spawnSmokePuff(c, SmokeCause.FIRE, e.s, p.clone().add(new V3(0, 0.5 * e.s, 0)));
|
|
6605
|
+
else kit.spawn(c, "smoke", p.clone().add(new V3(0, 0.7 * e.s, 0)), new V3(0, 1, 0), { variant: "black", s: 0.9 * e.s, life: 3.2 });
|
|
6606
|
+
}
|
|
6402
6607
|
if (c.rand() < 0.15)
|
|
6403
6608
|
kit.spawn(
|
|
6404
6609
|
c,
|
|
@@ -6417,14 +6622,9 @@ var GameVehicles = (() => {
|
|
|
6417
6622
|
life: 1.4 + c.rand() * 0.5
|
|
6418
6623
|
});
|
|
6419
6624
|
} else {
|
|
6420
|
-
const
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
"smoke",
|
|
6424
|
-
p,
|
|
6425
|
-
new V3((c.rand() - 0.5) * 0.2, preta ? 0.9 + c.rand() * 0.3 : 1.1 + c.rand() * 0.3, (c.rand() - 0.5) * 0.2),
|
|
6426
|
-
{ variant: preta ? "black" : "steam", s: (preta ? 0.75 : 0.6) * e.s * (0.8 + c.rand() * 0.4), life: preta ? 3.2 : 2 }
|
|
6427
|
-
);
|
|
6625
|
+
const cause = smokeCauseOfEmitter(e.kind);
|
|
6626
|
+
if (cause && plume) spawnSmokePuff(c, cause, e.s, p);
|
|
6627
|
+
else spawnOwnSmokePuff(c, e, p);
|
|
6428
6628
|
}
|
|
6429
6629
|
}
|
|
6430
6630
|
});
|
|
@@ -7399,7 +7599,7 @@ var GameVehicles = (() => {
|
|
|
7399
7599
|
kit.addEmitter(c, pt.pos.clone().add(new V3(-0.1, 0.25, 0)), "white");
|
|
7400
7600
|
hurtEngine(c, 0.6);
|
|
7401
7601
|
} else if (k === "engine") {
|
|
7402
|
-
kit.addEmitter(c, pt.pos.clone().add(new V3(0, 0.3, 0)), "
|
|
7602
|
+
kit.addEmitter(c, pt.pos.clone().add(new V3(0, 0.3, 0)), "oil", { rate: 6, damage: () => 1 - (c.engineHealth ?? 1) });
|
|
7403
7603
|
hurtEngine(c, force > 1.1 ? 0.1 : 0.3);
|
|
7404
7604
|
if (c.hood && force > 0.5 && !c.hood.noLatch) {
|
|
7405
7605
|
c.hood.latch = Math.max(c.hood.latch, 0.15);
|
|
@@ -7835,15 +8035,32 @@ var GameVehicles = (() => {
|
|
|
7835
8035
|
const m = c.meta;
|
|
7836
8036
|
return new V3(m.front - 0.6, (m.clearance || 0.3) + 0.3, 0);
|
|
7837
8037
|
}
|
|
8038
|
+
function worldPointOf(c, local) {
|
|
8039
|
+
c.vehicle.updateWorldMatrix(true, false);
|
|
8040
|
+
const wp = local.clone().applyMatrix4(c.vehicle.matrixWorld);
|
|
8041
|
+
return [wp.x, wp.y, wp.z];
|
|
8042
|
+
}
|
|
8043
|
+
function startVehicleFire(c, local, radius, life) {
|
|
8044
|
+
const effects = kit.effects?.();
|
|
8045
|
+
if (!effects) return false;
|
|
8046
|
+
const handle = effects.play({ effect: "volumetric_fire", point: worldPointOf(c, local), values: { radius, life } });
|
|
8047
|
+
if (handle != null) {
|
|
8048
|
+
c.vfxHandles = c.vfxHandles || [];
|
|
8049
|
+
c.vfxHandles.push(handle);
|
|
8050
|
+
}
|
|
8051
|
+
return true;
|
|
8052
|
+
}
|
|
7838
8053
|
kit.explode = function(c, o) {
|
|
7839
8054
|
o = o || {};
|
|
7840
8055
|
if (c.blast || c.exploded) return false;
|
|
7841
8056
|
const fuse = o.now ? 0 : o.delay != null ? o.delay : 3 + c.rand() * 5;
|
|
7842
|
-
c.blast = { phase: "fire", t: 0, T: fuse };
|
|
8057
|
+
c.blast = { phase: "fire", t: 0, T: fuse, skipBlastEffect: !!o.skipBlastEffect };
|
|
7843
8058
|
if (fuse > 0) {
|
|
7844
8059
|
const ep = enginePos(c);
|
|
7845
|
-
|
|
7846
|
-
|
|
8060
|
+
if (!startVehicleFire(c, ep.clone().add(new V3(0, 0.25, 0)), 0.55, fuse + 2)) {
|
|
8061
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.25, 0)), "fire", { rate: 10, s: 0.9 });
|
|
8062
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.6, 0)), "black", { rate: 6, s: 1.2 });
|
|
8063
|
+
}
|
|
7847
8064
|
I.hurtEngine(c, 0.1);
|
|
7848
8065
|
}
|
|
7849
8066
|
if (c.hood) c.hood.target = 0;
|
|
@@ -7861,8 +8078,10 @@ var GameVehicles = (() => {
|
|
|
7861
8078
|
return p.kind === "fuel_tank";
|
|
7862
8079
|
});
|
|
7863
8080
|
const tp = tk ? tk.pos.clone() : enginePos(c);
|
|
7864
|
-
|
|
7865
|
-
|
|
8081
|
+
if (!startVehicleFire(c, tp.clone().setY(Math.max(0.15, tp.y)), 0.65, 25)) {
|
|
8082
|
+
kit.addEmitter(c, tp.clone().setY(Math.max(0.15, tp.y)), "fire", { rate: 12, s: 1.1 });
|
|
8083
|
+
kit.addEmitter(c, tp.clone().setY(tp.y + 0.8), "black", { rate: 5, s: 1.4 });
|
|
8084
|
+
}
|
|
7866
8085
|
return "fire";
|
|
7867
8086
|
}
|
|
7868
8087
|
return null;
|
|
@@ -7969,42 +8188,51 @@ var GameVehicles = (() => {
|
|
|
7969
8188
|
c.emitters = c.emitters.filter(function(e) {
|
|
7970
8189
|
return e.kind !== "exhaust";
|
|
7971
8190
|
});
|
|
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
|
-
|
|
8191
|
+
const effects = kit.effects?.();
|
|
8192
|
+
if (effects) {
|
|
8193
|
+
if (!B.skipBlastEffect) {
|
|
8194
|
+
c.effects.updateWorldMatrix(true, false);
|
|
8195
|
+
const worldCen = cen.clone().applyMatrix4(c.effects.matrixWorld);
|
|
8196
|
+
effects.play({ effect: big ? "fuel_station_tank" : "car_fuel_tank", point: [worldCen.x, worldCen.y, worldCen.z], values: {} });
|
|
8197
|
+
}
|
|
8198
|
+
} else {
|
|
8199
|
+
const fl = new THREE.Sprite(
|
|
8200
|
+
new THREE.SpriteMaterial({
|
|
8201
|
+
map: I.glowTexture(),
|
|
8202
|
+
color: 16767392,
|
|
8203
|
+
blending: THREE.AdditiveBlending,
|
|
8204
|
+
transparent: true,
|
|
8205
|
+
depthWrite: false,
|
|
8206
|
+
fog: false
|
|
8207
|
+
})
|
|
8208
|
+
);
|
|
8209
|
+
fl.raycast = function() {
|
|
8210
|
+
};
|
|
8211
|
+
fl.position.copy(cen);
|
|
8212
|
+
fl.scale.setScalar(0.1);
|
|
8213
|
+
c.effects.add(fl);
|
|
8214
|
+
B.flash = fl;
|
|
8215
|
+
const sw = new THREE.Mesh(new THREE.RingGeometry(0.8, 1, 64), boomMat("#ffcf8a", 0.6, true));
|
|
8216
|
+
sw.rotation.x = -PI / 2;
|
|
8217
|
+
sw.position.set(cen.x, 0.07, cen.z);
|
|
8218
|
+
c.effects.add(sw);
|
|
8219
|
+
B.shock = sw;
|
|
8220
|
+
const k = big ? 1.8 : 1;
|
|
8221
|
+
for (let i = 0; i < (big ? 70 : 46); i++) {
|
|
8222
|
+
const d = new V3(c.rand() - 0.5, c.rand() * 0.9, c.rand() - 0.5).normalize();
|
|
8223
|
+
kit.spawn(c, "fire", cen.clone().addScaledVector(d, 0.3), d.multiplyScalar((2.5 + c.rand() * 4) * k), {
|
|
8224
|
+
s: (1 + c.rand() * 1.4) * k,
|
|
8225
|
+
life: 0.8 + c.rand() * 0.7
|
|
8226
|
+
});
|
|
8227
|
+
}
|
|
8228
|
+
for (let j = 0; j < (big ? 30 : 18); j++) {
|
|
8229
|
+
const d2 = new V3(c.rand() - 0.5, 0.4 + c.rand(), c.rand() - 0.5).normalize();
|
|
8230
|
+
kit.spawn(c, "smoke", cen.clone().addScaledVector(d2, 0.6), d2.multiplyScalar(1.5 + c.rand() * 2), {
|
|
8231
|
+
variant: "black",
|
|
8232
|
+
s: (1.4 + c.rand()) * k,
|
|
8233
|
+
life: 4 + c.rand() * 2
|
|
8234
|
+
});
|
|
8235
|
+
}
|
|
8008
8236
|
}
|
|
8009
8237
|
I.burst(c, "spark", cen, 40, { speed: 7, spread: 1.6 });
|
|
8010
8238
|
I.burst(c, "scrap", cen, 14, {
|
|
@@ -8017,7 +8245,7 @@ var GameVehicles = (() => {
|
|
|
8017
8245
|
const G = gm2.userData.glass;
|
|
8018
8246
|
if (!G || G.broken || !gm2.visible || !gm2.parent) return;
|
|
8019
8247
|
if (G.type === "laminated") {
|
|
8020
|
-
for (let
|
|
8248
|
+
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
8249
|
return;
|
|
8022
8250
|
}
|
|
8023
8251
|
I.shatterGlass(c, gm2, 1.4, new V3(0, 1, 0));
|
|
@@ -8043,14 +8271,19 @@ var GameVehicles = (() => {
|
|
|
8043
8271
|
c.emitters.forEach(function(e) {
|
|
8044
8272
|
if (e.kind === "fire") e.rate = Math.min(e.rate, 7);
|
|
8045
8273
|
});
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8274
|
+
if (effects) {
|
|
8275
|
+
startVehicleFire(c, ep.clone().add(new V3(0, 0.15, 0)), 0.55, 30);
|
|
8276
|
+
startVehicleFire(c, new V3(((m.front || 1) + (m.rear || -1)) / 2, (m.clearance || 0.3) + 0.35, 0), 0.45, 25);
|
|
8277
|
+
} else {
|
|
8278
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.15, 0)), "fire", { rate: 8, s: 0.8 });
|
|
8279
|
+
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 });
|
|
8280
|
+
kit.addEmitter(c, ep.clone().add(new V3(0, 0.9, 0)), "black", { rate: 4, s: 1.4 });
|
|
8281
|
+
}
|
|
8049
8282
|
c.parts.forEach(function(p) {
|
|
8050
8283
|
if (p.kind === "glass" || p.kind === "headlight" || p.kind === "taillight" || p.kind === "hood") p.done = true;
|
|
8051
8284
|
});
|
|
8052
8285
|
c.log.push({ kind: "explosion", label: kit.t(big ? "blast.tank_explosion" : "blast.explosion") });
|
|
8053
|
-
if (big) bigBoomFx(c);
|
|
8286
|
+
if (big && !effects) bigBoomFx(c);
|
|
8054
8287
|
}
|
|
8055
8288
|
function tickBoom(c, dt) {
|
|
8056
8289
|
const B = c.blast;
|
|
@@ -10480,7 +10713,7 @@ var GameVehicles = (() => {
|
|
|
10480
10713
|
}
|
|
10481
10714
|
if (b >= 3) {
|
|
10482
10715
|
I.hurtEngine(c, b === 4 ? 0.05 : 0.25);
|
|
10483
|
-
kit.addEmitter(c, p.clone().add(new V3(0, 0.3, 0)), "
|
|
10716
|
+
kit.addEmitter(c, p.clone().add(new V3(0, 0.3, 0)), "oil", { rate: b === 4 ? 6 : 4, damage: () => 1 - (c.engineHealth ?? 1) });
|
|
10484
10717
|
if (land) I.puddle(c, "oil", p.clone().setY(Math.max(0.2, m.clearance || 0.3)), b === 4 ? 0.9 : 0.6);
|
|
10485
10718
|
}
|
|
10486
10719
|
if (b === 4) kit.addEmitter(c, p.clone().add(new V3(0, 0.15, 0)), "fire", { rate: 7, s: 0.7 });
|
|
@@ -12845,6 +13078,11 @@ var GameVehicles = (() => {
|
|
|
12845
13078
|
return c;
|
|
12846
13079
|
}
|
|
12847
13080
|
kit.dispose = function(c) {
|
|
13081
|
+
if (Array.isArray(c.vfxHandles) && c.vfxHandles.length > 0) {
|
|
13082
|
+
const effects = kit.effects?.();
|
|
13083
|
+
for (const handle of c.vfxHandles) effects?.stop?.(handle);
|
|
13084
|
+
c.vfxHandles = [];
|
|
13085
|
+
}
|
|
12848
13086
|
const shared = Object.values(I.PARTICLE_GEOMETRIES);
|
|
12849
13087
|
c.root.traverse(function(o) {
|
|
12850
13088
|
if (o.isSprite) {
|
|
@@ -13794,6 +14032,7 @@ var GameVehicles = (() => {
|
|
|
13794
14032
|
|
|
13795
14033
|
// src/destructible/visual.ts
|
|
13796
14034
|
var HOLE_DECAL_SCALE = 2.4;
|
|
14035
|
+
var HOLE_BATCH_CAPACITY = 64;
|
|
13797
14036
|
var DOOR_DEPTH = 0.07;
|
|
13798
14037
|
var DOOR_SKIN_DEPTH = 0.09;
|
|
13799
14038
|
var DOOR_FLOOR_DEPTH = 0.2;
|
|
@@ -13945,7 +14184,25 @@ var GameVehicles = (() => {
|
|
|
13945
14184
|
__publicField(this, "holdFrame", -1);
|
|
13946
14185
|
/** Normal smoothing still running, by mesh: a mesh cut again gets a new task and the old one is dropped. */
|
|
13947
14186
|
__publicField(this, "smoothing", /* @__PURE__ */ new Map());
|
|
14187
|
+
/** The bullet holes of one carrier and material, drawn as one instanced batch each (a door full of holes still draws as one). */
|
|
14188
|
+
__publicField(this, "holes", /* @__PURE__ */ new Map());
|
|
13948
14189
|
__publicField(this, "hood");
|
|
14190
|
+
/** What `pump` drains when no shared queue owns the smoothing: the same steps, timed by `drainDetached`. */
|
|
14191
|
+
__publicField(this, "pumpQueue", {
|
|
14192
|
+
id: DEFERRED_QUEUE_ID.VEHICLE_CREASE,
|
|
14193
|
+
pending: () => this.smoothing.size + (this.warming ? 1 : 0),
|
|
14194
|
+
run: (deadline, clock) => {
|
|
14195
|
+
let ran = 0;
|
|
14196
|
+
for (const [msh, task] of this.smoothing) {
|
|
14197
|
+
if (msh.geometry !== task.geo || task.step(deadline, clock)) this.smoothing.delete(msh);
|
|
14198
|
+
ran++;
|
|
14199
|
+
if (clock() >= deadline) return ran;
|
|
14200
|
+
}
|
|
14201
|
+
this.warmIndexes(deadline, clock);
|
|
14202
|
+
return ran + 1;
|
|
14203
|
+
},
|
|
14204
|
+
flush: () => this.finishAll()
|
|
14205
|
+
});
|
|
13949
14206
|
;
|
|
13950
14207
|
c.smoothLater = (mesh2) => this.smoothLater(mesh2);
|
|
13951
14208
|
this.kit = kit;
|
|
@@ -14048,7 +14305,7 @@ var GameVehicles = (() => {
|
|
|
14048
14305
|
if (!z) return;
|
|
14049
14306
|
const B = z.box;
|
|
14050
14307
|
const THREE = this.THREE;
|
|
14051
|
-
const
|
|
14308
|
+
const lining = this.I.makeMaterial(DOOR_CARD_COLOR, { roughness: 0.85 });
|
|
14052
14309
|
const grid = (a0, a1, b0, b1) => {
|
|
14053
14310
|
const out = [];
|
|
14054
14311
|
for (const fa of [0.25, 0.5, 0.75]) for (const fb of [0.3, 0.7]) out.push([a0 + (a1 - a0) * fa, b0 + (b1 - b0) * fb]);
|
|
@@ -14063,7 +14320,7 @@ var GameVehicles = (() => {
|
|
|
14063
14320
|
const hingeFront = z.hinge !== "rear";
|
|
14064
14321
|
const hx = hingeFront ? B.x1 - 0.03 : B.x0 + 0.03;
|
|
14065
14322
|
const cy = (B.y0 + B.y1) / 2;
|
|
14066
|
-
const recess = this.box(len - 0.04, hgt - 0.04, 0.01,
|
|
14323
|
+
const recess = this.box(len - 0.04, hgt - 0.04, 0.01, lining, (B.x0 + B.x1) / 2, cy, sk + s * 4e-3);
|
|
14067
14324
|
recess.userData.noFollow = true;
|
|
14068
14325
|
const piv = new THREE.Group();
|
|
14069
14326
|
piv.name = p.id;
|
|
@@ -14080,7 +14337,7 @@ var GameVehicles = (() => {
|
|
|
14080
14337
|
if (sk == null) return;
|
|
14081
14338
|
const wy = B.y1 - B.y0 - 0.1;
|
|
14082
14339
|
const wz = B.z1 - B.z0 - 0.1;
|
|
14083
|
-
const recess = this.box(0.01, wy - 0.04, wz - 0.04,
|
|
14340
|
+
const recess = this.box(0.01, wy - 0.04, wz - 0.04, lining, sk + 4e-3, (B.y0 + B.y1) / 2, 0);
|
|
14084
14341
|
recess.userData.noFollow = true;
|
|
14085
14342
|
const piv = new THREE.Group();
|
|
14086
14343
|
piv.name = p.id;
|
|
@@ -14104,16 +14361,16 @@ var GameVehicles = (() => {
|
|
|
14104
14361
|
if (busy) return;
|
|
14105
14362
|
const r = piv.rotation;
|
|
14106
14363
|
const open = Math.abs(r.x) + Math.abs(r.y) + Math.abs(r.z) > 1e-3 || this.gone.has(id) || piv.parent !== this.c.vehicle;
|
|
14107
|
-
if (open &&
|
|
14364
|
+
if (open && piv.parent === this.c.vehicle && !this.skins.has(id)) {
|
|
14108
14365
|
busy = true;
|
|
14109
14366
|
try {
|
|
14110
|
-
this.skins.set(id, this.takeSkin(id, piv));
|
|
14367
|
+
this.skins.set(id, this.takeSkin(id, piv, this.gone.has(id)));
|
|
14111
14368
|
} finally {
|
|
14112
14369
|
busy = false;
|
|
14113
14370
|
}
|
|
14114
14371
|
}
|
|
14115
14372
|
panel.visible = open && !this.skins.get(id);
|
|
14116
|
-
recess.visible = open && !this.skins.get(id);
|
|
14373
|
+
recess.visible = open && !this.skins.get(id) && !this.gone.has(id);
|
|
14117
14374
|
if (open) this.openNow.add(id);
|
|
14118
14375
|
else this.openNow.delete(id);
|
|
14119
14376
|
this.seams.forEach((doors, seam) => {
|
|
@@ -14139,7 +14396,7 @@ var GameVehicles = (() => {
|
|
|
14139
14396
|
* Cuts the skin of a door or lid zone out of the body (as the damage's hanging door does) and hangs it, with the thin parts on it (trim, handle) and, for a door, the side
|
|
14140
14397
|
* window over it, on the hinge. Done with the hinge closed, so every piece keeps its place; answers whether there was skin to take.
|
|
14141
14398
|
*/
|
|
14142
|
-
takeSkin(id, piv) {
|
|
14399
|
+
takeSkin(id, piv, torn = false) {
|
|
14143
14400
|
const p = this.byId.get(id);
|
|
14144
14401
|
const z = p && this.zone(p);
|
|
14145
14402
|
if (!p || !z) return false;
|
|
@@ -14159,7 +14416,8 @@ var GameVehicles = (() => {
|
|
|
14159
14416
|
this.doorTops.set(id, top);
|
|
14160
14417
|
const rect = [B.x0 + 0.03, B.x1 - 0.03, B.y0 + Math.min(0.08, (B.y1 - B.y0) * 0.1), top];
|
|
14161
14418
|
const pcs = I.cutPanel(this.c, z, rect, true, dirty, { anyN: true }).map((x) => x.mesh).filter((m) => !!m);
|
|
14162
|
-
this.
|
|
14419
|
+
if (torn) this.mendLater(dirty);
|
|
14420
|
+
else this.mend(dirty);
|
|
14163
14421
|
if (pcs.length) {
|
|
14164
14422
|
leaveDeepSkinOnBody(this.THREE, pcs, { toVehicle: inv, side: z.side < 0 ? -1 : 1, depth: DOOR_SKIN_DEPTH });
|
|
14165
14423
|
const panes = I.windowsOver(this.c, z, inv);
|
|
@@ -14874,19 +15132,44 @@ var GameVehicles = (() => {
|
|
|
14874
15132
|
const pane = part?.role === "glass" ? this.panesOf(part).find((g) => g.visible) : void 0;
|
|
14875
15133
|
if (part?.role === "glass" && (!pane || pane.userData.glass?.broken)) return;
|
|
14876
15134
|
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
15135
|
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
15136
|
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
|
-
|
|
15137
|
+
const parent = carrier ?? this.c.vehicle;
|
|
15138
|
+
const material = holeMaterial(this.kit, part?.material ?? "steel");
|
|
15139
|
+
const key = `${parent.uuid}|${material.uuid}`;
|
|
15140
|
+
let batches = this.holes.get(key);
|
|
15141
|
+
let batch = batches?.[batches.length - 1];
|
|
15142
|
+
if (!batch || batch.count >= HOLE_BATCH_CAPACITY) {
|
|
15143
|
+
batch = new THREE.InstancedMesh(holeDiscGeometry(THREE), material, HOLE_BATCH_CAPACITY);
|
|
15144
|
+
batch.count = 0;
|
|
15145
|
+
batch.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|
|
15146
|
+
batch.castShadow = false;
|
|
15147
|
+
batch.receiveShadow = false;
|
|
15148
|
+
batch.userData.decal = true;
|
|
15149
|
+
batch.userData.noFollow = true;
|
|
15150
|
+
batch.renderOrder = 3;
|
|
15151
|
+
batch.raycast = () => {
|
|
15152
|
+
};
|
|
15153
|
+
batch.frustumCulled = false;
|
|
15154
|
+
parent.add(batch);
|
|
15155
|
+
if (!batches) {
|
|
15156
|
+
batches = [];
|
|
15157
|
+
this.holes.set(key, batches);
|
|
15158
|
+
}
|
|
15159
|
+
batches.push(batch);
|
|
15160
|
+
}
|
|
15161
|
+
const at = this.c.vehicle.localToWorld(new THREE.Vector3(...point).addScaledVector(n, 3e-3));
|
|
15162
|
+
const toward = this.c.vehicle.localToWorld(new THREE.Vector3(...point).addScaledVector(n, 1.003));
|
|
15163
|
+
const pose = new THREE.Object3D();
|
|
15164
|
+
pose.position.copy(at);
|
|
15165
|
+
pose.scale.set(radius, radius, 1);
|
|
15166
|
+
pose.lookAt(toward);
|
|
15167
|
+
pose.updateMatrix();
|
|
15168
|
+
parent.updateWorldMatrix(true, false);
|
|
15169
|
+
const instance = new THREE.Matrix4().copy(parent.matrixWorld).invert().multiply(pose.matrix);
|
|
15170
|
+
batch.setMatrixAt(batch.count, instance);
|
|
15171
|
+
batch.count += 1;
|
|
15172
|
+
batch.instanceMatrix.needsUpdate = true;
|
|
14890
15173
|
}
|
|
14891
15174
|
/** The door or lid a hinge group stands for. */
|
|
14892
15175
|
/** 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 +15322,7 @@ var GameVehicles = (() => {
|
|
|
15039
15322
|
}
|
|
15040
15323
|
if (this.queued) return;
|
|
15041
15324
|
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);
|
|
15325
|
+
drainDetached(this.pumpQueue, budgetMs);
|
|
15048
15326
|
}
|
|
15049
15327
|
setQueued(isQueued) {
|
|
15050
15328
|
this.queued = isQueued;
|
|
@@ -15060,24 +15338,24 @@ var GameVehicles = (() => {
|
|
|
15060
15338
|
return this.smoothing.size + (this.warming ? 1 : 0);
|
|
15061
15339
|
}
|
|
15062
15340
|
/** One slice of the pending work, for the shared queue. */
|
|
15063
|
-
runStep(deadline) {
|
|
15341
|
+
runStep(deadline, clock) {
|
|
15064
15342
|
const next = this.smoothing.entries().next();
|
|
15065
15343
|
if (!next.done) {
|
|
15066
15344
|
const [msh, task] = next.value;
|
|
15067
|
-
if (msh.geometry !== task.geo || task.step(deadline)) this.smoothing.delete(msh);
|
|
15345
|
+
if (msh.geometry !== task.geo || task.step(deadline, clock)) this.smoothing.delete(msh);
|
|
15068
15346
|
return true;
|
|
15069
15347
|
}
|
|
15070
15348
|
if (!this.warming) return false;
|
|
15071
|
-
this.warmIndexes(deadline);
|
|
15349
|
+
this.warmIndexes(deadline, clock);
|
|
15072
15350
|
return true;
|
|
15073
15351
|
}
|
|
15074
15352
|
finishAll() {
|
|
15075
15353
|
while (this.runStep(Infinity)) ;
|
|
15076
15354
|
}
|
|
15077
15355
|
/** 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) {
|
|
15356
|
+
warmIndexes(deadline, clock) {
|
|
15079
15357
|
if (!this.warming) return;
|
|
15080
|
-
this.warming = this.warming.filter((msh) => !warmTriIndex(msh.geometry, deadline));
|
|
15358
|
+
this.warming = this.warming.filter((msh) => !warmTriIndex(msh.geometry, deadline, clock));
|
|
15081
15359
|
if (!this.warming.length) this.warming = null;
|
|
15082
15360
|
}
|
|
15083
15361
|
/** Moves the panel of a lost zone out of the body (the kit's torn-off look). */
|
|
@@ -15090,13 +15368,16 @@ var GameVehicles = (() => {
|
|
|
15090
15368
|
else this.I.panelBand(this.c, z, 4, dirty);
|
|
15091
15369
|
} catch {
|
|
15092
15370
|
}
|
|
15371
|
+
this.mendLater(dirty);
|
|
15372
|
+
this.gone.add(p.id);
|
|
15373
|
+
}
|
|
15374
|
+
mendLater(dirty) {
|
|
15093
15375
|
dirty.forEach((msh) => {
|
|
15094
15376
|
const g = msh.geometry;
|
|
15095
15377
|
if (g.userData.crease || !g.index) this.smoothLater(msh);
|
|
15096
15378
|
else g.computeVertexNormals();
|
|
15097
15379
|
this.I.refreshBounds(g);
|
|
15098
15380
|
});
|
|
15099
|
-
this.gone.add(p.id);
|
|
15100
15381
|
}
|
|
15101
15382
|
// ---- parts coming off --------------------------------------------------------------------------------------------------------------------
|
|
15102
15383
|
outward(p, away) {
|
|
@@ -15329,9 +15610,12 @@ var GameVehicles = (() => {
|
|
|
15329
15610
|
rim: 4
|
|
15330
15611
|
};
|
|
15331
15612
|
var BLUNT = { steel: 0.8, aluminium: 1, glass: 1.5, plastic: 1.2, rubber: 0.3 };
|
|
15613
|
+
var SHIELDED_REACH = 0.25;
|
|
15614
|
+
var DENSITY = { steel: 7850, aluminium: 2700, glass: 2500, plastic: 1100, rubber: 1100, wood_hard: 750, fabric: 400 };
|
|
15332
15615
|
var SHIELDED = /* @__PURE__ */ new Set(["engine", "gearbox", "frame", "radiator", "fuel_tank", "oil_pan", "battery", "alternator", "brakes", "steering", "shocks"]);
|
|
15333
15616
|
var AMBIENT = 20;
|
|
15334
15617
|
var FLAME = 700;
|
|
15618
|
+
var FIREBALL_NOTICE = 0.05;
|
|
15335
15619
|
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
15620
|
var ARMOUR_STEEL_MM = { IIIA: 4, III: 7 };
|
|
15337
15621
|
var SOFT_LEAD = 0.8;
|
|
@@ -15354,6 +15638,8 @@ var GameVehicles = (() => {
|
|
|
15354
15638
|
var TYRE_FLAT_AIR = 0.2;
|
|
15355
15639
|
var BRAKE_FLUID_NEEDED = 0.6;
|
|
15356
15640
|
var BRAKE_NO_FLUID = 0.15;
|
|
15641
|
+
var ENGINE_SMOKE_FROM = 0.85;
|
|
15642
|
+
var ENGINE_OIL_SMOKE_RATE = 4;
|
|
15357
15643
|
var ENGINE_WORKING_C = 90;
|
|
15358
15644
|
var ENGINE_SETTLE_S = 30;
|
|
15359
15645
|
var ENGINE_HEATING = 0.5;
|
|
@@ -15587,8 +15873,9 @@ var GameVehicles = (() => {
|
|
|
15587
15873
|
for (const j of js) if (!j.open && (j.def.a === d.id || j.def.b === d.id)) openJoint(j, "part_lost", out);
|
|
15588
15874
|
recomputeGroups();
|
|
15589
15875
|
};
|
|
15590
|
-
const damage = (p,
|
|
15591
|
-
if (p.lost || !(
|
|
15876
|
+
const damage = (p, hitAmount, dtype, source, out, cause, pieces = 1) => {
|
|
15877
|
+
if (p.lost || !(hitAmount > 0)) return;
|
|
15878
|
+
const amount = pieces > 1 ? Math.min(hitAmount * pieces, Math.max(hitAmount, p.hp)) : hitAmount;
|
|
15592
15879
|
const before = p.hp;
|
|
15593
15880
|
const crumples = dtype === "blunt" && CRUMPLES.has(p.def.role) && (p.def.material === "steel" || p.def.material === "aluminium");
|
|
15594
15881
|
const punctures = dtype === "ballistic" && p.def.role === "tyre";
|
|
@@ -15596,6 +15883,7 @@ var GameVehicles = (() => {
|
|
|
15596
15883
|
out.push(ev({ type: "damage", part: p.def.id, amount: r2(before - p.hp), hp: r2(p.hp), damageType: dtype, ...source ? { source } : {} }));
|
|
15597
15884
|
if (!punctures) wear(p, amount, out);
|
|
15598
15885
|
syncZone(p);
|
|
15886
|
+
if (vis && p.def.role === "engine" && p.hp < p.def.hp * ENGINE_SMOKE_FROM) smokeFromBay(p, "oil", ENGINE_OIL_SMOKE_RATE);
|
|
15599
15887
|
if (p.hp <= 0) lose(p, "broken", out, cause);
|
|
15600
15888
|
else if (p.def.role === "light") vis?.crackLight(p.def, dtype === "ballistic");
|
|
15601
15889
|
if (p.def.role === "tyre" && !p.flat && p.hp < p.def.hp * 0.6 && !p.lost) {
|
|
@@ -15680,6 +15968,10 @@ var GameVehicles = (() => {
|
|
|
15680
15968
|
const out3 = dirToWorld(new V3(dirLocal.x * 0.5, dirLocal.y * 0.5 - 0.6, dirLocal.z * 0.5));
|
|
15681
15969
|
out.push(ev({ type: "leak", part: d.id, fluid, point: toWorld(holePoint), direction: r3(out3), rate: r2(rate), pressurized: !!d.contains.pressurized }));
|
|
15682
15970
|
};
|
|
15971
|
+
const smokeFromBay = (p, kind, rate) => {
|
|
15972
|
+
const [x, y, z] = engineBayVent(p.def.box);
|
|
15973
|
+
kit.addEmitter(c, new V3(x, y, z), kind, { rate, damage: () => 1 - p.hp / p.def.hp });
|
|
15974
|
+
};
|
|
15683
15975
|
const centreOf = (d) => new V3(d.box.center[0], d.box.center[1], d.box.center[2]);
|
|
15684
15976
|
const ignite = (p, out) => {
|
|
15685
15977
|
if (p.burning || p.lost) return;
|
|
@@ -15689,22 +15981,37 @@ var GameVehicles = (() => {
|
|
|
15689
15981
|
if (!vis) return;
|
|
15690
15982
|
const cen = centreOf(d);
|
|
15691
15983
|
kit.addEmitter(c, cen.clone().add(new V3(0, 0.1, 0)), "fire", { rate: d.role === "tyre" ? 7 : 10, s: d.role === "tyre" ? 0.6 : 0.9 });
|
|
15692
|
-
|
|
15984
|
+
if (d.role === "engine") smokeFromBay(p, "black", 5);
|
|
15985
|
+
else kit.addEmitter(c, cen.clone().add(new V3(0, 0.6, 0)), "black", { rate: 4, s: 1.1 });
|
|
15693
15986
|
if (d.role === "fuel_tank" || d.role === "engine") {
|
|
15694
15987
|
const l = leaks.get("fuel_tank");
|
|
15695
15988
|
if (l?.pud && l.fluid === "fuel") I.igniteFuel(c, l.pud);
|
|
15696
15989
|
}
|
|
15697
15990
|
};
|
|
15698
|
-
const burningBlast = (centreLocal, radius, energy, source, out) => {
|
|
15991
|
+
const burningBlast = (centreLocal, radius, energy, source, out, tnt = energy * DEFAULT_BLAST_IMPULSE.tntPerJoule) => {
|
|
15992
|
+
let tank = 0;
|
|
15699
15993
|
for (const d of model.parts) {
|
|
15700
15994
|
const p = ps.get(d.id);
|
|
15701
15995
|
if (p.lost) continue;
|
|
15702
15996
|
const dist = distToBox(d, centreLocal);
|
|
15703
15997
|
if (dist > radius) continue;
|
|
15704
|
-
const
|
|
15705
|
-
|
|
15706
|
-
damage(p,
|
|
15998
|
+
const work = waveOn(d, centreLocal, dist, tnt);
|
|
15999
|
+
if (d.role === "fuel_tank") tank = work;
|
|
16000
|
+
damage(p, work * (BLUNT[d.material] ?? 1), "explosive", source, out);
|
|
15707
16001
|
}
|
|
16002
|
+
return tank;
|
|
16003
|
+
};
|
|
16004
|
+
const waveOn = (d, centreLocal, dist, tnt) => {
|
|
16005
|
+
const [sx, sy, sz] = d.box.size;
|
|
16006
|
+
const toward = new V3(centreLocal.x - d.box.center[0], centreLocal.y - d.box.center[1], centreLocal.z - d.box.center[2]);
|
|
16007
|
+
const length = toward.length();
|
|
16008
|
+
if (length > 1e-6) toward.multiplyScalar(1 / length);
|
|
16009
|
+
else toward.set(0, 1, 0);
|
|
16010
|
+
const area3 = Math.abs(toward.x) * sy * sz + Math.abs(toward.y) * sx * sz + Math.abs(toward.z) * sx * sy;
|
|
16011
|
+
const face = Math.max(sx * sy, sx * sz, sy * sz, 1e-6);
|
|
16012
|
+
const thickness = Math.min(Math.min(sx, sy, sz), d.mass / ((DENSITY[d.material] ?? 1e3) * face));
|
|
16013
|
+
const wave = waveWork({ tnt, distance: dist, reach: SHIELDED.has(d.role) ? SHIELDED_REACH : 1, area: area3, mass: Math.max(d.mass, 0.05), thickness });
|
|
16014
|
+
return wave.energy + wave.shock;
|
|
15708
16015
|
};
|
|
15709
16016
|
const explode = (tank, source, out) => {
|
|
15710
16017
|
if (exploded) return;
|
|
@@ -15714,7 +16021,7 @@ var GameVehicles = (() => {
|
|
|
15714
16021
|
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
16022
|
tank.liters = 0;
|
|
15716
16023
|
leaks.delete(d.id);
|
|
15717
|
-
if (vis) kit.explode(c, { delay: 0.6 });
|
|
16024
|
+
if (vis) kit.explode(c, { delay: 0.6, skipBlastEffect: true });
|
|
15718
16025
|
else c.blast = c.blast ?? { phase: "fire", t: 0, T: 0.6 };
|
|
15719
16026
|
lose(tank, "broken", out);
|
|
15720
16027
|
burningBlast(centreOf(d), spec.radius, spec.energy, source, out);
|
|
@@ -15808,6 +16115,7 @@ var GameVehicles = (() => {
|
|
|
15808
16115
|
const d = p.def;
|
|
15809
16116
|
const E = h.energy ?? 0;
|
|
15810
16117
|
const cal = h.caliber ?? 9;
|
|
16118
|
+
const pieces = h.pieces ?? 1;
|
|
15811
16119
|
const dir = dirToLocal(h.direction ?? [0, 0, -1]).normalize();
|
|
15812
16120
|
const n = h.normal ? dirToLocal(h.normal).normalize() : normalOf(d, v);
|
|
15813
16121
|
const res = resist(d, p);
|
|
@@ -15818,7 +16126,7 @@ var GameVehicles = (() => {
|
|
|
15818
16126
|
if (metal && !through && cosInc < 0.3 && E > 40) {
|
|
15819
16127
|
const refl = dir.clone().addScaledVector(n, -2 * dir.dot(n));
|
|
15820
16128
|
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);
|
|
16129
|
+
damage(p, E * 0.05, "ballistic", h.source, out, worldPoint, pieces);
|
|
15822
16130
|
vis?.spark([v.x, v.y, v.z], [refl.x, refl.y, refl.z], 6);
|
|
15823
16131
|
return;
|
|
15824
16132
|
}
|
|
@@ -15849,13 +16157,13 @@ var GameVehicles = (() => {
|
|
|
15849
16157
|
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
16158
|
p.cracks.push(crack);
|
|
15851
16159
|
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);
|
|
16160
|
+
damage(p, E * (armourLevel && !through ? armourLevel.glassTakes : 0.5), "ballistic", h.source, out, worldPoint, pieces);
|
|
16161
|
+
} else damage(p, laminated ? E * 0.5 : p.hp, "ballistic", h.source, out, worldPoint, laminated ? pieces : 1);
|
|
15854
16162
|
break;
|
|
15855
16163
|
}
|
|
15856
16164
|
case "rubber": {
|
|
15857
16165
|
push(through);
|
|
15858
|
-
damage(p, E * 0.4, "ballistic", h.source, out, worldPoint);
|
|
16166
|
+
damage(p, E * 0.4, "ballistic", h.source, out, worldPoint, pieces);
|
|
15859
16167
|
if (through && !p.lost && !p.flat) {
|
|
15860
16168
|
if (E >= TYRE_BURST_JOULES || cal >= TYRE_BURST_CALIBER) deflate(p, 1);
|
|
15861
16169
|
else p.airLoss += TYRE_LEAK_PER_MM2 * Math.PI * (cal / 2) ** 2;
|
|
@@ -15872,7 +16180,7 @@ var GameVehicles = (() => {
|
|
|
15872
16180
|
vis?.spark([v.x, v.y, v.z], [dir.x, dir.y, dir.z], through ? 4 : 8);
|
|
15873
16181
|
let amount = through ? E * 0.6 : E * 0.25;
|
|
15874
16182
|
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);
|
|
16183
|
+
damage(p, amount, "ballistic", h.source, out, worldPoint, pieces);
|
|
15876
16184
|
if (through && d.role === "fuel_tank") rollIgnition(p, h, metal, out);
|
|
15877
16185
|
}
|
|
15878
16186
|
}
|
|
@@ -15943,12 +16251,12 @@ var GameVehicles = (() => {
|
|
|
15943
16251
|
const nearest = Math.min(...model.parts.map((d) => distToBox(d, v)));
|
|
15944
16252
|
if (nearest > radius) return;
|
|
15945
16253
|
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);
|
|
16254
|
+
const tankWork = burningBlast(v, radius, E, h.source, out, h.tnt);
|
|
15947
16255
|
const tank = [...ps.values()].find((q) => q.def.role === "fuel_tank" && !q.lost);
|
|
15948
16256
|
if (tank && !exploded) {
|
|
15949
16257
|
const dist = distToBox(tank.def, v);
|
|
15950
16258
|
if (dist <= radius) {
|
|
15951
|
-
const verdict = kit.blastDamage(c,
|
|
16259
|
+
const verdict = kit.blastDamage(c, tankWork);
|
|
15952
16260
|
if (verdict === "explosion") explode(tank, h.source, out);
|
|
15953
16261
|
else if (verdict === "fire") {
|
|
15954
16262
|
light(tank, out);
|
|
@@ -15956,7 +16264,14 @@ var GameVehicles = (() => {
|
|
|
15956
16264
|
}
|
|
15957
16265
|
}
|
|
15958
16266
|
}
|
|
15959
|
-
|
|
16267
|
+
const fireball = h.fireball ?? chargeFireball(E * DEFAULT_BLAST_IMPULSE.tntPerJoule);
|
|
16268
|
+
for (const d of model.parts) {
|
|
16269
|
+
const p = ps.get(d.id);
|
|
16270
|
+
if (p.lost || !d.ignitionC) continue;
|
|
16271
|
+
const needed = ignitionDose(d.ignitionC, AMBIENT);
|
|
16272
|
+
const share = Math.min(1, fireballDose(fireball, distToBox(d, v)) / needed);
|
|
16273
|
+
if (share >= FIREBALL_NOTICE) p.temp = Math.max(p.temp, AMBIENT + (d.ignitionC + 1 - AMBIENT) * share);
|
|
16274
|
+
}
|
|
15960
16275
|
};
|
|
15961
16276
|
const fireHit = (h, out) => {
|
|
15962
16277
|
sync();
|
|
@@ -16352,6 +16667,7 @@ var GameVehicles = (() => {
|
|
|
16352
16667
|
joints: js.map((j) => [j.def.id, j.hp, j.progress, j.open, j.by ?? null])
|
|
16353
16668
|
}),
|
|
16354
16669
|
partName: (pid) => ps.get(pid)?.def.name ?? pid,
|
|
16670
|
+
objectsOf: (pid) => vis?.objectsOf(pid) ?? [],
|
|
16355
16671
|
status: computeStatus,
|
|
16356
16672
|
animations: () => createVehicleClips(model, vis, kit, c),
|
|
16357
16673
|
crumple: (point, direction, depth) => {
|
|
@@ -16397,7 +16713,7 @@ var GameVehicles = (() => {
|
|
|
16397
16713
|
if (oil < OIL_NEEDED) engine.hp = Math.max(0, engine.hp - engine.def.hp * OIL_WEAR * work * seconds * ((OIL_NEEDED - oil) / OIL_NEEDED));
|
|
16398
16714
|
if (engineHeat >= ENGINE_STEAM_C && vis && !steaming) {
|
|
16399
16715
|
steaming = true;
|
|
16400
|
-
|
|
16716
|
+
smokeFromBay(engine, "white", 8);
|
|
16401
16717
|
}
|
|
16402
16718
|
if (engineHeat >= ENGINE_SEIZE_C || engine.hp <= engine.def.hp * ENGINE_SEIZE_HP) {
|
|
16403
16719
|
seized = true;
|
|
@@ -16467,7 +16783,7 @@ var GameVehicles = (() => {
|
|
|
16467
16783
|
if (ran > 0 && clock() >= deadline) break;
|
|
16468
16784
|
const work = tracked[cursor % tracked.length];
|
|
16469
16785
|
cursor = (cursor + 1) % tracked.length;
|
|
16470
|
-
if (work.pendingUnits(lastFrame) > 0 && work.runStep(deadline)) {
|
|
16786
|
+
if (work.pendingUnits(lastFrame) > 0 && work.runStep(deadline, clock)) {
|
|
16471
16787
|
ran++;
|
|
16472
16788
|
skipped = 0;
|
|
16473
16789
|
} else skipped++;
|
|
@@ -16612,6 +16928,131 @@ var GameVehicles = (() => {
|
|
|
16612
16928
|
leak
|
|
16613
16929
|
};
|
|
16614
16930
|
}
|
|
16931
|
+
|
|
16932
|
+
// src/data/cabin.json
|
|
16933
|
+
var cabin_default = {
|
|
16934
|
+
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)",
|
|
16935
|
+
entryDuckFactor: 0.44,
|
|
16936
|
+
categories: {
|
|
16937
|
+
passenger_car: {
|
|
16938
|
+
frontHeadroomMetres: 0.95,
|
|
16939
|
+
rearHeadroomMetres: 0.9,
|
|
16940
|
+
frontLegroomMetres: 0.62,
|
|
16941
|
+
widthMetres: 0.52,
|
|
16942
|
+
door: { widthMetres: 0.65, heightMetres: 0.8 }
|
|
16943
|
+
},
|
|
16944
|
+
suv_pickup: {
|
|
16945
|
+
frontHeadroomMetres: 0.98,
|
|
16946
|
+
rearHeadroomMetres: 0.93,
|
|
16947
|
+
frontLegroomMetres: 0.64,
|
|
16948
|
+
widthMetres: 0.54,
|
|
16949
|
+
door: { widthMetres: 0.7, heightMetres: 0.82 }
|
|
16950
|
+
},
|
|
16951
|
+
van: {
|
|
16952
|
+
frontHeadroomMetres: 1.05,
|
|
16953
|
+
rearHeadroomMetres: 1.05,
|
|
16954
|
+
frontLegroomMetres: 0.65,
|
|
16955
|
+
widthMetres: 0.54,
|
|
16956
|
+
door: { widthMetres: 0.75, heightMetres: 0.95 }
|
|
16957
|
+
},
|
|
16958
|
+
truck: {
|
|
16959
|
+
frontHeadroomMetres: 1,
|
|
16960
|
+
rearHeadroomMetres: 1,
|
|
16961
|
+
frontLegroomMetres: 0.62,
|
|
16962
|
+
widthMetres: 0.52,
|
|
16963
|
+
door: { widthMetres: 0.65, heightMetres: 0.85 }
|
|
16964
|
+
},
|
|
16965
|
+
bus: {
|
|
16966
|
+
frontHeadroomMetres: 1.2,
|
|
16967
|
+
rearHeadroomMetres: 1.2,
|
|
16968
|
+
frontLegroomMetres: 0.62,
|
|
16969
|
+
widthMetres: 0.5,
|
|
16970
|
+
door: { widthMetres: 0.7, heightMetres: 1.75 }
|
|
16971
|
+
},
|
|
16972
|
+
agricultural: {
|
|
16973
|
+
frontHeadroomMetres: 1.05,
|
|
16974
|
+
rearHeadroomMetres: null,
|
|
16975
|
+
frontLegroomMetres: 0.62,
|
|
16976
|
+
widthMetres: 0.52,
|
|
16977
|
+
door: { widthMetres: 0.65, heightMetres: 0.9 }
|
|
16978
|
+
},
|
|
16979
|
+
military_light: {
|
|
16980
|
+
frontHeadroomMetres: 0.95,
|
|
16981
|
+
rearHeadroomMetres: 0.92,
|
|
16982
|
+
frontLegroomMetres: 0.62,
|
|
16983
|
+
widthMetres: 0.5,
|
|
16984
|
+
door: { widthMetres: 0.6, heightMetres: 0.8 }
|
|
16985
|
+
},
|
|
16986
|
+
military_armored: {
|
|
16987
|
+
frontHeadroomMetres: 0.88,
|
|
16988
|
+
rearHeadroomMetres: 0.88,
|
|
16989
|
+
frontLegroomMetres: 0.58,
|
|
16990
|
+
widthMetres: 0.46,
|
|
16991
|
+
door: { widthMetres: 0.5, heightMetres: 0.55 }
|
|
16992
|
+
},
|
|
16993
|
+
open_vehicle: {
|
|
16994
|
+
frontHeadroomMetres: null,
|
|
16995
|
+
rearHeadroomMetres: null,
|
|
16996
|
+
frontLegroomMetres: null,
|
|
16997
|
+
widthMetres: null,
|
|
16998
|
+
door: null
|
|
16999
|
+
},
|
|
17000
|
+
boat_cabin: {
|
|
17001
|
+
frontHeadroomMetres: 1.05,
|
|
17002
|
+
rearHeadroomMetres: 1.05,
|
|
17003
|
+
frontLegroomMetres: 0.62,
|
|
17004
|
+
widthMetres: 0.52,
|
|
17005
|
+
door: { widthMetres: 0.6, heightMetres: 0.9 }
|
|
17006
|
+
},
|
|
17007
|
+
aircraft_enclosed: {
|
|
17008
|
+
frontHeadroomMetres: 0.95,
|
|
17009
|
+
rearHeadroomMetres: 0.92,
|
|
17010
|
+
frontLegroomMetres: 0.62,
|
|
17011
|
+
widthMetres: 0.48,
|
|
17012
|
+
door: { widthMetres: 0.55, heightMetres: 0.8 }
|
|
17013
|
+
}
|
|
17014
|
+
}
|
|
17015
|
+
};
|
|
17016
|
+
|
|
17017
|
+
// src/cabin.ts
|
|
17018
|
+
var CABIN_CATEGORIES = [
|
|
17019
|
+
"passenger_car",
|
|
17020
|
+
"suv_pickup",
|
|
17021
|
+
"van",
|
|
17022
|
+
"truck",
|
|
17023
|
+
"bus",
|
|
17024
|
+
"agricultural",
|
|
17025
|
+
"military_light",
|
|
17026
|
+
"military_armored",
|
|
17027
|
+
"open_vehicle",
|
|
17028
|
+
"boat_cabin",
|
|
17029
|
+
"aircraft_enclosed"
|
|
17030
|
+
];
|
|
17031
|
+
var toClearance = (value) => value === null ? Number.POSITIVE_INFINITY : value;
|
|
17032
|
+
var toCabinMinimum = (category, raw) => {
|
|
17033
|
+
if (category === "open_vehicle") {
|
|
17034
|
+
return {
|
|
17035
|
+
frontHeadroomMetres: Number.POSITIVE_INFINITY,
|
|
17036
|
+
rearHeadroomMetres: Number.POSITIVE_INFINITY,
|
|
17037
|
+
frontLegroomMetres: Number.POSITIVE_INFINITY,
|
|
17038
|
+
widthMetres: Number.POSITIVE_INFINITY,
|
|
17039
|
+
door: void 0
|
|
17040
|
+
};
|
|
17041
|
+
}
|
|
17042
|
+
return {
|
|
17043
|
+
frontHeadroomMetres: toClearance(raw.frontHeadroomMetres),
|
|
17044
|
+
rearHeadroomMetres: raw.rearHeadroomMetres === null ? void 0 : raw.rearHeadroomMetres,
|
|
17045
|
+
frontLegroomMetres: toClearance(raw.frontLegroomMetres),
|
|
17046
|
+
widthMetres: toClearance(raw.widthMetres),
|
|
17047
|
+
door: raw.door === null ? void 0 : { widthMetres: raw.door.widthMetres, heightMetres: raw.door.heightMetres }
|
|
17048
|
+
};
|
|
17049
|
+
};
|
|
17050
|
+
var CABIN_SOURCE = cabin_default.source;
|
|
17051
|
+
var ENTRY_DUCK_FACTOR = cabin_default.entryDuckFactor;
|
|
17052
|
+
var CABIN_MINIMUMS = Object.fromEntries(
|
|
17053
|
+
CABIN_CATEGORIES.map((category) => [category, toCabinMinimum(category, cabin_default.categories[category])])
|
|
17054
|
+
);
|
|
17055
|
+
var cabinMinimumOf = (category) => CABIN_MINIMUMS[category];
|
|
16615
17056
|
return __toCommonJS(index_exports);
|
|
16616
17057
|
})();
|
|
16617
17058
|
//# sourceMappingURL=index.global.js.map
|