Expand voxel gameplay, lighting, full-height streaming and world imports
MVP checks / mvp (push) Canceled after 0s
MVP checks / mvp (push) Canceled after 0s
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.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { Renderer } from "../renderer.js";
|
||||
|
||||
function meshFixture() {
|
||||
const renderer = Object.create(Renderer.prototype);
|
||||
renderer.sections = new Map([
|
||||
["-2,0,0", { name: "leaving" }],
|
||||
["-1,0,0", { name: "border" }],
|
||||
["0,0,0", { name: "retained" }],
|
||||
["1,0,0", { name: "far" }],
|
||||
]);
|
||||
renderer.dirty = new Set();
|
||||
renderer.disposed = [];
|
||||
renderer.disposeMesh = (mesh) => renderer.disposed.push(mesh);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
test("stream unload disposes only departing meshes and keeps visible mesh identities", () => {
|
||||
const renderer = meshFixture();
|
||||
const before = new Map(renderer.sections);
|
||||
renderer.dirty.add("-2,0,0");
|
||||
renderer.unloadSections([[-2, 0, 0]]);
|
||||
assert.deepEqual(renderer.disposed, [before.get("-2,0,0")]);
|
||||
for (const id of ["-1,0,0", "0,0,0", "1,0,0"])
|
||||
assert.equal(renderer.sections.get(id), before.get(id));
|
||||
assert.deepEqual([...renderer.dirty], ["-1,0,0"]);
|
||||
});
|
||||
|
||||
test("incoming cells queue their section and boundaries without clearing existing geometry", () => {
|
||||
const renderer = meshFixture();
|
||||
const before = [...renderer.sections.values()];
|
||||
renderer.change([{ pos: [32, 5, 5], block: 7 }]);
|
||||
assert.deepEqual([...renderer.sections.values()], before);
|
||||
assert.equal(renderer.disposed.length, 0);
|
||||
assert.deepEqual([...renderer.dirty].sort(), ["1,0,0", "2,0,0"]);
|
||||
});
|
||||
|
||||
test("unloading adjacent sections does not queue either for reconstruction", () => {
|
||||
const renderer = meshFixture();
|
||||
renderer.change([{ pos: [-17, 0, 0], block: 0 }]);
|
||||
renderer.unloadSections([[-2, 0, 0], [-1, 0, 0]]);
|
||||
assert.equal(renderer.dirty.has("-2,0,0"), false);
|
||||
assert.equal(renderer.dirty.has("-1,0,0"), false);
|
||||
assert.equal(renderer.dirty.has("0,0,0"), true);
|
||||
assert.equal(renderer.sections.size, 2);
|
||||
});
|
||||
Reference in New Issue
Block a user