Render surface maps directly and preserve their quality

This commit is contained in:
2026-10-05 14:16:39 +05:00
parent c5368fa8cc
commit 8b31891776
11 changed files with 533 additions and 11 deletions

20
scripts/render-map.mjs Normal file
View File

@@ -0,0 +1,20 @@
import { readFile, mkdir } from "node:fs/promises";
import { dirname, resolve } from "node:path";
import { gunzipSync } from "node:zlib";
import { renderSurfaceMap } from "../renderer/surface-map.mjs";
const [input, output] = process.argv.slice(2);
if (!input || !output)
throw new Error(
"Usage: npm run render:map -- <terrain.json.gz> <output.webp>",
);
const terrain = JSON.parse(
gunzipSync(await readFile(input), {
maxOutputLength: 256 * 1024 * 1024,
}).toString(),
);
await mkdir(dirname(resolve(output)), { recursive: true });
const report = await renderSurfaceMap(terrain, output);
console.log(
`Rendered ${report.width} × ${report.height} map cells from ${report.columns.toLocaleString()} surface columns: ${output}`,
);