polish: scene nits — live-lens yard, square stacks, deck-clear billboard, two-layer lamps, flare reach, phone traffic and exposure

This commit is contained in:
2026-10-12 18:59:33 +03:00
parent 71465fa481
commit 3602eeb3d1
23 changed files with 671 additions and 73 deletions

View File

@@ -1,5 +1,10 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
import {
FLARE_GAIN,
FLARE_SWELL,
flareReach,
HERO_CAR_HALF_WIDTH,
LAMPS_PER_VEHICLE,
TRAFFIC_BODY,
@@ -107,3 +112,25 @@ describe('expressway traffic stays clear of the hero car', () => {
expect(trafficPoolSize({ postEffects: false, postScale: 1 })).toBe(6);
});
});
describe('the flash to pass', () => {
it('peaks between 120 and 250 m, not within 100 m, and is gone past 420 m', () => {
const peak = Math.max(...Array.from({ length: 500 }, (_, d) => flareReach(d)));
expect(peak).toBe(1);
for (let d = 125; d <= 250; d += 5) expect(flareReach(d)).toBeGreaterThan(0.97);
expect(flareReach(120)).toBeGreaterThan(0.9);
for (let d = 0; d <= 100; d += 2) expect(flareReach(d)).toBeLessThan(0.35);
for (let d = 0; d <= 60; d += 2) expect(flareReach(d)).toBeLessThanOrEqual(0.15);
expect(flareReach(420)).toBe(0);
});
it('flares lamps in their own red and amber, only a little brighter', () => {
const source = readFileSync(resolve(process.cwd(), 'src/scene/world/traffic.ts'), 'utf8');
// No warm-white mix toward the headlight colour.
expect(source).not.toContain('vec3(1.0, 0.72, 0.58)');
expect(source).toContain('vGain * (1.0 + ${FLARE_GAIN.toFixed(2)} * vFlare)');
// At full lift (vFlare <= 0.7 + 1.6), a lamp gains at most ~0.8x of its own level.
expect(FLARE_GAIN * (0.7 + 1.6)).toBeLessThan(0.85);
expect(FLARE_SWELL).toBeLessThanOrEqual(0.3);
});
});