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

@@ -22,7 +22,9 @@ for (let x = -24; x < 24; x++) {
z,
x > 12 && z < -12
? "minecraft:water[level=0]"
: "minecraft:grass_block[snowy=false]",
: x < -12
? "minecraft:grass_block"
: "minecraft:grass_block[snowy=false]",
]);
}
}
@@ -91,6 +93,32 @@ assert.equal(
false,
);
await assertTerrainImage(await readFile(`${output}/map.webp`), "Surface map");
const mapMeta = await sharp(`${output}/map.webp`).metadata();
assert.equal(mapMeta.width, report.map.width);
assert.equal(mapMeta.height, report.map.height);
assert.equal(report.map.cameraY, 320);
const { data: mapPixels, info: mapInfo } = await sharp(`${output}/map.webp`)
.raw()
.toBuffer({ resolveWithObject: true });
const westGrass = (24 * mapInfo.width + 24) * mapInfo.channels;
assert.ok(
mapPixels[westGrass + 1] > mapPixels[westGrass],
"blocks without explicit default properties must appear on the aerial map",
);
const mapPixel = (x, z) => {
const pixelX = Math.floor(((x - snapshot.bounds.minX + 0.5) / 48) * mapInfo.width);
const pixelY = Math.floor(((z - snapshot.bounds.minZ + 0.5) / 48) * mapInfo.height);
const offset = (pixelY * mapInfo.width + pixelX) * mapInfo.channels;
return mapPixels.subarray(offset, offset + 3);
};
if (!process.argv[2]) {
const shadedGrass = mapPixel(10, 9);
const sunlitGrass = mapPixel(10, -9);
assert.ok(
sunlitGrass[1] - shadedGrass[1] > 20,
"the raised building must cast a visible shadow on the aerial map",
);
}
for (const point of points) {
for (const face of ["px", "nx", "py", "ny", "pz", "nz"]) {
const metadata = await sharp(