Files
MineGeo/scripts/render-map.mjs

21 lines
750 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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}`,
);