@thoughts-on-things/vantage-mc 0.1.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.
@@ -0,0 +1,157 @@
1
+ import * as react from 'react';
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';
7
+ import 'three';
8
+
9
+ interface VantageViewerProps {
10
+ /** A tiled world to stream: the `manifest.json` URL (from `vantage render`).
11
+ * Takes precedence over `tile`. */
12
+ world?: string;
13
+ /** A single `.vtile` to render: a URL, a raw buffer, or already-decoded data. */
14
+ tile?: TileSource;
15
+ /** The `.vtexarr` texture array (required for textured tiles). */
16
+ textures?: TextureSource;
17
+ /** Streaming behaviour for `world` sources (view distance, tile budget).
18
+ * Live: changes re-plan in place, like the other setting props. */
19
+ streaming?: StreamingSettings;
20
+ /** Initial camera framing. Default `'orbit'`. */
21
+ view?: ViewMode;
22
+ /** Antialias the WebGL context. Default `true`. Changing this remounts the canvas. */
23
+ antialias?: boolean;
24
+ /** Device pixel-ratio cap. Default `2`. Changing this remounts the canvas. */
25
+ maxPixelRatio?: number;
26
+ /** Live lighting appearance (ambient floor, daylight, exposure). Applied on
27
+ * change without re-baking — drive it from a slider for a day/night control. */
28
+ light?: LightSettings;
29
+ /** Live display fidelity (sharpness, AO, saturation, contrast, fog, render
30
+ * scale). Applied on change without re-baking — drive it from sliders. */
31
+ display?: DisplaySettings;
32
+ /** Keep the camera in the URL hash so any view is a shareable deep link.
33
+ * Default `true` — pass `false` if the page owns its hash (e.g. a router). */
34
+ urlState?: boolean;
35
+ className?: string;
36
+ style?: CSSProperties;
37
+ /** Called once a tile has loaded and been framed. */
38
+ onLoad?: (info: TileInfo) => void;
39
+ /** Called if loading or decoding fails. */
40
+ onError?: (error: Error) => void;
41
+ /** Custom node shown while loading. */
42
+ loading?: ReactNode;
43
+ /** Render prop / node shown on error. Receives the error. */
44
+ errorFallback?: (error: Error) => ReactNode;
45
+ /** Overlay components (panels, layers) and any custom UI. */
46
+ children?: ReactNode;
47
+ }
48
+ declare const VantageViewer: react.ForwardRefExoticComponent<VantageViewerProps & react.RefAttributes<VantageViewer$1 | null>>;
49
+
50
+ interface PanelProps {
51
+ /** Leading glyph (kept small + accent-coloured). */
52
+ icon?: ReactNode;
53
+ /** Uppercase title text. */
54
+ title: string;
55
+ /** Right-aligned header content (a toggle, a segmented control). Clicks here
56
+ * don't collapse the panel. */
57
+ headerExtra?: ReactNode;
58
+ /** Start collapsed (header only). Default `false`. */
59
+ defaultCollapsed?: boolean;
60
+ /** Allow collapsing via the header. Default `true`. */
61
+ collapsible?: boolean;
62
+ style?: CSSProperties;
63
+ className?: string;
64
+ children?: ReactNode;
65
+ }
66
+ declare function Panel({ icon, title, headerExtra, defaultCollapsed, collapsible, style, className, children }: PanelProps): react.JSX.Element;
67
+
68
+ interface BiomeLayerProps {
69
+ /** Show the legend panel. Default `true`. */
70
+ legend?: boolean;
71
+ /** Show the hover-to-identify tooltip. Default `true`. */
72
+ hover?: boolean;
73
+ /** Open into the biome layer as soon as a tile loads. Default `false`. */
74
+ defaultEnabled?: boolean;
75
+ /** Start the legend panel collapsed to its header. Default `false`. */
76
+ defaultCollapsed?: boolean;
77
+ /** Key that toggles the layer. Default `'b'`; pass `null` to disable. */
78
+ toggleKey?: string | null;
79
+ /** Panel heading. Default `'biomes'`. */
80
+ title?: string;
81
+ className?: string;
82
+ }
83
+ declare function BiomeLayer({ legend, hover, defaultEnabled, defaultCollapsed, toggleKey, title, className, }: BiomeLayerProps): react.JSX.Element | null;
84
+
85
+ interface LightPanelProps {
86
+ /** Panel heading. Default `'lighting'`. */
87
+ title?: string;
88
+ /** Start collapsed to the header. Default `true`. */
89
+ defaultCollapsed?: boolean;
90
+ className?: string;
91
+ }
92
+ declare function LightPanel({ title, defaultCollapsed, className }: LightPanelProps): react.JSX.Element | null;
93
+
94
+ interface SettingsPanelProps {
95
+ /** Panel heading. Default `'quality'`. */
96
+ title?: string;
97
+ /** Start collapsed to the header. Default `true`. */
98
+ defaultCollapsed?: boolean;
99
+ className?: string;
100
+ }
101
+ /** A quality preset: streamed range, resident-tile budget, and render scale.
102
+ * Tile budgets are sized to fill the view-distance disc (π·(vd/tileBlocks)²
103
+ * for 128-block tiles) so the range is actually reachable. */
104
+ interface QualityPreset {
105
+ name: string;
106
+ viewDistance: number;
107
+ maxTiles: number;
108
+ renderScale: number;
109
+ }
110
+ declare const QUALITY_PRESETS: QualityPreset[];
111
+ declare function SettingsPanel({ title, defaultCollapsed, className }: SettingsPanelProps): react.JSX.Element | null;
112
+
113
+ interface MapNavProps {
114
+ /** Show the compass. Default `true`. */
115
+ compass?: boolean;
116
+ /** Show the 2D/3D tilt toggle. Default `true`. */
117
+ tilt?: boolean;
118
+ /** Show the free-flight toggle. Default `true`. */
119
+ fly?: boolean;
120
+ /** Show the zoom in/out buttons. Default `true`. */
121
+ zoom?: boolean;
122
+ /** Show the home (re-frame) button. Default `true`. */
123
+ home?: boolean;
124
+ /** Show the centred-coordinate readout. Default `true`. */
125
+ coords?: boolean;
126
+ className?: string;
127
+ }
128
+ declare function MapNav({ compass, tilt, fly, zoom, home, coords, className }: MapNavProps): react.JSX.Element | null;
129
+
130
+ interface ReticleProps {
131
+ className?: string;
132
+ }
133
+ declare function Reticle({ className }: ReticleProps): react.JSX.Element | null;
134
+
135
+ type VantageStatus = 'idle' | 'loading' | 'ready' | 'error';
136
+ interface VantageContextValue {
137
+ /** The underlying engine, or `null` until mounted. Escape hatch for custom work. */
138
+ viewer: VantageViewer$1 | null;
139
+ status: VantageStatus;
140
+ error: Error | null;
141
+ /** Metadata for the loaded tile. */
142
+ info: TileInfo | null;
143
+ /** Biomes present in the current tile, most common first. */
144
+ biomes: BiomeEntry[];
145
+ biomeLayerEnabled: boolean;
146
+ highlightedBiome: number | null;
147
+ /** Biome id under the cursor, or `null`. */
148
+ hoveredBiome: number | null;
149
+ }
150
+ /** Access the viewer engine and live state. Must be used under `<VantageViewer>`. */
151
+ declare function useVantage(): VantageContextValue;
152
+
153
+ declare const CSS = "\n.vtg-root {\n position: relative; width: 100%; height: 100%; overflow: hidden;\n background: #0d1015; color-scheme: dark;\n --vtg-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n --vtg-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;\n --vtg-accent: #5b9bff;\n --vtg-text: #e6eefb;\n --vtg-muted: #93a9cc;\n --vtg-dim: #6f86ab;\n --vtg-line: rgba(132, 170, 230, 0.16);\n}\n.vtg-canvas { position: absolute; inset: 0; }\n/* Constrain the GL canvas to its container. The renderer keeps a high-res\n drawing buffer (devicePixelRatio \u00D7 renderScale) via setSize(\u2026, false), which\n leaves the canvas's intrinsic attribute size large; without an explicit\n display size that size leaks into layout and overflows. width/height:100%\n pins the *displayed* size to the container while the buffer stays crisp. */\n.vtg-canvas > canvas { display: block; width: 100%; height: 100%; }\n\n.vtg-glass {\n background: linear-gradient(180deg, rgba(18, 24, 35, 0.72), rgba(11, 15, 22, 0.7));\n border: 1px solid rgba(140, 178, 238, 0.18);\n border-radius: 13px;\n backdrop-filter: blur(16px) saturate(1.3);\n -webkit-backdrop-filter: blur(16px) saturate(1.3);\n box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.05);\n}\n\n.vtg-status {\n position: absolute; inset: 0; display: grid; place-content: center; text-align: center;\n font: 13px var(--vtg-sans); color: var(--vtg-muted); padding: 2rem;\n}\n.vtg-status.vtg-error { color: #ffb4b4; }\n\n/* --- panels --------------------------------------------------------------- */\n.vtg-panel {\n position: absolute; top: 16px; right: 16px; width: 240px; max-height: calc(100% - 32px);\n display: flex; flex-direction: column; overflow: hidden;\n font: 13px/1.45 var(--vtg-sans); color: var(--vtg-text);\n animation: vtg-rise 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;\n}\n.vtg-panel header {\n padding: 11px 13px; display: flex; align-items: center; gap: 9px;\n user-select: none; flex: none;\n}\n.vtg-panel:not(.vtg-collapsed) header { border-bottom: 1px solid var(--vtg-line); }\n.vtg-panel header.vtg-click { cursor: pointer; }\n.vtg-panel header.vtg-click:hover .vtg-title { color: #fff; }\n.vtg-chev {\n font-size: 9px; color: var(--vtg-dim); width: 10px; flex: none; text-align: center;\n transition: transform 0.18s ease, color 0.16s;\n}\n.vtg-panel header.vtg-click:hover .vtg-chev { color: var(--vtg-muted); }\n.vtg-title {\n display: flex; align-items: center; gap: 7px;\n font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;\n color: var(--vtg-text); transition: color 0.16s;\n}\n.vtg-title .vtg-ico { color: var(--vtg-accent); font-size: 12px; opacity: 0.9; }\n.vtg-head-extra { margin-left: auto; display: flex; align-items: center; gap: 6px; }\n.vtg-body { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }\n\n.vtg-toggle {\n font: 600 11px var(--vtg-sans); padding: 3px 12px; border-radius: 999px;\n border: 1px solid rgba(132, 170, 230, 0.38); background: rgba(40, 60, 90, 0.4);\n color: var(--vtg-muted); cursor: pointer;\n transition: background 0.16s, color 0.16s, border-color 0.16s;\n}\n.vtg-toggle:hover { border-color: rgba(132, 170, 230, 0.7); color: var(--vtg-text); }\n.vtg-toggle.vtg-on { background: var(--vtg-accent); border-color: var(--vtg-accent); color: #07101f; }\n\n/* --- biome legend --------------------------------------------------------- */\n.vtg-legend { overflow-y: auto; padding: 7px; scrollbar-width: thin; scrollbar-color: rgba(132,170,230,0.3) transparent; }\n.vtg-row {\n display: flex; align-items: center; gap: 9px; padding: 5px 8px;\n border-radius: 7px; cursor: pointer; white-space: nowrap;\n transition: background 0.16s, opacity 0.16s, box-shadow 0.16s;\n}\n.vtg-row:hover { background: rgba(132, 170, 230, 0.12); }\n.vtg-row.vtg-sel { background: rgba(91, 155, 255, 0.26); }\n.vtg-row.vtg-hover { box-shadow: inset 0 0 0 1px rgba(143, 182, 232, 0.75); }\n.vtg-row.vtg-dim { opacity: 0.34; }\n.vtg-chip { width: 13px; height: 13px; border-radius: 4px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45); }\n.vtg-name { overflow: hidden; text-overflow: ellipsis; }\n.vtg-pct { margin-left: auto; color: var(--vtg-dim); font: 11px var(--vtg-mono); font-variant-numeric: tabular-nums; }\n\n/* --- segmented toggle (render mode) --------------------------------------- */\n.vtg-seg { display: flex; gap: 2px; padding: 2px; border-radius: 999px; background: rgba(40, 60, 90, 0.4); border: 1px solid rgba(132, 170, 230, 0.28); }\n.vtg-seg button {\n font: 600 10px var(--vtg-sans); letter-spacing: 0.04em; text-transform: uppercase;\n padding: 3px 10px; border-radius: 999px; border: none; background: transparent; color: var(--vtg-muted);\n cursor: pointer; transition: background 0.16s, color 0.16s;\n}\n.vtg-seg button:hover { color: var(--vtg-text); }\n.vtg-seg button.vtg-seg-on { background: var(--vtg-accent); color: #07101f; }\n.vtg-seg-full { display: flex; }\n.vtg-seg-full button { flex: 1; text-align: center; padding: 4px 0; }\n\n/* --- sliders -------------------------------------------------------------- */\n.vtg-sliders { padding: 13px; display: flex; flex-direction: column; gap: 13px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(132,170,230,0.3) transparent; }\n.vtg-slider { display: flex; flex-direction: column; gap: 7px; cursor: pointer; }\n.vtg-slider-row { display: flex; justify-content: space-between; align-items: baseline; color: var(--vtg-muted); font-size: 12px; }\n.vtg-slider-row b { color: var(--vtg-text); font: 600 11px var(--vtg-mono); font-variant-numeric: tabular-nums; }\n.vtg-slider input[type=range] {\n -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px;\n background: rgba(132, 170, 230, 0.25); outline: none; cursor: pointer;\n}\n.vtg-slider input[type=range]::-webkit-slider-thumb {\n -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;\n background: var(--vtg-accent); cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);\n transition: transform 0.12s;\n}\n.vtg-slider input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.18); }\n.vtg-slider input[type=range]::-moz-range-thumb {\n width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--vtg-accent);\n cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);\n}\n\n/* --- hover-to-identify tooltip -------------------------------------------- */\n.vtg-tip {\n position: fixed; display: flex; align-items: center; gap: 8px;\n padding: 6px 10px; pointer-events: none; z-index: 10;\n font: 12px/1 var(--vtg-sans); color: var(--vtg-text);\n background: rgba(13, 17, 25, 0.88); border: 1px solid var(--vtg-line); border-radius: 8px;\n backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);\n}\n.vtg-tip .vtg-chip { width: 12px; height: 12px; border-radius: 3px; }\n\n/* --- navigation cluster (compass \u00B7 zoom \u00B7 home \u00B7 coords) ------------------ */\n.vtg-nav {\n position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);\n display: flex; align-items: center; gap: 6px; padding: 6px;\n animation: vtg-rise 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;\n}\n.vtg-navbtn {\n width: 30px; height: 30px; flex: none; display: grid; place-items: center;\n border-radius: 9px; border: 1px solid transparent; background: transparent;\n color: var(--vtg-muted); cursor: pointer; padding: 0;\n transition: background 0.15s, color 0.15s, border-color 0.15s;\n}\n.vtg-navbtn:hover { background: rgba(132, 170, 230, 0.14); color: var(--vtg-text); border-color: var(--vtg-line); }\n.vtg-navbtn:active { background: rgba(91, 155, 255, 0.26); }\n.vtg-navbtn svg { width: 16px; height: 16px; display: block; }\n.vtg-navbtn-text { width: auto; min-width: 30px; padding: 0 8px; font: 700 11px var(--vtg-mono); letter-spacing: 0.03em; }\n.vtg-navbtn.vtg-on { background: var(--vtg-accent); border-color: var(--vtg-accent); color: #07101f; }\n.vtg-navbtn.vtg-on:hover { background: var(--vtg-accent); color: #07101f; }\n.vtg-nav-sep { width: 1px; align-self: stretch; margin: 4px 2px; background: var(--vtg-line); }\n\n.vtg-compass {\n position: relative; width: 34px; height: 34px; flex: none; border-radius: 50%;\n border: 1px solid var(--vtg-line); background: rgba(20, 28, 40, 0.5);\n cursor: pointer; display: grid; place-items: center;\n transition: border-color 0.16s, background 0.16s;\n}\n.vtg-compass:hover { border-color: rgba(132, 170, 230, 0.5); background: rgba(30, 42, 60, 0.6); }\n.vtg-compass svg { width: 30px; height: 30px; }\n.vtg-compass .vtg-n { fill: #ff6a6a; }\n.vtg-compass .vtg-s { fill: #c2d2ee; }\n.vtg-compass .vtg-cn { fill: var(--vtg-dim); font: 700 6px var(--vtg-sans); }\n\n.vtg-coords {\n display: flex; align-items: center; gap: 8px; padding: 0 10px 0 6px;\n font: 11px var(--vtg-mono); color: var(--vtg-muted); font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.vtg-coords b { color: var(--vtg-dim); font-weight: 600; margin-right: 1px; }\n\n/* --- centre reticle (navigation reference) -------------------------------- */\n.vtg-reticle {\n position: absolute; left: 50%; top: 50%; width: 30px; height: 30px;\n transform: translate(-50%, -50%); pointer-events: none; z-index: 4;\n}\n.vtg-ret-ring {\n position: absolute; inset: 0; border-radius: 50%;\n border: 1.5px solid rgba(180, 205, 240, 0.28); transform: scale(0.62);\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);\n transition: border-color 0.2s ease, transform 0.2s ease;\n}\n.vtg-ret-dot {\n position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px;\n border-radius: 50%; background: rgba(238, 244, 255, 0.85);\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 6px rgba(0, 0, 0, 0.55);\n transition: background 0.2s ease;\n}\n.vtg-reticle-on .vtg-ret-ring { border-color: rgba(143, 182, 232, 0.85); transform: scale(1); }\n.vtg-reticle-on .vtg-ret-dot { background: #fff; }\n\n@keyframes vtg-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }\n.vtg-nav { animation-name: vtg-rise-x; }\n@keyframes vtg-rise-x { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }\n";
154
+ /** Inject the component stylesheet once. No-op on the server or after the first call. */
155
+ declare function injectStyles(): void;
156
+
157
+ export { BiomeEntry, BiomeLayer, type BiomeLayerProps, CSS, DisplaySettings, LightPanel, type LightPanelProps, LightSettings, MapNav, type MapNavProps, Panel, type PanelProps, QUALITY_PRESETS, type QualityPreset, Reticle, type ReticleProps, SettingsPanel, type SettingsPanelProps, StreamingSettings, TextureSource, TileInfo, TileSource, type VantageContextValue, VantageViewer$1 as VantageEngine, type VantageStatus, VantageViewer, type VantageViewerProps, ViewMode, injectStyles, useVantage };