Render textured aerial maps and support legacy recovery links
This commit is contained in:
19
renderer/map-view.mjs
Normal file
19
renderer/map-view.mjs
Normal file
@@ -0,0 +1,19 @@
|
||||
// Keep one world block square in the image, including rectangular exports.
|
||||
// Eight pixels per block preserves the vanilla textures in typical 128-block
|
||||
// exports; large worlds are capped to a manageable image size.
|
||||
export function mapDimensions(bounds) {
|
||||
const spanX = bounds.maxX - bounds.minX;
|
||||
const spanZ = bounds.maxZ - bounds.minZ;
|
||||
if (
|
||||
!Number.isInteger(spanX) ||
|
||||
!Number.isInteger(spanZ) ||
|
||||
spanX < 1 ||
|
||||
spanZ < 1
|
||||
)
|
||||
throw new Error("Surface map bounds must have a positive integer size");
|
||||
const scale = Math.min(8, 2048 / Math.max(spanX, spanZ));
|
||||
return {
|
||||
width: Math.max(1, Math.round(spanX * scale)),
|
||||
height: Math.max(1, Math.round(spanZ * scale)),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user