@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.
@@ -2300,6 +2300,7 @@ function createVehicleDashboard(THREE, built, options) {
2300
2300
 
2301
2301
  // src/lamps.ts
2302
2302
  import { isLightBudget, LIGHT_PRIORITY } from "@adatechnology/game-render-three";
2303
+ import { strayLampsOf } from "@adatechnology/game-vehicles";
2303
2304
  var LAMP_RULES = {
2304
2305
  glow: { head: { off: 0.04, position: 0.3, low: 1, high: 1.35 }, tail: { off: 0.15, on: 0.7, brake: 1.6 }, fog: { off: 0.04, on: 1.1 }, amber: { off: 0.1, on: 2.2 }, beacon: { off: 0.35, dark: 0.12, lit: 2.8 } },
2305
2306
  low: { color: 16773584, intensity: 2.4, distance: 32, angle: 0.42, penumbra: 0.55, decay: 1.6, drop: 0.09 },
@@ -2313,12 +2314,9 @@ function createVehicleLamps(THREE, built, options = {}) {
2313
2314
  const budget = isLightBudget(options.lights) ? options.lights : null;
2314
2315
  const owner = options.owner ?? "vehicle-lamps";
2315
2316
  const context = built.context;
2316
- const lamps = (context?.lights ?? []).filter((l) => l && Array.isArray(l.inner)).map((l) => l.fog ? Object.create(l, { kind: { value: "fog" } }) : l);
2317
- const bulbs = (context?.fogBulbs ?? []).filter((o) => o?.material);
2318
- built.group.traverse((o) => {
2319
- if (o.userData?.lamp === "fog" && o.material && !bulbs.includes(o)) bulbs.push(o);
2320
- });
2321
- if (bulbs.length) lamps.push({ kind: "fog", inner: bulbs });
2317
+ const view = (l, kind) => l.kind === kind ? l : Object.create(l, { kind: { value: kind } });
2318
+ const lamps = (context?.lights ?? []).filter((l) => l && Array.isArray(l.inner)).map((l) => l.fog ? view(l, "fog") : l);
2319
+ for (const l of context ? strayLampsOf(context, THREE) : []) lamps.push(view(l, l.fog ? "fog" : "aux"));
2322
2320
  const beacons = [];
2323
2321
  built.group.traverse((o) => {
2324
2322
  if (o.userData?.lamp === "beacon" && o.material) beacons.push({ mesh: o, side: o.userData.beaconSide === 1 ? 1 : 0 });
@@ -2347,6 +2345,7 @@ function createVehicleLamps(THREE, built, options = {}) {
2347
2345
  const amber = /* @__PURE__ */ new Set();
2348
2346
  const sideOf = /* @__PURE__ */ new Map();
2349
2347
  for (const l of lamps) {
2348
+ if (l.kind === "aux") continue;
2350
2349
  const x = l.group?.position?.x ?? 0;
2351
2350
  for (const m of l.inner) {
2352
2351
  const mat = Array.isArray(m.material) ? null : m.material;
@@ -2423,7 +2422,8 @@ function createVehicleLamps(THREE, built, options = {}) {
2423
2422
  const at = anchorObject?.getWorldPosition?.(new THREE.Vector3());
2424
2423
  if (at) across.set(l, built.group.worldToLocal(at).x);
2425
2424
  }
2426
- const beamSide = (sign) => !has.head || working("headlight").some((l) => (across.get(l) ?? 0) * sign > 0 || Math.abs(across.get(l) ?? 0) < CENTRE_LAMP_X);
2425
+ const litOn = (kind, sign) => working(kind).some((l) => (across.get(l) ?? 0) * sign > 0 || Math.abs(across.get(l) ?? 0) < CENTRE_LAMP_X);
2426
+ const beamSide = (sign) => !has.head || litOn("headlight", sign);
2427
2427
  const health = () => lamps.map((l) => isOut(l) ? 1 : 0).join("");
2428
2428
  let healthSeen = health();
2429
2429
  const state = { mode: "off", fog: false, interior: false, brake: false, reverse: false, left: false, right: false };
@@ -2443,7 +2443,8 @@ function createVehicleLamps(THREE, built, options = {}) {
2443
2443
  const lit2 = beamId === id ? front.filter((_, i) => sides[i]) : [];
2444
2444
  beam(id, lit2.length > 0, () => spots(lit2, LAMP_RULES[id]), lit2.length);
2445
2445
  }
2446
- beam("fog", state.fog && has.fog && working("fog").length > 0, () => spots(fogAnchors, LAMP_RULES.fog));
2446
+ const fogLit = state.fog && has.fog ? fogAnchors.filter((_, i) => litOn("fog", i === 0 ? -1 : 1)) : [];
2447
+ beam("fog", fogLit.length > 0, () => spots(fogLit, LAMP_RULES.fog), fogLit.length);
2447
2448
  beam("reverse", state.reverse && (!has.tail || working("taillight").length > 0), () => point(rear, LAMP_RULES.reverse));
2448
2449
  beam("interior", state.interior, () => point(cabin, LAMP_RULES.interior));
2449
2450
  };
@@ -4029,4 +4030,4 @@ export {
4029
4030
  createProvingModule,
4030
4031
  loadProvingModule
4031
4032
  };
4032
- //# sourceMappingURL=chunk-IHMZYKUW.js.map
4033
+ //# sourceMappingURL=chunk-CCKLH536.js.map