@adatechnology/game-vehicles 0.6.13 → 0.6.15
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 +38 -2
- package/dist/index.global.js +151 -17
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +151 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -227,6 +227,29 @@ declare function installZoneDerive(kit: Kit): {
|
|
|
227
227
|
ownerOf: (c: BuildContext, o: Object3D | null | undefined) => DamageZone | null;
|
|
228
228
|
};
|
|
229
229
|
|
|
230
|
+
/**
|
|
231
|
+
* The lamps a body draws outside the kit's lamp units: the round fog lamps a body lists in `c.fogBulbs` (or tags `userData.lamp = 'fog'`) and the
|
|
232
|
+
* lit strips and lamps set into a bumper (a daytime running lamp, a fog lamp drawn as a lit panel). None is in `c.lights`, so no damage zone
|
|
233
|
+
* holds them and a round that hits one used to leave it glowing. Each becomes a lamp of its own: the destructible model makes it a light part,
|
|
234
|
+
* the shots break it and put it out, and the lamp switch of `game-vehicles-three` reads it. `c.lights` and the zones stay as the fleet drew them.
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
/** A lamp found outside the kit's lamp units. `fog`: switched by the fog lamp switch; `aux`: lit as drawn (a running lamp), only put out by damage. */
|
|
238
|
+
type StrayLamp = VehicleLamp & {
|
|
239
|
+
fog?: boolean;
|
|
240
|
+
aux?: boolean;
|
|
241
|
+
side: 'left' | 'right' | 'center';
|
|
242
|
+
};
|
|
243
|
+
type Geometry = {
|
|
244
|
+
Box3: new () => Box3;
|
|
245
|
+
Vector3: new () => Vector3;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* The stray lamps of a built vehicle, found on the first call and kept on `c.strayLamps`. Read on demand (the destructible model, the lamp switch), never
|
|
249
|
+
* while building: finding them updates the world matrices and the bounding boxes of the drawing, which the build leaves as the fleet drew them.
|
|
250
|
+
*/
|
|
251
|
+
declare function strayLampsOf(c: BuildContext, THREE: Geometry): StrayLamp[];
|
|
252
|
+
|
|
230
253
|
/** A zone box in `c.vehicle` coordinates. */
|
|
231
254
|
interface ZoneBox {
|
|
232
255
|
x0: number;
|
|
@@ -301,6 +324,7 @@ declare function installContext(kit: Kit): {
|
|
|
301
324
|
wheels: Object3D[];
|
|
302
325
|
parts: VehiclePart[];
|
|
303
326
|
lights: VehicleLamp[];
|
|
327
|
+
strayLamps: StrayLamp[] | undefined;
|
|
304
328
|
spin: VehicleSpin[];
|
|
305
329
|
emitters: VehicleEmitter[];
|
|
306
330
|
log: unknown[];
|
|
@@ -657,6 +681,8 @@ type LampMesh = Mesh;
|
|
|
657
681
|
type CrackedLamp = {
|
|
658
682
|
lens: LampMesh[];
|
|
659
683
|
inner: LampMesh[];
|
|
684
|
+
/** The chrome bowl behind the bulb, when the body registered it. */
|
|
685
|
+
reflector?: LampMesh[];
|
|
660
686
|
halo?: Array<{
|
|
661
687
|
visible: boolean;
|
|
662
688
|
}>;
|
|
@@ -1257,7 +1283,13 @@ var mechanics = {
|
|
|
1257
1283
|
pillar_c: "{Side} C pillar",
|
|
1258
1284
|
engine: "Engine",
|
|
1259
1285
|
radiator: "Radiator",
|
|
1260
|
-
fuel_tank: "Fuel tank"
|
|
1286
|
+
fuel_tank: "Fuel tank",
|
|
1287
|
+
fog_light: "{Side} fog light",
|
|
1288
|
+
fog_light_center: "Fog light",
|
|
1289
|
+
lamp_front: "{Side} front lamp",
|
|
1290
|
+
lamp_front_center: "Front lamp",
|
|
1291
|
+
lamp_rear: "{Side} rear lamp",
|
|
1292
|
+
lamp_rear_center: "Rear lamp"
|
|
1261
1293
|
};
|
|
1262
1294
|
var en = {
|
|
1263
1295
|
plate: plate,
|
|
@@ -1615,6 +1647,8 @@ interface DamageZone {
|
|
|
1615
1647
|
owned: ThreeObject[];
|
|
1616
1648
|
/** The lamps, panes and wheels the zone holds. */
|
|
1617
1649
|
lights: VehicleLamp[];
|
|
1650
|
+
/** The lamps drawn outside the kit's lamp units (fog bulbs, lit strips in a bumper), each breakable on its own (`stray-lamps.ts`). */
|
|
1651
|
+
strayLamps?: StrayLamp[];
|
|
1618
1652
|
glass: ThreeObject[];
|
|
1619
1653
|
wheels: ThreeObject[];
|
|
1620
1654
|
tags: string[];
|
|
@@ -2044,6 +2078,8 @@ interface PartDef {
|
|
|
2044
2078
|
zoneId?: string;
|
|
2045
2079
|
/** The panes of a glass part no damage zone claims. */
|
|
2046
2080
|
panes?: Mesh[];
|
|
2081
|
+
/** The lamps of a light part no damage zone claims (a fog lamp, a lit strip in a bumper: `c.strayLamps`). */
|
|
2082
|
+
lamps?: VehicleLamp[];
|
|
2047
2083
|
/** Fluid held, in litres. */
|
|
2048
2084
|
contains?: {
|
|
2049
2085
|
fluid: string;
|
|
@@ -2318,4 +2354,4 @@ declare function swingOf(vehicle: VehicleContext, partId: string): number;
|
|
|
2318
2354
|
*/
|
|
2319
2355
|
declare function cabinEnclosure(source: CabinSource, options?: CabinEnclosureOptions): Enclosure | null;
|
|
2320
2356
|
|
|
2321
|
-
export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BusRowsOptions, CABIN_LEAK, CRASH_RULES, type CabinBox, type CabinEnclosureOptions, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, type CutTest, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DriveReport, type EngineBaySpec, type ExplodeOptions, type FlagEffect, type FluidDefinition, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, type HeadlightLens, type HeadlightOptions, 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, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, type ResolvedConfiguration, type RollState, SEED_SALTS, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, type SmoothLoftOptions, type Splat, type SplatOptions, 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 VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, clamp, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash, swingOf, wrapThreeForLod };
|
|
2357
|
+
export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BusRowsOptions, CABIN_LEAK, CRASH_RULES, type CabinBox, type CabinEnclosureOptions, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, type CutTest, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DriveReport, type EngineBaySpec, type ExplodeOptions, type FlagEffect, type FluidDefinition, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, type HeadlightLens, type HeadlightOptions, 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, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, type ResolvedConfiguration, type RollState, SEED_SALTS, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, 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 VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, clamp, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash, strayLampsOf, swingOf, wrapThreeForLod };
|
package/dist/index.global.js
CHANGED
|
@@ -58,6 +58,7 @@ var GameVehicles = (() => {
|
|
|
58
58
|
rng: () => rng,
|
|
59
59
|
smooth: () => smooth,
|
|
60
60
|
strHash: () => strHash,
|
|
61
|
+
strayLampsOf: () => strayLampsOf,
|
|
61
62
|
swingOf: () => swingOf,
|
|
62
63
|
wrapThreeForLod: () => wrapThreeForLod
|
|
63
64
|
});
|
|
@@ -1910,7 +1911,13 @@ var GameVehicles = (() => {
|
|
|
1910
1911
|
pillar_c: "{Side} C pillar",
|
|
1911
1912
|
engine: "Engine",
|
|
1912
1913
|
radiator: "Radiator",
|
|
1913
|
-
fuel_tank: "Fuel tank"
|
|
1914
|
+
fuel_tank: "Fuel tank",
|
|
1915
|
+
fog_light: "{Side} fog light",
|
|
1916
|
+
fog_light_center: "Fog light",
|
|
1917
|
+
lamp_front: "{Side} front lamp",
|
|
1918
|
+
lamp_front_center: "Front lamp",
|
|
1919
|
+
lamp_rear: "{Side} rear lamp",
|
|
1920
|
+
lamp_rear_center: "Rear lamp"
|
|
1914
1921
|
}
|
|
1915
1922
|
};
|
|
1916
1923
|
|
|
@@ -2121,7 +2128,13 @@ var GameVehicles = (() => {
|
|
|
2121
2128
|
pillar_c: "Coluna C {sideM}",
|
|
2122
2129
|
engine: "Motor",
|
|
2123
2130
|
radiator: "Radiador",
|
|
2124
|
-
fuel_tank: "Tanque de combust\xEDvel"
|
|
2131
|
+
fuel_tank: "Tanque de combust\xEDvel",
|
|
2132
|
+
fog_light: "Farol de neblina {sideM}",
|
|
2133
|
+
fog_light_center: "Farol de neblina",
|
|
2134
|
+
lamp_front: "Luz dianteira {side}",
|
|
2135
|
+
lamp_front_center: "Luz dianteira",
|
|
2136
|
+
lamp_rear: "Luz traseira {side}",
|
|
2137
|
+
lamp_rear_center: "Luz traseira"
|
|
2125
2138
|
}
|
|
2126
2139
|
};
|
|
2127
2140
|
|
|
@@ -7229,12 +7242,16 @@ var GameVehicles = (() => {
|
|
|
7229
7242
|
}
|
|
7230
7243
|
kit.breakLight = breakLight;
|
|
7231
7244
|
const crazedCache = /* @__PURE__ */ new Map();
|
|
7232
|
-
const CRAZED_OPACITY = 0.
|
|
7245
|
+
const CRAZED_OPACITY = 0.5;
|
|
7246
|
+
const CRAZED_TINT = 0.6;
|
|
7247
|
+
const CRAZED_ROUGHNESS = 0.6;
|
|
7233
7248
|
function crazed(material) {
|
|
7234
7249
|
const known = crazedCache.get(material);
|
|
7235
7250
|
if (known) return known;
|
|
7236
7251
|
const m = I.crackLens(material).clone();
|
|
7237
7252
|
m.opacity = Math.max(m.opacity ?? 1, CRAZED_OPACITY);
|
|
7253
|
+
m.color?.multiplyScalar(CRAZED_TINT);
|
|
7254
|
+
m.roughness = Math.max(m.roughness ?? 0, CRAZED_ROUGHNESS);
|
|
7238
7255
|
m.transparent = true;
|
|
7239
7256
|
m.userData.shared = true;
|
|
7240
7257
|
crazedCache.set(material, m);
|
|
@@ -7252,6 +7269,7 @@ var GameVehicles = (() => {
|
|
|
7252
7269
|
L.dark = true;
|
|
7253
7270
|
for (const m of L.inner) m.material = MATERIALS.bulbBroken;
|
|
7254
7271
|
for (const h of L.halo ?? []) h.visible = false;
|
|
7272
|
+
for (const m of L.reflector ?? []) m.material = MATERIALS.broken;
|
|
7255
7273
|
}
|
|
7256
7274
|
kit.crackLight = crackLight;
|
|
7257
7275
|
const shared = { glassUV, drawWeb, crackGlass, glassRim, shatterGlass, hitGlass, breakLight, crackLight };
|
|
@@ -12818,6 +12836,88 @@ var GameVehicles = (() => {
|
|
|
12818
12836
|
return kit;
|
|
12819
12837
|
}
|
|
12820
12838
|
|
|
12839
|
+
// src/stray-lamps.ts
|
|
12840
|
+
var END_DEPTH = 0.45;
|
|
12841
|
+
var LAMP_EMISSIVE_MIN = 0.25;
|
|
12842
|
+
var LAMP_INTENSITY_MIN = 0.2;
|
|
12843
|
+
var UNIT_MARGIN = 0.03;
|
|
12844
|
+
var CLUSTER_GAP = 0.04;
|
|
12845
|
+
var CENTRE_Z = 0.08;
|
|
12846
|
+
function glowsLikeLamp(material) {
|
|
12847
|
+
if (!material || Array.isArray(material)) return false;
|
|
12848
|
+
const { emissive, emissiveIntensity } = material;
|
|
12849
|
+
if (!emissive || !((emissiveIntensity ?? 0) >= LAMP_INTENSITY_MIN)) return false;
|
|
12850
|
+
return Math.max(emissive.r, emissive.g, emissive.b) >= LAMP_EMISSIVE_MIN;
|
|
12851
|
+
}
|
|
12852
|
+
function membersOf(lights) {
|
|
12853
|
+
const members = /* @__PURE__ */ new Set();
|
|
12854
|
+
for (const L of lights) {
|
|
12855
|
+
L.group?.traverse((o) => members.add(o));
|
|
12856
|
+
for (const m of [...L.lens, ...L.inner, ...L.halo ?? []]) members.add(m);
|
|
12857
|
+
}
|
|
12858
|
+
return members;
|
|
12859
|
+
}
|
|
12860
|
+
function sideOf(box2) {
|
|
12861
|
+
const z = (box2.min.z + box2.max.z) / 2;
|
|
12862
|
+
return Math.abs(z) < CENTRE_Z ? "center" : z < 0 ? "left" : "right";
|
|
12863
|
+
}
|
|
12864
|
+
function lampOf(inner, box2, front, flags) {
|
|
12865
|
+
return { group: null, lens: [], inner, kind: front ? "headlight" : "taillight", tint: front ? "clear" : "red", broken: false, side: sideOf(box2), ...flags };
|
|
12866
|
+
}
|
|
12867
|
+
function strayLampsOf(c, THREE) {
|
|
12868
|
+
c.strayLamps ?? (c.strayLamps = findStrayLamps(c, THREE));
|
|
12869
|
+
return c.strayLamps;
|
|
12870
|
+
}
|
|
12871
|
+
function findStrayLamps(c, THREE) {
|
|
12872
|
+
const Box = THREE.Box3;
|
|
12873
|
+
const vehicle = c.vehicle;
|
|
12874
|
+
vehicle.updateMatrixWorld(true);
|
|
12875
|
+
const inverse = vehicle.matrixWorld.clone().invert();
|
|
12876
|
+
const localBox = (o) => new Box().setFromObject(o).applyMatrix4(inverse);
|
|
12877
|
+
const lights = c.lights ?? [];
|
|
12878
|
+
const members = membersOf(lights);
|
|
12879
|
+
const units = lights.map((L) => {
|
|
12880
|
+
const bb = new Box();
|
|
12881
|
+
for (const o of L.group ? [L.group] : [...L.lens, ...L.inner]) bb.union(localBox(o));
|
|
12882
|
+
return bb.expandByScalar(UNIT_MARGIN);
|
|
12883
|
+
});
|
|
12884
|
+
const front = c.meta?.front ?? new Box().setFromObject(vehicle).applyMatrix4(inverse).max.x;
|
|
12885
|
+
const rear = c.meta?.rear ?? new Box().setFromObject(vehicle).applyMatrix4(inverse).min.x;
|
|
12886
|
+
const found = [];
|
|
12887
|
+
const bulbs = [...c.fogBulbs ?? []];
|
|
12888
|
+
vehicle.traverse((o) => {
|
|
12889
|
+
if (o.userData.lamp === "fog" && o.isMesh && !bulbs.includes(o)) bulbs.push(o);
|
|
12890
|
+
});
|
|
12891
|
+
for (const bulb of bulbs) {
|
|
12892
|
+
if (members.has(bulb)) continue;
|
|
12893
|
+
members.add(bulb);
|
|
12894
|
+
const bb = localBox(bulb);
|
|
12895
|
+
found.push(lampOf([bulb], bb, bb.max.x > (front + rear) / 2, { fog: true }));
|
|
12896
|
+
}
|
|
12897
|
+
const loose = [];
|
|
12898
|
+
vehicle.traverse((o) => {
|
|
12899
|
+
const mesh2 = o;
|
|
12900
|
+
if (!mesh2.isMesh || members.has(mesh2) || mesh2.userData.glass || mesh2.userData.decal || mesh2.userData.lamp === "beacon") return;
|
|
12901
|
+
if (!glowsLikeLamp(mesh2.material)) return;
|
|
12902
|
+
const bb = localBox(mesh2);
|
|
12903
|
+
const mid = bb.getCenter(new THREE.Vector3());
|
|
12904
|
+
const atFront = mid.x > front - END_DEPTH;
|
|
12905
|
+
if (!atFront && mid.x > rear + END_DEPTH) return;
|
|
12906
|
+
if (units.some((u) => u.containsPoint(mid))) return;
|
|
12907
|
+
loose.push({ mesh: mesh2, box: bb, front: atFront });
|
|
12908
|
+
});
|
|
12909
|
+
const groups = [];
|
|
12910
|
+
for (const piece of loose) {
|
|
12911
|
+
const near = groups.find((g) => g.front === piece.front && g.box.clone().expandByScalar(CLUSTER_GAP).intersectsBox(piece.box));
|
|
12912
|
+
if (near) {
|
|
12913
|
+
near.meshes.push(piece.mesh);
|
|
12914
|
+
near.box.union(piece.box);
|
|
12915
|
+
} else groups.push({ meshes: [piece.mesh], box: piece.box.clone(), front: piece.front });
|
|
12916
|
+
}
|
|
12917
|
+
for (const g of groups) found.push(lampOf(g.meshes, g.box, g.front, { aux: true }));
|
|
12918
|
+
return found;
|
|
12919
|
+
}
|
|
12920
|
+
|
|
12821
12921
|
// src/destructible/armour.ts
|
|
12822
12922
|
var ARMOUR_LEVELS = {
|
|
12823
12923
|
IIIA: { glassStops: 1700, glassHp: 6e3, glassTakes: 0.25, steel: 8 },
|
|
@@ -12852,6 +12952,7 @@ var GameVehicles = (() => {
|
|
|
12852
12952
|
var HITCH_CHANCE = { car: 30, truck: 60, bus: 0, tractor: 100, quad: 40, bike: 0, tank: 0, boat: 0, plane: 0, heli: 0 };
|
|
12853
12953
|
var GLASS_LENS_HP = 320;
|
|
12854
12954
|
var PLASTIC_LENS_HP = 900;
|
|
12955
|
+
var STRAY_LAMP_MARGIN = 0.03;
|
|
12855
12956
|
var STEEL_KG_M2 = 7;
|
|
12856
12957
|
var ALU_KG_M2 = 3.2;
|
|
12857
12958
|
var kindOf = (c) => {
|
|
@@ -12923,6 +13024,18 @@ var GameVehicles = (() => {
|
|
|
12923
13024
|
center: [b.center[0], b.center[1] - b.size[1] / 2 + Math.min(0.14, b.size[1]) / 2 + 0.04, b.center[2]],
|
|
12924
13025
|
size: [b.size[0] * 0.5, Math.min(0.14, b.size[1]), b.size[2] * 0.95]
|
|
12925
13026
|
});
|
|
13027
|
+
function strayLampBox(c, lamp, inverse) {
|
|
13028
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
13029
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
13030
|
+
for (const mesh2 of [...lamp.lens, ...lamp.inner]) {
|
|
13031
|
+
const b = paneBox(c, mesh2, inverse);
|
|
13032
|
+
for (let i = 0; i < 3; i++) {
|
|
13033
|
+
lo[i] = Math.min(lo[i], b.center[i] - b.size[i] / 2);
|
|
13034
|
+
hi[i] = Math.max(hi[i], b.center[i] + b.size[i] / 2);
|
|
13035
|
+
}
|
|
13036
|
+
}
|
|
13037
|
+
return { center: [0, 1, 2].map((i) => (lo[i] + hi[i]) / 2), size: [0, 1, 2].map((i) => hi[i] - lo[i] + 2 * STRAY_LAMP_MARGIN) };
|
|
13038
|
+
}
|
|
12926
13039
|
function paneBox(c, pane, inverse) {
|
|
12927
13040
|
pane.geometry.computeBoundingBox();
|
|
12928
13041
|
const box2 = pane.geometry.boundingBox.clone().applyMatrix4(pane.matrixWorld);
|
|
@@ -13084,6 +13197,15 @@ var GameVehicles = (() => {
|
|
|
13084
13197
|
const laminated = G?.type === "laminated" || !!armoured;
|
|
13085
13198
|
add({ id: `pane_${G?.key ?? "glass"}`, role: "glass", name: String(G?.label ?? G?.key ?? "glass"), material: "glass", box: bb, mass: 10 * areaOf(bb.size), hp: armoured ? armoured.glassHp : laminated ? 4e3 : 450, panes: [pane], visual: false, tags: ["glass"] });
|
|
13086
13199
|
}
|
|
13200
|
+
for (const lamp of strayLampsOf(c, kit.THREE)) {
|
|
13201
|
+
const front = lamp.kind !== "taillight";
|
|
13202
|
+
const lens = front ? spec.headlightLens ?? "polycarbonate" : "acrylic";
|
|
13203
|
+
const glassLens = lens === "glass";
|
|
13204
|
+
const box2 = strayLampBox(c, lamp, inverse);
|
|
13205
|
+
const what = lamp.fog ? "fog_light" : front ? "lamp_front" : "lamp_rear";
|
|
13206
|
+
const name = lamp.side === "center" ? t(`mechanics.${what}_center`) : t(`mechanics.${what}`, { side: t(`sides.${lamp.side}`), sideM: t(`sides.${lamp.side}M`) });
|
|
13207
|
+
add({ id: lamp.side === "center" ? what : `${what}_${lamp.side}`, role: "light", name, material: glassLens ? "glass" : "plastic", box: box2, mass: 0.4 + 4 * areaOf(box2.size), hp: glassLens ? GLASS_LENS_HP : PLASTIC_LENS_HP, lamps: [lamp], visual: true, tags: ["light", `lens_${lens}`, ...lamp.fog ? ["fog"] : []] });
|
|
13208
|
+
}
|
|
13087
13209
|
if (!hubZone) {
|
|
13088
13210
|
const h = Math.max(0.15, belt - clearance);
|
|
13089
13211
|
add({
|
|
@@ -13654,6 +13776,9 @@ var GameVehicles = (() => {
|
|
|
13654
13776
|
var HOLE_TEXTURE_SIZE = 64;
|
|
13655
13777
|
var LAMP_BOX_MARGIN = 0.03;
|
|
13656
13778
|
var GLOW_MIN_EMISSIVE = 0.05;
|
|
13779
|
+
var MIRROR_MIN_METALNESS = 0.8;
|
|
13780
|
+
var MIRROR_MAX_ROUGHNESS = 0.35;
|
|
13781
|
+
var MIRROR_MIN_LIGHTNESS = 0.4;
|
|
13657
13782
|
var LAMINATED_HP = 1e3;
|
|
13658
13783
|
var HOOD_SINK = 2e-3;
|
|
13659
13784
|
var HOOD_GAP_CLOSED = 0.016;
|
|
@@ -13741,6 +13866,14 @@ var GameVehicles = (() => {
|
|
|
13741
13866
|
cache2.set(material, made);
|
|
13742
13867
|
return made;
|
|
13743
13868
|
}
|
|
13869
|
+
function isGlowing(material) {
|
|
13870
|
+
const { emissive, emissiveIntensity } = material;
|
|
13871
|
+
return !!emissive && (emissiveIntensity ?? 0) > 0 && emissive.r + emissive.g + emissive.b >= GLOW_MIN_EMISSIVE;
|
|
13872
|
+
}
|
|
13873
|
+
function isMirrorChrome(material) {
|
|
13874
|
+
const { metalness, roughness, color: color2 } = material;
|
|
13875
|
+
return (metalness ?? 0) >= MIRROR_MIN_METALNESS && (roughness ?? 1) <= MIRROR_MAX_ROUGHNESS && !!color2 && (color2.r + color2.g + color2.b) / 3 >= MIRROR_MIN_LIGHTNESS;
|
|
13876
|
+
}
|
|
13744
13877
|
var VehicleVisuals = class {
|
|
13745
13878
|
constructor(kit, c, model) {
|
|
13746
13879
|
__publicField(this, "kit");
|
|
@@ -13835,7 +13968,7 @@ var GameVehicles = (() => {
|
|
|
13835
13968
|
case "bumper":
|
|
13836
13969
|
return z ? z.owned.filter((o) => o.parent) : [];
|
|
13837
13970
|
case "light":
|
|
13838
|
-
return
|
|
13971
|
+
return this.lampsOf(p).map((L) => L.group).filter((g) => g && g.parent);
|
|
13839
13972
|
case "rim":
|
|
13840
13973
|
return z ? z.wheels.filter((o) => o.parent) : [];
|
|
13841
13974
|
case "tyre": {
|
|
@@ -14738,7 +14871,7 @@ var GameVehicles = (() => {
|
|
|
14738
14871
|
if (on === this.lightsOn) return;
|
|
14739
14872
|
this.lightsOn = on;
|
|
14740
14873
|
const dark = this.I.MATERIALS.bulbBroken;
|
|
14741
|
-
for (const L of this.c.lights) {
|
|
14874
|
+
for (const L of [...this.c.lights, ...this.c.strayLamps ?? []]) {
|
|
14742
14875
|
if (L.broken || L.dark) continue;
|
|
14743
14876
|
for (const h of L.halo ?? []) h.visible = on;
|
|
14744
14877
|
for (const m of L.inner ?? []) {
|
|
@@ -14754,33 +14887,34 @@ var GameVehicles = (() => {
|
|
|
14754
14887
|
/** The lens of a light is holed or cracked and stays; `pierced`: a round went through it to the bulb, and the lamp goes dark. */
|
|
14755
14888
|
crackLight(p, pierced) {
|
|
14756
14889
|
if (pierced) this.darkenGlowIn(p);
|
|
14757
|
-
const
|
|
14758
|
-
|
|
14759
|
-
|
|
14890
|
+
for (const L of this.lampsOf(p)) this.kit.crackLight(this.c, L, new this.THREE.Vector3(p.box.center[0] > 0 ? -1 : 1, 0, 0), pierced);
|
|
14891
|
+
}
|
|
14892
|
+
/** The lamps of a light part: the ones its zone holds, or its own when no zone claims it (a fog lamp, a lit strip in the bumper). */
|
|
14893
|
+
lampsOf(p) {
|
|
14894
|
+
return p.lamps ?? this.zone(p)?.lights ?? [];
|
|
14760
14895
|
}
|
|
14761
14896
|
/** Everything of the lamp that glows goes dark: the fleet draws extra bulbs, reversing and amber strips in a lamp's place that the lamp's own list does not hold. */
|
|
14762
14897
|
darkenGlowIn(p) {
|
|
14763
14898
|
const dark = this.I.MATERIALS.bulbBroken;
|
|
14899
|
+
const dull = this.I.MATERIALS.broken;
|
|
14764
14900
|
const [cx, cy, cz] = p.box.center;
|
|
14765
14901
|
const [sx, sy, sz] = p.box.size;
|
|
14766
14902
|
this.c.vehicle.updateMatrixWorld(true);
|
|
14767
14903
|
this.c.vehicle.traverse((o) => {
|
|
14768
14904
|
const mesh2 = o;
|
|
14769
|
-
if (!mesh2.isMesh || mesh2.userData.glass || mesh2.material === dark || Array.isArray(mesh2.material)) return;
|
|
14770
|
-
const
|
|
14771
|
-
if (!
|
|
14905
|
+
if (!mesh2.isMesh || mesh2.userData.glass || mesh2.userData.decal || mesh2.material === dark || mesh2.material === dull || Array.isArray(mesh2.material)) return;
|
|
14906
|
+
const glows = isGlowing(mesh2.material);
|
|
14907
|
+
if (!glows && !isMirrorChrome(mesh2.material)) return;
|
|
14772
14908
|
mesh2.geometry.computeBoundingBox();
|
|
14773
14909
|
const mid = this.c.vehicle.worldToLocal(mesh2.localToWorld(mesh2.geometry.boundingBox.getCenter(new this.THREE.Vector3())));
|
|
14774
14910
|
if (Math.abs(mid.x - cx) > sx / 2 + LAMP_BOX_MARGIN || Math.abs(mid.y - cy) > sy / 2 + LAMP_BOX_MARGIN || Math.abs(mid.z - cz) > sz / 2 + LAMP_BOX_MARGIN) return;
|
|
14775
|
-
mesh2.material = dark;
|
|
14911
|
+
mesh2.material = glows ? dark : dull;
|
|
14776
14912
|
});
|
|
14777
14913
|
}
|
|
14778
14914
|
/** The lens of a light breaks and its unit stays (damaged) or goes (destroyed). */
|
|
14779
14915
|
breakLight(p, gone) {
|
|
14780
14916
|
this.darkenGlowIn(p);
|
|
14781
|
-
const
|
|
14782
|
-
if (!z) return;
|
|
14783
|
-
for (const L of z.lights) {
|
|
14917
|
+
for (const L of this.lampsOf(p)) {
|
|
14784
14918
|
L.lensMaterial = p.material;
|
|
14785
14919
|
this.kit.breakLight(this.c, L, new this.THREE.Vector3(p.box.center[0] > 0 ? -1 : 1, 0, 0));
|
|
14786
14920
|
if (gone) {
|
|
@@ -14972,8 +15106,7 @@ var GameVehicles = (() => {
|
|
|
14972
15106
|
moved = true;
|
|
14973
15107
|
}
|
|
14974
15108
|
if (p.role === "light") {
|
|
14975
|
-
const
|
|
14976
|
-
for (const L of z?.lights ?? []) {
|
|
15109
|
+
for (const L of this.lampsOf(p)) {
|
|
14977
15110
|
L.broken = L.broken || true;
|
|
14978
15111
|
for (const h of L.halo ?? []) h.visible = false;
|
|
14979
15112
|
}
|
|
@@ -15979,6 +16112,7 @@ var GameVehicles = (() => {
|
|
|
15979
16112
|
if (meshParts) return meshParts;
|
|
15980
16113
|
meshParts = /* @__PURE__ */ new Map();
|
|
15981
16114
|
for (const d of model.parts) {
|
|
16115
|
+
for (const L of d.lamps ?? []) for (const m of [...L.lens, ...L.inner]) meshParts.set(m, d.id);
|
|
15982
16116
|
if (d.role !== "glass") continue;
|
|
15983
16117
|
const z = kit.zonesOf(c).find((q) => q.id === d.zoneId);
|
|
15984
16118
|
for (const g of z?.glass ?? d.panes ?? []) meshParts.set(g, d.id);
|