@thoughts-on-things/vantage-mc 0.4.0 → 0.6.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.
- package/README.md +15 -13
- package/dist/{biome-uodZHCCI.d.ts → biome-NBWIY7dT.d.ts} +34 -13
- package/dist/{chunk-HGHIERQW.js → chunk-46RBFJ4D.js} +379 -47
- package/dist/{chunk-ILHVIGCI.js → chunk-EVPUXVSB.js} +39 -13
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/react/index.d.ts +9 -5
- package/dist/react/index.js +19 -16
- package/dist/three/index.d.ts +6 -6
- package/dist/three/index.js +2 -2
- package/dist/{viewer-Ba31QN1M.d.ts → viewer-C5vYxrL1.d.ts} +86 -5
- package/package.json +9 -6
|
@@ -18,7 +18,10 @@ var TILE_MAGIC = {
|
|
|
18
18
|
/** + a per-tile lightmap atlas: the greedy vertex tail samples baked
|
|
19
19
|
* light/AO from a texture instead of vertices, so lighting gradients no
|
|
20
20
|
* longer fragment greedy merges (~23% fewer vertices). */
|
|
21
|
-
VTL8: "VTL8"
|
|
21
|
+
VTL8: "VTL8",
|
|
22
|
+
/** VTL8 geometry + a losslessly packed RG8 lightmap (sky/block nibbles,
|
|
23
|
+
* full-byte AO), stored as gzip-friendly planes. */
|
|
24
|
+
VTL9: "VTL9"
|
|
22
25
|
};
|
|
23
26
|
var UV_SCALE = 128;
|
|
24
27
|
var TEXTURE_MAGIC = "VTA1";
|
|
@@ -295,7 +298,21 @@ function readLightmap(r) {
|
|
|
295
298
|
pixels[i * 4 + 2] = ao[i];
|
|
296
299
|
pixels[i * 4 + 3] = 255;
|
|
297
300
|
}
|
|
298
|
-
return { width, height, pixels };
|
|
301
|
+
return { width, height, packed: false, pixels };
|
|
302
|
+
}
|
|
303
|
+
function readPackedLightmap(r) {
|
|
304
|
+
const width = r.u32();
|
|
305
|
+
const height = r.u32();
|
|
306
|
+
const n = width * height;
|
|
307
|
+
if (n === 0) return void 0;
|
|
308
|
+
const light = r.u8a(n);
|
|
309
|
+
const ao = r.u8a(n);
|
|
310
|
+
const pixels = new Uint8Array(2 * n);
|
|
311
|
+
for (let i = 0; i < n; i++) {
|
|
312
|
+
pixels[i * 2] = light[i];
|
|
313
|
+
pixels[i * 2 + 1] = ao[i];
|
|
314
|
+
}
|
|
315
|
+
return { width, height, packed: true, pixels };
|
|
299
316
|
}
|
|
300
317
|
function expandSection(raw) {
|
|
301
318
|
const { vertexCount, indexCount } = raw;
|
|
@@ -340,24 +357,26 @@ function bakeVertexLight(sec, lm) {
|
|
|
340
357
|
const k = i - lmStart;
|
|
341
358
|
const u = lmuv[k * 2] - 1 >> 1;
|
|
342
359
|
const v = lmuv[k * 2 + 1] - 1 >> 1;
|
|
343
|
-
const
|
|
344
|
-
const
|
|
345
|
-
const
|
|
360
|
+
const texel = v * lm.width + u;
|
|
361
|
+
const o = texel * (lm.packed ? 2 : 4);
|
|
362
|
+
const packed = lm.packed ? lm.pixels[o] : 0;
|
|
363
|
+
const sky = lm.packed ? packed >> 4 : Math.round(lm.pixels[o] / 17);
|
|
364
|
+
const blk = lm.packed ? packed & 15 : Math.round(lm.pixels[o + 1] / 17);
|
|
346
365
|
light[i] = sky << 4 | blk;
|
|
347
|
-
colors[i * 4 + 3] = lm.pixels[o + 2];
|
|
366
|
+
colors[i * 4 + 3] = lm.pixels[o + (lm.packed ? 1 : 2)];
|
|
348
367
|
}
|
|
349
368
|
sec.colors = colors;
|
|
350
369
|
}
|
|
351
370
|
function parseTileQuantized(buffer) {
|
|
352
371
|
const r = new ByteReader(buffer);
|
|
353
372
|
const magic = r.magic();
|
|
354
|
-
if (magic !== TILE_MAGIC.VTL6 && magic !== TILE_MAGIC.VTL7 && magic !== TILE_MAGIC.VTL8) return null;
|
|
373
|
+
if (magic !== TILE_MAGIC.VTL6 && magic !== TILE_MAGIC.VTL7 && magic !== TILE_MAGIC.VTL8 && magic !== TILE_MAGIC.VTL9) return null;
|
|
355
374
|
r.off = 4;
|
|
356
375
|
const version = r.u32();
|
|
357
|
-
const readSection = magic === TILE_MAGIC.VTL8 ? readLitSectionRaw : magic === TILE_MAGIC.VTL7 ? readCompactSectionRaw : readQuantizedSectionRaw;
|
|
376
|
+
const readSection = magic === TILE_MAGIC.VTL8 || magic === TILE_MAGIC.VTL9 ? readLitSectionRaw : magic === TILE_MAGIC.VTL7 ? readCompactSectionRaw : readQuantizedSectionRaw;
|
|
358
377
|
const solid = readSection(r);
|
|
359
378
|
const fluid = readSection(r);
|
|
360
|
-
const lightmap = magic === TILE_MAGIC.VTL8 ? readLightmap(r) : void 0;
|
|
379
|
+
const lightmap = magic === TILE_MAGIC.VTL9 ? readPackedLightmap(r) : magic === TILE_MAGIC.VTL8 ? readLightmap(r) : void 0;
|
|
361
380
|
const surface = readSurface(r);
|
|
362
381
|
const biomeNames = readLegend(r);
|
|
363
382
|
return { magic, version, solid, fluid, surface, biomeNames, ...lightmap ? { lightmap } : {} };
|
|
@@ -387,10 +406,10 @@ function parseTile(buffer) {
|
|
|
387
406
|
const magic = r.magic();
|
|
388
407
|
r.off = 4;
|
|
389
408
|
const version = r.u32();
|
|
390
|
-
if (magic === TILE_MAGIC.VTL8) {
|
|
409
|
+
if (magic === TILE_MAGIC.VTL8 || magic === TILE_MAGIC.VTL9) {
|
|
391
410
|
const solid = expandSection(readLitSectionRaw(r));
|
|
392
411
|
const fluid = expandSection(readLitSectionRaw(r));
|
|
393
|
-
const lightmap = readLightmap(r);
|
|
412
|
+
const lightmap = magic === TILE_MAGIC.VTL9 ? readPackedLightmap(r) : readLightmap(r);
|
|
394
413
|
if (lightmap) bakeVertexLight(solid, lightmap);
|
|
395
414
|
const surface = readSurface(r);
|
|
396
415
|
const biomeNames = readLegend(r);
|
|
@@ -513,8 +532,8 @@ function parseManifest(data) {
|
|
|
513
532
|
if (typeof data !== "object" || data === null) throw new Error("vantage: manifest is not an object");
|
|
514
533
|
const m = data;
|
|
515
534
|
const format = m["format"];
|
|
516
|
-
if (format !== 1 && format !== 2 && format !== 3 && format !== 4) {
|
|
517
|
-
throw new Error(`vantage: unsupported manifest format ${String(format)} (expected 1..
|
|
535
|
+
if (format !== 1 && format !== 2 && format !== 3 && format !== 4 && format !== 5) {
|
|
536
|
+
throw new Error(`vantage: unsupported manifest format ${String(format)} (expected 1..5)`);
|
|
518
537
|
}
|
|
519
538
|
const tileChunks = m["tileChunks"];
|
|
520
539
|
const tileBlocks = m["tileBlocks"];
|
|
@@ -571,12 +590,19 @@ function parseManifest(data) {
|
|
|
571
590
|
yRange = { min: yr["min"], max: yr["max"] };
|
|
572
591
|
}
|
|
573
592
|
const maxSectionVerts = m["maxSectionVerts"];
|
|
593
|
+
const textureLayers = m["textureLayers"];
|
|
594
|
+
const pr = m["progress"];
|
|
595
|
+
const progress = typeof pr === "object" && pr !== null && typeof pr["done"] === "number" && typeof pr["total"] === "number" ? { done: pr["done"], total: pr["total"] } : void 0;
|
|
574
596
|
return {
|
|
575
597
|
format,
|
|
576
598
|
tileChunks,
|
|
577
599
|
tileBlocks,
|
|
578
600
|
textures,
|
|
579
601
|
...typeof maxSectionVerts === "number" && maxSectionVerts > 0 ? { maxSectionVerts } : {},
|
|
602
|
+
...typeof textureLayers === "number" && textureLayers > 0 ? { textureLayers } : {},
|
|
603
|
+
...m["rendering"] === true ? { rendering: true } : {},
|
|
604
|
+
...m["dynamic"] === true ? { dynamic: true } : {},
|
|
605
|
+
...progress ? { progress } : {},
|
|
580
606
|
...spawn ? { spawn } : {},
|
|
581
607
|
...m["caves"] === true ? { caves: true } : {},
|
|
582
608
|
...yRange ? { yRange } : {},
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BiomeEntry, b as ByteReader, a as DecodedTextureArray, D as DecodedTile, L as Lightmap, c as LowresLevel, M as ManifestTile, d as MeshSection, e as QuantizedSection, Q as QuantizedTile, R as Rgb, S as SurfaceMap, T as TEXTURE_MAGIC, f as TILE_MAGIC, g as TextureAnimation, h as TileMagic, U as UV_SCALE, W as WorldFetch, i as WorldManifest, j as WorldSource, k as biomePalette, l as canonicalQuadIndices, p as parseManifest, m as parseTextureArray, n as parseTile, o as parseTileQuantized, s as stripNamespace, q as summarizeBiomes, r as summarizeSurfaceBiomes, t as tileKey, w as worldFromDirectory, u as worldFromFiles, v as worldFromUrl } from '../biome-
|
|
1
|
+
export { B as BiomeEntry, b as ByteReader, a as DecodedTextureArray, D as DecodedTile, L as Lightmap, c as LowresLevel, M as ManifestTile, d as MeshSection, e as QuantizedSection, Q as QuantizedTile, R as Rgb, S as SurfaceMap, T as TEXTURE_MAGIC, f as TILE_MAGIC, g as TextureAnimation, h as TileMagic, U as UV_SCALE, W as WorldFetch, i as WorldManifest, j as WorldSource, k as biomePalette, l as canonicalQuadIndices, p as parseManifest, m as parseTextureArray, n as parseTile, o as parseTileQuantized, s as stripNamespace, q as summarizeBiomes, r as summarizeSurfaceBiomes, t as tileKey, w as worldFromDirectory, u as worldFromFiles, v as worldFromUrl } from '../biome-NBWIY7dT.js';
|
|
2
2
|
|
|
3
3
|
declare const LOWRES_MAGIC = "VLR1";
|
|
4
4
|
/** Height sentinel for samples with no terrain (unpopulated chunks). */
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, UV_SCALE, biomePalette, canonicalQuadIndices, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey, worldFromDirectory, worldFromFiles, worldFromUrl } from '../chunk-
|
|
1
|
+
export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, UV_SCALE, biomePalette, canonicalQuadIndices, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey, worldFromDirectory, worldFromFiles, worldFromUrl } from '../chunk-EVPUXVSB.js';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { j as WorldSource, B as BiomeEntry } from '../biome-
|
|
4
|
-
export { D as DecodedTile } from '../biome-
|
|
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-
|
|
6
|
-
export { D as DEFAULT_ORBIT_ANGLE, V as VANILLA_DISPLAY } from '../viewer-
|
|
3
|
+
import { j as WorldSource, B as BiomeEntry } from '../biome-NBWIY7dT.js';
|
|
4
|
+
export { D as DecodedTile } from '../biome-NBWIY7dT.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-C5vYxrL1.js';
|
|
6
|
+
export { D as DEFAULT_ORBIT_ANGLE, V as VANILLA_DISPLAY } from '../viewer-C5vYxrL1.js';
|
|
7
7
|
import 'three';
|
|
8
8
|
|
|
9
9
|
interface VantageViewerProps {
|
|
@@ -17,7 +17,7 @@ interface VantageViewerProps {
|
|
|
17
17
|
tile?: TileSource;
|
|
18
18
|
/** The `.vtexarr` texture array (required for textured tiles). */
|
|
19
19
|
textures?: TextureSource;
|
|
20
|
-
/** Streaming behaviour for `world` sources (view distance, tile
|
|
20
|
+
/** Streaming behaviour for `world` sources (view distance, tile/byte budgets).
|
|
21
21
|
* Live: changes re-plan in place, like the other setting props. */
|
|
22
22
|
streaming?: StreamingSettings;
|
|
23
23
|
/** Initial camera framing. Default `'orbit'`. */
|
|
@@ -26,6 +26,9 @@ interface VantageViewerProps {
|
|
|
26
26
|
antialias?: boolean;
|
|
27
27
|
/** Device pixel-ratio cap. Default `2`. Changing this remounts the canvas. */
|
|
28
28
|
maxPixelRatio?: number;
|
|
29
|
+
/** Render only when the view changes, with a low-frequency tick for animated
|
|
30
|
+
* textures. Default `true`; idle maps then use effectively no GPU time. */
|
|
31
|
+
renderOnDemand?: boolean;
|
|
29
32
|
/** Live lighting appearance (ambient floor, daylight, exposure). Applied on
|
|
30
33
|
* change without re-baking — drive it from a slider for a day/night control. */
|
|
31
34
|
light?: LightSettings;
|
|
@@ -108,6 +111,7 @@ interface QualityPreset {
|
|
|
108
111
|
name: string;
|
|
109
112
|
viewDistance: number;
|
|
110
113
|
maxTiles: number;
|
|
114
|
+
maxBytes: number;
|
|
111
115
|
renderScale: number;
|
|
112
116
|
}
|
|
113
117
|
declare const QUALITY_PRESETS: QualityPreset[];
|
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { VantageViewer, DEFAULT_ORBIT_ANGLE } from '../chunk-
|
|
2
|
-
export { DEFAULT_ORBIT_ANGLE, VANILLA_DISPLAY } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { VantageViewer, DEFAULT_ORBIT_ANGLE } from '../chunk-46RBFJ4D.js';
|
|
2
|
+
export { DEFAULT_ORBIT_ANGLE, VANILLA_DISPLAY } from '../chunk-46RBFJ4D.js';
|
|
3
|
+
import '../chunk-EVPUXVSB.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
|
|
|
@@ -291,6 +291,7 @@ var VantageViewer2 = forwardRef(function VantageViewer3(props, ref) {
|
|
|
291
291
|
view = "orbit",
|
|
292
292
|
antialias = true,
|
|
293
293
|
maxPixelRatio = 2,
|
|
294
|
+
renderOnDemand = true,
|
|
294
295
|
light,
|
|
295
296
|
display,
|
|
296
297
|
urlState = true,
|
|
@@ -315,7 +316,7 @@ var VantageViewer2 = forwardRef(function VantageViewer3(props, ref) {
|
|
|
315
316
|
injectStyles();
|
|
316
317
|
const el = canvasRef.current;
|
|
317
318
|
if (!el) return;
|
|
318
|
-
const v = new VantageViewer(el, { antialias, maxPixelRatio, view, light, display, streaming, urlState });
|
|
319
|
+
const v = new VantageViewer(el, { antialias, maxPixelRatio, renderOnDemand, view, light, display, streaming, urlState });
|
|
319
320
|
engineRef.current = v;
|
|
320
321
|
setEngine(v);
|
|
321
322
|
let pendingStats = null;
|
|
@@ -353,7 +354,7 @@ var VantageViewer2 = forwardRef(function VantageViewer3(props, ref) {
|
|
|
353
354
|
engineRef.current = null;
|
|
354
355
|
setEngine(null);
|
|
355
356
|
};
|
|
356
|
-
}, [antialias, maxPixelRatio]);
|
|
357
|
+
}, [antialias, maxPixelRatio, renderOnDemand]);
|
|
357
358
|
useEffect(() => {
|
|
358
359
|
if (!engine) return;
|
|
359
360
|
let cancelled = false;
|
|
@@ -376,7 +377,7 @@ var VantageViewer2 = forwardRef(function VantageViewer3(props, ref) {
|
|
|
376
377
|
}, [engine, display?.sharpness, display?.ao, display?.saturation, display?.contrast, display?.fog, display?.renderScale]);
|
|
377
378
|
useEffect(() => {
|
|
378
379
|
if (engine && streaming) engine.setStreaming(streaming);
|
|
379
|
-
}, [engine, streaming?.viewDistance, streaming?.maxTiles, streaming?.concurrency]);
|
|
380
|
+
}, [engine, streaming?.viewDistance, streaming?.maxTiles, streaming?.concurrency, streaming?.maxBytes]);
|
|
380
381
|
const ctx = useMemo(
|
|
381
382
|
() => ({
|
|
382
383
|
viewer: engine,
|
|
@@ -573,38 +574,40 @@ function LightPanel({ title = "lighting", defaultCollapsed = true, className })
|
|
|
573
574
|
}
|
|
574
575
|
);
|
|
575
576
|
}
|
|
577
|
+
var MiB = 1024 * 1024;
|
|
576
578
|
var QUALITY_PRESETS = [
|
|
577
|
-
{ name: "low", viewDistance: 448, maxTiles: 44, renderScale: 0.75 },
|
|
578
|
-
{ name: "med", viewDistance: 768, maxTiles: 120, renderScale: 1 },
|
|
579
|
-
{ name: "high", viewDistance: 1152, maxTiles: 264, renderScale: 1 },
|
|
580
|
-
{ name: "ultra", viewDistance: 1408, maxTiles: 400, renderScale: 1 }
|
|
579
|
+
{ name: "low", viewDistance: 448, maxTiles: 44, maxBytes: 320 * MiB, renderScale: 0.75 },
|
|
580
|
+
{ name: "med", viewDistance: 768, maxTiles: 120, maxBytes: 512 * MiB, renderScale: 1 },
|
|
581
|
+
{ name: "high", viewDistance: 1152, maxTiles: 264, maxBytes: 768 * MiB, renderScale: 1 },
|
|
582
|
+
{ name: "ultra", viewDistance: 1408, maxTiles: 400, maxBytes: 1024 * MiB, renderScale: 1 }
|
|
581
583
|
];
|
|
582
584
|
function SettingsPanel({ title = "quality", defaultCollapsed = true, className }) {
|
|
583
585
|
const { viewer } = useVantage();
|
|
584
|
-
const [k, setK] = useState({ viewDistance: 768, maxTiles: 120, renderScale: 1, fog: 1 });
|
|
586
|
+
const [k, setK] = useState({ viewDistance: 768, maxTiles: 120, maxBytes: 512 * MiB, renderScale: 1, fog: 1 });
|
|
585
587
|
useEffect(() => {
|
|
586
588
|
if (!viewer) return;
|
|
587
589
|
const s = viewer.streamingSettings;
|
|
588
590
|
const d = viewer.displaySettings;
|
|
589
|
-
setK({ viewDistance: s.viewDistance, maxTiles: s.maxTiles, renderScale: d.renderScale, fog: d.fog });
|
|
591
|
+
setK({ viewDistance: s.viewDistance, maxTiles: s.maxTiles, maxBytes: s.maxBytes, renderScale: d.renderScale, fog: d.fog });
|
|
590
592
|
}, [viewer]);
|
|
591
593
|
if (!viewer) return null;
|
|
592
594
|
const apply = (next) => {
|
|
593
595
|
const merged = { ...k, ...next };
|
|
594
596
|
setK(merged);
|
|
595
|
-
if (next.viewDistance !== void 0 || next.maxTiles !== void 0) {
|
|
596
|
-
viewer.setStreaming({ viewDistance: merged.viewDistance, maxTiles: merged.maxTiles });
|
|
597
|
+
if (next.viewDistance !== void 0 || next.maxTiles !== void 0 || next.maxBytes !== void 0) {
|
|
598
|
+
viewer.setStreaming({ viewDistance: merged.viewDistance, maxTiles: merged.maxTiles, maxBytes: merged.maxBytes });
|
|
597
599
|
}
|
|
598
600
|
if (next.renderScale !== void 0 || next.fog !== void 0) {
|
|
599
601
|
viewer.setDisplay({ renderScale: merged.renderScale, fog: merged.fog });
|
|
600
602
|
}
|
|
601
603
|
};
|
|
602
604
|
const active = QUALITY_PRESETS.find(
|
|
603
|
-
(p) => p.viewDistance === k.viewDistance && p.maxTiles === k.maxTiles && p.renderScale === k.renderScale
|
|
605
|
+
(p) => p.viewDistance === k.viewDistance && p.maxTiles === k.maxTiles && p.maxBytes === k.maxBytes && p.renderScale === k.renderScale
|
|
604
606
|
);
|
|
605
607
|
const SLIDERS = [
|
|
606
608
|
{ key: "viewDistance", label: "view distance", min: 256, max: 2048, step: 64, fmt: (v) => `${v}m` },
|
|
607
609
|
{ key: "maxTiles", label: "tile budget", min: 24, max: 512, step: 8, fmt: (v) => `${v}` },
|
|
610
|
+
{ key: "maxBytes", label: "memory budget", min: 128 * MiB, max: 1536 * MiB, step: 64 * MiB, fmt: (v) => `${Math.round(v / MiB)} MiB` },
|
|
608
611
|
{ key: "renderScale", label: "render scale", min: 0.5, max: 2, step: 0.05, fmt: (v) => `${v.toFixed(2)}\xD7` },
|
|
609
612
|
{ key: "fog", label: "haze", min: 0, max: 1, step: 0.05, fmt: (v) => v.toFixed(2) }
|
|
610
613
|
];
|
|
@@ -621,7 +624,7 @@ function SettingsPanel({ title = "quality", defaultCollapsed = true, className }
|
|
|
621
624
|
"button",
|
|
622
625
|
{
|
|
623
626
|
className: active?.name === p.name ? "vtg-seg-on" : void 0,
|
|
624
|
-
onClick: () => apply({ viewDistance: p.viewDistance, maxTiles: p.maxTiles, renderScale: p.renderScale }),
|
|
627
|
+
onClick: () => apply({ viewDistance: p.viewDistance, maxTiles: p.maxTiles, maxBytes: p.maxBytes, renderScale: p.renderScale }),
|
|
625
628
|
children: p.name
|
|
626
629
|
},
|
|
627
630
|
p.name
|
package/dist/three/index.d.ts
CHANGED
|
@@ -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-
|
|
3
|
-
export { B as BiomeEntry, b as ByteReader, L as Lightmap, c as LowresLevel, M as ManifestTile, d as MeshSection, e as QuantizedSection, T as TEXTURE_MAGIC, f as TILE_MAGIC, g as TextureAnimation, h as TileMagic, U as UV_SCALE, W as WorldFetch, i as WorldManifest, j as WorldSource, k as biomePalette, l as canonicalQuadIndices, p as parseManifest, m as parseTextureArray, n as parseTile, o as parseTileQuantized, s as stripNamespace, q as summarizeBiomes, r as summarizeSurfaceBiomes, t as tileKey, w as worldFromDirectory, u as worldFromFiles, v as worldFromUrl } from '../biome-
|
|
2
|
+
import { R as Rgb, Q as QuantizedTile, D as DecodedTile, a as DecodedTextureArray, S as SurfaceMap } from '../biome-NBWIY7dT.js';
|
|
3
|
+
export { B as BiomeEntry, b as ByteReader, L as Lightmap, c as LowresLevel, M as ManifestTile, d as MeshSection, e as QuantizedSection, T as TEXTURE_MAGIC, f as TILE_MAGIC, g as TextureAnimation, h as TileMagic, U as UV_SCALE, W as WorldFetch, i as WorldManifest, j as WorldSource, k as biomePalette, l as canonicalQuadIndices, p as parseManifest, m as parseTextureArray, n as parseTile, o as parseTileQuantized, s as stripNamespace, q as summarizeBiomes, r as summarizeSurfaceBiomes, t as tileKey, w as worldFromDirectory, u as worldFromFiles, v as worldFromUrl } from '../biome-NBWIY7dT.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-
|
|
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-C5vYxrL1.js';
|
|
7
7
|
|
|
8
8
|
/** The objects and metadata produced from a tile. */
|
|
9
9
|
interface TerrainObjects {
|
|
@@ -26,7 +26,7 @@ interface TerrainObjects {
|
|
|
26
26
|
/** The meshes built from one tile with caller-provided (shared) materials. */
|
|
27
27
|
interface TileMeshes {
|
|
28
28
|
terrain: THREE.Mesh;
|
|
29
|
-
/** The atlas-lit tail of the solid geometry (VTL8), drawn with the
|
|
29
|
+
/** The atlas-lit tail of the solid geometry (VTL8+), drawn with the
|
|
30
30
|
* lightmapped sibling material. */
|
|
31
31
|
terrainLm?: THREE.Mesh;
|
|
32
32
|
/** The tail's lightmap texture — dispose it with the tile. */
|
|
@@ -42,11 +42,11 @@ interface TileMeshes {
|
|
|
42
42
|
*/
|
|
43
43
|
declare function buildTileMeshes(tile: DecodedTile, palette: Rgb[], material: THREE.ShaderMaterial, waterMaterial: THREE.ShaderMaterial): TileMeshes;
|
|
44
44
|
/**
|
|
45
|
-
* Build a VTL6
|
|
45
|
+
* Build a VTL6+ tile's meshes in the quantized fast path: shared QUANTIZED
|
|
46
46
|
* materials (from `createTerrainMaterial(tex, { quantized: true, palette })`),
|
|
47
47
|
* zero per-vertex CPU work. This is what the streaming TileManager uses.
|
|
48
48
|
*
|
|
49
|
-
* A VTL8 tile's atlas-lit vertex tail becomes its own mesh (`terrainLm`) drawn
|
|
49
|
+
* A VTL8+ tile's atlas-lit vertex tail becomes its own mesh (`terrainLm`) drawn
|
|
50
50
|
* with `lmMaterial` (from {@link createLightmappedMaterial}) — pass it whenever
|
|
51
51
|
* the world is format 4+, or the tail would render full-bright.
|
|
52
52
|
*/
|
package/dist/three/index.js
CHANGED
|
@@ -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-
|
|
2
|
-
export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, UV_SCALE, biomePalette, canonicalQuadIndices, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey, worldFromDirectory, worldFromFiles, worldFromUrl } from '../chunk-
|
|
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-46RBFJ4D.js';
|
|
2
|
+
export { ByteReader, LOWRES_EMPTY, LOWRES_MAGIC, TEXTURE_MAGIC, TILE_MAGIC, UV_SCALE, biomePalette, canonicalQuadIndices, isGzip, maybeInflate, parseLowresTile, parseManifest, parseTextureArray, parseTile, parseTileQuantized, stripNamespace, summarizeBiomes, summarizeSurfaceBiomes, tileKey, worldFromDirectory, worldFromFiles, worldFromUrl } from '../chunk-EVPUXVSB.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { i as WorldManifest, W as WorldFetch, R as Rgb, B as BiomeEntry, a as DecodedTextureArray, D as DecodedTile, j as WorldSource } from './biome-
|
|
2
|
+
import { i as WorldManifest, W as WorldFetch, R as Rgb, M as ManifestTile, c as LowresLevel, B as BiomeEntry, a as DecodedTextureArray, D as DecodedTile, j as WorldSource } from './biome-NBWIY7dT.js';
|
|
3
3
|
|
|
4
4
|
interface TileManagerOptions {
|
|
5
5
|
manifest: WorldManifest;
|
|
@@ -12,7 +12,7 @@ interface TileManagerOptions {
|
|
|
12
12
|
/** The shared water shader (from {@link createWaterMaterial}). */
|
|
13
13
|
waterMaterial: THREE.ShaderMaterial;
|
|
14
14
|
/** The shared atlas-lit shader (from {@link createLightmappedMaterial});
|
|
15
|
-
* required to draw VTL8 tiles' lightmapped geometry (manifest format 4+). */
|
|
15
|
+
* required to draw VTL8+ tiles' lightmapped geometry (manifest format 4+). */
|
|
16
16
|
lmMaterial?: THREE.ShaderMaterial;
|
|
17
17
|
/** The shared lowres LOD shader (from {@link createLowresMaterial}); required
|
|
18
18
|
* to stream a format-2 manifest's lowres pyramid. */
|
|
@@ -26,6 +26,17 @@ interface TileManagerOptions {
|
|
|
26
26
|
maxTiles?: number;
|
|
27
27
|
/** Concurrent tile fetches. Default `4`. */
|
|
28
28
|
concurrency?: number;
|
|
29
|
+
/** Estimated CPU/GPU residency budget in bytes. Unlike `maxTiles`, this
|
|
30
|
+
* accounts for large and small tiles having very different geometry. One
|
|
31
|
+
* nearest oversized tile is allowed for forward progress. Default `512 MiB`. */
|
|
32
|
+
maxBytes?: number;
|
|
33
|
+
/** Live/on-demand renders grow the shared texture atlas in viewport order, so
|
|
34
|
+
* a fetched tile can reference layers the atlas doesn't have yet. When set,
|
|
35
|
+
* the manager widens the atlas (awaiting this) before building a tile that
|
|
36
|
+
* needs newer layers, so nothing is ever drawn against a missing-texture
|
|
37
|
+
* atlas. Returns the atlas layer count now loaded. Omitted for a
|
|
38
|
+
* static/complete render, whose atlas never grows. */
|
|
39
|
+
ensureAtlas?: (layers: number) => Promise<number>;
|
|
29
40
|
}
|
|
30
41
|
/** Live totals across resident tiles. */
|
|
31
42
|
interface TileStats {
|
|
@@ -41,6 +52,8 @@ interface TileStats {
|
|
|
41
52
|
triangleCount: number;
|
|
42
53
|
/** Compressed bytes fetched and resident. */
|
|
43
54
|
bytes: number;
|
|
55
|
+
/** Estimated CPU/GPU bytes held by resident and upload-pending resources. */
|
|
56
|
+
residentBytes: number;
|
|
44
57
|
}
|
|
45
58
|
interface TileEvents extends Record<string, unknown> {
|
|
46
59
|
/** A tile finished loading or was unloaded; payload = live stats. */
|
|
@@ -50,6 +63,12 @@ declare class TileManager {
|
|
|
50
63
|
private readonly opts;
|
|
51
64
|
private readonly lowresMaterial;
|
|
52
65
|
private readonly lmMaterial;
|
|
66
|
+
/** Widens the shared atlas to cover a tile's layers before it's drawn (live
|
|
67
|
+
* renders only); null when the atlas is complete. */
|
|
68
|
+
private readonly ensureAtlas;
|
|
69
|
+
/** Best-known covered atlas layer count. `Infinity` disables the gate — a
|
|
70
|
+
* static render never grows its atlas. */
|
|
71
|
+
private atlasLayers;
|
|
53
72
|
private readonly index;
|
|
54
73
|
private readonly records;
|
|
55
74
|
private readonly emitter;
|
|
@@ -66,6 +85,9 @@ declare class TileManager {
|
|
|
66
85
|
/** Built tiles awaiting scene insertion — flushed ONE per update() call so
|
|
67
86
|
* multi-MB GPU uploads never pile into a single frame. */
|
|
68
87
|
private pendingAdd;
|
|
88
|
+
/** Built records still holding upload-pending typed arrays. Pumping pauses at
|
|
89
|
+
* one concurrency-window so decode cannot outrun GPU submission. */
|
|
90
|
+
private pendingBuilt;
|
|
69
91
|
private inFlight;
|
|
70
92
|
private lastFocusX;
|
|
71
93
|
private lastFocusZ;
|
|
@@ -74,6 +96,11 @@ declare class TileManager {
|
|
|
74
96
|
* backoff escalates; cleared on success or unload (a fresh pan-in retries). */
|
|
75
97
|
private failCounts;
|
|
76
98
|
private nextRetrySweep;
|
|
99
|
+
/** Learned tile weights survive eviction and make future admission byte-aware. */
|
|
100
|
+
private readonly sizeHints;
|
|
101
|
+
private averageHiresBytes;
|
|
102
|
+
private focusX;
|
|
103
|
+
private focusZ;
|
|
77
104
|
private biomesCache;
|
|
78
105
|
private statsCache;
|
|
79
106
|
/** Y range of everything loaded so far, for ray-march bounds. */
|
|
@@ -125,17 +152,32 @@ declare class TileManager {
|
|
|
125
152
|
* ring edge, loading).
|
|
126
153
|
*/
|
|
127
154
|
private applyCoverage;
|
|
155
|
+
/** Ingest tiles a progressive render has newly published. Unknown tiles join
|
|
156
|
+
* the streaming index and force a re-plan so they stream in on the next
|
|
157
|
+
* update(); already-known tiles are ignored. Returns whether anything was
|
|
158
|
+
* added. */
|
|
159
|
+
addTiles(tiles: ManifestTile[]): boolean;
|
|
160
|
+
/** Install the lowres pyramid once a progressive render finishes (its earlier
|
|
161
|
+
* manifests carried no lowres). No-op without a lowres material, or if a
|
|
162
|
+
* pyramid is already present. Forces a re-plan so the coarse rings stream in. */
|
|
163
|
+
ingestLowres(lowres: {
|
|
164
|
+
grid: number;
|
|
165
|
+
levels: LowresLevel[];
|
|
166
|
+
}): void;
|
|
128
167
|
/** Live-tune streaming (view distance, tile budget, fetch concurrency).
|
|
129
168
|
* Takes effect on the next update(): the plan is recomputed from scratch. */
|
|
130
169
|
configure(settings: {
|
|
131
170
|
viewDistance?: number;
|
|
132
171
|
maxTiles?: number;
|
|
133
172
|
concurrency?: number;
|
|
173
|
+
maxBytes?: number;
|
|
134
174
|
}): void;
|
|
135
175
|
/** The current stream-in radius, in blocks. */
|
|
136
176
|
get viewDistance(): number;
|
|
137
177
|
/** The current resident-tile budget. */
|
|
138
178
|
get maxTiles(): number;
|
|
179
|
+
/** The current estimated CPU+GPU residency budget. */
|
|
180
|
+
get maxBytes(): number;
|
|
139
181
|
/** Fetch + decode one lowres LOD tile into a heightfield mesh. */
|
|
140
182
|
private loadLowres;
|
|
141
183
|
/** A transient failure (network blip, 5xx) retries with exponential backoff
|
|
@@ -148,6 +190,10 @@ declare class TileManager {
|
|
|
148
190
|
private retrySweep;
|
|
149
191
|
private loadTile;
|
|
150
192
|
private unload;
|
|
193
|
+
/** Correct estimation misses after a tile is decoded. Farthest hires records
|
|
194
|
+
* leave first; one nearest tile is always kept so an oversized outlier does
|
|
195
|
+
* not create an unload/refetch loop. Learned weights make the next plan fit. */
|
|
196
|
+
private trimToMemoryBudget;
|
|
151
197
|
private invalidate;
|
|
152
198
|
/** Live totals across resident tiles. */
|
|
153
199
|
get stats(): TileStats;
|
|
@@ -415,6 +461,8 @@ interface StreamingSettings {
|
|
|
415
461
|
maxTiles?: number;
|
|
416
462
|
/** Concurrent tile fetches. Default `4`. */
|
|
417
463
|
concurrency?: number;
|
|
464
|
+
/** Estimated CPU/GPU tile residency budget, in bytes. Default `512 MiB`. */
|
|
465
|
+
maxBytes?: number;
|
|
418
466
|
}
|
|
419
467
|
interface VantageViewerOptions {
|
|
420
468
|
/** Initial camera framing. Default `'orbit'`. */
|
|
@@ -488,6 +536,13 @@ interface ViewerEvents extends Record<string, unknown> {
|
|
|
488
536
|
slice: {
|
|
489
537
|
y: number | null;
|
|
490
538
|
};
|
|
539
|
+
/** Progressive render progress, while a live bake streams in. `done` reaches
|
|
540
|
+
* `total` and `rendering` flips false on the final manifest. */
|
|
541
|
+
progress: {
|
|
542
|
+
done: number;
|
|
543
|
+
total: number;
|
|
544
|
+
rendering: boolean;
|
|
545
|
+
};
|
|
491
546
|
}
|
|
492
547
|
declare class VantageViewer {
|
|
493
548
|
readonly renderer: THREE.WebGLRenderer;
|
|
@@ -516,6 +571,11 @@ declare class VantageViewer {
|
|
|
516
571
|
private worldSpan;
|
|
517
572
|
private tilesUnsub;
|
|
518
573
|
private lastBiomesEmit;
|
|
574
|
+
private progressiveManager;
|
|
575
|
+
private lastTextureLayers;
|
|
576
|
+
/** An in-flight atlas re-fetch, so the tile-insert gate and the progressive
|
|
577
|
+
* poll coalesce onto one request instead of racing separate fetches. */
|
|
578
|
+
private atlasRefresh;
|
|
519
579
|
private biomeEnabled;
|
|
520
580
|
private highlight;
|
|
521
581
|
private mixTarget;
|
|
@@ -556,6 +616,27 @@ declare class VantageViewer {
|
|
|
556
616
|
* the camera as it moves and unload behind it; the whole world is reachable
|
|
557
617
|
* without ever holding more than the streaming budget in memory. */
|
|
558
618
|
private loadWorld;
|
|
619
|
+
/** Emit a `progress` event from a manifest (falling back to the tile count
|
|
620
|
+
* when the generator didn't include a `progress` block). */
|
|
621
|
+
private emitProgress;
|
|
622
|
+
/** Follow a live (`rendering: true`) render: re-fetch the manifest on an
|
|
623
|
+
* interval, stream newly-baked tiles in, widen the texture array when the
|
|
624
|
+
* atlas grows, and install the lowres pyramid once the bake completes. Runs
|
|
625
|
+
* until the render finishes or the world is replaced. */
|
|
626
|
+
private pollProgressive;
|
|
627
|
+
/** Ensure the terrain atlas covers at least `layers` texture-array layers,
|
|
628
|
+
* re-fetching `terrain.vtexarr` if it's behind. Coalesces concurrent callers
|
|
629
|
+
* — the on-demand tile-insert gate and the progressive poll — onto one
|
|
630
|
+
* request. Resolves once the atlas is current (or the fetch failed and the
|
|
631
|
+
* old atlas stands, to be retried by a later gate/poll). */
|
|
632
|
+
private ensureAtlasLayers;
|
|
633
|
+
/** Re-fetch `terrain.vtexarr` and widen every shared material's atlas (they
|
|
634
|
+
* share the sampler uniform objects, so one update reaches all). */
|
|
635
|
+
private refetchAtlas;
|
|
636
|
+
/** Set the world bounds + span from a manifest's tile extents, without moving
|
|
637
|
+
* the camera. Used to frame a world on load and to widen the extent when a
|
|
638
|
+
* progressive render finishes and the full size is finally known. */
|
|
639
|
+
private updateWorldBounds;
|
|
559
640
|
/** Frame a streamed world: pivot on the spawn point when the manifest has
|
|
560
641
|
* one (that's where the builds are), else the centre of the tile extents.
|
|
561
642
|
* Distances are tied to the streaming view distance, not the world size —
|
|
@@ -650,12 +731,12 @@ declare class VantageViewer {
|
|
|
650
731
|
* visible frame. */
|
|
651
732
|
private targetPixelRatio;
|
|
652
733
|
private applyDisplay;
|
|
653
|
-
/** The current streaming settings (view distance, tile
|
|
734
|
+
/** The current streaming settings (view distance, tile/byte budgets, concurrency). */
|
|
654
735
|
get streamingSettings(): Required<StreamingSettings>;
|
|
655
|
-
/** Live-tune streaming: view distance, resident
|
|
736
|
+
/** Live-tune streaming: view distance, resident tile/byte budgets, concurrency.
|
|
656
737
|
* Applies immediately to a streamed world (tiles re-plan, fog and camera
|
|
657
738
|
* range follow) and persists for future loads. The fidelity dial: raise
|
|
658
|
-
* viewDistance/maxTiles to see farther, lower them on weak hardware. */
|
|
739
|
+
* viewDistance/maxTiles/maxBytes to see farther, lower them on weak hardware. */
|
|
659
740
|
setStreaming(settings: StreamingSettings): void;
|
|
660
741
|
/** The current view serialized as a `#@x,y,z,dist,rot,tilt[,sliceY]` hash
|
|
661
742
|
* fragment — paste-able into any URL serving the same world. The trailing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughts-on-things/vantage-mc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -62,6 +62,9 @@
|
|
|
62
62
|
"esbuild": "^0.28.1"
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
+
"allowScripts": {
|
|
66
|
+
"esbuild": true
|
|
67
|
+
},
|
|
65
68
|
"peerDependencies": {
|
|
66
69
|
"react": ">=18",
|
|
67
70
|
"react-dom": ">=18",
|
|
@@ -80,13 +83,13 @@
|
|
|
80
83
|
"@types/react": "^19.0.0",
|
|
81
84
|
"@types/react-dom": "^19.0.0",
|
|
82
85
|
"@types/three": "^0.160.0",
|
|
83
|
-
"@vitejs/plugin-react": "^
|
|
86
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
84
87
|
"react": "^19.0.0",
|
|
85
88
|
"react-dom": "^19.0.0",
|
|
86
|
-
"three": "^0.
|
|
89
|
+
"three": "^0.185.1",
|
|
87
90
|
"tsup": "^8.3.5",
|
|
88
|
-
"typescript": "^
|
|
89
|
-
"vite": "^
|
|
90
|
-
"vitest": "^
|
|
91
|
+
"typescript": "^6.0.3",
|
|
92
|
+
"vite": "^8.0.16",
|
|
93
|
+
"vitest": "^4.1.8"
|
|
91
94
|
}
|
|
92
95
|
}
|