Render surface maps directly and preserve their quality
This commit is contained in:
20
scripts/render-map.mjs
Normal file
20
scripts/render-map.mjs
Normal 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}`,
|
||||
);
|
||||
Reference in New Issue
Block a user