Map Terrain Preview
The world editor now exposes downsampled heightmap previews so polar snapshots can be inspected directly inside the dashboard before downloading or loading them into Minestom.
API Snapshot
GET /api/world/map-versions/{id}/preview- Requires the usual
editor:maps.readaccess (same guard as the detail route). - Produces
200 OKwith a JSON payload sampling the stored Polar world:originX/originZ: block-space origin of the sampled grid (minimum chunk coordinate * 16).fullWidth/fullDepth: original extent (in blocks) covered by the snapshot.stride: sampling stride in blocks (auto-tunes to keep the response below 256×256 cells unless astridequery param overrides it).columns/rows: number of samples in the returned grid.minHeight/maxHeight: min/max block height encountered (unscaled).minSection/maxSection: Polar section range persisted in the file.dataVersion: Mojang data version carried by the Polar world.heights: flattened row-major array. Every entry is the top solid block Y coordinate (or-1for empty columns), already downsampled bystride.
- The route handles missing data with
404, malformed IDs via the existingparseObjectIdhelper, and surfaces unexpected errors as500with a friendly payload. - Implementation:
services/gameserver/src/main/java/net/uebliche/platform/rest/editor/MapRoutes.java.
- Requires the usual
Frontend Viewer
app/dashboard/src/components/MapTerrainViewer.vuerenders a Three.js mesh from the sampled heightmap.- Uses instanced
BufferGeometrywith per-vertex colours and a basic gradient to visualise height. - Adds an orbit camera with damping, a subtle grid helper, and transparent overlays for loading/error states.
- Automatically rescales Y to fit typical overworld ranges while keeping the preview centred.
- Uses instanced
app/dashboard/src/views/home/Maps.vueembeds the viewer per version card behind a "3D-Vorschau" toggle so the list stays compact.app/dashboard/src/stores/mapStore.tscaches previews per version, exposesfetchTerrainPreview, and invalidates the cache when a new Polar payload is uploaded.
Notes & Limitations
- The sampling logic currently relies on the motion-blocking heightmap; caves or overhangs are not rendered.
- Large worlds get auto-strided to keep the payload practical; pass
?stride=1for full resolution at the cost of bandwidth. - Only map versions with a stored Polar binary surface preview data. Draft versions without uploads still return
404.