Render textured aerial maps and support legacy recovery links

This commit is contained in:
2026-10-05 18:11:12 +05:00
parent dcc3779262
commit 2cbaf45340
12 changed files with 226 additions and 35 deletions

View File

@@ -5,7 +5,6 @@ import { resolve, sep } from "node:path";
import sharp from "sharp";
import { assetsRoot, prepareAssets } from "../scripts/assets.mjs";
import { assertTerrainImage } from "./image-validation.mjs";
import { renderSurfaceMap } from "./surface-map.mjs";
/** @param {import('../shared/protocol').TerrainSnapshot} snapshot
* @param {Array<{id:string,x:number,y:number,z:number}>} viewpoints
* @param {string} output
@@ -203,7 +202,15 @@ export async function renderSnapshot(
}
}
await report({ percent: 85, message: "Rendering the surface map" });
stats.map = await renderSurfaceMap(snapshot, `${output}/map.webp`);
const map = await page.evaluate(() => window.renderMap());
const mapBytes = Buffer.from(map.data.split(",")[1], "base64");
if (map.data.startsWith("data:image/webp;"))
await writeFile(`${output}/map.webp`, mapBytes);
else
await sharp(mapBytes)
.webp({ quality: 92 })
.toFile(`${output}/map.webp`);
stats.map = { width: map.width, height: map.height, cameraY: 320 };
await report({
percent: 90,
message: "Rendered all panoramas and the surface map",