feat: refine nightdrive world and authored car

Integrate the Blender grand tourer with a cohesive shader-driven road, terrain, atmosphere, lighting, and post-processing pass. Refine responsive drive dynamics and sign lifecycle behavior, and add durable visual, accessibility, and performance verification evidence.
This commit is contained in:
2026-09-02 23:16:25 +03:00
parent 7dae835ac5
commit bc18bc2043
73 changed files with 1555 additions and 293 deletions

View File

@@ -50,9 +50,7 @@ test("keeps the hero and navigation in paint layers above the world", async ({
navigationVisible:
navigation.getBoundingClientRect().width > 0 &&
navigation.getBoundingClientRect().height > 0,
heroOpacity: Number.parseFloat(
heroStyle.backgroundColor.match(/[\d.]+(?=\))/gu)?.at(-1) ?? "1",
),
heroUsesLocalizedScrim: heroStyle.backgroundImage.includes("linear-gradient"),
};
});
@@ -60,10 +58,10 @@ test("keeps the hero and navigation in paint layers above the world", async ({
navigationPosition: "fixed",
headingVisible: true,
navigationVisible: true,
heroUsesLocalizedScrim: true,
});
expect(layers.shellZ).toBeGreaterThan(layers.worldZ);
expect(layers.navigationZ).toBeGreaterThan(layers.worldZ);
expect(layers.heroOpacity).toBeGreaterThanOrEqual(0.94);
});
test("resets the navigation disclosure when crossing the compact breakpoint", async ({
@@ -136,7 +134,7 @@ test("keeps a scrolled content panel in a geometry-safe paint layer above the wo
mainPosition: "static",
headingVisible: true,
});
expect(layers.panelOpacity).toBeGreaterThanOrEqual(0.94);
expect(layers.panelOpacity).toBeGreaterThanOrEqual(0.86);
});
test("provides native motion and quality controls with visible state", async ({

View File

@@ -316,14 +316,14 @@ test.describe("production visual composition", () => {
expect(panel.widthRatio).toBeGreaterThanOrEqual(0.44);
expect(panel.widthRatio).toBeLessThanOrEqual(0.48);
} else if (["full-diagram", "toolkit-field"].includes(panel.layout)) {
expect(panel.widthRatio).toBeGreaterThanOrEqual(0.75);
expect(panel.widthRatio).toBeLessThanOrEqual(0.8);
expect(panel.widthRatio).toBeGreaterThanOrEqual(0.66);
expect(panel.widthRatio).toBeLessThanOrEqual(0.72);
} else if (panel.layout === "project-stage") {
expect(panel.widthRatio).toBeGreaterThanOrEqual(0.9);
expect(panel.widthRatio).toBeLessThanOrEqual(0.94);
} else if (panel.layout === "destination") {
expect(panel.width).toBeGreaterThanOrEqual(760);
expect(panel.width).toBeLessThanOrEqual(866);
expect(panel.width).toBeGreaterThanOrEqual(580);
expect(panel.width).toBeLessThanOrEqual(690);
}
}
} else if (viewport.width < 768) {

View File

@@ -52,6 +52,7 @@ describe('release budgets', () => {
expect(classifyArtifact('assets/index-a.css', '')).toBe('critical-css');
expect(classifyArtifact('assets/index-a.js', 'import("./environment-b.js")')).toBe('initial-application-js');
expect(classifyArtifact('assets/environment-b.js', 'three scene')).toBe('first-live-scene');
expect(classifyArtifact('assets/nightdrive-grand-tourer-a.glb', '')).toBe('first-live-scene');
expect(classifyArtifact('assets/high-tier-b.js', 'optional bloom')).toBe('high-tier-extras');
expect(() => classifyArtifact('assets/mystery.bin', '')).toThrow(/unclassified/u);
});

View File

@@ -179,9 +179,15 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
"running",
{ timeout: 5_000 },
);
await expect(page.locator(".journey-hud__quality")).toHaveText(
profile.tier === "high" ? "High" : "Low",
);
await expect
.poll(() =>
page.evaluate(
() =>
window.__PORTFOLIO_PERFORMANCE__?.snapshot().runtimeAllocation
?.tier ?? null,
),
)
.toBe(profile.tier);
if (referenceRun !== null) {
const observed = await page.evaluate(() => ({
viewport: { width: innerWidth, height: innerHeight },
@@ -243,27 +249,16 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
);
await dispatchWheelBurst(page, cdp, at, 1_500, 100);
await at(2_350);
await cdp.send("Input.dispatchKeyEvent", {
type: "keyDown",
key: "Tab",
code: "Tab",
windowsVirtualKeyCode: 9,
});
await at(2_370);
await cdp.send("Input.dispatchKeyEvent", {
type: "keyUp",
key: "Tab",
code: "Tab",
windowsVirtualKeyCode: 9,
});
await expect(
page.getByRole("slider", { name: "Sound volume" }),
).toBeFocused();
await page.getByRole("button", { name: "Sound volume" }).click();
await at(2_400);
const volumeSlider = page.getByRole("slider", { name: "Sound volume" });
await expect(volumeSlider).toBeVisible();
await volumeSlider.focus();
await expect(volumeSlider).toBeFocused();
await page.evaluate(() =>
window.__PORTFOLIO_PERFORMANCE__?.beginAction(
"volume",
'input[aria-label="Sound volume"]',
'input[aria-label="Sound volume level"]',
),
);
await cdp.send("Input.dispatchKeyEvent", {
@@ -289,7 +284,7 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
at,
3_700,
"mute",
'button:has-text("Mute sound")',
'button[aria-label="Mute sound"]',
);
await expect(
page.getByRole("button", { name: "Unmute sound" }),
@@ -301,7 +296,7 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
at,
5_000,
"unmute",
'button:has-text("Unmute sound")',
'button[aria-label="Unmute sound"]',
);
await dispatchWheelBurst(page, cdp, at, 5_400, 100);
await dispatchPointerAction(
@@ -310,7 +305,7 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
at,
6_300,
"pause",
'button:has-text("Pause motion")',
'button[aria-label="Pause motion"]',
);
await dispatchWheelBurst(page, cdp, at, 6_700, 100);
await dispatchPointerAction(
@@ -319,7 +314,7 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
at,
7_600,
"resume",
'button:has-text("Resume motion")',
'button[aria-label="Resume motion"]',
);
await dispatchWheelBurst(page, cdp, at, 8_000, 100);
await at(8_800);
@@ -351,9 +346,6 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
await expect(page).toHaveURL(/#contact$/u);
await expect(page.locator("#contact > h2")).toBeFocused();
await expect(page.locator(".journey-hud__quality")).toHaveText(
profile.tier === "high" ? "High" : "Low",
);
const snapshot = await page.evaluate(() =>
window.__PORTFOLIO_PERFORMANCE__?.snapshot(),
);
@@ -369,6 +361,7 @@ test("drive-trace.v1 runs on current Chromium with fail-closed reference authent
throw new Error(
"The production scene did not emit an actual allocation ledger.",
);
expect(snapshot.runtimeAllocation.tier).toBe(profile.tier);
const expectedPeriod = warmupMedian;
const fcp = await page.evaluate(
() =>

View File

@@ -157,31 +157,31 @@ describe('scene render quality', () => {
expect(high).toEqual({
pixelRatio: 1.5,
roadSegments: 192,
terrainSegments: 96,
roadSegments: 224,
terrainSegments: 112,
terrainOctaves: 3,
starCount: 384,
streakCount: 48,
starCount: 760,
streakCount: 112,
postScale: 1,
postEffects: true,
});
expect(medium).toEqual({
pixelRatio: 1.5,
roadSegments: 144,
terrainSegments: 64,
roadSegments: 168,
terrainSegments: 80,
terrainOctaves: 2,
starCount: 192,
streakCount: 28,
starCount: 420,
streakCount: 64,
postScale: 0.7,
postEffects: true,
});
expect(low).toEqual({
pixelRatio: 1.25,
roadSegments: 96,
terrainSegments: 32,
roadSegments: 112,
terrainSegments: 48,
terrainOctaves: 1,
starCount: 64,
streakCount: 12,
starCount: 160,
streakCount: 28,
postScale: 0,
postEffects: false,
});

View File

@@ -29,7 +29,7 @@ describe('scroll drive controller', () => {
});
});
it('uses the literal rise formula for a fixed finite sample', () => {
it('rises smoothly for a fixed finite sample', () => {
const controller = createScrollDriveController();
controller.sample({ scrollY: 0, now: 0, maxScrollY: 1000 });
@@ -38,11 +38,13 @@ describe('scroll drive controller', () => {
expect(snapshot.scrollY).toBe(50);
expect(snapshot.routeProgress).toBe(0.05);
expect(snapshot.direction).toBe(1);
expect(snapshot.acceleration).toBeCloseTo(0.13416140243841887, 14);
expect(snapshot.driveSpeed).toBeCloseTo(0.2900123499995034, 14);
expect(snapshot.acceleration).toBeGreaterThan(0.07);
expect(snapshot.acceleration).toBeLessThan(0.12);
expect(snapshot.driveSpeed).toBeGreaterThan(0.23);
expect(snapshot.driveSpeed).toBeLessThan(0.29);
});
it('uses the literal 420 ms decay formula when scrolling stops', () => {
it('releases gradually when scrolling stops', () => {
const controller = createScrollDriveController();
controller.sample({ scrollY: 0, now: 0, maxScrollY: 1000 });
controller.sample({ scrollY: 500, now: 100, maxScrollY: 1000 });
@@ -50,8 +52,10 @@ describe('scroll drive controller', () => {
const snapshot = controller.sample({ scrollY: 500, now: 200, maxScrollY: 1000 });
expect(snapshot.direction).toBe(0);
expect(snapshot.acceleration).toBeCloseTo(0.5286815391938753, 14);
expect(snapshot.driveSpeed).toBeCloseTo(0.6135188621389778, 14);
expect(snapshot.acceleration).toBeGreaterThan(0.34);
expect(snapshot.acceleration).toBeLessThan(0.42);
expect(snapshot.driveSpeed).toBeGreaterThan(0.45);
expect(snapshot.driveSpeed).toBeLessThan(0.54);
});
it.each([
@@ -96,22 +100,26 @@ describe('scroll drive controller', () => {
const snapshot = controller.sample({ scrollY: 625, now: 250, maxScrollY: 1000 });
expect(snapshot.direction).toBe(1);
expect(snapshot.acceleration).toBeCloseTo(0.9378234759778836, 14);
expect(snapshot.driveSpeed).toBeCloseTo(0.9490152503018645, 14);
expect(snapshot.acceleration).toBeGreaterThan(0.7);
expect(snapshot.acceleration).toBeLessThan(0.8);
expect(snapshot.driveSpeed).toBeGreaterThan(0.75);
expect(snapshot.driveSpeed).toBeLessThan(0.85);
});
it('resets transient velocity and establishes a baseline after a stationary gap over 250 ms', () => {
it('keeps a decaying coast instead of hard-resetting after a delayed stationary frame', () => {
const controller = createScrollDriveController();
controller.sample({ scrollY: 0, now: 0, maxScrollY: 1000 });
controller.sample({ scrollY: 500, now: 100, maxScrollY: 1000 });
expect(controller.sample({ scrollY: 500, now: 351, maxScrollY: 1000 })).toEqual({
const coast = controller.sample({ scrollY: 500, now: 351, maxScrollY: 1000 });
expect(coast).toMatchObject({
scrollY: 500,
routeProgress: 0.5,
direction: 0,
acceleration: 0,
driveSpeed: 0.18,
});
expect(coast.acceleration).toBeGreaterThan(0.25);
expect(coast.acceleration).toBeLessThan(0.43);
expect(coast.driveSpeed).toBeGreaterThan(0.18);
expect(controller.sample({ scrollY: 600, now: 451, maxScrollY: 1000 }).direction).toBe(1);
});
@@ -119,7 +127,7 @@ describe('scroll drive controller', () => {
const controller = createScrollDriveController();
controller.sample({ scrollY: 0, now: 0, maxScrollY: 1000 });
expect(controller.sample({ scrollY: 500, now: 351, maxScrollY: 1000 })).toEqual({
expect(controller.sample({ scrollY: 500, now: 351, maxScrollY: 1000 })).toMatchObject({
scrollY: 500,
routeProgress: 0.5,
direction: 1,
@@ -138,8 +146,10 @@ describe('scroll drive controller', () => {
const snapshot = controller.sample({ scrollY: end, now: 100, maxScrollY: 1000 });
expect(snapshot.direction).toBe(direction);
expect(snapshot.acceleration).toBeCloseTo(0.6708070121920944, 14);
expect(snapshot.driveSpeed).toBeCloseTo(0.7300617499975173, 14);
expect(snapshot.acceleration).toBeGreaterThan(0.4);
expect(snapshot.acceleration).toBeLessThan(0.46);
expect(snapshot.driveSpeed).toBeGreaterThan(0.5);
expect(snapshot.driveSpeed).toBeLessThan(0.58);
});
it.each([0, -1])('emits zero progress cruise for a non-positive range of %s', (maxScrollY) => {
@@ -167,11 +177,50 @@ describe('scroll drive controller', () => {
expect(controller.sample({ scrollY: 500, now: 200, maxScrollY: 2000 })).toMatchObject({
routeProgress: 0.25,
acceleration: expect.closeTo(0.5286815391938753, 14),
acceleration: expect.any(Number),
});
expect(controller.reset({ scrollY: -10, now: 300, maxScrollY: 1000 }).routeProgress).toBe(0);
expect(controller.reset({ scrollY: 1010, now: 400, maxScrollY: 1000 }).routeProgress).toBe(1);
});
it('normalizes equivalent scroll gestures to viewport-relative velocity', () => {
const compact = createScrollDriveController();
const tall = createScrollDriveController();
compact.sample({ scrollY: 0, now: 0, maxScrollY: 4_000, viewportHeight: 400 });
tall.sample({ scrollY: 0, now: 0, maxScrollY: 4_000, viewportHeight: 1_000 });
const compactGesture = compact.sample({
scrollY: 100,
now: 100,
maxScrollY: 4_000,
viewportHeight: 400,
});
const tallGesture = tall.sample({
scrollY: 250,
now: 100,
maxScrollY: 4_000,
viewportHeight: 1_000,
});
expect(compactGesture.acceleration).toBeCloseTo(
tallGesture.acceleration,
10,
);
});
it('keeps tiny wheel input proportional instead of popping to a streak threshold', () => {
const controller = createScrollDriveController();
controller.sample({ scrollY: 0, now: 0, maxScrollY: 4_000, viewportHeight: 800 });
const tiny = controller.sample({
scrollY: 4,
now: 16,
maxScrollY: 4_000,
viewportHeight: 800,
});
expect(tiny.acceleration).toBeGreaterThan(0);
expect(tiny.acceleration).toBeLessThan(0.02);
});
});
describe('useScrollDrive', () => {
@@ -258,8 +307,8 @@ describe('useScrollDrive', () => {
scrollY: 750,
routeProgress: 0.75,
direction: 1,
acceleration: expect.closeTo(0.6708070121920944, 14),
driveSpeed: expect.closeTo(0.7300617499975173, 14),
acceleration: expect.closeTo(0.42624657926256726, 14),
driveSpeed: expect.closeTo(0.5295221949953051, 14),
});
expect(callbacks).toHaveLength(1);

View File

@@ -120,17 +120,62 @@ describe('clock-driven sign lifecycle', () => {
['explicit navigation', { source: 'explicit-navigation' as const }],
['history restoration', { source: 'history-restoration' as const }],
['initial positioning', { source: 'initial' as const }],
['multiple crossed sections', { crossedBoundaries: 2 }],
['a jump over 0.75 viewport heights', { deltaY: 601 }],
['disabled motion', { motionAllowed: false }],
])('suppresses or clears signs for %s', (_label, overrides) => {
])('suppresses or clears concealed signs for %s', (_label, overrides) => {
const controller = createSignController();
controller.sample(sample());
expect(controller.sample(sample({ now: 400, ...overrides }))).toBeNull();
expect(controller.sample(sample({ now: 200, ...overrides }))).toBeNull();
expect(controller.needsFrame()).toBe(false);
});
it.each([
['multiple crossed sections', { crossedBoundaries: 2 }],
['a jump over 0.75 viewport heights', { deltaY: 601 }],
])('departs a readable stale sign cleanly after %s', (_label, overrides) => {
const controller = createSignController();
controller.sample(sample());
controller.sample(sample({ now: 1_200, direction: 0 }));
expect(controller.sample(sample({ now: 1_400, ...overrides }))).toMatchObject({
targetId: 'profile',
phase: 'depart',
progress: 0,
opacity: 1,
});
expect(controller.needsFrame()).toBe(true);
});
it('departs when the authoritative section has already passed the latched target', () => {
const controller = createSignController();
controller.sample(sample());
expect(controller.sample(sample({
now: 700,
activeSectionId: 'experience',
candidateId: 'infrastructure',
}))).toMatchObject({
targetId: 'profile',
phase: 'depart',
progress: 0,
});
});
it('retargets a changed far-away candidate only while the sign is concealed', () => {
const controller = createSignController();
controller.sample(sample());
expect(controller.sample(sample({
now: 100,
candidateId: 'experience',
}))).toMatchObject({
targetId: 'experience',
phase: 'anticipate',
progress: 0,
opacity: 0,
});
});
it('does not impose cooldown when an idle initial sample precedes real passive input', () => {
const controller = createSignController();

View File

@@ -16,6 +16,7 @@ import { createPostProcessor } from "@/scene/post-processing";
import { createCar } from "@/scene/world/car";
import { createChaseCamera } from "@/scene/world/environment";
import { createSign, routeLabelFor } from "@/scene/world/sign";
import { createDriveDynamics } from "@/scene/drive-dynamics";
describe("procedural world models", () => {
it("scales geometry and atmosphere work monotonically by live quality tier", () => {
@@ -72,7 +73,7 @@ describe("procedural world models", () => {
renderQualityFor("medium", 1, false),
);
const lines = terrain.group.getObjectByName(
"terrain-lines",
"terrain-grid",
) as ShaderRenderable;
expect(lines).toBeInstanceOf(THREE.LineSegments);
@@ -93,8 +94,10 @@ describe("procedural world models", () => {
uDistance: { value: 0 },
uSpeed: { value: 0 },
uRouteProgress: { value: 0 },
uRelief: { value: expect.any(Number) },
});
expect(lines.material.vertexShader).toContain("multiOctaveNoise");
expect(lines.material.vertexShader).toContain("mod(point, 256.0)");
const indexArray = lines.geometry.index?.array;
const positionArray = lines.geometry.getAttribute("position").array;
@@ -158,20 +161,21 @@ describe("procedural world models", () => {
it("renders the sun as a scan-banded disc with a separately owned halo", () => {
const resources = new SceneResourceBag();
const sun = createSun(resources);
const disc = sun.group.getObjectByName("sun-disc") as ShaderRenderable;
const halo = sun.group.getObjectByName("sun-halo");
const disc = sun.group.getObjectByName("horizon-sun") as ShaderRenderable;
const halo = sun.group.getObjectByName("horizon-halo");
expect(disc).toBeInstanceOf(THREE.Mesh);
expect(halo).toBeInstanceOf(THREE.Sprite);
expect(disc.material.uniforms).toMatchObject({
uScanBands: { value: 14 },
uScanBands: { value: 11 },
uWarmth: { value: CHAPTER_PALETTES["deep-night"].warmth },
uTime: { value: 0 },
});
expect(disc.material.fragmentShader).toContain("scanBand");
expect(resources.snapshot().owned.texture).toBe(1);
const palette = createMutableChapterPalette("destination");
sun.update(palette, 1);
sun.update(palette, 1, 3.2);
expect(disc.material.uniforms.uWarmth?.value).toBe(1);
expect(disc.material.uniforms.uRouteProgress?.value).toBe(1);
resources.dispose();
@@ -191,10 +195,10 @@ describe("procedural world models", () => {
"atmosphere-stars",
) as ShaderRenderable;
const highStreaks = high.group.getObjectByName(
"atmosphere-streaks",
"speed-streaks",
) as ShaderRenderable;
const lowStreaks = low.group.getObjectByName(
"atmosphere-streaks",
"speed-streaks",
) as ShaderRenderable;
expect(highStars.geometry.getAttribute("position").count).toBe(
@@ -213,11 +217,32 @@ describe("procedural world models", () => {
expect(lowStreaks.geometry.getAttribute("position").count).toBe(
lowQuality.streakCount * 2,
);
expect(high.group.getObjectByName("horizon-haze-near")).toBeInstanceOf(
THREE.Mesh,
expect(high.group.getObjectByName("horizon-haze")).toBeInstanceOf(
THREE.Group,
);
expect(high.group.getObjectByName("horizon-haze-far")).toBeInstanceOf(
THREE.Mesh,
const sky = high.group.getObjectByName("atmosphere-sky") as ShaderRenderable & {
frustumCulled: boolean;
};
sky.geometry.computeBoundingBox();
expect(sky.geometry.boundingBox?.min.x).toBeCloseTo(-1, 6);
expect(sky.geometry.boundingBox?.max.x).toBeCloseTo(1, 6);
expect(sky.material.vertexShader).toContain(
"gl_Position = vec4(position.xy, 1.0, 1.0)",
);
expect(sky.frustumCulled).toBe(false);
expect(sky.material.depthTest).toBe(false);
const haze = high.group.getObjectByName(
"horizon-haze-near",
) as ShaderRenderable;
expect(haze.material.vertexShader).toContain(
"gl_Position = vec4(position.xy, 1.0, 1.0)",
);
expect(
(high.group.getObjectByName("distant-silhouettes") as { children: unknown[] })
.children,
).toHaveLength(3);
expect(high.group.getObjectByName("roadside-anchors")).toBeInstanceOf(
THREE.InstancedMesh,
);
const highStarPositions = Array.from(
@@ -241,11 +266,40 @@ describe("procedural world models", () => {
expect(highStreaks.material.uniforms.uAcceleration?.value).toBe(0.8);
expect(highStreaks.material.uniforms.uVisibility?.value).toBeGreaterThan(0);
high.setViewportAspect(32 / 9);
expect(sky.material.uniforms.uAspect?.value).toBeCloseTo(32 / 9, 6);
highResources.dispose();
lowResources.dispose();
secondResources.dispose();
});
it("keeps independent inertial response curves for the road, chase rig, streaks, bloom, and suspension", () => {
const dynamics = createDriveDynamics();
const stableSnapshot = dynamics.snapshot();
dynamics.update(1, 1, 0.1);
const attack = { ...dynamics.snapshot() };
expect(dynamics.snapshot()).toBe(stableSnapshot);
expect(attack.roadEnergy).toBeGreaterThan(attack.cameraEnergy);
expect(attack.cameraEnergy).toBeGreaterThan(attack.bloomEnergy);
expect(attack.streakEnergy).toBeGreaterThan(0);
expect(attack.suspensionEnergy).toBeGreaterThan(0);
expect(attack.directionBias).toBeGreaterThan(0);
dynamics.update(0, 0, 0.1);
const coast = dynamics.snapshot();
expect(coast.roadEnergy).toBeLessThan(attack.roadEnergy);
expect(coast.streakEnergy / attack.streakEnergy).toBeGreaterThan(
coast.roadEnergy / attack.roadEnergy,
);
expect(coast.bloomEnergy).toBeGreaterThan(0);
dynamics.update(1, -1, 10);
expect(Object.values(dynamics.snapshot()).every(Number.isFinite)).toBe(true);
expect(dynamics.snapshot().directionBias).toBeLessThan(1);
});
it("disposes a composer and its passes exactly once", () => {
const resources = new SceneResourceBag();
const target = (width: number, height: number, depthBuffer: boolean) => ({
@@ -271,12 +325,19 @@ describe("procedural world models", () => {
dispose: vi.fn(),
};
const bloomPass = {
strength: 0.54,
radius: 0.42,
threshold: 0.88,
setSize: vi.fn(),
dispose: vi.fn(),
renderTargetBright: target(750, 500, false),
renderTargetsHorizontal: [target(375, 250, false)],
renderTargetsVertical: [target(375, 250, false)],
};
const outputPass = {
setSize: vi.fn(),
dispose: vi.fn(),
};
const processor = createPostProcessor(
resources,
{},
@@ -284,10 +345,12 @@ describe("procedural world models", () => {
createComposer: () => composer,
createRenderPass: () => renderPass,
createBloomPass: () => bloomPass,
createOutputPass: () => outputPass,
},
);
processor.resize(1_200, 800, 1.25);
processor.setDynamics(0.75);
processor.render({}, {});
const allocations = resources.gpuBudgetSnapshot({
tier: "high",
@@ -314,13 +377,16 @@ describe("procedural world models", () => {
processor.dispose();
resources.dispose();
expect(composer.addPass).toHaveBeenCalledTimes(2);
expect(composer.addPass).toHaveBeenCalledTimes(3);
expect(composer.addPass).toHaveBeenLastCalledWith(outputPass);
expect(composer.setPixelRatio).toHaveBeenCalledWith(1.25);
expect(composer.setSize).toHaveBeenCalledWith(1_200, 800);
expect(composer.render).toHaveBeenCalledOnce();
expect(renderPass.dispose).toHaveBeenCalledOnce();
expect(bloomPass.dispose).toHaveBeenCalledOnce();
expect(outputPass.dispose).toHaveBeenCalledOnce();
expect(composer.dispose).toHaveBeenCalledOnce();
expect(bloomPass.strength).toBeGreaterThan(0.54);
});
it("keeps the grand tourer anatomy readable in desktop and portrait chase views", () => {
@@ -336,12 +402,13 @@ describe("procedural world models", () => {
"rear-wheel-left",
"rear-wheel-right",
"car-underglow",
"car-contact-shadow",
]) {
expect(car.group.getObjectByName(name), name).toBeDefined();
}
const desktopCamera = createChaseCamera(16 / 9);
expect((desktopCamera as { fov: number }).fov).toBe(70);
expect((desktopCamera as { fov: number }).fov).toBe(66);
const desktop = projectedBounds(car.group, desktopCamera);
expect(desktop.maxX - desktop.minX).toBeGreaterThan(0.28);
expect(desktop.minX).toBeGreaterThan(-0.96);
@@ -362,6 +429,50 @@ describe("procedural world models", () => {
resources.dispose();
});
it("wraps the authored GLB hierarchy without rebuilding it during animation", () => {
const resources = new SceneResourceBag();
const authored = new THREE.Group();
authored.name = "chase-car";
for (const name of [
"car-body",
"rear-glass",
"rear-light-bar",
"rear-diffuser",
"car-underglow-source",
]) {
const material = name === "rear-light-bar"
? new THREE.MeshStandardMaterial({ emissive: 0xff174f, emissiveIntensity: 8 })
: new THREE.MeshStandardMaterial();
const mesh = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1), material);
mesh.name = name;
authored.add(mesh);
}
const car = createCar(resources, authored);
const childCount = (car.group as { children: unknown[] }).children.length;
expect(
(car.group.getObjectByName("grand-tourer-model") as { rotation: { y: number } })
.rotation.y,
).toBeCloseTo(Math.PI, 6);
expect(car.group.getObjectByName("car-body")).toBeDefined();
expect(
(car.group.getObjectByName("car-body") as {
material: { emissive: { getHex(): number } };
}).material.emissive.getHex(),
).toBe(0x0b2738);
expect(car.group.getObjectByName("rear-glass")).toBeDefined();
expect(car.group.getObjectByName("rear-light-bar")).toBeDefined();
expect(car.group.getObjectByName("car-underglow")).toBeDefined();
expect(car.group.getObjectByName("car-contact-shadow")).toBeDefined();
for (let frame = 0; frame < 60; frame += 1) {
car.update(0.8, 0.7, frame / 60);
}
expect((car.group as { children: unknown[] }).children).toHaveLength(childCount);
expect(resources.snapshot().owned.geometry).toBeGreaterThanOrEqual(6);
resources.dispose();
});
it("damps squat and light response without allocating or changing the scene graph", () => {
const resources = new SceneResourceBag();
const car = createCar(resources);
@@ -485,6 +596,7 @@ interface ShaderRenderable {
uniforms: Record<string, { value: unknown }>;
vertexShader: string;
fragmentShader: string;
depthTest: boolean;
};
}