MVP checks / mvp (push) Waiting to run
Add shared Rust/WASM physics, worker meshing and diagnostics, 64-chunk full-height streaming, atlas texture support, and baseline world import. Document the current implementation and include the supplied in-game lobby screenshot.
22 lines
1.0 KiB
JavaScript
22 lines
1.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { shadowFrame } from '../shadow-frame.js';
|
|
|
|
const sun = [-.5, .78, .37];
|
|
const clip = (m, p) => [0, 1, 2].map(i => m[i] * p[0] + m[i + 4] * p[1] + m[i + 8] * p[2] + m[i + 12]);
|
|
test('shadow projection puts the camera neighborhood in range and light-facing objects closer', () => {
|
|
for (const eye of [[0, 2, 8], [-123.5, 70, 400], [32700, 50, -32700]]) {
|
|
const { matrix, center } = shadowFrame(eye, sun);
|
|
assert.ok(clip(matrix, center).every(v => Math.abs(v) < 1e-4));
|
|
const near = clip(matrix, center.map((v, i) => v + sun[i] * 20));
|
|
const far = clip(matrix, center.map((v, i) => v - sun[i] * 20));
|
|
assert.ok(near[2] < far[2]);
|
|
assert.ok([...near, ...far].every(v => v >= -1 && v <= 1));
|
|
}
|
|
});
|
|
test('sub-texel camera movement keeps the shadow grid fixed', () => {
|
|
const a = shadowFrame([0, 0, 0], sun).matrix;
|
|
const b = shadowFrame([.001, .001, .001], sun).matrix;
|
|
for (const i of [0, 1, 4, 5, 8, 9, 12, 13]) assert.equal(a[i], b[i]);
|
|
});
|