@adatechnology/game-vehicles 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +55 -1
- package/dist/index.global.js +336 -73
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +336 -73
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2060,6 +2060,58 @@ interface VehicleKit {
|
|
|
2060
2060
|
*/
|
|
2061
2061
|
declare function createVehicleKit(options: VehicleKitOptions): VehicleKit;
|
|
2062
2062
|
|
|
2063
|
+
/**
|
|
2064
|
+
* The mark a round leaves in a vehicle's skin, from the round itself (calibre, mass, energy, how it met the panel) and the panel's material: no table per weapon.
|
|
2065
|
+
* A pistol round punches a clean hole with a tight dimple, a rifle round a small sharp hole with torn petals and a wide ring of chipped paint, a slug or a heavy
|
|
2066
|
+
* calibre a big ragged hole with the sheet pushed in, a shotgun pellet that stops a dimple without a bore, and a round at a slant a long gouge.
|
|
2067
|
+
*/
|
|
2068
|
+
/** What the mark looks like: drives the drawing of the mark (texture, size, stretch). */
|
|
2069
|
+
type HoleStyle = 'round' | 'petalled' | 'ragged' | 'dimple' | 'gouge';
|
|
2070
|
+
interface BulletHoleInput {
|
|
2071
|
+
/** Diameter of the round, millimetres (`Hit.caliber`). */
|
|
2072
|
+
readonly caliberMm: number;
|
|
2073
|
+
/** Kinetic energy at the panel, joules. */
|
|
2074
|
+
readonly energy: number;
|
|
2075
|
+
/** Mass of the round, grams (`Hit.mass`); without it the speed is not known and the mark goes by calibre. */
|
|
2076
|
+
readonly massGrams?: number;
|
|
2077
|
+
/** |cos| of the angle between the round's path and the panel's normal: 1 square on, 0 along the panel. */
|
|
2078
|
+
readonly cosIncidence: number;
|
|
2079
|
+
/** The round went through the panel. */
|
|
2080
|
+
readonly through: boolean;
|
|
2081
|
+
/** The panel's material (`steel`, `aluminium`, `glass`, `plastic`, `rubber`). */
|
|
2082
|
+
readonly material: string;
|
|
2083
|
+
/** The bore the panel already took (`holeDiam` of the impl, with a soft point's spread), metres. */
|
|
2084
|
+
readonly boreDiameter: number;
|
|
2085
|
+
}
|
|
2086
|
+
interface BulletHoleShape {
|
|
2087
|
+
readonly style: HoleStyle;
|
|
2088
|
+
/** Diameter of the dark bore, metres (0: no bore, the sheet is only dented or scraped). */
|
|
2089
|
+
readonly boreDiameter: number;
|
|
2090
|
+
/** Diameter of the whole mark across (bare metal and chipped paint around the bore), metres. */
|
|
2091
|
+
readonly markDiameter: number;
|
|
2092
|
+
/** How far the sheet is pushed in at the middle, metres. */
|
|
2093
|
+
readonly dentDepth: number;
|
|
2094
|
+
/** Length over width of the mark, along the round's path on the panel (1: round). */
|
|
2095
|
+
readonly elongation: number;
|
|
2096
|
+
/** Torn petals of sheet around the bore (0: a clean edge). */
|
|
2097
|
+
readonly petals: number;
|
|
2098
|
+
}
|
|
2099
|
+
/** Below this |cos| the round meets the panel at a slant (more than ~63° off square): it scrapes a gouge instead of a round hole. */
|
|
2100
|
+
declare const GOUGE_COS = 0.45;
|
|
2101
|
+
/** A round faster than this, metres per second, is a rifle round: its shock tears the sheet and chips the paint wide. */
|
|
2102
|
+
declare const RIFLE_SPEED = 600;
|
|
2103
|
+
/**
|
|
2104
|
+
* Without the round's mass (a world's shot carries the calibre and the energy only): a round carrying this many joules per square millimetre of its
|
|
2105
|
+
* cross-section is a rifle round (5.56 about 70, 7.62x39 about 40, .30-30 about 45; 9 mm about 8, .44 Magnum about 16, a 12 ga slug about 11).
|
|
2106
|
+
*/
|
|
2107
|
+
declare const RIFLE_ENERGY_DENSITY = 35;
|
|
2108
|
+
/** A round this wide or wider, millimetres, is a slug or a heavy calibre: a big ragged hole. */
|
|
2109
|
+
declare const HEAVY_CALIBER_MM = 12;
|
|
2110
|
+
/** The style of the mark from the round and how it met the panel. */
|
|
2111
|
+
declare function holeStyleOf(input: BulletHoleInput): HoleStyle;
|
|
2112
|
+
/** The size and shape of the mark (see {@link BulletHoleShape}). */
|
|
2113
|
+
declare function bulletHoleShape(input: BulletHoleInput): BulletHoleShape;
|
|
2114
|
+
|
|
2063
2115
|
/** Build states: new English name -> original seed text. */
|
|
2064
2116
|
declare const LEGACY_STATES: Record<string, string>;
|
|
2065
2117
|
/** Salts mixed into the seed of each phase of `applyZones`. */
|
|
@@ -2233,6 +2285,8 @@ interface PartDef {
|
|
|
2233
2285
|
material: MaterialId;
|
|
2234
2286
|
box: LocalBox;
|
|
2235
2287
|
mass: number;
|
|
2288
|
+
/** Where the part's mass sits, in the vehicle's space, when it is not the middle of its box: the synthetic chassis of a vehicle with no underbody zone holds the shell its box spans, and its weight sits over what the vehicle stands on. */
|
|
2289
|
+
massCentre?: Vec3;
|
|
2236
2290
|
/** Energy in joules that wrecks the part. */
|
|
2237
2291
|
hp: number;
|
|
2238
2292
|
/** The damage zone this part is, when it is one. */
|
|
@@ -2634,4 +2688,4 @@ declare const hullVolume: (points: ArrayLike<number>, faces: readonly HullFace[]
|
|
|
2634
2688
|
*/
|
|
2635
2689
|
declare const reducePoints: (points: ArrayLike<number>, max: number) => number[];
|
|
2636
2690
|
|
|
2637
|
-
export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BayBox, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BusRowsOptions, CABIN_CATEGORIES, CABIN_LEAK, CABIN_MINIMUMS, CABIN_SOURCE, CRASH_RULES, type CabinBox, type CabinCategory, type CabinDoorMinimum, type CabinEnclosureOptions, type CabinMinimum, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, CutNode, type CutTest, DOOR_SHELL_DEPTH, DOOR_SHELL_MAX_DEPTH, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DoorShellParams, type DoorShellResult, type DriveReport, ENTRY_DUCK_FACTOR, type EngineBaySpec, type ExplodeOptions, FLOATING_AREA, type FlagEffect, type FluidDefinition, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, type HeadlightLens, type HeadlightOptions, type HullFace, type HullPlan, HullSoup, type ImpactOptions, type InteriorOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LabelArgument, type LocalBox, type LocaleStrings, type LodSettings, type LoftRow, type LoftStation, type OverallHealth, PLUME_PUFFS, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartSink, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, RAIN_MOVE_STEP, RAIN_OPENING_DIAMETER, RAIN_TURN_STEP, type ResolvedConfiguration, type RollState, SEED_SALTS, SMOKE_LOOKS, SMOKE_WIND, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, SmokeCause, type SmokeLook, type SmokePuff, type SmokePuffParams, type SmoothLoftOptions, type Splat, type SplatOptions, type StrayLamp, type TaillightOptions, type ThreeObject, type ThreeVector, type Translate, type TumbleSpec, type UiHelpers, type UnderbodySpec, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleLamp, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleRainCover, type VehicleRainCoverOptions, type VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, cabinMinimumOf, clamp, convexFaces, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, createVehicleRainCover, defaultDamageableKinds, defaultLodSettings, doorShell, engineBayVent, format, hash, hullVolume, legacyGlassId, legacyLightId, legacyZoneId, listLocales, newHullPlan, openEdgeCount, planDivision, reducePoints, registerLegacySeeds, registerLocale, resolveStrings, rng, smokeCauseOfEmitter, smokePuff, smokeRate, smooth, strHash, strayLampsOf, swingOf, wrapThreeForLod };
|
|
2691
|
+
export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BayBox, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BulletHoleInput, type BulletHoleShape, type BusRowsOptions, CABIN_CATEGORIES, CABIN_LEAK, CABIN_MINIMUMS, CABIN_SOURCE, CRASH_RULES, type CabinBox, type CabinCategory, type CabinDoorMinimum, type CabinEnclosureOptions, type CabinMinimum, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, CutNode, type CutTest, DOOR_SHELL_DEPTH, DOOR_SHELL_MAX_DEPTH, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DoorShellParams, type DoorShellResult, type DriveReport, ENTRY_DUCK_FACTOR, type EngineBaySpec, type ExplodeOptions, FLOATING_AREA, type FlagEffect, type FluidDefinition, GOUGE_COS, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, HEAVY_CALIBER_MM, type HeadlightLens, type HeadlightOptions, type HoleStyle, type HullFace, type HullPlan, HullSoup, type ImpactOptions, type InteriorOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LabelArgument, type LocalBox, type LocaleStrings, type LodSettings, type LoftRow, type LoftStation, type OverallHealth, PLUME_PUFFS, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartSink, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, RAIN_MOVE_STEP, RAIN_OPENING_DIAMETER, RAIN_TURN_STEP, RIFLE_ENERGY_DENSITY, RIFLE_SPEED, type ResolvedConfiguration, type RollState, SEED_SALTS, SMOKE_LOOKS, SMOKE_WIND, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, SmokeCause, type SmokeLook, type SmokePuff, type SmokePuffParams, type SmoothLoftOptions, type Splat, type SplatOptions, type StrayLamp, type TaillightOptions, type ThreeObject, type ThreeVector, type Translate, type TumbleSpec, type UiHelpers, type UnderbodySpec, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleLamp, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleRainCover, type VehicleRainCoverOptions, type VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, bulletHoleShape, cabinBoxOf, cabinEnclosure, cabinMinimumOf, clamp, convexFaces, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, createVehicleRainCover, defaultDamageableKinds, defaultLodSettings, doorShell, engineBayVent, format, hash, holeStyleOf, hullVolume, legacyGlassId, legacyLightId, legacyZoneId, listLocales, newHullPlan, openEdgeCount, planDivision, reducePoints, registerLegacySeeds, registerLocale, resolveStrings, rng, smokeCauseOfEmitter, smokePuff, smokeRate, smooth, strHash, strayLampsOf, swingOf, wrapThreeForLod };
|
package/dist/index.global.js
CHANGED
|
@@ -34,6 +34,8 @@ var GameVehicles = (() => {
|
|
|
34
34
|
ENTRY_DUCK_FACTOR: () => ENTRY_DUCK_FACTOR,
|
|
35
35
|
FLAT_PAD: () => FLAT_PAD,
|
|
36
36
|
FLOATING_AREA: () => FLOATING_AREA,
|
|
37
|
+
GOUGE_COS: () => GOUGE_COS,
|
|
38
|
+
HEAVY_CALIBER_MM: () => HEAVY_CALIBER_MM,
|
|
37
39
|
JOINT_RULES: () => JOINT_RULES,
|
|
38
40
|
LEGACY_STATES: () => LEGACY_STATES,
|
|
39
41
|
LEGACY_ZONE_IDS: () => LEGACY_ZONE_IDS,
|
|
@@ -42,6 +44,8 @@ var GameVehicles = (() => {
|
|
|
42
44
|
RAIN_MOVE_STEP: () => RAIN_MOVE_STEP,
|
|
43
45
|
RAIN_OPENING_DIAMETER: () => RAIN_OPENING_DIAMETER,
|
|
44
46
|
RAIN_TURN_STEP: () => RAIN_TURN_STEP,
|
|
47
|
+
RIFLE_ENERGY_DENSITY: () => RIFLE_ENERGY_DENSITY,
|
|
48
|
+
RIFLE_SPEED: () => RIFLE_SPEED,
|
|
45
49
|
SEED_SALTS: () => SEED_SALTS,
|
|
46
50
|
SMOKE_LOOKS: () => SMOKE_LOOKS,
|
|
47
51
|
SMOKE_WIND: () => SMOKE_WIND,
|
|
@@ -49,6 +53,7 @@ var GameVehicles = (() => {
|
|
|
49
53
|
armourLevelOf: () => armourLevelOf,
|
|
50
54
|
buildVehicleItem: () => buildVehicleItem,
|
|
51
55
|
buildVehicleModel: () => buildVehicleModel,
|
|
56
|
+
bulletHoleShape: () => bulletHoleShape,
|
|
52
57
|
cabinBoxOf: () => cabinBoxOf,
|
|
53
58
|
cabinEnclosure: () => cabinEnclosure,
|
|
54
59
|
cabinMinimumOf: () => cabinMinimumOf,
|
|
@@ -69,6 +74,7 @@ var GameVehicles = (() => {
|
|
|
69
74
|
engineBayVent: () => engineBayVent,
|
|
70
75
|
format: () => format,
|
|
71
76
|
hash: () => hash,
|
|
77
|
+
holeStyleOf: () => holeStyleOf,
|
|
72
78
|
hullOf: () => hullOf,
|
|
73
79
|
hullPlanKind: () => hullPlanKind,
|
|
74
80
|
hullVolume: () => hullVolume,
|
|
@@ -13192,8 +13198,8 @@ var GameVehicles = (() => {
|
|
|
13192
13198
|
};
|
|
13193
13199
|
}
|
|
13194
13200
|
kit.lodHiddenMaterials = function() {
|
|
13195
|
-
const
|
|
13196
|
-
return new Set(lod.hiddenMaterials.map((name) =>
|
|
13201
|
+
const materials2 = kit.materials;
|
|
13202
|
+
return new Set(lod.hiddenMaterials.map((name) => materials2[name]).filter(Boolean));
|
|
13197
13203
|
};
|
|
13198
13204
|
}
|
|
13199
13205
|
|
|
@@ -13524,6 +13530,52 @@ var GameVehicles = (() => {
|
|
|
13524
13530
|
return kit;
|
|
13525
13531
|
}
|
|
13526
13532
|
|
|
13533
|
+
// src/hole-shape.ts
|
|
13534
|
+
var GOUGE_COS = 0.45;
|
|
13535
|
+
var RIFLE_SPEED = 600;
|
|
13536
|
+
var RIFLE_ENERGY_DENSITY = 35;
|
|
13537
|
+
var HEAVY_CALIBER_MM = 12;
|
|
13538
|
+
var LONGEST_GOUGE = 4;
|
|
13539
|
+
var SHORTEST_GOUGE = 1.5;
|
|
13540
|
+
var SHEET_METALS = /* @__PURE__ */ new Set(["steel", "aluminium"]);
|
|
13541
|
+
function speedOf(input) {
|
|
13542
|
+
const mass = input.massGrams;
|
|
13543
|
+
if (!mass || mass <= 0 || input.energy <= 0) return void 0;
|
|
13544
|
+
return Math.sqrt(2 * input.energy / (mass / 1e3));
|
|
13545
|
+
}
|
|
13546
|
+
function isRifleRound(input) {
|
|
13547
|
+
const speed = speedOf(input);
|
|
13548
|
+
if (speed !== void 0) return speed >= RIFLE_SPEED;
|
|
13549
|
+
const area3 = Math.PI * (input.caliberMm / 2) ** 2;
|
|
13550
|
+
return area3 > 0 && input.energy / area3 >= RIFLE_ENERGY_DENSITY;
|
|
13551
|
+
}
|
|
13552
|
+
function holeStyleOf(input) {
|
|
13553
|
+
const sheet = SHEET_METALS.has(input.material);
|
|
13554
|
+
if (sheet && input.cosIncidence < GOUGE_COS) return "gouge";
|
|
13555
|
+
if (!input.through) return "dimple";
|
|
13556
|
+
if (input.caliberMm >= HEAVY_CALIBER_MM) return "ragged";
|
|
13557
|
+
return sheet && isRifleRound(input) ? "petalled" : "round";
|
|
13558
|
+
}
|
|
13559
|
+
function bulletHoleShape(input) {
|
|
13560
|
+
const style = holeStyleOf(input);
|
|
13561
|
+
const bore = Math.max(3e-3, input.boreDiameter);
|
|
13562
|
+
const caliber = input.caliberMm / 1e3;
|
|
13563
|
+
switch (style) {
|
|
13564
|
+
case "gouge": {
|
|
13565
|
+
const elongation = Math.min(LONGEST_GOUGE, Math.max(SHORTEST_GOUGE, 1 / Math.max(input.cosIncidence, 0.05)));
|
|
13566
|
+
return { style, boreDiameter: input.through ? bore * 0.6 : 0, markDiameter: caliber * 1.8, dentDepth: caliber * 0.12, elongation, petals: 0 };
|
|
13567
|
+
}
|
|
13568
|
+
case "dimple":
|
|
13569
|
+
return { style, boreDiameter: 0, markDiameter: caliber * 1.9, dentDepth: caliber * 0.25, elongation: 1, petals: 0 };
|
|
13570
|
+
case "ragged":
|
|
13571
|
+
return { style, boreDiameter: bore * 1.15, markDiameter: bore * 2.6, dentDepth: caliber * 0.35, elongation: 1, petals: 7 };
|
|
13572
|
+
case "petalled":
|
|
13573
|
+
return { style, boreDiameter: bore, markDiameter: bore * 3.4, dentDepth: caliber * 0.18, elongation: 1, petals: 5 };
|
|
13574
|
+
default:
|
|
13575
|
+
return { style, boreDiameter: bore, markDiameter: bore * 2.2, dentDepth: caliber * 0.15, elongation: 1, petals: 0 };
|
|
13576
|
+
}
|
|
13577
|
+
}
|
|
13578
|
+
|
|
13527
13579
|
// src/stray-lamps.ts
|
|
13528
13580
|
var END_DEPTH = 0.45;
|
|
13529
13581
|
var LAMP_EMISSIVE_MIN = 0.25;
|
|
@@ -13713,6 +13765,26 @@ var GameVehicles = (() => {
|
|
|
13713
13765
|
return meta.armored || meta.bullet ? "III" : null;
|
|
13714
13766
|
}
|
|
13715
13767
|
|
|
13768
|
+
// src/destructible/support-span.ts
|
|
13769
|
+
var SUPPORT_BAND_M = 0.12;
|
|
13770
|
+
function supportSpanOf(vehicle, inverse) {
|
|
13771
|
+
const boxes = [];
|
|
13772
|
+
vehicle.traverse((node) => {
|
|
13773
|
+
const mesh2 = node;
|
|
13774
|
+
if (!mesh2.isMesh || mesh2.userData.decal || !mesh2.geometry) return;
|
|
13775
|
+
mesh2.geometry.computeBoundingBox();
|
|
13776
|
+
const bounds = mesh2.geometry.boundingBox;
|
|
13777
|
+
if (!bounds) return;
|
|
13778
|
+
const box2 = bounds.clone().applyMatrix4(mesh2.matrixWorld).applyMatrix4(inverse);
|
|
13779
|
+
if (box2.isEmpty()) return;
|
|
13780
|
+
boxes.push({ minX: box2.min.x, maxX: box2.max.x, minY: box2.min.y });
|
|
13781
|
+
});
|
|
13782
|
+
if (boxes.length === 0) return void 0;
|
|
13783
|
+
const ground = Math.min(...boxes.map((box2) => box2.minY));
|
|
13784
|
+
const resting = boxes.filter((box2) => box2.minY <= ground + SUPPORT_BAND_M);
|
|
13785
|
+
return { rear: Math.min(...resting.map((box2) => box2.minX)), front: Math.max(...resting.map((box2) => box2.maxX)) };
|
|
13786
|
+
}
|
|
13787
|
+
|
|
13716
13788
|
// src/destructible/model.ts
|
|
13717
13789
|
var JOINT_RULES = {
|
|
13718
13790
|
hinge: { strength: 5e3, tools: ["wrench", "screwdriver"], seconds: 3 },
|
|
@@ -13992,12 +14064,15 @@ var GameVehicles = (() => {
|
|
|
13992
14064
|
}
|
|
13993
14065
|
if (!hubZone) {
|
|
13994
14066
|
const h = Math.max(0.15, belt - clearance);
|
|
14067
|
+
const box2 = floorPan({ center: [(F + R) / 2, clearance + h * 0.45, 0], size: [Math.max(0.4, L * 0.8), h * 0.7, Math.max(0.2, W * 0.9)] });
|
|
14068
|
+
const support = supportSpanOf(c.vehicle, inverse);
|
|
13995
14069
|
add({
|
|
13996
14070
|
id: hubId,
|
|
13997
14071
|
role: "frame",
|
|
13998
14072
|
name: t("mechanics.chassis"),
|
|
13999
14073
|
material: "steel",
|
|
14000
|
-
box:
|
|
14074
|
+
box: box2,
|
|
14075
|
+
...support ? { massCentre: [(support.front + support.rear) / 2, box2.center[1], box2.center[2]] } : {},
|
|
14001
14076
|
mass: mass * 0.25,
|
|
14002
14077
|
hp: 15e4 * armour,
|
|
14003
14078
|
visual: false,
|
|
@@ -14597,8 +14672,185 @@ var GameVehicles = (() => {
|
|
|
14597
14672
|
return [tub, seal];
|
|
14598
14673
|
}
|
|
14599
14674
|
|
|
14675
|
+
// src/destructible/hole-mark.ts
|
|
14676
|
+
var TEXTURE_SIZE = 128;
|
|
14677
|
+
var DISC_RINGS = [0, 0.18, 0.34, 0.5, 0.66, 0.82, 1];
|
|
14678
|
+
var DISC_SPOKES = 24;
|
|
14679
|
+
var BOWL_LEAN = 0.85;
|
|
14680
|
+
var BOWL_REACH = 0.9;
|
|
14681
|
+
var BARE = { steel: "#a9aeb2", aluminium: "#cfd3d6", plastic: "#d9d6cc", rubber: "#141414", glass: "#eef3f5" };
|
|
14682
|
+
var STEEL_BARE = "#a9aeb2";
|
|
14683
|
+
var PRIMER = "#7d8285";
|
|
14684
|
+
var PETAL_TIP = 0.62;
|
|
14685
|
+
var PETAL_WIDTH = 0.42;
|
|
14686
|
+
var PETAL_SHADE = "#6f7478";
|
|
14687
|
+
var BORE_SHARE = { round: 0.45, petalled: 0.3, ragged: 0.44, dimple: 0, gouge: 0.2 };
|
|
14688
|
+
var materials = /* @__PURE__ */ new WeakMap();
|
|
14689
|
+
var disc = null;
|
|
14690
|
+
function holeMarkGeometry(THREE) {
|
|
14691
|
+
if (disc) return disc;
|
|
14692
|
+
const positions = [];
|
|
14693
|
+
const normals = [];
|
|
14694
|
+
const uvs = [];
|
|
14695
|
+
for (const r of DISC_RINGS) {
|
|
14696
|
+
const spokes = r === 0 ? 1 : DISC_SPOKES;
|
|
14697
|
+
const lean = r > 0 && r < BOWL_REACH ? BOWL_LEAN * Math.sin(Math.PI * r / BOWL_REACH) / r : 0;
|
|
14698
|
+
for (let k = 0; k < spokes; k++) {
|
|
14699
|
+
const a = k / DISC_SPOKES * Math.PI * 2;
|
|
14700
|
+
const x = Math.cos(a) * r;
|
|
14701
|
+
const y = Math.sin(a) * r;
|
|
14702
|
+
const n = new THREE.Vector3(-x * lean, -y * lean, 1).normalize();
|
|
14703
|
+
positions.push(x, y, 0);
|
|
14704
|
+
normals.push(n.x, n.y, n.z);
|
|
14705
|
+
uvs.push(0.5 + x / 2, 0.5 + y / 2);
|
|
14706
|
+
}
|
|
14707
|
+
}
|
|
14708
|
+
const geometry = new THREE.BufferGeometry();
|
|
14709
|
+
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
|
|
14710
|
+
geometry.setAttribute("normal", new THREE.Float32BufferAttribute(normals, 3));
|
|
14711
|
+
geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2));
|
|
14712
|
+
geometry.setIndex(discIndices());
|
|
14713
|
+
disc = geometry;
|
|
14714
|
+
return geometry;
|
|
14715
|
+
}
|
|
14716
|
+
function discIndices() {
|
|
14717
|
+
const indices = [];
|
|
14718
|
+
const start2 = (ring2) => 1 + (ring2 - 1) * DISC_SPOKES;
|
|
14719
|
+
for (let k = 0; k < DISC_SPOKES; k++) indices.push(0, start2(1) + k, start2(1) + (k + 1) % DISC_SPOKES);
|
|
14720
|
+
for (let ring2 = 1; ring2 < DISC_RINGS.length - 1; ring2++) {
|
|
14721
|
+
for (let k = 0; k < DISC_SPOKES; k++) {
|
|
14722
|
+
const a = start2(ring2) + k;
|
|
14723
|
+
const b = start2(ring2) + (k + 1) % DISC_SPOKES;
|
|
14724
|
+
const c = start2(ring2 + 1) + k;
|
|
14725
|
+
const d = start2(ring2 + 1) + (k + 1) % DISC_SPOKES;
|
|
14726
|
+
indices.push(a, c, d, a, d, b);
|
|
14727
|
+
}
|
|
14728
|
+
}
|
|
14729
|
+
return indices;
|
|
14730
|
+
}
|
|
14731
|
+
function jagged(x, options) {
|
|
14732
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14733
|
+
x.beginPath();
|
|
14734
|
+
for (let i = 0; i <= options.points; i++) {
|
|
14735
|
+
const a = i / options.points * Math.PI * 2;
|
|
14736
|
+
const wobble = Math.sin(i * 12.9898 + options.seed * 78.233) * 43758.5453;
|
|
14737
|
+
const r = mid * options.radius * (1 - options.jag + 2 * options.jag * (wobble - Math.floor(wobble)));
|
|
14738
|
+
x.lineTo(mid + Math.cos(a) * r, mid + Math.sin(a) * r);
|
|
14739
|
+
}
|
|
14740
|
+
x.closePath();
|
|
14741
|
+
}
|
|
14742
|
+
function drawBore(x, share, bare) {
|
|
14743
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14744
|
+
const r = mid * share;
|
|
14745
|
+
const wall = x.createRadialGradient(mid, mid, 0, mid, mid, r);
|
|
14746
|
+
wall.addColorStop(0, "#000000");
|
|
14747
|
+
wall.addColorStop(0.6, "#050505");
|
|
14748
|
+
wall.addColorStop(1, "#2a2b2c");
|
|
14749
|
+
x.fillStyle = wall;
|
|
14750
|
+
x.beginPath();
|
|
14751
|
+
x.arc(mid, mid, r, 0, Math.PI * 2);
|
|
14752
|
+
x.fill();
|
|
14753
|
+
x.strokeStyle = bare;
|
|
14754
|
+
x.lineWidth = Math.max(1, mid * 0.05);
|
|
14755
|
+
x.beginPath();
|
|
14756
|
+
x.arc(mid, mid, r, 0, Math.PI * 2);
|
|
14757
|
+
x.stroke();
|
|
14758
|
+
}
|
|
14759
|
+
function drawPetals(x, share, petals) {
|
|
14760
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14761
|
+
x.fillStyle = PETAL_SHADE;
|
|
14762
|
+
for (let i = 0; i < petals; i++) {
|
|
14763
|
+
const a = i / petals * Math.PI * 2 + 0.4;
|
|
14764
|
+
const half = Math.PI / petals * PETAL_WIDTH;
|
|
14765
|
+
x.beginPath();
|
|
14766
|
+
x.moveTo(mid + Math.cos(a - half) * mid * share, mid + Math.sin(a - half) * mid * share);
|
|
14767
|
+
x.lineTo(mid + Math.cos(a) * mid * share * PETAL_TIP, mid + Math.sin(a) * mid * share * PETAL_TIP);
|
|
14768
|
+
x.lineTo(mid + Math.cos(a + half) * mid * share, mid + Math.sin(a + half) * mid * share);
|
|
14769
|
+
x.closePath();
|
|
14770
|
+
x.fill();
|
|
14771
|
+
}
|
|
14772
|
+
}
|
|
14773
|
+
function drawRing(x, material, style) {
|
|
14774
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14775
|
+
const bare = BARE[material] ?? STEEL_BARE;
|
|
14776
|
+
const share = BORE_SHARE[style];
|
|
14777
|
+
if (material === "steel" || material === "aluminium") {
|
|
14778
|
+
x.fillStyle = PRIMER;
|
|
14779
|
+
jagged(x, { radius: style === "petalled" ? 0.9 : 0.86, jag: 0.12, points: 22, seed: style.length });
|
|
14780
|
+
x.fill();
|
|
14781
|
+
}
|
|
14782
|
+
x.fillStyle = bare;
|
|
14783
|
+
jagged(x, { radius: Math.max(share + 0.18, style === "dimple" ? 0.55 : 0.6), jag: 0.08, points: 18, seed: style.length + 3 });
|
|
14784
|
+
x.fill();
|
|
14785
|
+
x.strokeStyle = "rgba(70, 72, 74, 0.55)";
|
|
14786
|
+
x.lineWidth = 1;
|
|
14787
|
+
for (let i = 0; i < 14; i++) {
|
|
14788
|
+
const a = i / 14 * Math.PI * 2 + 0.2;
|
|
14789
|
+
x.beginPath();
|
|
14790
|
+
x.moveTo(mid + Math.cos(a) * mid * (share + 0.05), mid + Math.sin(a) * mid * (share + 0.05));
|
|
14791
|
+
x.lineTo(mid + Math.cos(a) * mid * (share + 0.2), mid + Math.sin(a) * mid * (share + 0.2));
|
|
14792
|
+
x.stroke();
|
|
14793
|
+
}
|
|
14794
|
+
}
|
|
14795
|
+
function drawDimple(x) {
|
|
14796
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14797
|
+
const hollow = x.createRadialGradient(mid * 0.92, mid * 0.92, 0, mid, mid, mid * 0.4);
|
|
14798
|
+
hollow.addColorStop(0, "#3c3e40");
|
|
14799
|
+
hollow.addColorStop(1, "rgba(60, 62, 64, 0)");
|
|
14800
|
+
x.fillStyle = hollow;
|
|
14801
|
+
x.beginPath();
|
|
14802
|
+
x.arc(mid, mid, mid * 0.4, 0, Math.PI * 2);
|
|
14803
|
+
x.fill();
|
|
14804
|
+
}
|
|
14805
|
+
function drawCrease(x) {
|
|
14806
|
+
const mid = TEXTURE_SIZE / 2;
|
|
14807
|
+
const crease = x.createLinearGradient(0, mid * 0.75, 0, mid * 1.25);
|
|
14808
|
+
crease.addColorStop(0, "rgba(20, 20, 20, 0)");
|
|
14809
|
+
crease.addColorStop(0.5, "#141414");
|
|
14810
|
+
crease.addColorStop(1, "rgba(20, 20, 20, 0)");
|
|
14811
|
+
x.fillStyle = crease;
|
|
14812
|
+
x.fillRect(mid * 0.15, mid * 0.75, mid * 1.7, mid * 0.5);
|
|
14813
|
+
}
|
|
14814
|
+
function drawMark(x, material, style) {
|
|
14815
|
+
const bare = BARE[material] ?? STEEL_BARE;
|
|
14816
|
+
const share = BORE_SHARE[style];
|
|
14817
|
+
drawRing(x, material, style);
|
|
14818
|
+
if (style === "dimple") return drawDimple(x);
|
|
14819
|
+
if (style === "gouge") drawCrease(x);
|
|
14820
|
+
drawBore(x, share, bare);
|
|
14821
|
+
if (style === "petalled") drawPetals(x, share, 5);
|
|
14822
|
+
if (style !== "ragged") return;
|
|
14823
|
+
x.fillStyle = "#030303";
|
|
14824
|
+
jagged(x, { radius: share, jag: 0.22, points: 11, seed: 7 });
|
|
14825
|
+
x.fill();
|
|
14826
|
+
drawPetals(x, share, 7);
|
|
14827
|
+
}
|
|
14828
|
+
function holeMarkMaterial(kit, material, style) {
|
|
14829
|
+
const key = kit;
|
|
14830
|
+
const cache2 = materials.get(key) ?? /* @__PURE__ */ new Map();
|
|
14831
|
+
materials.set(key, cache2);
|
|
14832
|
+
const id = `${material}|${style}`;
|
|
14833
|
+
const known = cache2.get(id);
|
|
14834
|
+
if (known) return known;
|
|
14835
|
+
const shared = kit._;
|
|
14836
|
+
const THREE = kit.THREE;
|
|
14837
|
+
const canvas = kit.document?.createElement?.("canvas");
|
|
14838
|
+
const context = canvas?.getContext?.("2d");
|
|
14839
|
+
let made = shared.MATERIALS.dark;
|
|
14840
|
+
if (canvas && context) {
|
|
14841
|
+
canvas.width = canvas.height = TEXTURE_SIZE;
|
|
14842
|
+
drawMark(context, material, style);
|
|
14843
|
+
const map = new THREE.CanvasTexture(canvas);
|
|
14844
|
+
const metal = material === "steel" || material === "aluminium";
|
|
14845
|
+
made = new THREE.MeshStandardMaterial({ map, transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -1, polygonOffsetUnits: -2, roughness: 0.5, metalness: metal ? 0.55 : 0 });
|
|
14846
|
+
}
|
|
14847
|
+
cache2.set(id, made);
|
|
14848
|
+
return made;
|
|
14849
|
+
}
|
|
14850
|
+
|
|
14600
14851
|
// src/destructible/visual.ts
|
|
14601
|
-
var
|
|
14852
|
+
var HOLE_LIFT = 1e-3;
|
|
14853
|
+
var HOLE_MIN_MARK = 4e-3;
|
|
14602
14854
|
var HOLE_BATCH_CAPACITY = 64;
|
|
14603
14855
|
var DOOR_DEPTH = 0.07;
|
|
14604
14856
|
var DOOR_SKIN_DEPTH = 0.09;
|
|
@@ -14621,7 +14873,6 @@ var GameVehicles = (() => {
|
|
|
14621
14873
|
var DOOR_SILL = 0.25;
|
|
14622
14874
|
var DOOR_STRIP_OVER = 0.05;
|
|
14623
14875
|
var DOOR_TOP_OVER_PANE = 0.03;
|
|
14624
|
-
var HOLE_TEXTURE_SIZE = 64;
|
|
14625
14876
|
var LAMP_BOX_MARGIN = 0.03;
|
|
14626
14877
|
var GLOW_MIN_EMISSIVE = 0.05;
|
|
14627
14878
|
var MIRROR_MIN_METALNESS = 0.8;
|
|
@@ -14674,46 +14925,6 @@ var GameVehicles = (() => {
|
|
|
14674
14925
|
var SIDEWALL_SHARE = 0.3;
|
|
14675
14926
|
var MIRROR_GLASS_MIN = 0.05;
|
|
14676
14927
|
var MIRROR_GLASS_COLOR = "#59636a";
|
|
14677
|
-
var HOLE_RIM = { steel: "#b7bcc0", aluminium: "#d3d6d8", plastic: "#d9d6cc", rubber: "#141414", glass: "#eef3f5" };
|
|
14678
|
-
var holeMaterials = /* @__PURE__ */ new WeakMap();
|
|
14679
|
-
var holeDisc = null;
|
|
14680
|
-
function holeDiscGeometry(THREE) {
|
|
14681
|
-
holeDisc = holeDisc ?? new THREE.CircleGeometry(1, 12);
|
|
14682
|
-
return holeDisc;
|
|
14683
|
-
}
|
|
14684
|
-
function holeMaterial(kit, material) {
|
|
14685
|
-
const key = kit;
|
|
14686
|
-
const cache2 = holeMaterials.get(key) ?? /* @__PURE__ */ new Map();
|
|
14687
|
-
holeMaterials.set(key, cache2);
|
|
14688
|
-
const known = cache2.get(material);
|
|
14689
|
-
if (known) return known;
|
|
14690
|
-
const I = kit._;
|
|
14691
|
-
const THREE = kit.THREE;
|
|
14692
|
-
const canvas = kit.document?.createElement?.("canvas");
|
|
14693
|
-
const x = canvas?.getContext?.("2d");
|
|
14694
|
-
let made = I.MATERIALS.dark;
|
|
14695
|
-
if (x) {
|
|
14696
|
-
canvas.width = canvas.height = HOLE_TEXTURE_SIZE;
|
|
14697
|
-
const mid = HOLE_TEXTURE_SIZE / 2;
|
|
14698
|
-
x.fillStyle = HOLE_RIM[material] ?? HOLE_RIM.steel;
|
|
14699
|
-
x.beginPath();
|
|
14700
|
-
for (let i = 0; i < 18; i++) {
|
|
14701
|
-
const a = i / 18 * Math.PI * 2;
|
|
14702
|
-
const r = mid * (i % 2 ? 0.98 : 0.76);
|
|
14703
|
-
x.lineTo(mid + Math.cos(a) * r, mid + Math.sin(a) * r);
|
|
14704
|
-
}
|
|
14705
|
-
x.closePath();
|
|
14706
|
-
x.fill();
|
|
14707
|
-
x.fillStyle = "#050505";
|
|
14708
|
-
x.beginPath();
|
|
14709
|
-
x.arc(mid, mid, mid * 0.42, 0, Math.PI * 2);
|
|
14710
|
-
x.fill();
|
|
14711
|
-
const map = new THREE.CanvasTexture(canvas);
|
|
14712
|
-
made = new THREE.MeshStandardMaterial({ map, transparent: true, depthWrite: false, polygonOffset: true, polygonOffsetFactor: -2, roughness: 0.55, metalness: material === "steel" || material === "aluminium" ? 0.6 : 0 });
|
|
14713
|
-
}
|
|
14714
|
-
cache2.set(material, made);
|
|
14715
|
-
return made;
|
|
14716
|
-
}
|
|
14717
14928
|
function isGlowing(material) {
|
|
14718
14929
|
const { emissive, emissiveIntensity } = material;
|
|
14719
14930
|
return !!emissive && (emissiveIntensity ?? 0) > 0 && emissive.r + emissive.g + emissive.b >= GLOW_MIN_EMISSIVE;
|
|
@@ -15746,31 +15957,24 @@ var GameVehicles = (() => {
|
|
|
15746
15957
|
this.extra.set(p.id, [g]);
|
|
15747
15958
|
}
|
|
15748
15959
|
// ---- marks -------------------------------------------------------------------------------------------------------------------------------
|
|
15749
|
-
/**
|
|
15750
|
-
|
|
15960
|
+
/**
|
|
15961
|
+
* A bullet mark lying on the panel at `point` (`c.vehicle` coordinates), facing out along `normal`: its look and size come from `shape` (`bulletHoleShape`), its
|
|
15962
|
+
* long axis lies along `along` (the round's path) over the panel, and it is a child of the part's carrier so it goes where the panel goes.
|
|
15963
|
+
*/
|
|
15964
|
+
holeDecal(point, normal, shape, part, along) {
|
|
15751
15965
|
const THREE = this.THREE;
|
|
15752
15966
|
const pane = part?.role === "glass" ? this.panesOf(part).find((g) => g.visible) : void 0;
|
|
15753
15967
|
if (part?.role === "glass" && (!pane || pane.userData.glass?.broken)) return;
|
|
15754
|
-
const
|
|
15755
|
-
const n = new THREE.Vector3(...normal);
|
|
15968
|
+
const across = Math.max(HOLE_MIN_MARK, shape.markDiameter) / 2;
|
|
15969
|
+
const n = new THREE.Vector3(...normal).normalize();
|
|
15756
15970
|
const carrier = (part && (this.plates.get(part.id) ?? (part.id === this.hood?.id ? this.c.hood?.piv : void 0))) ?? (pane && pane.parent !== this.c.vehicle ? pane.parent : null);
|
|
15757
15971
|
const parent = carrier ?? this.c.vehicle;
|
|
15758
|
-
const material =
|
|
15972
|
+
const material = holeMarkMaterial(this.kit, part?.material ?? "steel", shape.style);
|
|
15759
15973
|
const key = `${parent.uuid}|${material.uuid}`;
|
|
15760
15974
|
let batches = this.holes.get(key);
|
|
15761
15975
|
let batch = batches?.[batches.length - 1];
|
|
15762
15976
|
if (!batch || batch.count >= HOLE_BATCH_CAPACITY) {
|
|
15763
|
-
batch =
|
|
15764
|
-
batch.count = 0;
|
|
15765
|
-
batch.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|
|
15766
|
-
batch.castShadow = false;
|
|
15767
|
-
batch.receiveShadow = false;
|
|
15768
|
-
batch.userData.decal = true;
|
|
15769
|
-
batch.userData.noFollow = true;
|
|
15770
|
-
batch.renderOrder = 3;
|
|
15771
|
-
batch.raycast = () => {
|
|
15772
|
-
};
|
|
15773
|
-
batch.frustumCulled = false;
|
|
15977
|
+
batch = this.holeBatch(material);
|
|
15774
15978
|
parent.add(batch);
|
|
15775
15979
|
if (!batches) {
|
|
15776
15980
|
batches = [];
|
|
@@ -15778,19 +15982,33 @@ var GameVehicles = (() => {
|
|
|
15778
15982
|
}
|
|
15779
15983
|
batches.push(batch);
|
|
15780
15984
|
}
|
|
15781
|
-
const
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
|
|
15786
|
-
|
|
15787
|
-
pose.updateMatrix();
|
|
15985
|
+
const u = new THREE.Vector3(...along ?? [0, 0, 0]).addScaledVector(n, -new THREE.Vector3(...along ?? [0, 0, 0]).dot(n));
|
|
15986
|
+
if (u.lengthSq() < 1e-8) u.crossVectors(n, Math.abs(n.y) < 0.9 ? new THREE.Vector3(0, 1, 0) : new THREE.Vector3(1, 0, 0));
|
|
15987
|
+
u.normalize();
|
|
15988
|
+
const w = new THREE.Vector3().crossVectors(n, u);
|
|
15989
|
+
const at = new THREE.Vector3(...point).addScaledVector(n, HOLE_LIFT);
|
|
15990
|
+
const local = new THREE.Matrix4().makeBasis(u.multiplyScalar(across * shape.elongation), w.multiplyScalar(across), n).setPosition(at);
|
|
15788
15991
|
parent.updateWorldMatrix(true, false);
|
|
15789
|
-
const instance = new THREE.Matrix4().copy(parent.matrixWorld).invert().multiply(
|
|
15992
|
+
const instance = new THREE.Matrix4().copy(parent.matrixWorld).invert().multiply(this.c.vehicle.matrixWorld).multiply(local);
|
|
15790
15993
|
batch.setMatrixAt(batch.count, instance);
|
|
15791
15994
|
batch.count += 1;
|
|
15792
15995
|
batch.instanceMatrix.needsUpdate = true;
|
|
15793
15996
|
}
|
|
15997
|
+
/** A new batch of marks of one material (a door full of holes still draws as one). */
|
|
15998
|
+
holeBatch(material) {
|
|
15999
|
+
const batch = new this.THREE.InstancedMesh(holeMarkGeometry(this.THREE), material, HOLE_BATCH_CAPACITY);
|
|
16000
|
+
batch.count = 0;
|
|
16001
|
+
batch.instanceMatrix.setUsage(this.THREE.DynamicDrawUsage);
|
|
16002
|
+
batch.castShadow = false;
|
|
16003
|
+
batch.receiveShadow = false;
|
|
16004
|
+
batch.userData.decal = true;
|
|
16005
|
+
batch.userData.noFollow = true;
|
|
16006
|
+
batch.renderOrder = 3;
|
|
16007
|
+
batch.raycast = () => {
|
|
16008
|
+
};
|
|
16009
|
+
batch.frustumCulled = false;
|
|
16010
|
+
return batch;
|
|
16011
|
+
}
|
|
15794
16012
|
/** The door or lid a hinge group stands for. */
|
|
15795
16013
|
/** The part a separately drawn piece stands for (a mirror on the door, a battery under the hood), so a shot at it lands on that part. */
|
|
15796
16014
|
extraIdOf(o) {
|
|
@@ -16231,6 +16449,46 @@ var GameVehicles = (() => {
|
|
|
16231
16449
|
return clips;
|
|
16232
16450
|
}
|
|
16233
16451
|
|
|
16452
|
+
// src/destructible/mark-fit.ts
|
|
16453
|
+
var MARK_PROBE = 0.02;
|
|
16454
|
+
var MARK_FALL = 2e-3;
|
|
16455
|
+
var MARK_RISE = 15e-4;
|
|
16456
|
+
var MARK_RIM_SAMPLES = 12;
|
|
16457
|
+
var MARK_SHRINK = 0.7;
|
|
16458
|
+
var MARK_FIT_TRIES = 7;
|
|
16459
|
+
function createMarkFitter(deps) {
|
|
16460
|
+
const axesOf = (n, along) => {
|
|
16461
|
+
const u = along.clone().addScaledVector(n, -along.dot(n));
|
|
16462
|
+
if (u.lengthSq() < 1e-8) u.crossVectors(n, Math.abs(n.y) < 0.9 ? deps.vector(0, 1, 0) : deps.vector(1, 0, 0));
|
|
16463
|
+
u.normalize();
|
|
16464
|
+
return { u, w: deps.vector(0, 0, 0).crossVectors(n, u).normalize() };
|
|
16465
|
+
};
|
|
16466
|
+
const rimOnSurface = (at, axes, half) => {
|
|
16467
|
+
const inward = deps.dirToWorld(at.normal.clone().negate());
|
|
16468
|
+
for (let k = 0; k < MARK_RIM_SAMPLES; k++) {
|
|
16469
|
+
const a = k / MARK_RIM_SAMPLES * Math.PI * 2;
|
|
16470
|
+
const q = at.point.clone().addScaledVector(axes.u, Math.cos(a) * half.along).addScaledVector(axes.w, Math.sin(a) * half.across).addScaledVector(at.normal, MARK_PROBE);
|
|
16471
|
+
const hit = deps.surfaceRay({ origin: deps.toWorld(q), direction: inward, maxDistance: MARK_PROBE * 2 });
|
|
16472
|
+
const fall = hit ? hit.distance - MARK_PROBE : Infinity;
|
|
16473
|
+
if (fall > MARK_FALL || fall < -MARK_RISE) return false;
|
|
16474
|
+
}
|
|
16475
|
+
return true;
|
|
16476
|
+
};
|
|
16477
|
+
return (shape, at) => {
|
|
16478
|
+
const placed = { ...at, normal: at.normal.clone().normalize() };
|
|
16479
|
+
const axes = axesOf(placed.normal, at.along);
|
|
16480
|
+
let scale = 1;
|
|
16481
|
+
for (let tries = 0; tries < MARK_FIT_TRIES; tries++) {
|
|
16482
|
+
const across = shape.markDiameter / 2 * scale;
|
|
16483
|
+
if (rimOnSurface(placed, axes, { along: across * shape.elongation, across })) break;
|
|
16484
|
+
scale *= MARK_SHRINK;
|
|
16485
|
+
}
|
|
16486
|
+
if (scale === 1) return shape;
|
|
16487
|
+
const markDiameter = shape.markDiameter * scale;
|
|
16488
|
+
return { ...shape, markDiameter, boreDiameter: Math.min(shape.boreDiameter, markDiameter * 0.8) };
|
|
16489
|
+
};
|
|
16490
|
+
}
|
|
16491
|
+
|
|
16234
16492
|
// src/destructible/impl.ts
|
|
16235
16493
|
var RESIST = { steel: 380, aluminium: 220, glass: 90, plastic: 70, rubber: 120 };
|
|
16236
16494
|
var ROLE_RESIST = {
|
|
@@ -16746,6 +17004,8 @@ var GameVehicles = (() => {
|
|
|
16746
17004
|
if (near && igniteRand() < 1 - Math.exp(-chancePerSecond * dt)) light(tank, out);
|
|
16747
17005
|
};
|
|
16748
17006
|
const normalOf = (d, v) => faceNormal(d, v);
|
|
17007
|
+
const fitter = createMarkFitter({ vector: (x, y, z) => new V3(x, y, z), surfaceRay: (ray) => surfaceRay(ray), toWorld, dirToWorld });
|
|
17008
|
+
const fitMark = (v, n, shape, along) => vis ? fitter(shape, { point: v, normal: n, along }) : shape;
|
|
16749
17009
|
const ballistic = (h, out) => {
|
|
16750
17010
|
sync();
|
|
16751
17011
|
const M = toFrameMatrix();
|
|
@@ -16763,15 +17023,17 @@ var GameVehicles = (() => {
|
|
|
16763
17023
|
const cosInc = Math.abs(dir.dot(n));
|
|
16764
17024
|
const metal = d.material === "steel" || d.material === "aluminium";
|
|
16765
17025
|
const worldPoint = toWorld(v);
|
|
17026
|
+
const opens = (h.piercing ?? 1) < SOFT_LEAD ? EXPANDED_HOLE : 1;
|
|
17027
|
+
const holeDiam = Math.max(6e-3, cal / 1e3 * (d.material === "glass" ? 1.4 : 1) * opens);
|
|
17028
|
+
const shapeOf = (pierced) => bulletHoleShape({ caliberMm: cal, energy: E, ...h.mass !== void 0 ? { massGrams: h.mass } : {}, cosIncidence: cosInc, through: pierced, material: d.material, boreDiameter: holeDiam });
|
|
16766
17029
|
if (metal && !through && cosInc < 0.3 && E > 40) {
|
|
16767
17030
|
const refl = dir.clone().addScaledVector(n, -2 * dir.dot(n));
|
|
16768
17031
|
out.push(ev({ type: "ricochet", part: d.id, point: worldPoint, direction: r3(dirToWorld(refl)), energy: r2(E * 0.4) }));
|
|
16769
17032
|
damage(p, E * 0.05, "ballistic", h.source, out, worldPoint, pieces);
|
|
16770
17033
|
vis?.spark([v.x, v.y, v.z], [refl.x, refl.y, refl.z], 6);
|
|
17034
|
+
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z], fitMark(v, n, shapeOf(false), dir), d, [dir.x, dir.y, dir.z]);
|
|
16771
17035
|
return;
|
|
16772
17036
|
}
|
|
16773
|
-
const opens = (h.piercing ?? 1) < SOFT_LEAD ? EXPANDED_HOLE : 1;
|
|
16774
|
-
const holeDiam = Math.max(6e-3, cal / 1e3 * (d.material === "glass" ? 1.4 : 1) * opens);
|
|
16775
17037
|
const energyLeft = () => {
|
|
16776
17038
|
const metal2 = d.material === "steel" || d.material === "aluminium";
|
|
16777
17039
|
const mm = h.penetration?.steel;
|
|
@@ -16782,8 +17044,8 @@ var GameVehicles = (() => {
|
|
|
16782
17044
|
if (!hole) return;
|
|
16783
17045
|
const hp = { point: r3(fromVehicle(v, M)), normal: r3(fromVehicle(n, new THREE.Matrix4().extractRotation(M))), diameter: r2(holeDiam), through };
|
|
16784
17046
|
p.holes.push(hp);
|
|
16785
|
-
out.push(ev({ type: "hole", part: d.id, hole: hp, worldPoint, ...through ? { energyLeft: r2(energyLeft()) } : {}, ...through ? { exitPoint: add3(worldPoint, r3(dirToWorld(dir.clone().multiplyScalar(Math.max(0.02, Math.min(d.box.size[0], d.box.size[1], d.box.size[2])))))) } : {} }));
|
|
16786
|
-
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z],
|
|
17047
|
+
out.push(ev({ type: "hole", part: d.id, hole: hp, worldPoint, worldNormal: r3(dirToWorld(n.clone().normalize())), direction: r3(dirToWorld(dir)), ...through ? { energyLeft: r2(energyLeft()) } : {}, ...through ? { exitPoint: add3(worldPoint, r3(dirToWorld(dir.clone().multiplyScalar(Math.max(0.02, Math.min(d.box.size[0], d.box.size[1], d.box.size[2])))))) } : {} }));
|
|
17048
|
+
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z], d.material === "glass" ? shapeOf(through) : fitMark(v, n, shapeOf(through), dir), d, [dir.x, dir.y, dir.z]);
|
|
16787
17049
|
if (d.role === "mirror") vis?.shatterMirror(d.id);
|
|
16788
17050
|
startLeak(p, v, cal, out, dir);
|
|
16789
17051
|
};
|
|
@@ -16816,6 +17078,7 @@ var GameVehicles = (() => {
|
|
|
16816
17078
|
const dent = { point: r3(fromVehicle(v, M)), normal: r3(fromVehicle(n, new THREE.Matrix4().extractRotation(M))), radius: r2(Math.max(0.02, holeDiam * 2)), depth: r2(Math.min(0.03, E / 6e4 + 2e-3)) };
|
|
16817
17079
|
p.dents.push(dent);
|
|
16818
17080
|
out.push(ev({ type: "dent", part: d.id, dent, worldPoint }));
|
|
17081
|
+
vis?.holeDecal([v.x, v.y, v.z], [n.x, n.y, n.z], fitMark(v, n, shapeOf(false), dir), d, [dir.x, dir.y, dir.z]);
|
|
16819
17082
|
}
|
|
16820
17083
|
vis?.spark([v.x, v.y, v.z], [dir.x, dir.y, dir.z], through ? 4 : 8);
|
|
16821
17084
|
let amount = through ? E * 0.6 : E * 0.25;
|