@thoughts-on-things/vantage-mc
The web frontend for Vantage — render a Minecraft (Java) world as
a fast, beautiful, navigable 3D map in the browser. The native Zig generator bakes
versioned binary tiles (.vtile / .vtexarr); this package streams and shades
them with three.js.
It ships in three layers so you can enter at whatever altitude you need:
| Import |
What it is |
Depends on |
@thoughts-on-things/vantage-mc/core |
Zero-dependency, isomorphic decoder for the binary tile format |
— |
@thoughts-on-things/vantage-mc/three (also the default package export) |
three.js meshes/materials + a framework-agnostic viewer engine |
three |
@thoughts-on-things/vantage-mc/react |
Drop-in React components |
three, react |
Install
npm install @thoughts-on-things/vantage-mc three
npm install react react-dom # if you use the React entry point
three, react, and react-dom are peer dependencies — you bring your own.
The package is ESM-only: CJS consumers need "type": "module" or a dynamic
import().
Quick start (React)
The whole map in one component. Point it at the manifest the generator produced
(just render <save> writes manifest.json + tiles/ + the texture array to
web/public/). Tiles stream in around the camera as the user pans — world size
doesn't matter.
import { VantageViewer, BiomeLayer } from '@thoughts-on-things/vantage-mc/react';
export function Map() {
return (
<div style={{ width: '100%', height: '100vh' }}>
<VantageViewer world="/manifest.json">
<BiomeLayer legend hover />
</VantageViewer>
</div>
);
}
<VantageViewer> fills its parent, frames the world at its spawn point, and
provides the engine state to children via context. <BiomeLayer> adds the
interactive biome legend (click to isolate, hover the map to identify, press
B to toggle) — aggregated live across whatever tiles are resident. Add
<SettingsPanel /> for a quality menu: low/med/high/ultra
presets plus view-distance, tile-count, memory-budget, render-scale, and haze sliders, all
applied live (viewer.setStreaming re-plans in place, no reload). Or set the
ring up-front with
streaming={{ viewDistance: 1024, maxTiles: 128, maxBytes: 512 * 1024 * 1024 }}.
maxTiles is a count guard; maxBytes is the stronger residency limit for
worlds whose tile complexity varies widely. When a budget cuts the ring short,
admission stays a contiguous nearest-first disc and the fog wall hugs the real
frontier, so limits read as distance haze rather than missing tiles. Evicted
tiles also keep their compressed payloads in a client-side cache
(tileCacheBytes, default 192 MiB), so panning back over explored terrain
rebuilds instantly instead of re-fetching — on a vantage server, instead of
re-baking.
The camera also lives in the URL hash (#@x,y,z,dist,rot,tilt), so every
view is a shareable deep link: the hash follows the camera (debounced,
history.replaceState — no history spam), a link opens at its saved view, and
pasting a new hash into the address bar pans there live. Pass
urlState={false} if your page owns its hash (e.g. a router); the plain
engine keeps it opt-in (new VantageViewer(el, { urlState: true })).
Authenticated multiplayer servers
To exercise this integration from a repository checkout, run
just server-dev at the repository root. It launches an authenticated
loopback sidecar and this demo together, with a fresh credential and coordinated
shutdown. just server-smoke performs a headless protocol and lazy-bake
preflight. These credentials are for the local walkthrough only.
Use a WorldSource when a launcher needs to attach its existing session to
the manifest and every streamed artifact. worldFromHttp supports a custom
native fetch transport and confines manifest paths to the same origin and
directory before attaching credentials:
import { worldFromHttp } from '@thoughts-on-things/vantage-mc/core';
import { VantageViewer } from '@thoughts-on-things/vantage-mc/three';
const world = await worldFromHttp(
'https://host.example/map-app/world/manifest.json',
{ accessToken: sessionToken, fetch: nativeHttpFetch },
);
const viewer = await VantageViewer.mount('#app', { world });
For a direct connection to protocol v1, use
worldFromVantageServer('https://map.example/', { accessToken }). Hosts with
their own player sessions should prefer an existing session-gated same-origin
proxy. See the multiplayer server guide for the trust
boundary and deployment contract.
The viewer renders on demand: a frame draws only when something changed —
camera motion, tiles streaming in, a setting — plus a gentle 10 fps tick while
animated textures (water, lava) are on screen, so an idle map costs ~0 GPU/CPU
instead of a render loop. Input still draws the same frame it arrives. Pass
renderOnDemand: false to the engine if you drive per-frame effects off its
scene, or call viewer.invalidate() after mutating it externally.
viewer.screenshot() returns the current view as a PNG data URL (<MapNav>
has a button for it, next to its fullscreen toggle).
Every dimension
vantage render bakes the nether and the end alongside the overworld and
writes a world.json index next to them. Point the viewer at that instead of a
single manifest and it opens one dimension, offers the rest, and takes each
one's sky, fog and light floor from its manifest — so the nether arrives
crimson and lit by its lava, the end as pale islands over the void:
import { VantageViewer, DimensionPicker } from '@thoughts-on-things/vantage-mc/react';
<VantageViewer world="/world.json">
<DimensionPicker />
</VantageViewer>
<DimensionPicker> renders nothing for a single-dimension world, so it is safe
to include unconditionally. The dimension is part of the deep link
(#the_nether@x,y,z,…), and each dimension remembers where its camera was.
Engine API: viewer.dimensions, viewer.dimension,
await viewer.setDimension('the_nether'), and a 'dimension' event.
It behaves as a toolbar: Tab reaches the open dimension, ←/→ walk the row,
Enter switches (arrowing never triggers a load). position puts it in any
corner or the top centre — on phone-width screens it moves above the navigation
cluster rather than fighting the corner panels. Passing className lets you
re-home it entirely: the desktop app resets its position and drops its glass to
seat the row inside its own toolbar.
On small screens (phones, one screen of a foldable) the stock panels shrink to
fit: below 760px the dimension picker sits just above the navigation cluster
and the lighting and quality panels form a row above it, and below 480px the coordinate readout hides so every nav
button fits without scrolling. The panels' corners come from the
vtg-panel-tl, vtg-panel-bl and vtg-panel-br classes, so your own CSS can
move them.
Every dimension directory is a complete render — its own manifest, tiles, LOD
pyramid and texture array — so world="/the_nether/manifest.json" also works,
and a viewer that only knows about manifest.json still gets the overworld at
the render root.
Worlds baked with vantage render --caves full get the cave view: a
depth slice that cuts the world at any Y. Toggle it with C or <MapNav>'s
layers button, set the depth with the <DepthSlider> gauge, and share it —
the slice is part of the URL hash (#@x,y,z,dist,rot,tilt,sliceY). Engine
API: viewer.setSlice(y | null), viewer.toggleSlice(), viewer.slice,
viewer.sliceRange, viewer.hasCaves, and a 'slice' event.
Format-2 manifests carry a lowres LOD pyramid (.vlr colored
heightfields): the viewer keeps coarse rings resident far beyond the hires
disc — level 1 also underlays it as a loading placeholder — so the whole world
stays visible at any zoom, right out to a satellite view.
Live players appear as real Minecraft player models when the world serves a
players.json (vantage live --players-file, vantage server, or the
last-known positions vantage render writes out of the save). The viewer finds
it on its own, interpolates between roster polls so players walk rather than
teleport, and gives each one a constant-size name tag drawn through terrain.
Drop in <PlayerList /> for a roster panel with click-to-fly and follow, or
drive it yourself: viewer.players, viewer.setPlayers({ names, offline, foreign, scale }), viewer.focusPlayer(uuid), viewer.followPlayer(uuid | null), and 'players' / 'follow' events. Full guide:
docs/players.md.
<VantageViewer world="/manifest.json" players={{ offline: false }}>
<PlayerList />
</VantageViewer>
A single standalone tile (from vantage meshtex) still works:
<VantageViewer tile="/terrain.vtile" textures="/terrain.vtexarr" />
Reach the engine for custom UI with the useVantage() hook or a ref:
import { useVantage } from '@thoughts-on-things/vantage-mc/react';
function Stats() {
const { info, biomes, hoveredBiome } = useVantage();
return <span>{info?.triangleCount.toLocaleString()} tris · {biomes.length} biomes</span>;
}
As a backend — your own three.js scene
Skip the engine and drop Vantage meshes into a scene you control (your own
camera, lighting, post-processing):
import { maybeInflate, parseTile, parseTextureArray } from '@thoughts-on-things/vantage-mc/core';
import { buildTerrain } from '@thoughts-on-things/vantage-mc/three';
const tile = parseTile(await maybeInflate(await (await fetch('/tiles/t.0.0.vtile')).arrayBuffer()));
const tex = parseTextureArray(await maybeInflate(await (await fetch('/terrain.vtexarr')).arrayBuffer()));
const { terrain, water, bounds, shader } = buildTerrain(tile, tex);
scene.add(terrain);
if (water) scene.add(water);
// `shader` exposes the live uniforms: biome mix, fog, light direction.
shader!.uniforms.uBiomeMix.value = 1; // recolour by biome
Or stream a whole world into your scene with TileManager (shared materials,
camera-lookahead priority, bounded fetch/decode/upload backpressure,
byte-weighted residency, height/biome queries):
import { biomePalette, maybeInflate, parseManifest, parseTextureArray } from '@thoughts-on-things/vantage-mc/core';
import { createTerrainMaterial, createWaterMaterial, TileManager } from '@thoughts-on-things/vantage-mc/three';
const manifest = parseManifest(await (await fetch('/manifest.json')).json());
const tex = parseTextureArray(await maybeInflate(await (await fetch(manifest.textures)).arrayBuffer()));
const material = createTerrainMaterial(tex);
const tiles = new TileManager({
manifest,
baseUrl: location.origin + '/',
scene,
material,
waterMaterial: createWaterMaterial(material),
palette: biomePalette(manifest.biomes.length),
maxBytes: 512 * 1024 * 1024,
});
// each frame: keep the resident set centred on your camera
tiles.update(camera.position.x, camera.position.z);
Or the batteries-included engine without React:
import { VantageViewer } from '@thoughts-on-things/vantage-mc/three';
const viewer = await VantageViewer.mount('#app', { world: '/manifest.json' });
viewer.setBiomeLayer(true);
viewer.on('hover', (biomeId) => { /* ... */ });
viewer.on('stats', ({ loaded, triangleCount, residentBytes }) => { /* streaming HUD */ });
Just the format
@thoughts-on-things/vantage-mc/core has no dependencies and runs anywhere (browser, worker, Node) —
use it to inspect or transcode tiles without a renderer:
import { parseTile, summarizeBiomes } from '@thoughts-on-things/vantage-mc/core';
const tile = parseTile(buffer);
console.log(tile.magic, tile.vertexCount, tile.indexCount / 3, 'tris');
for (const b of summarizeBiomes(tile)) console.log(b.label, `${Math.round(b.fraction * 100)}%`);
The decoder handles every tile version the generator emits (VTL1–VTL6) and
returns only the fields a given version carries (textured, hasBiome, fluid,
surface). Tiles and the texture array ship gzip-wrapped on disk (~8× smaller);
maybeInflate sniffs the magic and inflates via the platform's native
DecompressionStream — a no-op when the server already handled it.
API surface
@thoughts-on-things/vantage-mc/core — parseTile, parseTextureArray, parseManifest,
parseLowresTile, maybeInflate, isGzip, tileKey, summarizeBiomes,
biomePalette, stripNamespace, ByteReader, worldFromUrl,
worldFromHttp, worldFromVantageServer; types DecodedTile,
MeshSection, SurfaceMap, DecodedTextureArray, WorldManifest,
ManifestTile, LowresTile, BiomeEntry, Rgb, WorldSource,
WorldConditionalFetch, HttpWorldOptions, VantageServerOptions,
PlayerState, PlayerSnapshot; parsePlayers, samePlayers.
@thoughts-on-things/vantage-mc/three — buildTerrain, buildTileMeshes,
buildQuantizedTileMeshes, buildLowresMesh, TileManager,
createTerrainMaterial, createWaterMaterial, createLowresMaterial,
createSky, pickBiome, MapControls, PlayerLayer, boxFaces,
defaultSkinCanvas, headIconCanvas, normalizeSkin, VantageViewer
(engine), VANILLA_DISPLAY, DEFAULT_ORBIT_ANGLE; types TerrainObjects,
TileMeshes, TileManagerOptions, TileStats, VantageViewerOptions,
LoadOptions, StreamingSettings, LightSettings, DisplaySettings,
PlayerOptions, PlayerSettings, PlayerView, TileInfo, ViewMode.
Re-exports all of core.
@thoughts-on-things/vantage-mc/react — <VantageViewer>, <BiomeLayer>, <SettingsPanel>,
<LightPanel>, <MapNav>, <DepthSlider>, <PlayerList>, <Reticle>,
<Panel>, useVantage, injectStyles, QUALITY_PRESETS; types
VantageViewerProps, BiomeLayerProps, SettingsPanelProps,
PlayerListProps, VantageContextValue, VantageStatus. Re-exports the
engine and core types.
Develop
This directory is both the published package and its demo (the reference
consumer in demo/).
npm install
npm run dev # Vite dev server at http://127.0.0.1:8753 (serves public/)
npm run typecheck # tsc --noEmit
npm run build # tsdown → dist/ (ESM + .d.ts for each entry)
From the repo root the Justfile wraps the loop:
just render "<save>" bakes tiles into public/, then just serve runs the
dev server.
The generator and this package are decoupled by the versioned binary tile
contract (src/core/format.ts): the frontend only
needs the format, never the world — so a new Minecraft version "just works"
once the generator can read it.