@thoughts-on-things/vantage-mc 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -158,6 +158,17 @@ declare function parseTileQuantized(buffer: ArrayBuffer): QuantizedTile | null;
158
158
  */
159
159
  declare function parseTile(buffer: ArrayBuffer): DecodedTile;
160
160
 
161
+ /** One animated texture's playback metadata (version ≥ 2 files). */
162
+ interface TextureAnimation {
163
+ /** First layer of the baked frame sequence — the layer meshes reference. */
164
+ base: number;
165
+ /** Layers in the sequence (the mcmeta frame order is already unrolled). */
166
+ count: number;
167
+ /** Ticks per frame (20 ticks/second). */
168
+ frametime: number;
169
+ /** Blend adjacent frames instead of stepping. */
170
+ interpolate: boolean;
171
+ }
161
172
  /** A decoded texture array: `layers` images of `width`×`height` RGBA pixels. */
162
173
  interface DecodedTextureArray {
163
174
  width: number;
@@ -165,9 +176,12 @@ interface DecodedTextureArray {
165
176
  layers: number;
166
177
  /** `width * height * layers * 4` tightly-packed RGBA bytes. */
167
178
  pixels: Uint8Array<ArrayBuffer>;
179
+ /** Animated textures (empty for version-1 files, which bake only frame 0). */
180
+ anims: TextureAnimation[];
168
181
  }
169
182
  /**
170
- * Decode a `.vtexarr` buffer.
183
+ * Decode a `.vtexarr` buffer. Version 2 appends an animation table after the
184
+ * pixels; version 1 (no table) still decodes, with `anims` empty.
171
185
  *
172
186
  * @throws if the magic is not `VTA1`.
173
187
  */
@@ -231,6 +245,38 @@ declare function tileKey(x: number, z: number): string;
231
245
  */
232
246
  declare function parseManifest(data: unknown): WorldManifest;
233
247
 
248
+ /** Fetch one file of a world render by its manifest-relative path (e.g.
249
+ * `tiles/t.0.0.vtile`). Reject with an `AbortError`-named error if `signal`
250
+ * fires mid-read. */
251
+ type WorldFetch = (path: string, signal?: AbortSignal) => Promise<ArrayBuffer>;
252
+ /** A tiled world render, wherever it lives. Pass one to the viewer's `world`
253
+ * option (or build one with {@link worldFromUrl}, {@link worldFromDirectory},
254
+ * or {@link worldFromFiles}). */
255
+ interface WorldSource {
256
+ /** The `manifest.json` value, still unvalidated — the viewer parses it. */
257
+ manifest: unknown;
258
+ /** Where the world came from, for error messages (a URL, a folder name). */
259
+ label: string;
260
+ /** Fetch a file by manifest-relative path. */
261
+ fetch: WorldFetch;
262
+ }
263
+ /** A world served over HTTP: fetches `manifest.json` at `url` and resolves
264
+ * tile paths relative to it. This is what a plain string `world` option
265
+ * turns into. */
266
+ declare function worldFromUrl(url: string, base?: string): Promise<WorldSource>;
267
+ /** A world in a local directory picked with the File System Access API
268
+ * (`window.showDirectoryPicker()`, Chromium) — reads `manifest.json` from the
269
+ * directory root and resolves tile paths through subdirectory handles on
270
+ * demand, so nothing is read until it streams in. */
271
+ declare function worldFromDirectory(dir: FileSystemDirectoryHandle): Promise<WorldSource>;
272
+ /** A world from a flat file list — `<input webkitdirectory>` or a drag-and-drop
273
+ * walk (the fallback for browsers without `showDirectoryPicker`). Finds the
274
+ * shallowest `manifest.json` and keys every file relative to its folder, so
275
+ * picking a parent folder of the render also works. `pathOf` overrides how a
276
+ * file's relative path is derived (default: `webkitRelativePath`, falling
277
+ * back to `name`). */
278
+ declare function worldFromFiles(files: Iterable<File>, pathOf?: (file: File) => string): Promise<WorldSource>;
279
+
234
280
  /** An RGB triple in 0..1. */
235
281
  type Rgb = readonly [number, number, number];
236
282
  /**
@@ -272,4 +318,4 @@ declare function summarizeSurfaceBiomes(surface: SurfaceMap, names: string[], pa
272
318
  */
273
319
  declare function summarizeBiomes(tile: DecodedTile, palette?: Rgb[]): BiomeEntry[];
274
320
 
275
- export { type BiomeEntry as B, type DecodedTile as D, type LowresLevel as L, type ManifestTile as M, type QuantizedTile as Q, type Rgb as R, type SurfaceMap as S, TEXTURE_MAGIC as T, type WorldManifest as W, type DecodedTextureArray as a, ByteReader as b, type MeshSection as c, type QuantizedSection as d, TILE_MAGIC as e, type TileMagic as f, biomePalette as g, parseTextureArray as h, parseTile as i, parseTileQuantized as j, summarizeBiomes as k, summarizeSurfaceBiomes as l, parseManifest as p, stripNamespace as s, tileKey as t };
321
+ export { type BiomeEntry as B, type DecodedTile as D, type LowresLevel as L, type ManifestTile as M, type QuantizedTile as Q, type Rgb as R, type SurfaceMap as S, TEXTURE_MAGIC as T, type WorldFetch as W, type DecodedTextureArray as a, ByteReader as b, type MeshSection as c, type QuantizedSection as d, TILE_MAGIC as e, type TextureAnimation as f, type TileMagic as g, type WorldManifest as h, type WorldSource as i, biomePalette as j, parseTextureArray as k, parseTile as l, parseTileQuantized as m, summarizeBiomes as n, summarizeSurfaceBiomes as o, parseManifest as p, worldFromFiles as q, worldFromUrl as r, stripNamespace as s, tileKey as t, worldFromDirectory as w };
@@ -1,4 +1,4 @@
1
- import { biomePalette, LOWRES_EMPTY, tileKey, parseLowresTile, maybeInflate, parseTileQuantized, summarizeSurfaceBiomes, parseTile, summarizeBiomes, parseManifest, parseTextureArray } from './chunk-X7ZJUHP2.js';
1
+ import { biomePalette, LOWRES_EMPTY, tileKey, parseLowresTile, maybeInflate, parseTileQuantized, summarizeSurfaceBiomes, parseTile, summarizeBiomes, worldFromUrl, parseManifest, parseTextureArray } from './chunk-TC3HQWAD.js';
2
2
  import * as THREE2 from 'three';
3
3
 
4
4
  var SKY_TOP = [0.3, 0.52, 0.84];
@@ -57,7 +57,8 @@ var VERT = (
57
57
  vBlk = (light - sky * 16.0) / 15.0;
58
58
  // Water surface waves come from real mesh geometry (Minecraft flowing-water
59
59
  // heights, baked in the mesher) \u2014 the normal here carries the slope, so the
60
- // waves catch light. No vertex animation \u2014 the water is static.
60
+ // waves catch light. No vertex animation \u2014 motion comes from the animated
61
+ // texture frames (see the fragment shader's uAnim/uTime).
61
62
  vN = normalize(mat3(modelMatrix) * nrm);
62
63
  vec4 wp = modelMatrix * vec4(pos, 1.0);
63
64
  vec4 mv = viewMatrix * wp;
@@ -75,6 +76,8 @@ var FRAG = (
75
76
  precision highp float;
76
77
  precision highp sampler2DArray;
77
78
  uniform sampler2DArray map;
79
+ uniform sampler2D uAnim; // per-layer animation LUT: frame count, frametime lo/hi, interpolate
80
+ uniform float uTime; // seconds (the viewer advances and wraps it)
78
81
  uniform vec3 lightDir;
79
82
  uniform float uBiomeMix; // 0 = textured, 1 = biome layer
80
83
  uniform float uHi; // highlighted biome id, or -1
@@ -155,25 +158,45 @@ var FRAG = (
155
158
  void main() {
156
159
  float lightAmt; vec3 lightCol;
157
160
  bakedLight(lightAmt, lightCol);
158
- vec4 t = texture(map, vec3(vUv, vLayer), -uSharpness); // negative bias = sharper
161
+ // Animated textures (water, lava, magma, kelp, \u2026): the LUT row for this
162
+ // base layer holds the baked frame count and frametime; frames occupy the
163
+ // consecutive layers after the base, so playback is base + wrap(frame).
164
+ // vLayer is a flat varying \u2014 uniform per primitive \u2014 so the branch and the
165
+ // extra interpolation tap are quad-coherent.
166
+ vec4 anim = texelFetch(uAnim, ivec2(int(vLayer + 0.5), 0), 0) * 255.0;
167
+ float layer = vLayer;
168
+ float blendf = 0.0;
169
+ if (anim.r > 1.5) {
170
+ float ft = max(anim.g + anim.b * 256.0, 1.0); // ticks per frame
171
+ float frames = uTime * 20.0 / ft; // 20 ticks per second
172
+ layer = vLayer + mod(floor(frames), anim.r);
173
+ if (anim.a > 0.5) blendf = fract(frames); // interpolate: blend to next
174
+ }
175
+ vec4 t = texture(map, vec3(vUv, layer), -uSharpness); // negative bias = sharper
176
+ if (blendf > 0.0) {
177
+ float nxt = vLayer + mod(layer - vLayer + 1.0, anim.r);
178
+ t = mix(t, texture(map, vec3(vUv, nxt), -uSharpness), blendf);
179
+ }
159
180
  if (t.a < 0.05) discard; // drop only fully-empty texels; the
160
181
  // fractional edge becomes MSAA coverage
161
182
  t.rgb = toLinear(t.rgb); // work in linear; encode at the end
162
183
  vec3 fogCol = toLinear(uFogColor);
163
184
  vec3 N = normalize(vN);
164
185
 
165
- // Water pass: a semi-transparent blue tint over the normally-lit seabed.
166
- // The depth read comes from the SEABED darkening (sky light is
167
- // attenuated through water in the light pass), seen through the clear surface,
168
- // NOT from fading the water to opaque. So keep the surface fairly transparent
169
- // so sand/gravel/seagrass show through; the wave look is the real flowing-water
170
- // mesh geometry, whose sloped normal (vN) catches light.
186
+ // Water pass: the animated water texture \xD7 biome tint (the game's own
187
+ // formula \u2014 the texture is authored grey, its average ~0.45 linear, so a
188
+ // lift keeps overall brightness where a flat tint would sit), blended
189
+ // semi-transparently over the normally-lit seabed. The depth read comes
190
+ // from the SEABED darkening (sky light is attenuated through water in the
191
+ // light pass), seen through the clear surface, NOT from fading the water
192
+ // to opaque. So keep the surface fairly transparent so sand/gravel/seagrass
193
+ // show through; the wave look is the real flowing-water mesh geometry,
194
+ // whose sloped normal (vN) catches light.
171
195
  if (uWater > 0.5) {
172
196
  float depth = vTint.a;
173
- vec3 wcol = toLinear(vTint.rgb);
197
+ vec3 wcol = t.rgb * toLinear(vTint.rgb) * 2.2;
174
198
  wcol = mix(wcol, wcol * vec3(0.55, 0.66, 0.85), depth * 0.7); // deep water cools + deepens
175
- vec3 Nw = normalize(vN);
176
- float ndl2 = max(dot(Nw, normalize(lightDir)), 0.0);
199
+ float ndl2 = max(dot(N, normalize(lightDir)), 0.0);
177
200
  // Flat-lit (mostly the water colour \xD7 baked light); only a small
178
201
  // directional term so the wave-slope normals read, no blown-out sun sheen.
179
202
  vec3 wlit = grade(wcol * (0.62 + 0.28 * SUN * ndl2) * lightAmt * lightCol * uExposure);
@@ -206,6 +229,24 @@ var FRAG = (
206
229
  }
207
230
  `
208
231
  );
232
+ function animLutTexture(layers, anims) {
233
+ const n = Math.max(1, layers);
234
+ const data = new Uint8Array(4 * n);
235
+ for (let i = 0; i < n; i++) data[i * 4] = 1;
236
+ for (const a of anims) {
237
+ if (a.base < 0 || a.base >= n) continue;
238
+ const ft = Math.min(Math.max(a.frametime, 1), 65535);
239
+ data[a.base * 4 + 0] = Math.min(a.count, 255);
240
+ data[a.base * 4 + 1] = ft & 255;
241
+ data[a.base * 4 + 2] = ft >> 8;
242
+ data[a.base * 4 + 3] = a.interpolate ? 255 : 0;
243
+ }
244
+ const tex = new THREE2.DataTexture(data, n, 1, THREE2.RGBAFormat, THREE2.UnsignedByteType);
245
+ tex.magFilter = THREE2.NearestFilter;
246
+ tex.minFilter = THREE2.NearestFilter;
247
+ tex.needsUpdate = true;
248
+ return tex;
249
+ }
209
250
  function paletteTexture(palette) {
210
251
  const n = Math.max(1, palette.length);
211
252
  const data = new Uint8Array(4 * n);
@@ -238,6 +279,9 @@ function createTerrainMaterial(texData, opts = {}) {
238
279
  defines: opts.quantized ? { QUANTIZED: "" } : {},
239
280
  uniforms: {
240
281
  map: { value: tex },
282
+ uAnim: { value: animLutTexture(texData.layers, texData.anims ?? []) },
283
+ uTime: { value: 0 },
284
+ // seconds; the viewer advances it every frame
241
285
  // Per-tile dequantization transform, set per-mesh in onBeforeRender
242
286
  // (quantized path only; inert otherwise).
243
287
  uPosMin: { value: new THREE2.Vector3() },
@@ -813,10 +857,7 @@ var TileManager = class {
813
857
  this.records.set(key, rec);
814
858
  this.inFlight++;
815
859
  try {
816
- const url = new URL(ref.path, this.opts.baseUrl).toString();
817
- const res = await fetch(url, { signal: abort.signal });
818
- if (!res.ok) throw new Error(`${res.status} ${res.statusText} for ${url}`);
819
- const tile = parseLowresTile(await maybeInflate(await res.arrayBuffer()));
860
+ const tile = parseLowresTile(await maybeInflate(await this.opts.fetch(ref.path, abort.signal)));
820
861
  if (this.disposed || rec.state !== "loading") return;
821
862
  const mesh = buildLowresMesh(tile, this.lowresMaterial);
822
863
  if (!mesh) {
@@ -881,10 +922,7 @@ var TileManager = class {
881
922
  this.records.set(key, rec);
882
923
  this.inFlight++;
883
924
  try {
884
- const url = new URL(ref.path, this.opts.baseUrl).toString();
885
- const res = await fetch(url, { signal: abort.signal });
886
- if (!res.ok) throw new Error(`${res.status} ${res.statusText} for ${url}`);
887
- const buffer = await maybeInflate(await res.arrayBuffer());
925
+ const buffer = await maybeInflate(await this.opts.fetch(ref.path, abort.signal));
888
926
  if (this.disposed || rec.state !== "loading") return;
889
927
  let meshes;
890
928
  const q = parseTileQuantized(buffer);
@@ -2017,12 +2055,10 @@ var VantageViewer = class _VantageViewer {
2017
2055
  /** Stream a tiled world render from its `manifest.json`. Tiles load around
2018
2056
  * the camera as it moves and unload behind it; the whole world is reachable
2019
2057
  * without ever holding more than the streaming budget in memory. */
2020
- async loadWorld(url, view) {
2021
- const abs = new URL(url, typeof document !== "undefined" ? document.baseURI : void 0).toString();
2022
- const res = await fetch(abs);
2023
- if (!res.ok) throw new Error(`${res.status} ${res.statusText} for ${abs}`);
2024
- const manifest = parseManifest(await res.json());
2025
- const texData = parseTextureArray(await maybeInflate(await fetchBuffer(new URL(manifest.textures, abs).toString())));
2058
+ async loadWorld(world, view) {
2059
+ const source = typeof world === "string" ? await worldFromUrl(world) : world;
2060
+ const manifest = parseManifest(source.manifest);
2061
+ const texData = parseTextureArray(await maybeInflate(await source.fetch(manifest.textures)));
2026
2062
  this.disposeCurrent();
2027
2063
  const palette = biomePalette(manifest.biomes.length);
2028
2064
  const shader = createTerrainMaterial(texData, { quantized: true, palette });
@@ -2036,7 +2072,7 @@ var VantageViewer = class _VantageViewer {
2036
2072
  this.tile = null;
2037
2073
  this.tiles = new TileManager({
2038
2074
  manifest,
2039
- baseUrl: abs,
2075
+ fetch: source.fetch,
2040
2076
  scene: this.scene,
2041
2077
  material: shader,
2042
2078
  waterMaterial: waterShader,
@@ -2531,6 +2567,7 @@ var VantageViewer = class _VantageViewer {
2531
2567
  this.mixCurrent += (this.mixTarget - this.mixCurrent) * 0.2;
2532
2568
  if (Math.abs(this.mixCurrent - this.mixTarget) < 15e-4) this.mixCurrent = this.mixTarget;
2533
2569
  this.shader.uniforms["uBiomeMix"].value = this.mixCurrent;
2570
+ this.shader.uniforms["uTime"].value = now / 1e3 % 3600;
2534
2571
  }
2535
2572
  this.pickHover();
2536
2573
  this.renderer.setRenderTarget(this.msaa);
@@ -280,12 +280,25 @@ function parseTextureArray(buffer) {
280
280
  if (magic !== TEXTURE_MAGIC) {
281
281
  throw new Error(`vantage: unrecognized texture magic "${magic}" (expected ${TEXTURE_MAGIC})`);
282
282
  }
283
- r.off = 8;
283
+ r.off = 4;
284
+ const version = r.u32();
284
285
  const width = r.u32();
285
286
  const height = r.u32();
286
287
  const layers = r.u32();
287
288
  const pixels = r.u8a(width * height * layers * 4);
288
- return { width, height, layers, pixels };
289
+ const anims = [];
290
+ if (version >= 2) {
291
+ const n = r.u32();
292
+ for (let i = 0; i < n; i++) {
293
+ const base = r.u32();
294
+ const count = r.u16();
295
+ const frametime = r.u16();
296
+ const interpolate = r.u8() !== 0;
297
+ r.off += 3;
298
+ anims.push({ base, count, frametime, interpolate });
299
+ }
300
+ }
301
+ return { width, height, layers, pixels, anims };
289
302
  }
290
303
 
291
304
  // src/core/manifest.ts
@@ -360,6 +373,84 @@ function parseManifest(data) {
360
373
  };
361
374
  }
362
375
 
376
+ // src/core/source.ts
377
+ function throwIfAborted(signal) {
378
+ if (signal?.aborted) throw new DOMException("The operation was aborted.", "AbortError");
379
+ }
380
+ function normalizePath(path) {
381
+ return path.startsWith("./") ? path.slice(2) : path;
382
+ }
383
+ async function worldFromUrl(url, base) {
384
+ const abs = new URL(url, base ?? (typeof document !== "undefined" ? document.baseURI : void 0)).toString();
385
+ const res = await fetch(abs);
386
+ if (!res.ok) throw new Error(`${res.status} ${res.statusText} for ${abs}`);
387
+ const manifest = await res.json();
388
+ return {
389
+ manifest,
390
+ label: abs,
391
+ fetch: async (path, signal) => {
392
+ const target = new URL(normalizePath(path), abs).toString();
393
+ const r = await fetch(target, signal ? { signal } : void 0);
394
+ if (!r.ok) throw new Error(`${r.status} ${r.statusText} for ${target}`);
395
+ return r.arrayBuffer();
396
+ }
397
+ };
398
+ }
399
+ async function worldFromDirectory(dir) {
400
+ const readFile = async (path, signal) => {
401
+ throwIfAborted(signal);
402
+ const segments = normalizePath(path).split("/").filter((s) => s.length > 0 && s !== ".");
403
+ if (segments.length === 0 || segments.includes("..")) throw new Error(`vantage: bad tile path ${path}`);
404
+ let node = dir;
405
+ for (const segment of segments.slice(0, -1)) node = await node.getDirectoryHandle(segment);
406
+ const handle = await node.getFileHandle(segments[segments.length - 1]);
407
+ return handle.getFile();
408
+ };
409
+ let manifestFile;
410
+ try {
411
+ manifestFile = await readFile("manifest.json");
412
+ } catch {
413
+ throw new Error(
414
+ `vantage: no manifest.json in "${dir.name}" \u2014 pick the folder a \`vantage render\` wrote (it holds manifest.json, terrain.vtexarr, and tiles/)`
415
+ );
416
+ }
417
+ return {
418
+ manifest: JSON.parse(await manifestFile.text()),
419
+ label: dir.name,
420
+ fetch: async (path, signal) => {
421
+ const file = await readFile(path, signal);
422
+ throwIfAborted(signal);
423
+ return file.arrayBuffer();
424
+ }
425
+ };
426
+ }
427
+ async function worldFromFiles(files, pathOf = (f) => f.webkitRelativePath || f.name) {
428
+ const byPath = /* @__PURE__ */ new Map();
429
+ for (const file of files) byPath.set(normalizePath(pathOf(file)).replace(/\\/g, "/"), file);
430
+ let manifestPath = null;
431
+ for (const path of byPath.keys()) {
432
+ if (path !== "manifest.json" && !path.endsWith("/manifest.json")) continue;
433
+ if (manifestPath === null || path.split("/").length < manifestPath.split("/").length) manifestPath = path;
434
+ }
435
+ if (manifestPath === null) {
436
+ throw new Error(
437
+ "vantage: no manifest.json among the selected files \u2014 pick the folder a `vantage render` wrote (it holds manifest.json, terrain.vtexarr, and tiles/)"
438
+ );
439
+ }
440
+ const prefix = manifestPath.slice(0, manifestPath.length - "manifest.json".length);
441
+ const root = prefix === "" ? "world" : prefix.slice(0, -1);
442
+ return {
443
+ manifest: JSON.parse(await byPath.get(manifestPath).text()),
444
+ label: root,
445
+ fetch: (path, signal) => {
446
+ throwIfAborted(signal);
447
+ const file = byPath.get(prefix + normalizePath(path));
448
+ if (!file) return Promise.reject(new Error(`vantage: ${path} is not in the selected folder`));
449
+ return file.arrayBuffer();
450
+ }
451
+ };
452
+ }
453
+
363
454
  // src/core/lowres.ts
364
455
  var LOWRES_MAGIC = "VLR1";
365
456
  var LOWRES_EMPTY = -32768;
@@ -480,4 +571,4 @@ function summarizeBiomes(tile, palette) {
480
571
  return toEntries(counts, names, pal);
481
572
  }
482
573
 
483
- export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, biomePalette, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey };
574
+ export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, biomePalette, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey, worldFromDirectory, worldFromFiles, worldFromUrl };
@@ -1,4 +1,4 @@
1
- export { B as BiomeEntry, b as ByteReader, a as DecodedTextureArray, D as DecodedTile, L as LowresLevel, M as ManifestTile, c as MeshSection, d as QuantizedSection, Q as QuantizedTile, R as Rgb, S as SurfaceMap, T as TEXTURE_MAGIC, e as TILE_MAGIC, f as TileMagic, W as WorldManifest, g as biomePalette, p as parseManifest, h as parseTextureArray, i as parseTile, j as parseTileQuantized, s as stripNamespace, k as summarizeBiomes, l as summarizeSurfaceBiomes, t as tileKey } from '../biome-LCQwACRa.js';
1
+ export { B as BiomeEntry, b as ByteReader, a as DecodedTextureArray, D as DecodedTile, L as LowresLevel, M as ManifestTile, c as MeshSection, d as QuantizedSection, Q as QuantizedTile, R as Rgb, S as SurfaceMap, T as TEXTURE_MAGIC, e as TILE_MAGIC, f as TextureAnimation, g as TileMagic, W as WorldFetch, h as WorldManifest, i as WorldSource, j as biomePalette, p as parseManifest, k as parseTextureArray, l as parseTile, m as parseTileQuantized, s as stripNamespace, n as summarizeBiomes, o as summarizeSurfaceBiomes, t as tileKey, w as worldFromDirectory, q as worldFromFiles, r as worldFromUrl } from '../biome-CO419Coy.js';
2
2
 
3
3
  declare const LOWRES_MAGIC = "VLR1";
4
4
  /** Height sentinel for samples with no terrain (unpopulated chunks). */
@@ -1 +1 @@
1
- export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, biomePalette, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey } from '../chunk-X7ZJUHP2.js';
1
+ export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, biomePalette, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey, worldFromDirectory, worldFromFiles, worldFromUrl } from '../chunk-TC3HQWAD.js';
@@ -1,15 +1,18 @@
1
1
  import * as react from 'react';
2
2
  import { CSSProperties, ReactNode } from 'react';
3
- import { g as TileSource, T as TextureSource, S as StreamingSettings, k as ViewMode, L as LightSettings, a as DisplaySettings, d as TileInfo, i as VantageViewer$1 } from '../viewer-DkAMDMtW.js';
4
- export { D as DEFAULT_ORBIT_ANGLE, V as VANILLA_DISPLAY } from '../viewer-DkAMDMtW.js';
5
- import { B as BiomeEntry } from '../biome-LCQwACRa.js';
6
- export { D as DecodedTile } from '../biome-LCQwACRa.js';
3
+ import { i as WorldSource, B as BiomeEntry } from '../biome-CO419Coy.js';
4
+ export { D as DecodedTile } from '../biome-CO419Coy.js';
5
+ import { g as TileSource, T as TextureSource, S as StreamingSettings, k as ViewMode, L as LightSettings, a as DisplaySettings, d as TileInfo, i as VantageViewer$1 } from '../viewer-D8UWlNNc.js';
6
+ export { D as DEFAULT_ORBIT_ANGLE, V as VANILLA_DISPLAY } from '../viewer-D8UWlNNc.js';
7
7
  import 'three';
8
8
 
9
9
  interface VantageViewerProps {
10
- /** A tiled world to stream: the `manifest.json` URL (from `vantage render`).
10
+ /** A tiled world to stream: the `manifest.json` URL (from `vantage render`),
11
+ * or a `WorldSource` for renders that don't live on a server — e.g.
12
+ * `worldFromDirectory(handle)` for a folder the user picked. Keep the object
13
+ * referentially stable (state/memo): a new identity reloads the world.
11
14
  * Takes precedence over `tile`. */
12
- world?: string;
15
+ world?: string | WorldSource;
13
16
  /** A single `.vtile` to render: a URL, a raw buffer, or already-decoded data. */
14
17
  tile?: TileSource;
15
18
  /** The `.vtexarr` texture array (required for textured tiles). */
@@ -1,6 +1,6 @@
1
- import { VantageViewer, DEFAULT_ORBIT_ANGLE } from '../chunk-7V27NYZD.js';
2
- export { DEFAULT_ORBIT_ANGLE, VANILLA_DISPLAY } from '../chunk-7V27NYZD.js';
3
- import '../chunk-X7ZJUHP2.js';
1
+ import { VantageViewer, DEFAULT_ORBIT_ANGLE } from '../chunk-576KSRE6.js';
2
+ export { DEFAULT_ORBIT_ANGLE, VANILLA_DISPLAY } from '../chunk-576KSRE6.js';
3
+ import '../chunk-TC3HQWAD.js';
4
4
  import { createContext, forwardRef, useRef, useState, useImperativeHandle, useEffect, useMemo, useContext } from 'react';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
 
@@ -1,9 +1,9 @@
1
1
  import * as THREE from 'three';
2
- import { R as Rgb, Q as QuantizedTile, D as DecodedTile, a as DecodedTextureArray, S as SurfaceMap } from '../biome-LCQwACRa.js';
3
- export { B as BiomeEntry, b as ByteReader, L as LowresLevel, M as ManifestTile, c as MeshSection, d as QuantizedSection, T as TEXTURE_MAGIC, e as TILE_MAGIC, f as TileMagic, W as WorldManifest, g as biomePalette, p as parseManifest, h as parseTextureArray, i as parseTile, j as parseTileQuantized, s as stripNamespace, k as summarizeBiomes, l as summarizeSurfaceBiomes, t as tileKey } from '../biome-LCQwACRa.js';
2
+ import { R as Rgb, Q as QuantizedTile, D as DecodedTile, a as DecodedTextureArray, S as SurfaceMap } from '../biome-CO419Coy.js';
3
+ export { B as BiomeEntry, b as ByteReader, L as LowresLevel, M as ManifestTile, c as MeshSection, d as QuantizedSection, T as TEXTURE_MAGIC, e as TILE_MAGIC, f as TextureAnimation, g as TileMagic, W as WorldFetch, h as WorldManifest, i as WorldSource, j as biomePalette, p as parseManifest, k as parseTextureArray, l as parseTile, m as parseTileQuantized, s as stripNamespace, n as summarizeBiomes, o as summarizeSurfaceBiomes, t as tileKey, w as worldFromDirectory, q as worldFromFiles, r as worldFromUrl } from '../biome-CO419Coy.js';
4
4
  import { LowresTile } from '../core/index.js';
5
5
  export { LOWRES_EMPTY, LOWRES_MAGIC, isGzip, maybeInflate, parseLowresTile } from '../core/index.js';
6
- export { D as DEFAULT_ORBIT_ANGLE, a as DisplaySettings, H as HeightSampler, L as LightSettings, b as LoadOptions, M as MapControls, c as MapControlsOptions, S as StreamingSettings, T as TextureSource, d as TileInfo, e as TileManager, f as TileManagerOptions, g as TileSource, h as TileStats, V as VANILLA_DISPLAY, i as VantageViewer, j as VantageViewerOptions, k as ViewMode } from '../viewer-DkAMDMtW.js';
6
+ export { D as DEFAULT_ORBIT_ANGLE, a as DisplaySettings, H as HeightSampler, L as LightSettings, b as LoadOptions, M as MapControls, c as MapControlsOptions, S as StreamingSettings, T as TextureSource, d as TileInfo, e as TileManager, f as TileManagerOptions, g as TileSource, h as TileStats, V as VANILLA_DISPLAY, i as VantageViewer, j as VantageViewerOptions, k as ViewMode } from '../viewer-D8UWlNNc.js';
7
7
 
8
8
  /** The objects and metadata produced from a tile. */
9
9
  interface TerrainObjects {
@@ -1,2 +1,2 @@
1
- export { DEFAULT_ORBIT_ANGLE, MapControls, SKY_HORIZON, SKY_TOP, TileManager, VANILLA_DISPLAY, VantageViewer, buildLowresMesh, buildQuantizedTileMeshes, buildTerrain, buildTileMeshes, createLowresMaterial, createSky, createTerrainMaterial, createWaterMaterial, pickBiome } from '../chunk-7V27NYZD.js';
2
- export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, biomePalette, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey } from '../chunk-X7ZJUHP2.js';
1
+ export { DEFAULT_ORBIT_ANGLE, MapControls, SKY_HORIZON, SKY_TOP, TileManager, VANILLA_DISPLAY, VantageViewer, buildLowresMesh, buildQuantizedTileMeshes, buildTerrain, buildTileMeshes, createLowresMaterial, createSky, createTerrainMaterial, createWaterMaterial, pickBiome } from '../chunk-576KSRE6.js';
2
+ export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, biomePalette, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey, worldFromDirectory, worldFromFiles, worldFromUrl } from '../chunk-TC3HQWAD.js';
@@ -1,10 +1,11 @@
1
1
  import * as THREE from 'three';
2
- import { W as WorldManifest, R as Rgb, B as BiomeEntry, a as DecodedTextureArray, D as DecodedTile } from './biome-LCQwACRa.js';
2
+ import { h as WorldManifest, W as WorldFetch, R as Rgb, B as BiomeEntry, a as DecodedTextureArray, D as DecodedTile, i as WorldSource } from './biome-CO419Coy.js';
3
3
 
4
4
  interface TileManagerOptions {
5
5
  manifest: WorldManifest;
6
- /** URL the manifest was fetched from — tile paths resolve relative to it. */
7
- baseUrl: string;
6
+ /** Fetch a file by manifest-relative path — a {@link WorldSource}'s `fetch`
7
+ * (HTTP, a local folder, …). Tile paths are passed through verbatim. */
8
+ fetch: WorldFetch;
8
9
  scene: THREE.Scene;
9
10
  /** The shared terrain shader (from {@link createTerrainMaterial}). */
10
11
  material: THREE.ShaderMaterial;
@@ -422,8 +423,10 @@ interface VantageViewerOptions {
422
423
  type TileSource = string | ArrayBuffer | DecodedTile;
423
424
  type TextureSource = string | ArrayBuffer | DecodedTextureArray;
424
425
  interface LoadOptions {
425
- /** A tiled world to stream: the `manifest.json` URL. Takes precedence over `tile`. */
426
- world?: string;
426
+ /** A tiled world to stream: the `manifest.json` URL, or a {@link WorldSource}
427
+ * for worlds that don't live on an HTTP server (a local folder, a zip — see
428
+ * `worldFromDirectory` / `worldFromFiles`). Takes precedence over `tile`. */
429
+ world?: string | WorldSource;
427
430
  /** A single `.vtile` to render (the non-streaming path). */
428
431
  tile?: TileSource;
429
432
  /** The `.vtexarr` texture array (required for textured tiles). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughts-on-things/vantage-mc",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Render a Minecraft (Java) world as a fast, beautiful 3D web map. The web frontend for the Vantage generator.",
5
5
  "type": "module",
6
6
  "license": "MIT",