@adatechnology/game-vehicles-three 0.9.5 → 0.9.7

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 CHANGED
@@ -4,7 +4,7 @@ import { EffectSink, Vec3, AudioSink, AnimationClipSpec } from '@adatechnology/g
4
4
  import { CabinSource, VehicleContext } from '@adatechnology/game-vehicles';
5
5
  import { LoopRecipe, Falloff, SampleAlias, SoundRecipe, SoundBank } from '@adatechnology/game-audio';
6
6
  import * as THREE_NS from 'three';
7
- import { Texture, Material, Color, Object3D, Matrix4, MeshStandardMaterial, MeshBasicMaterial, Mesh, Vector3, CanvasTexture, CircleGeometry, BufferGeometry, Side } from 'three';
7
+ import { Texture, Material, Color, Object3D, Matrix4, MeshStandardMaterial, MeshBasicMaterial, Mesh, Vector3, Box3, CanvasTexture, CircleGeometry, BufferGeometry, Side } from 'three';
8
8
  import '@adatechnology/game-vehicles-driving';
9
9
  import '@adatechnology/game-vehicles-proving';
10
10
 
@@ -362,6 +362,7 @@ interface VehicleLamps {
362
362
  declare function createVehicleLamps(THREE: {
363
363
  Object3D: new () => Object3D;
364
364
  Vector3: new () => Vector3;
365
+ Box3: new () => Box3;
365
366
  }, built: BuiltVehicle, options?: {
366
367
  lights?: unknown;
367
368
  owner?: string;
@@ -14661,7 +14661,7 @@ var GameVehiclesThree = (() => {
14661
14661
  off: 3e-3,
14662
14662
  nv: 4
14663
14663
  });
14664
- skin(c, Gd, o.refl || REFL, { u0: pu, u1: 1 - pu, yb, yt, off: 6e-3, nv: 4 });
14664
+ const reflector = skin(c, Gd, o.refl || REFL, { u0: pu, u1: 1 - pu, yb, yt, off: 6e-3, nv: 4 });
14665
14665
  (o.proj || []).forEach(function(q) {
14666
14666
  const r = sh(q[0]), y = (r[0] + r[1]) / 2 + (q[1] || 0), s = Gd.at(q[0], y), rad = q[2] || Math.min(0.034, (r[1] - r[0]) * 0.4);
14667
14667
  const cup = onSurf(c.cylinder(rad * 1.35, rad * 1.2, 0.012, LH, 0, 0, 0), s, 8e-3);
@@ -14692,7 +14692,7 @@ var GameVehiclesThree = (() => {
14692
14692
  lens.push(ln);
14693
14693
  if (!inner.length) inner.push(ln);
14694
14694
  const cs = Gd.at(0.5, (rg[0] + rg[1]) / 2).p;
14695
- regLight(c, "headlight", o.label || (sd > 0 ? trl("labels.right_headlight") : trl("labels.left_headlight")), inner, lens, cs);
14695
+ Object.assign(regLight(c, "headlight", o.label || (sd > 0 ? trl("labels.right_headlight") : trl("labels.left_headlight")), inner, lens, cs), { reflector: [reflector] });
14696
14696
  return Gd;
14697
14697
  };
14698
14698
  K.tail = function(sd, o) {
@@ -30008,7 +30008,13 @@ var GameVehiclesThree = (() => {
30008
30008
  pillar_c: "{Side} C pillar",
30009
30009
  engine: "Engine",
30010
30010
  radiator: "Radiator",
30011
- fuel_tank: "Fuel tank"
30011
+ fuel_tank: "Fuel tank",
30012
+ fog_light: "{Side} fog light",
30013
+ fog_light_center: "Fog light",
30014
+ lamp_front: "{Side} front lamp",
30015
+ lamp_front_center: "Front lamp",
30016
+ lamp_rear: "{Side} rear lamp",
30017
+ lamp_rear_center: "Rear lamp"
30012
30018
  }
30013
30019
  };
30014
30020
  var pt_BR_default2 = {
@@ -30217,7 +30223,13 @@ var GameVehiclesThree = (() => {
30217
30223
  pillar_c: "Coluna C {sideM}",
30218
30224
  engine: "Motor",
30219
30225
  radiator: "Radiador",
30220
- fuel_tank: "Tanque de combust\xEDvel"
30226
+ fuel_tank: "Tanque de combust\xEDvel",
30227
+ fog_light: "Farol de neblina {sideM}",
30228
+ fog_light_center: "Farol de neblina",
30229
+ lamp_front: "Luz dianteira {side}",
30230
+ lamp_front_center: "Luz dianteira",
30231
+ lamp_rear: "Luz traseira {side}",
30232
+ lamp_rear_center: "Luz traseira"
30221
30233
  }
30222
30234
  };
30223
30235
  var registry = { en: en_default2, "pt-BR": pt_BR_default2 };
@@ -35282,12 +35294,16 @@ var GameVehiclesThree = (() => {
35282
35294
  }
35283
35295
  kit.breakLight = breakLight;
35284
35296
  const crazedCache = /* @__PURE__ */ new Map();
35285
- const CRAZED_OPACITY = 0.6;
35297
+ const CRAZED_OPACITY = 0.5;
35298
+ const CRAZED_TINT = 0.6;
35299
+ const CRAZED_ROUGHNESS = 0.6;
35286
35300
  function crazed(material) {
35287
35301
  const known = crazedCache.get(material);
35288
35302
  if (known) return known;
35289
35303
  const m = I.crackLens(material).clone();
35290
35304
  m.opacity = Math.max(m.opacity ?? 1, CRAZED_OPACITY);
35305
+ m.color?.multiplyScalar(CRAZED_TINT);
35306
+ m.roughness = Math.max(m.roughness ?? 0, CRAZED_ROUGHNESS);
35291
35307
  m.transparent = true;
35292
35308
  m.userData.shared = true;
35293
35309
  crazedCache.set(material, m);
@@ -35305,6 +35321,7 @@ var GameVehiclesThree = (() => {
35305
35321
  L.dark = true;
35306
35322
  for (const m of L.inner) m.material = MATERIALS.bulbBroken;
35307
35323
  for (const h of L.halo ?? []) h.visible = false;
35324
+ for (const m of L.reflector ?? []) m.material = MATERIALS.broken;
35308
35325
  }
35309
35326
  kit.crackLight = crackLight;
35310
35327
  const shared2 = { glassUV, drawWeb, crackGlass, glassRim, shatterGlass, hitGlass, breakLight, crackLight };
@@ -40834,6 +40851,86 @@ var GameVehiclesThree = (() => {
40834
40851
  (plugins || []).forEach(kit.plugin);
40835
40852
  return kit;
40836
40853
  }
40854
+ var END_DEPTH = 0.45;
40855
+ var LAMP_EMISSIVE_MIN = 0.25;
40856
+ var LAMP_INTENSITY_MIN = 0.2;
40857
+ var UNIT_MARGIN = 0.03;
40858
+ var CLUSTER_GAP = 0.04;
40859
+ var CENTRE_Z = 0.08;
40860
+ function glowsLikeLamp(material) {
40861
+ if (!material || Array.isArray(material)) return false;
40862
+ const { emissive, emissiveIntensity } = material;
40863
+ if (!emissive || !((emissiveIntensity ?? 0) >= LAMP_INTENSITY_MIN)) return false;
40864
+ return Math.max(emissive.r, emissive.g, emissive.b) >= LAMP_EMISSIVE_MIN;
40865
+ }
40866
+ function membersOf(lights) {
40867
+ const members = /* @__PURE__ */ new Set();
40868
+ for (const L of lights) {
40869
+ L.group?.traverse((o) => members.add(o));
40870
+ for (const m of [...L.lens, ...L.inner, ...L.halo ?? []]) members.add(m);
40871
+ }
40872
+ return members;
40873
+ }
40874
+ function sideOf(box2) {
40875
+ const z = (box2.min.z + box2.max.z) / 2;
40876
+ return Math.abs(z) < CENTRE_Z ? "center" : z < 0 ? "left" : "right";
40877
+ }
40878
+ function lampOf(inner, box2, front, flags) {
40879
+ return { group: null, lens: [], inner, kind: front ? "headlight" : "taillight", tint: front ? "clear" : "red", broken: false, side: sideOf(box2), ...flags };
40880
+ }
40881
+ function strayLampsOf(c, THREE) {
40882
+ c.strayLamps ?? (c.strayLamps = findStrayLamps(c, THREE));
40883
+ return c.strayLamps;
40884
+ }
40885
+ function findStrayLamps(c, THREE) {
40886
+ const Box = THREE.Box3;
40887
+ const vehicle = c.vehicle;
40888
+ vehicle.updateMatrixWorld(true);
40889
+ const inverse = vehicle.matrixWorld.clone().invert();
40890
+ const localBox = (o) => new Box().setFromObject(o).applyMatrix4(inverse);
40891
+ const lights = c.lights ?? [];
40892
+ const members = membersOf(lights);
40893
+ const units = lights.map((L) => {
40894
+ const bb = new Box();
40895
+ for (const o of L.group ? [L.group] : [...L.lens, ...L.inner]) bb.union(localBox(o));
40896
+ return bb.expandByScalar(UNIT_MARGIN);
40897
+ });
40898
+ const front = c.meta?.front ?? new Box().setFromObject(vehicle).applyMatrix4(inverse).max.x;
40899
+ const rear = c.meta?.rear ?? new Box().setFromObject(vehicle).applyMatrix4(inverse).min.x;
40900
+ const found = [];
40901
+ const bulbs = [...c.fogBulbs ?? []];
40902
+ vehicle.traverse((o) => {
40903
+ if (o.userData.lamp === "fog" && o.isMesh && !bulbs.includes(o)) bulbs.push(o);
40904
+ });
40905
+ for (const bulb of bulbs) {
40906
+ if (members.has(bulb)) continue;
40907
+ members.add(bulb);
40908
+ const bb = localBox(bulb);
40909
+ found.push(lampOf([bulb], bb, bb.max.x > (front + rear) / 2, { fog: true }));
40910
+ }
40911
+ const loose = [];
40912
+ vehicle.traverse((o) => {
40913
+ const mesh2 = o;
40914
+ if (!mesh2.isMesh || members.has(mesh2) || mesh2.userData.glass || mesh2.userData.decal || mesh2.userData.lamp === "beacon") return;
40915
+ if (!glowsLikeLamp(mesh2.material)) return;
40916
+ const bb = localBox(mesh2);
40917
+ const mid = bb.getCenter(new THREE.Vector3());
40918
+ const atFront = mid.x > front - END_DEPTH;
40919
+ if (!atFront && mid.x > rear + END_DEPTH) return;
40920
+ if (units.some((u) => u.containsPoint(mid))) return;
40921
+ loose.push({ mesh: mesh2, box: bb, front: atFront });
40922
+ });
40923
+ const groups = [];
40924
+ for (const piece of loose) {
40925
+ const near = groups.find((g) => g.front === piece.front && g.box.clone().expandByScalar(CLUSTER_GAP).intersectsBox(piece.box));
40926
+ if (near) {
40927
+ near.meshes.push(piece.mesh);
40928
+ near.box.union(piece.box);
40929
+ } else groups.push({ meshes: [piece.mesh], box: piece.box.clone(), front: piece.front });
40930
+ }
40931
+ for (const g of groups) found.push(lampOf(g.meshes, g.box, g.front, { aux: true }));
40932
+ return found;
40933
+ }
40837
40934
  var ARMOUR_LEVELS = {
40838
40935
  IIIA: { glassStops: 1700, glassHp: 6e3, glassTakes: 0.25, steel: 8 },
40839
40936
  III: { glassStops: 3600, glassHp: 9e3, glassTakes: 0.25, steel: 30 }
@@ -40865,6 +40962,7 @@ var GameVehiclesThree = (() => {
40865
40962
  var HITCH_CHANCE = { car: 30, truck: 60, bus: 0, tractor: 100, quad: 40, bike: 0, tank: 0, boat: 0, plane: 0, heli: 0 };
40866
40963
  var GLASS_LENS_HP = 320;
40867
40964
  var PLASTIC_LENS_HP = 900;
40965
+ var STRAY_LAMP_MARGIN = 0.03;
40868
40966
  var STEEL_KG_M2 = 7;
40869
40967
  var ALU_KG_M2 = 3.2;
40870
40968
  var kindOf = (c) => {
@@ -40936,6 +41034,18 @@ var GameVehiclesThree = (() => {
40936
41034
  center: [b.center[0], b.center[1] - b.size[1] / 2 + Math.min(0.14, b.size[1]) / 2 + 0.04, b.center[2]],
40937
41035
  size: [b.size[0] * 0.5, Math.min(0.14, b.size[1]), b.size[2] * 0.95]
40938
41036
  });
41037
+ function strayLampBox(c, lamp, inverse) {
41038
+ const lo = [Infinity, Infinity, Infinity];
41039
+ const hi = [-Infinity, -Infinity, -Infinity];
41040
+ for (const mesh2 of [...lamp.lens, ...lamp.inner]) {
41041
+ const b = paneBox(c, mesh2, inverse);
41042
+ for (let i = 0; i < 3; i++) {
41043
+ lo[i] = Math.min(lo[i], b.center[i] - b.size[i] / 2);
41044
+ hi[i] = Math.max(hi[i], b.center[i] + b.size[i] / 2);
41045
+ }
41046
+ }
41047
+ 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) };
41048
+ }
40939
41049
  function paneBox(c, pane, inverse) {
40940
41050
  pane.geometry.computeBoundingBox();
40941
41051
  const box2 = pane.geometry.boundingBox.clone().applyMatrix4(pane.matrixWorld);
@@ -41097,6 +41207,15 @@ var GameVehiclesThree = (() => {
41097
41207
  const laminated = G2?.type === "laminated" || !!armoured;
41098
41208
  add2({ id: `pane_${G2?.key ?? "glass"}`, role: "glass", name: String(G2?.label ?? G2?.key ?? "glass"), material: "glass", box: bb, mass: 10 * areaOf(bb.size), hp: armoured ? armoured.glassHp : laminated ? 4e3 : 450, panes: [pane], visual: false, tags: ["glass"] });
41099
41209
  }
41210
+ for (const lamp of strayLampsOf(c, kit.THREE)) {
41211
+ const front = lamp.kind !== "taillight";
41212
+ const lens = front ? spec.headlightLens ?? "polycarbonate" : "acrylic";
41213
+ const glassLens = lens === "glass";
41214
+ const box2 = strayLampBox(c, lamp, inverse);
41215
+ const what = lamp.fog ? "fog_light" : front ? "lamp_front" : "lamp_rear";
41216
+ const name = lamp.side === "center" ? t(`mechanics.${what}_center`) : t(`mechanics.${what}`, { side: t(`sides.${lamp.side}`), sideM: t(`sides.${lamp.side}M`) });
41217
+ add2({ 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"] : []] });
41218
+ }
41100
41219
  if (!hubZone) {
41101
41220
  const h = Math.max(0.15, belt - clearance);
41102
41221
  add2({
@@ -41661,6 +41780,9 @@ var GameVehiclesThree = (() => {
41661
41780
  var HOLE_TEXTURE_SIZE = 64;
41662
41781
  var LAMP_BOX_MARGIN = 0.03;
41663
41782
  var GLOW_MIN_EMISSIVE = 0.05;
41783
+ var MIRROR_MIN_METALNESS = 0.8;
41784
+ var MIRROR_MAX_ROUGHNESS = 0.35;
41785
+ var MIRROR_MIN_LIGHTNESS = 0.4;
41664
41786
  var LAMINATED_HP = 1e3;
41665
41787
  var HOOD_SINK = 2e-3;
41666
41788
  var HOOD_GAP_CLOSED = 0.016;
@@ -41748,6 +41870,14 @@ var GameVehiclesThree = (() => {
41748
41870
  cache2.set(material, made);
41749
41871
  return made;
41750
41872
  }
41873
+ function isGlowing(material) {
41874
+ const { emissive, emissiveIntensity } = material;
41875
+ return !!emissive && (emissiveIntensity ?? 0) > 0 && emissive.r + emissive.g + emissive.b >= GLOW_MIN_EMISSIVE;
41876
+ }
41877
+ function isMirrorChrome(material) {
41878
+ const { metalness, roughness, color: color2 } = material;
41879
+ return (metalness ?? 0) >= MIRROR_MIN_METALNESS && (roughness ?? 1) <= MIRROR_MAX_ROUGHNESS && !!color2 && (color2.r + color2.g + color2.b) / 3 >= MIRROR_MIN_LIGHTNESS;
41880
+ }
41751
41881
  var VehicleVisuals = class {
41752
41882
  constructor(kit, c, model) {
41753
41883
  __publicField(this, "kit");
@@ -41830,7 +41960,7 @@ var GameVehiclesThree = (() => {
41830
41960
  case "bumper":
41831
41961
  return z ? z.owned.filter((o) => o.parent) : [];
41832
41962
  case "light":
41833
- return z ? z.lights.map((L) => L.group).filter((g) => g && g.parent) : [];
41963
+ return this.lampsOf(p).map((L) => L.group).filter((g) => g && g.parent);
41834
41964
  case "rim":
41835
41965
  return z ? z.wheels.filter((o) => o.parent) : [];
41836
41966
  case "tyre": {
@@ -42733,7 +42863,7 @@ var GameVehiclesThree = (() => {
42733
42863
  if (on === this.lightsOn) return;
42734
42864
  this.lightsOn = on;
42735
42865
  const dark = this.I.MATERIALS.bulbBroken;
42736
- for (const L of this.c.lights) {
42866
+ for (const L of [...this.c.lights, ...this.c.strayLamps ?? []]) {
42737
42867
  if (L.broken || L.dark) continue;
42738
42868
  for (const h of L.halo ?? []) h.visible = on;
42739
42869
  for (const m of L.inner ?? []) {
@@ -42749,33 +42879,34 @@ var GameVehiclesThree = (() => {
42749
42879
  /** 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. */
42750
42880
  crackLight(p, pierced) {
42751
42881
  if (pierced) this.darkenGlowIn(p);
42752
- const z = this.zone(p);
42753
- if (!z) return;
42754
- for (const L of z.lights) this.kit.crackLight(this.c, L, new this.THREE.Vector3(p.box.center[0] > 0 ? -1 : 1, 0, 0), pierced);
42882
+ 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);
42883
+ }
42884
+ /** 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). */
42885
+ lampsOf(p) {
42886
+ return p.lamps ?? this.zone(p)?.lights ?? [];
42755
42887
  }
42756
42888
  /** 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. */
42757
42889
  darkenGlowIn(p) {
42758
42890
  const dark = this.I.MATERIALS.bulbBroken;
42891
+ const dull = this.I.MATERIALS.broken;
42759
42892
  const [cx, cy, cz] = p.box.center;
42760
42893
  const [sx, sy, sz] = p.box.size;
42761
42894
  this.c.vehicle.updateMatrixWorld(true);
42762
42895
  this.c.vehicle.traverse((o) => {
42763
42896
  const mesh2 = o;
42764
- if (!mesh2.isMesh || mesh2.userData.glass || mesh2.material === dark || Array.isArray(mesh2.material)) return;
42765
- const { emissive, emissiveIntensity } = mesh2.material;
42766
- if (!emissive || !(emissiveIntensity > 0) || emissive.r + emissive.g + emissive.b < GLOW_MIN_EMISSIVE) return;
42897
+ if (!mesh2.isMesh || mesh2.userData.glass || mesh2.userData.decal || mesh2.material === dark || mesh2.material === dull || Array.isArray(mesh2.material)) return;
42898
+ const glows = isGlowing(mesh2.material);
42899
+ if (!glows && !isMirrorChrome(mesh2.material)) return;
42767
42900
  mesh2.geometry.computeBoundingBox();
42768
42901
  const mid = this.c.vehicle.worldToLocal(mesh2.localToWorld(mesh2.geometry.boundingBox.getCenter(new this.THREE.Vector3())));
42769
42902
  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;
42770
- mesh2.material = dark;
42903
+ mesh2.material = glows ? dark : dull;
42771
42904
  });
42772
42905
  }
42773
42906
  /** The lens of a light breaks and its unit stays (damaged) or goes (destroyed). */
42774
42907
  breakLight(p, gone) {
42775
42908
  this.darkenGlowIn(p);
42776
- const z = this.zone(p);
42777
- if (!z) return;
42778
- for (const L of z.lights) {
42909
+ for (const L of this.lampsOf(p)) {
42779
42910
  L.lensMaterial = p.material;
42780
42911
  this.kit.breakLight(this.c, L, new this.THREE.Vector3(p.box.center[0] > 0 ? -1 : 1, 0, 0));
42781
42912
  if (gone) {
@@ -42967,8 +43098,7 @@ var GameVehiclesThree = (() => {
42967
43098
  moved = true;
42968
43099
  }
42969
43100
  if (p.role === "light") {
42970
- const z = this.zone(p);
42971
- for (const L of z?.lights ?? []) {
43101
+ for (const L of this.lampsOf(p)) {
42972
43102
  L.broken = L.broken || true;
42973
43103
  for (const h of L.halo ?? []) h.visible = false;
42974
43104
  }
@@ -43970,6 +44100,7 @@ var GameVehiclesThree = (() => {
43970
44100
  if (meshParts) return meshParts;
43971
44101
  meshParts = /* @__PURE__ */ new Map();
43972
44102
  for (const d of model.parts) {
44103
+ for (const L of d.lamps ?? []) for (const m of [...L.lens, ...L.inner]) meshParts.set(m, d.id);
43973
44104
  if (d.role !== "glass") continue;
43974
44105
  const z = kit.zonesOf(c).find((q) => q.id === d.zoneId);
43975
44106
  for (const g of z?.glass ?? d.panes ?? []) meshParts.set(g, d.id);
@@ -49785,12 +49916,9 @@ var GameVehiclesThree = (() => {
49785
49916
  const budget = isLightBudget(options.lights) ? options.lights : null;
49786
49917
  const owner = options.owner ?? "vehicle-lamps";
49787
49918
  const context = built2.context;
49788
- const lamps = (context?.lights ?? []).filter((l) => l && Array.isArray(l.inner)).map((l) => l.fog ? Object.create(l, { kind: { value: "fog" } }) : l);
49789
- const bulbs = (context?.fogBulbs ?? []).filter((o) => o?.material);
49790
- built2.group.traverse((o) => {
49791
- if (o.userData?.lamp === "fog" && o.material && !bulbs.includes(o)) bulbs.push(o);
49792
- });
49793
- if (bulbs.length) lamps.push({ kind: "fog", inner: bulbs });
49919
+ const view = (l, kind) => l.kind === kind ? l : Object.create(l, { kind: { value: kind } });
49920
+ const lamps = (context?.lights ?? []).filter((l) => l && Array.isArray(l.inner)).map((l) => l.fog ? view(l, "fog") : l);
49921
+ for (const l of context ? strayLampsOf(context, THREE) : []) lamps.push(view(l, l.fog ? "fog" : "aux"));
49794
49922
  const beacons = [];
49795
49923
  built2.group.traverse((o) => {
49796
49924
  if (o.userData?.lamp === "beacon" && o.material) beacons.push({ mesh: o, side: o.userData.beaconSide === 1 ? 1 : 0 });
@@ -49817,15 +49945,16 @@ var GameVehiclesThree = (() => {
49817
49945
  for (const h of l.halo ?? []) haloBase.set(h, h.scale.x);
49818
49946
  }
49819
49947
  const amber = /* @__PURE__ */ new Set();
49820
- const sideOf = /* @__PURE__ */ new Map();
49948
+ const sideOf2 = /* @__PURE__ */ new Map();
49821
49949
  for (const l of lamps) {
49950
+ if (l.kind === "aux") continue;
49822
49951
  const x = l.group?.position?.x ?? 0;
49823
49952
  for (const m of l.inner) {
49824
49953
  const mat = Array.isArray(m.material) ? null : m.material;
49825
49954
  const c = (mat && (copies.get(mat) ?? mat))?.color;
49826
49955
  if (c && c.r > 0.5 && c.r - c.b > 0.35 && c.g < c.r * 0.8 && c.g > c.b) {
49827
49956
  amber.add(m);
49828
- sideOf.set(m, x >= 0 ? "left" : "right");
49957
+ sideOf2.set(m, x >= 0 ? "left" : "right");
49829
49958
  }
49830
49959
  }
49831
49960
  }
@@ -49895,7 +50024,8 @@ var GameVehiclesThree = (() => {
49895
50024
  const at = anchorObject?.getWorldPosition?.(new THREE.Vector3());
49896
50025
  if (at) across.set(l, built2.group.worldToLocal(at).x);
49897
50026
  }
49898
- const beamSide = (sign2) => !has.head || working("headlight").some((l) => (across.get(l) ?? 0) * sign2 > 0 || Math.abs(across.get(l) ?? 0) < CENTRE_LAMP_X);
50027
+ const litOn = (kind, sign2) => working(kind).some((l) => (across.get(l) ?? 0) * sign2 > 0 || Math.abs(across.get(l) ?? 0) < CENTRE_LAMP_X);
50028
+ const beamSide = (sign2) => !has.head || litOn("headlight", sign2);
49899
50029
  const health = () => lamps.map((l) => isOut(l) ? 1 : 0).join("");
49900
50030
  let healthSeen = health();
49901
50031
  const state = { mode: "off", fog: false, interior: false, brake: false, reverse: false, left: false, right: false };
@@ -49906,7 +50036,7 @@ var GameVehiclesThree = (() => {
49906
50036
  else if (l.kind === "taillight") glow(l, state.brake ? g.tail.brake : state.mode === "off" ? g.tail.off : g.tail.on);
49907
50037
  else if (l.kind === "fog") glow(l, state.fog ? g.fog.on : g.fog.off);
49908
50038
  }
49909
- for (const m of amber) glowMesh(m, state[sideOf.get(m) ?? "left"] ? g.amber.on : g.amber.off);
50039
+ for (const m of amber) glowMesh(m, state[sideOf2.get(m) ?? "left"] ? g.amber.on : g.amber.off);
49910
50040
  const lit = state.beacon ?? null;
49911
50041
  for (const b of beacons) glowMesh(b.mesh, lit === null ? g.beacon.off : lit === b.side ? g.beacon.lit : g.beacon.dark);
49912
50042
  const beamId = state.mode === "low" || state.mode === "high" ? state.mode : null;
@@ -49915,7 +50045,8 @@ var GameVehiclesThree = (() => {
49915
50045
  const lit2 = beamId === id ? front.filter((_, i) => sides[i]) : [];
49916
50046
  beam(id, lit2.length > 0, () => spots(lit2, LAMP_RULES[id]), lit2.length);
49917
50047
  }
49918
- beam("fog", state.fog && has.fog && working("fog").length > 0, () => spots(fogAnchors, LAMP_RULES.fog));
50048
+ const fogLit = state.fog && has.fog ? fogAnchors.filter((_, i) => litOn("fog", i === 0 ? -1 : 1)) : [];
50049
+ beam("fog", fogLit.length > 0, () => spots(fogLit, LAMP_RULES.fog), fogLit.length);
49919
50050
  beam("reverse", state.reverse && (!has.tail || working("taillight").length > 0), () => point(rear, LAMP_RULES.reverse));
49920
50051
  beam("interior", state.interior, () => point(cabin, LAMP_RULES.interior));
49921
50052
  };