Skip to content

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.read access (same guard as the detail route).
    • Produces 200 OK with 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 a stride query 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 -1 for empty columns), already downsampled by stride.
    • The route handles missing data with 404, malformed IDs via the existing parseObjectId helper, and surfaces unexpected errors as 500 with a friendly payload.
    • Implementation: services/gameserver/src/main/java/net/uebliche/platform/rest/editor/MapRoutes.java.

Frontend Viewer

  • app/dashboard/src/components/MapTerrainViewer.vue renders a Three.js mesh from the sampled heightmap.
    • Uses instanced BufferGeometry with 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.
  • app/dashboard/src/views/home/Maps.vue embeds the viewer per version card behind a "3D-Vorschau" toggle so the list stays compact.
  • app/dashboard/src/stores/mapStore.ts caches previews per version, exposes fetchTerrainPreview, 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=1 for 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.