21 lines
750 B
JavaScript
21 lines
750 B
JavaScript
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}`,
|
||
);
|