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.
This commit is contained in:
2026-10-09 16:43:35 +09:00
parent 71c8d3b7ff
commit e358e24436
642 changed files with 35202 additions and 17642 deletions
@@ -0,0 +1,20 @@
import assert from 'node:assert/strict';
import * as R from './mesh-refraction-reference.mjs';
const {v3,makeDepthTexture,depthAt,photoSurface,triangleOracle,tracePhotoDDA}=R;
const F=Math.fround,A=(a,b)=>F(a+b),S=(a,b)=>F(a-b),M=(a,b)=>F(a*b),D=(a,b)=>F(a/b),V=a=>a.map(F),add=(a,b)=>a.map((x,i)=>A(x,b[i])),sub=(a,b)=>a.map((x,i)=>S(x,b[i])),mul=(a,b)=>a.map(x=>M(x,b)),dot=(a,b)=>A(A(M(a[0],b[0]),M(a[1],b[1])),M(a[2],b[2])),cross=(a,b)=>[S(M(a[1],b[2]),M(a[2],b[1])),S(M(a[2],b[0]),M(a[0],b[2])),S(M(a[0],b[1]),M(a[1],b[0]))],INF=F(1e20);
function triangle(o,r,a,b,c){let e1=sub(b,a),e2=sub(c,a),p=cross(r,e2),det=dot(e1,p);if(det<=F(1e-9))return INF;let s=sub(o,a),u=D(dot(s,p),det);if(u<F(-.00001)||u>F(1.00001))return INF;let q=cross(s,e1),v=D(dot(r,q),det);if(v<F(-.00001)||A(u,v)>F(1.00001))return INF;let t=D(dot(e2,q),det);return t>=0?t:INF;}
function shaderDDA(surface,origin,ray){const o=V(origin.toArray()),r=V(ray.toArray());let near=0,far=INF;const bounds=[[-.5,.5],[-.5,.5],[0,.25]];for(let i=0;i<3;i++){let [lo,hi]=bounds[i];if(Math.abs(r[i])<F(1e-9)){if(!(o[i]>=lo&&o[i]<=hi))return null;}else{let a=D(S(lo,o[i]),r[i]),b=D(S(hi,o[i]),r[i]);near=Math.max(near,Math.min(a,b));far=Math.min(far,Math.max(a,b));if(far<near)return null;}}
let p=add(o,mul(r,near)),direction=r.slice(0,2).map(Math.sign),cell=p.slice(0,2).map((v,i)=>Math.min(127,Math.max(0,Math.floor(A(M(A(v,.5),128),M(direction[i],.00001)))))),next=[INF,INF],delta=[INF,INF];for(let i=0;i<2;i++)if(Math.abs(r[i])>=F(1e-9)){next[i]=D(S(S(D(A(cell[i],r[i]>=0?1:0),128),.5),o[i]),r[i]);delta[i]=D(1,M(128,Math.abs(r[i])));}
const vert=(x,y)=>[S(D(x,128),.5),S(D(y,128),.5),M(F(depthAt(surface.texture,D(x,128),D(y,128))),.25)];
for(let i=0;i<257;i++){let ll=vert(cell[0],cell[1]),lr=vert(A(cell[0],1),cell[1]),ul=vert(cell[0],A(cell[1],1)),ur=vert(A(cell[0],1),A(cell[1],1));let t=Math.min(triangle(o,r,ul,ll,ur),triangle(o,r,ll,lr,ur)),end=Math.min(far,...next);if(t>=S(near,.00001)&&t<=A(end,.00001)&&t<F(1e19))return{t,point:add(o,mul(r,t)),cells:i+1};if(end>=S(far,.000001))return null;let cx=next[0]<=next[1],cy=next[1]<=next[0];near=end;if(cx){cell[0]=A(cell[0],direction[0]);next[0]=A(next[0],delta[0]);}if(cy){cell[1]=A(cell[1],direction[1]);next[1]=A(next[1],delta[1]);}if(cell.some(v=>v<0||v>=128))return null;}throw Error('257 cells exhausted');}
const surface=photoSurface(makeDepthTexture(67,53,(x,y)=>.5+.21*Math.sin(x*1.2)+.25*Math.cos(y*.9+x*.4)));
let seed=0x5eed,random=()=>{seed=(Math.imul(seed,1664525)+1013904223)>>>0;return seed/2**32;},cases=[];
for(let i=0;i<1500;i++){const o=v3((random()-.5)*1.8,(random()-.5)*1.8,.4+random()),target=v3((random()-.5)*1.2,(random()-.5)*1.2,random()*.2);cases.push([o,target.sub(o).normalize()]);}
for(const x of [-.5,-.25,0,.25,.5])for(const y of [-.5,-.25,0,.25,.5])for(const dx of [-.3,0,.3])for(const dy of [-.3,0,.3])cases.push([v3(x,y,1),v3(dx,dy,-1).normalize()]);
for(let i=0;i<20;i++)cases.push([v3(-.6,-.45+i*.02,.249),v3(1,.85,-.0001).normalize()]);
let misses=0,worst=0,maxcells=0;
for(let i=0;i<cases.length;i++){const [o,r]=cases[i],actual=shaderDDA(surface,o,r),expected=tracePhotoDDA(surface,o,r).hit;assert.equal(Boolean(actual),Boolean(expected),`hit/miss ray ${i}`);if(actual){const error=v3(...actual.point).distanceTo(expected.point);worst=Math.max(worst,error);maxcells=Math.max(maxcells,actual.cells);assert.ok(error<.0001,`ray ${i} error ${error}`);}else misses++;if(i<40){const oracle=triangleOracle(surface,o,r);assert.equal(Boolean(actual),Boolean(oracle));}}
console.log(JSON.stringify({kind:'CPU Float32 arithmetic mirror of production DDA and Moller triangles; not GPU',rays:cases.length,misses,worstHitPointError:worst,maxcells}));
const longSurface=photoSurface(makeDepthTexture(2,2,(x,y)=>x*y));let longWorst=0,longMax=0,longCases=0;
for(let i=0;i<80;i++){const o=v3(-.6,-.45+i*.005,.249),r=v3(1,.85,-.0001).normalize(),a=shaderDDA(longSurface,o,r),e=tracePhotoDDA(longSurface,o,r).hit;assert.equal(Boolean(a),Boolean(e),`long ray ${i}`);if(a){longMax=Math.max(longMax,a.cells);longWorst=Math.max(longWorst,v3(...a.point).distanceTo(e.point));assert.ok(v3(...a.point).distanceTo(e.point)<.0001);}longCases++;}
console.log(JSON.stringify({kind:'CPU Float32 long XY traversal',rays:longCases,worstHitPointError:longWorst,maxcells:longMax}));