Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Give the vegetation pop test a free port, and accept the height falloff size (part of #394)

Nguyen Xuan Anbc191ee1150e
diff --git a/changes/394.size.md b/changes/394.size.md
index 3ae115d7..33ee0ed8 100644
--- a/changes/394.size.md
+++ b/changes/394.size.md
@@ -1,3 +1,5 @@
-- scene:lit-box: volumeFog heightFalloff (one uniform, one shader line, one validated field), needs An to accept it as it crosses the 50000 goal
-- scene:agent-scene: same change
-- scene:agent-scene+lazy: same change
+- scene:lit-box: volumeFog heightFalloff (one uniform, one shader line, one validated field) lets a mist thin with height, about 81 B.
+- scene:agent-scene: the same change, about 91 B.
+- scene:agent-scene+lazy: the same change.
+- goal:lit-box: volumeFog heightFalloff is a visible capability; it makes valley mist dense at the floor and thin above, where a uniform box read as a grey block over the forest. Approved by the lead under An's 2026-11-04 rule on size trade-offs.
+- goal:agent-scene: the same change, approved the same way.
diff --git a/tests/vegetation-pop.test.js b/tests/vegetation-pop.test.js
index 9c864510..caf36365 100644
--- a/tests/vegetation-pop.test.js
+++ b/tests/vegetation-pop.test.js
@@ -4,16 +4,28 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
+import { createServer } from 'node:net';
// A pop is a single-frame change of the mean RGB value (0 to 1) above this, or above this share of the change a hard switch
// makes in one frame. Measured 2026-11-04 on SwiftShader: the fade's largest step is 0.083, a hard switch is 0.30, and plain
// camera motion over the same dolly changes a frame by 0.006 on average and 0.010 at most.
const POP_THRESHOLD = 0.1;
const HARD_SWITCH_RATIO = 0.4;
-const PORT = 5187;
-async function startServer() {
- const server = spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--host', '127.0.0.1', '--port', String(PORT), '--strictPort'], { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
+// A fixed port collided when several checkouts ran the suite at once, so ask the system for a free one.
+function freePort() {
+ return new Promise((resolve, reject) => {
+ const probe = createServer();
+ probe.once('error', reject);
+ probe.listen(0, '127.0.0.1', () => {
+ const { port } = probe.address();
+ probe.close(() => resolve(port));
+ });
+ });
+}
+
+async function startServer(port) {
+ const server = spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--host', '127.0.0.1', '--port', String(port), '--strictPort'], { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
await new Promise((resolve, reject) => {
const timeout = setTimeout(() => reject(new Error('The dev server did not start.')), 30000);
server.stdout.on('data', (data) => {
@@ -91,7 +103,8 @@ test('a slow dolly across the impostor boundary shows no pop in a frame differen
context.skip('playwright is not installed');
return;
}
- const server = await startServer();
+ const port = await freePort();
+ const server = await startServer(port);
let browser;
try {
try {
@@ -101,7 +114,7 @@ test('a slow dolly across the impostor boundary shows no pop in a frame differen
return;
}
const page = await browser.newPage({ viewport: { width: 320, height: 180 } });
- await page.goto(`http://127.0.0.1:${PORT}/`);
+ await page.goto(`http://127.0.0.1:${port}/`);
// One tree fills the view. With the switch distances scaled by 0.05 its card begins at 7.5 m, so the dolly from 6 to 9.5 m crosses the whole fade band.
const crossing = { start: 6, end: 9.5, steps: 40, fade: 0.06, distanceScale: 0.05 };
const withFade = await frameChanges(page, crossing);