Files
behind_glass/scripts/test-scene-zoom-materials.mjs
horoli e358e24436 Replace project with current server release and Windows setup
Import the 2026-10-09 source release, Fastify/SQLite backend, restored source
assets, and analytics-enabled server build. Replace files from the previous
release while retaining the existing repository history.

Make builds portable across Windows and Linux, configure local startup,
normalize Windows static asset paths, and fix test fixture cleanup and file
URL handling. Exclude local environment settings, databases, dependencies,
validation output, and TypeScript build cache from version control.

Validation: npm ci, static and server builds, 106 arrival tests, and actual
local HTTP checks passed. The full suite passed 467 of 470 tests; three tests
still require QA fixtures omitted from the supplied release, documented in
README-서버실행.md.
2026-10-09 16:43:35 +09:00

24 lines
1.7 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
const reeded=await readFile(new URL('../src/shaders/reeded.frag',import.meta.url),'utf8');
const frosted=await readFile(new URL('../src/shaders/frosted.frag',import.meta.url),'utf8');
// The shaders expose a small pure GLSL helper; execute that exact arithmetic in JS.
function stableUv(shader) {
const body=shader.match(/vec2 patternScreenUv\(vec2 uv\)\{return ([^;]+);\}/)?.[1];
assert.ok(body,'legacy screen-pattern coordinates must compensate projection zoom');
const expression=body.replaceAll('uv','component').replaceAll('uSceneOffset','offset').replaceAll('uSceneZoom','zoom').replaceAll('max(','Math.max(');
return new Function('component','zoom','offset',`return ${expression};`);
}
for(const shader of [reeded,frosted]) {
const stable=stableUv(shader);
for(const original of [.1,.25,.5,.8]) for(const zoom of [1,1.5,2,3]) for(const offset of [0,.2,-.6]) {
const projected=.5+(original-.5)*zoom+offset*.5;
assert.ok(Math.abs(stable(projected,zoom,offset)-original)<1e-12,'the same material point keeps its original pattern coordinate under projection zoom');
}
assert.match(shader,/patternScreenUv\(vUv\)/,'actual pattern coordinate consumes the compensated helper');
}
assert.match(reeded,/coord=patternScreenUv\(vUv\)\.x\*count/);
assert.match(frosted,/st=patternScreenUv\(vUv\)\*/);
assert.match(frosted,/rad=vec2\(\.008\)\*uSceneZoom\*/,'frosted blur footprint magnifies with the view');
console.log('Scene zoom materials: shader helper arithmetic preserves zoom1 pattern coordinates and tracks zoomed material points; Frosted footprint source contract verified (no GPU execution)');