@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.
- package/LICENSE +21 -0
- package/README.md +200 -0
- package/dist/biome-LCQwACRa.d.ts +275 -0
- package/dist/chunk-7V27NYZD.js +2605 -0
- package/dist/chunk-X7ZJUHP2.js +483 -0
- package/dist/core/index.d.ts +39 -0
- package/dist/core/index.js +1 -0
- package/dist/react/index.d.ts +157 -0
- package/dist/react/index.js +715 -0
- package/dist/three/index.d.ts +110 -0
- package/dist/three/index.js +2 -0
- package/dist/viewer-DkAMDMtW.d.ts +628 -0
- package/package.json +91 -0
|
@@ -0,0 +1,715 @@
|
|
|
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';
|
|
4
|
+
import { createContext, forwardRef, useRef, useState, useImperativeHandle, useEffect, useMemo, useContext } from 'react';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var VantageContext = createContext(null);
|
|
8
|
+
function useVantage() {
|
|
9
|
+
const ctx = useContext(VantageContext);
|
|
10
|
+
if (!ctx) throw new Error("vantage: useVantage() must be used inside <VantageViewer>");
|
|
11
|
+
return ctx;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// src/react/styles.ts
|
|
15
|
+
var STYLE_ID = "vantage-styles";
|
|
16
|
+
var CSS = `
|
|
17
|
+
.vtg-root {
|
|
18
|
+
position: relative; width: 100%; height: 100%; overflow: hidden;
|
|
19
|
+
background: #0d1015; color-scheme: dark;
|
|
20
|
+
--vtg-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
21
|
+
--vtg-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
|
|
22
|
+
--vtg-accent: #5b9bff;
|
|
23
|
+
--vtg-text: #e6eefb;
|
|
24
|
+
--vtg-muted: #93a9cc;
|
|
25
|
+
--vtg-dim: #6f86ab;
|
|
26
|
+
--vtg-line: rgba(132, 170, 230, 0.16);
|
|
27
|
+
}
|
|
28
|
+
.vtg-canvas { position: absolute; inset: 0; }
|
|
29
|
+
/* Constrain the GL canvas to its container. The renderer keeps a high-res
|
|
30
|
+
drawing buffer (devicePixelRatio \xD7 renderScale) via setSize(\u2026, false), which
|
|
31
|
+
leaves the canvas's intrinsic attribute size large; without an explicit
|
|
32
|
+
display size that size leaks into layout and overflows. width/height:100%
|
|
33
|
+
pins the *displayed* size to the container while the buffer stays crisp. */
|
|
34
|
+
.vtg-canvas > canvas { display: block; width: 100%; height: 100%; }
|
|
35
|
+
|
|
36
|
+
.vtg-glass {
|
|
37
|
+
background: linear-gradient(180deg, rgba(18, 24, 35, 0.72), rgba(11, 15, 22, 0.7));
|
|
38
|
+
border: 1px solid rgba(140, 178, 238, 0.18);
|
|
39
|
+
border-radius: 13px;
|
|
40
|
+
backdrop-filter: blur(16px) saturate(1.3);
|
|
41
|
+
-webkit-backdrop-filter: blur(16px) saturate(1.3);
|
|
42
|
+
box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.vtg-status {
|
|
46
|
+
position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
|
|
47
|
+
font: 13px var(--vtg-sans); color: var(--vtg-muted); padding: 2rem;
|
|
48
|
+
}
|
|
49
|
+
.vtg-status.vtg-error { color: #ffb4b4; }
|
|
50
|
+
|
|
51
|
+
/* --- panels --------------------------------------------------------------- */
|
|
52
|
+
.vtg-panel {
|
|
53
|
+
position: absolute; top: 16px; right: 16px; width: 240px; max-height: calc(100% - 32px);
|
|
54
|
+
display: flex; flex-direction: column; overflow: hidden;
|
|
55
|
+
font: 13px/1.45 var(--vtg-sans); color: var(--vtg-text);
|
|
56
|
+
animation: vtg-rise 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
57
|
+
}
|
|
58
|
+
.vtg-panel header {
|
|
59
|
+
padding: 11px 13px; display: flex; align-items: center; gap: 9px;
|
|
60
|
+
user-select: none; flex: none;
|
|
61
|
+
}
|
|
62
|
+
.vtg-panel:not(.vtg-collapsed) header { border-bottom: 1px solid var(--vtg-line); }
|
|
63
|
+
.vtg-panel header.vtg-click { cursor: pointer; }
|
|
64
|
+
.vtg-panel header.vtg-click:hover .vtg-title { color: #fff; }
|
|
65
|
+
.vtg-chev {
|
|
66
|
+
font-size: 9px; color: var(--vtg-dim); width: 10px; flex: none; text-align: center;
|
|
67
|
+
transition: transform 0.18s ease, color 0.16s;
|
|
68
|
+
}
|
|
69
|
+
.vtg-panel header.vtg-click:hover .vtg-chev { color: var(--vtg-muted); }
|
|
70
|
+
.vtg-title {
|
|
71
|
+
display: flex; align-items: center; gap: 7px;
|
|
72
|
+
font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
|
|
73
|
+
color: var(--vtg-text); transition: color 0.16s;
|
|
74
|
+
}
|
|
75
|
+
.vtg-title .vtg-ico { color: var(--vtg-accent); font-size: 12px; opacity: 0.9; }
|
|
76
|
+
.vtg-head-extra { margin-left: auto; display: flex; align-items: center; gap: 6px; }
|
|
77
|
+
.vtg-body { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
|
|
78
|
+
|
|
79
|
+
.vtg-toggle {
|
|
80
|
+
font: 600 11px var(--vtg-sans); padding: 3px 12px; border-radius: 999px;
|
|
81
|
+
border: 1px solid rgba(132, 170, 230, 0.38); background: rgba(40, 60, 90, 0.4);
|
|
82
|
+
color: var(--vtg-muted); cursor: pointer;
|
|
83
|
+
transition: background 0.16s, color 0.16s, border-color 0.16s;
|
|
84
|
+
}
|
|
85
|
+
.vtg-toggle:hover { border-color: rgba(132, 170, 230, 0.7); color: var(--vtg-text); }
|
|
86
|
+
.vtg-toggle.vtg-on { background: var(--vtg-accent); border-color: var(--vtg-accent); color: #07101f; }
|
|
87
|
+
|
|
88
|
+
/* --- biome legend --------------------------------------------------------- */
|
|
89
|
+
.vtg-legend { overflow-y: auto; padding: 7px; scrollbar-width: thin; scrollbar-color: rgba(132,170,230,0.3) transparent; }
|
|
90
|
+
.vtg-row {
|
|
91
|
+
display: flex; align-items: center; gap: 9px; padding: 5px 8px;
|
|
92
|
+
border-radius: 7px; cursor: pointer; white-space: nowrap;
|
|
93
|
+
transition: background 0.16s, opacity 0.16s, box-shadow 0.16s;
|
|
94
|
+
}
|
|
95
|
+
.vtg-row:hover { background: rgba(132, 170, 230, 0.12); }
|
|
96
|
+
.vtg-row.vtg-sel { background: rgba(91, 155, 255, 0.26); }
|
|
97
|
+
.vtg-row.vtg-hover { box-shadow: inset 0 0 0 1px rgba(143, 182, 232, 0.75); }
|
|
98
|
+
.vtg-row.vtg-dim { opacity: 0.34; }
|
|
99
|
+
.vtg-chip { width: 13px; height: 13px; border-radius: 4px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45); }
|
|
100
|
+
.vtg-name { overflow: hidden; text-overflow: ellipsis; }
|
|
101
|
+
.vtg-pct { margin-left: auto; color: var(--vtg-dim); font: 11px var(--vtg-mono); font-variant-numeric: tabular-nums; }
|
|
102
|
+
|
|
103
|
+
/* --- segmented toggle (render mode) --------------------------------------- */
|
|
104
|
+
.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); }
|
|
105
|
+
.vtg-seg button {
|
|
106
|
+
font: 600 10px var(--vtg-sans); letter-spacing: 0.04em; text-transform: uppercase;
|
|
107
|
+
padding: 3px 10px; border-radius: 999px; border: none; background: transparent; color: var(--vtg-muted);
|
|
108
|
+
cursor: pointer; transition: background 0.16s, color 0.16s;
|
|
109
|
+
}
|
|
110
|
+
.vtg-seg button:hover { color: var(--vtg-text); }
|
|
111
|
+
.vtg-seg button.vtg-seg-on { background: var(--vtg-accent); color: #07101f; }
|
|
112
|
+
.vtg-seg-full { display: flex; }
|
|
113
|
+
.vtg-seg-full button { flex: 1; text-align: center; padding: 4px 0; }
|
|
114
|
+
|
|
115
|
+
/* --- sliders -------------------------------------------------------------- */
|
|
116
|
+
.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; }
|
|
117
|
+
.vtg-slider { display: flex; flex-direction: column; gap: 7px; cursor: pointer; }
|
|
118
|
+
.vtg-slider-row { display: flex; justify-content: space-between; align-items: baseline; color: var(--vtg-muted); font-size: 12px; }
|
|
119
|
+
.vtg-slider-row b { color: var(--vtg-text); font: 600 11px var(--vtg-mono); font-variant-numeric: tabular-nums; }
|
|
120
|
+
.vtg-slider input[type=range] {
|
|
121
|
+
-webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px;
|
|
122
|
+
background: rgba(132, 170, 230, 0.25); outline: none; cursor: pointer;
|
|
123
|
+
}
|
|
124
|
+
.vtg-slider input[type=range]::-webkit-slider-thumb {
|
|
125
|
+
-webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;
|
|
126
|
+
background: var(--vtg-accent); cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
|
|
127
|
+
transition: transform 0.12s;
|
|
128
|
+
}
|
|
129
|
+
.vtg-slider input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.18); }
|
|
130
|
+
.vtg-slider input[type=range]::-moz-range-thumb {
|
|
131
|
+
width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--vtg-accent);
|
|
132
|
+
cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* --- hover-to-identify tooltip -------------------------------------------- */
|
|
136
|
+
.vtg-tip {
|
|
137
|
+
position: fixed; display: flex; align-items: center; gap: 8px;
|
|
138
|
+
padding: 6px 10px; pointer-events: none; z-index: 10;
|
|
139
|
+
font: 12px/1 var(--vtg-sans); color: var(--vtg-text);
|
|
140
|
+
background: rgba(13, 17, 25, 0.88); border: 1px solid var(--vtg-line); border-radius: 8px;
|
|
141
|
+
backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
|
|
142
|
+
}
|
|
143
|
+
.vtg-tip .vtg-chip { width: 12px; height: 12px; border-radius: 3px; }
|
|
144
|
+
|
|
145
|
+
/* --- navigation cluster (compass \xB7 zoom \xB7 home \xB7 coords) ------------------ */
|
|
146
|
+
.vtg-nav {
|
|
147
|
+
position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
|
|
148
|
+
display: flex; align-items: center; gap: 6px; padding: 6px;
|
|
149
|
+
animation: vtg-rise 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
150
|
+
}
|
|
151
|
+
.vtg-navbtn {
|
|
152
|
+
width: 30px; height: 30px; flex: none; display: grid; place-items: center;
|
|
153
|
+
border-radius: 9px; border: 1px solid transparent; background: transparent;
|
|
154
|
+
color: var(--vtg-muted); cursor: pointer; padding: 0;
|
|
155
|
+
transition: background 0.15s, color 0.15s, border-color 0.15s;
|
|
156
|
+
}
|
|
157
|
+
.vtg-navbtn:hover { background: rgba(132, 170, 230, 0.14); color: var(--vtg-text); border-color: var(--vtg-line); }
|
|
158
|
+
.vtg-navbtn:active { background: rgba(91, 155, 255, 0.26); }
|
|
159
|
+
.vtg-navbtn svg { width: 16px; height: 16px; display: block; }
|
|
160
|
+
.vtg-navbtn-text { width: auto; min-width: 30px; padding: 0 8px; font: 700 11px var(--vtg-mono); letter-spacing: 0.03em; }
|
|
161
|
+
.vtg-navbtn.vtg-on { background: var(--vtg-accent); border-color: var(--vtg-accent); color: #07101f; }
|
|
162
|
+
.vtg-navbtn.vtg-on:hover { background: var(--vtg-accent); color: #07101f; }
|
|
163
|
+
.vtg-nav-sep { width: 1px; align-self: stretch; margin: 4px 2px; background: var(--vtg-line); }
|
|
164
|
+
|
|
165
|
+
.vtg-compass {
|
|
166
|
+
position: relative; width: 34px; height: 34px; flex: none; border-radius: 50%;
|
|
167
|
+
border: 1px solid var(--vtg-line); background: rgba(20, 28, 40, 0.5);
|
|
168
|
+
cursor: pointer; display: grid; place-items: center;
|
|
169
|
+
transition: border-color 0.16s, background 0.16s;
|
|
170
|
+
}
|
|
171
|
+
.vtg-compass:hover { border-color: rgba(132, 170, 230, 0.5); background: rgba(30, 42, 60, 0.6); }
|
|
172
|
+
.vtg-compass svg { width: 30px; height: 30px; }
|
|
173
|
+
.vtg-compass .vtg-n { fill: #ff6a6a; }
|
|
174
|
+
.vtg-compass .vtg-s { fill: #c2d2ee; }
|
|
175
|
+
.vtg-compass .vtg-cn { fill: var(--vtg-dim); font: 700 6px var(--vtg-sans); }
|
|
176
|
+
|
|
177
|
+
.vtg-coords {
|
|
178
|
+
display: flex; align-items: center; gap: 8px; padding: 0 10px 0 6px;
|
|
179
|
+
font: 11px var(--vtg-mono); color: var(--vtg-muted); font-variant-numeric: tabular-nums;
|
|
180
|
+
white-space: nowrap;
|
|
181
|
+
}
|
|
182
|
+
.vtg-coords b { color: var(--vtg-dim); font-weight: 600; margin-right: 1px; }
|
|
183
|
+
|
|
184
|
+
/* --- centre reticle (navigation reference) -------------------------------- */
|
|
185
|
+
.vtg-reticle {
|
|
186
|
+
position: absolute; left: 50%; top: 50%; width: 30px; height: 30px;
|
|
187
|
+
transform: translate(-50%, -50%); pointer-events: none; z-index: 4;
|
|
188
|
+
}
|
|
189
|
+
.vtg-ret-ring {
|
|
190
|
+
position: absolute; inset: 0; border-radius: 50%;
|
|
191
|
+
border: 1.5px solid rgba(180, 205, 240, 0.28); transform: scale(0.62);
|
|
192
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
|
|
193
|
+
transition: border-color 0.2s ease, transform 0.2s ease;
|
|
194
|
+
}
|
|
195
|
+
.vtg-ret-dot {
|
|
196
|
+
position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px;
|
|
197
|
+
border-radius: 50%; background: rgba(238, 244, 255, 0.85);
|
|
198
|
+
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 6px rgba(0, 0, 0, 0.55);
|
|
199
|
+
transition: background 0.2s ease;
|
|
200
|
+
}
|
|
201
|
+
.vtg-reticle-on .vtg-ret-ring { border-color: rgba(143, 182, 232, 0.85); transform: scale(1); }
|
|
202
|
+
.vtg-reticle-on .vtg-ret-dot { background: #fff; }
|
|
203
|
+
|
|
204
|
+
@keyframes vtg-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
|
205
|
+
.vtg-nav { animation-name: vtg-rise-x; }
|
|
206
|
+
@keyframes vtg-rise-x { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
|
|
207
|
+
`;
|
|
208
|
+
function injectStyles() {
|
|
209
|
+
if (typeof document === "undefined") return;
|
|
210
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
211
|
+
const style = document.createElement("style");
|
|
212
|
+
style.id = STYLE_ID;
|
|
213
|
+
style.textContent = CSS;
|
|
214
|
+
document.head.appendChild(style);
|
|
215
|
+
}
|
|
216
|
+
function cssRgb(c) {
|
|
217
|
+
return `rgb(${c[0] * 255 | 0},${c[1] * 255 | 0},${c[2] * 255 | 0})`;
|
|
218
|
+
}
|
|
219
|
+
var INITIAL = {
|
|
220
|
+
status: "idle",
|
|
221
|
+
error: null,
|
|
222
|
+
info: null,
|
|
223
|
+
biomes: [],
|
|
224
|
+
biomeLayerEnabled: false,
|
|
225
|
+
highlightedBiome: null,
|
|
226
|
+
hoveredBiome: null
|
|
227
|
+
};
|
|
228
|
+
var VantageViewer2 = forwardRef(function VantageViewer3(props, ref) {
|
|
229
|
+
const {
|
|
230
|
+
world,
|
|
231
|
+
tile,
|
|
232
|
+
textures,
|
|
233
|
+
streaming,
|
|
234
|
+
view = "orbit",
|
|
235
|
+
antialias = true,
|
|
236
|
+
maxPixelRatio = 2,
|
|
237
|
+
light,
|
|
238
|
+
display,
|
|
239
|
+
urlState = true,
|
|
240
|
+
className,
|
|
241
|
+
style,
|
|
242
|
+
onLoad,
|
|
243
|
+
onError,
|
|
244
|
+
loading,
|
|
245
|
+
errorFallback,
|
|
246
|
+
children
|
|
247
|
+
} = props;
|
|
248
|
+
const canvasRef = useRef(null);
|
|
249
|
+
const engineRef = useRef(null);
|
|
250
|
+
const [engine, setEngine] = useState(null);
|
|
251
|
+
const [s, setS] = useState(INITIAL);
|
|
252
|
+
const onLoadRef = useRef(onLoad);
|
|
253
|
+
const onErrorRef = useRef(onError);
|
|
254
|
+
onLoadRef.current = onLoad;
|
|
255
|
+
onErrorRef.current = onError;
|
|
256
|
+
useImperativeHandle(ref, () => engine, [engine]);
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
injectStyles();
|
|
259
|
+
const el = canvasRef.current;
|
|
260
|
+
if (!el) return;
|
|
261
|
+
const v = new VantageViewer(el, { antialias, maxPixelRatio, view, light, display, streaming, urlState });
|
|
262
|
+
engineRef.current = v;
|
|
263
|
+
setEngine(v);
|
|
264
|
+
let pendingStats = null;
|
|
265
|
+
let statsRaf = null;
|
|
266
|
+
const offs = [
|
|
267
|
+
v.on("load", (info) => {
|
|
268
|
+
setS((p) => ({ ...p, status: "ready", info, biomes: info.biomes, error: null }));
|
|
269
|
+
onLoadRef.current?.(info);
|
|
270
|
+
}),
|
|
271
|
+
// Streamed worlds: keep the HUD's totals and the biome legend live as
|
|
272
|
+
// tiles come and go. Stats can fire several times per frame during a big
|
|
273
|
+
// load and every setS re-renders all context consumers, so coalesce
|
|
274
|
+
// bursts into one commit per animation frame.
|
|
275
|
+
v.on("stats", (stats) => {
|
|
276
|
+
pendingStats = stats;
|
|
277
|
+
statsRaf ??= requestAnimationFrame(() => {
|
|
278
|
+
statsRaf = null;
|
|
279
|
+
const latest = pendingStats;
|
|
280
|
+
setS(
|
|
281
|
+
(p) => p.info ? { ...p, info: { ...p.info, vertexCount: latest.vertexCount, triangleCount: latest.triangleCount } } : p
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
}),
|
|
285
|
+
v.on("biomes", (biomes) => setS((p) => ({ ...p, biomes }))),
|
|
286
|
+
v.on("hover", (id) => setS((p) => p.hoveredBiome === id ? p : { ...p, hoveredBiome: id })),
|
|
287
|
+
v.on(
|
|
288
|
+
"biomelayer",
|
|
289
|
+
({ enabled, highlight }) => setS((p) => ({ ...p, biomeLayerEnabled: enabled, highlightedBiome: highlight }))
|
|
290
|
+
)
|
|
291
|
+
];
|
|
292
|
+
return () => {
|
|
293
|
+
offs.forEach((off) => off());
|
|
294
|
+
if (statsRaf !== null) cancelAnimationFrame(statsRaf);
|
|
295
|
+
v.dispose();
|
|
296
|
+
engineRef.current = null;
|
|
297
|
+
setEngine(null);
|
|
298
|
+
};
|
|
299
|
+
}, [antialias, maxPixelRatio]);
|
|
300
|
+
useEffect(() => {
|
|
301
|
+
if (!engine) return;
|
|
302
|
+
let cancelled = false;
|
|
303
|
+
setS((p) => ({ ...p, status: "loading", error: null }));
|
|
304
|
+
engine.load({ world, tile, textures, view }).catch((e) => {
|
|
305
|
+
if (cancelled) return;
|
|
306
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
307
|
+
setS((p) => ({ ...p, status: "error", error: err }));
|
|
308
|
+
onErrorRef.current?.(err);
|
|
309
|
+
});
|
|
310
|
+
return () => {
|
|
311
|
+
cancelled = true;
|
|
312
|
+
};
|
|
313
|
+
}, [engine, world, tile, textures, view]);
|
|
314
|
+
useEffect(() => {
|
|
315
|
+
if (engine && light) engine.setLight(light);
|
|
316
|
+
}, [engine, light?.ambient, light?.daylight, light?.exposure]);
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
if (engine && display) engine.setDisplay(display);
|
|
319
|
+
}, [engine, display?.sharpness, display?.ao, display?.saturation, display?.contrast, display?.fog, display?.renderScale]);
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
if (engine && streaming) engine.setStreaming(streaming);
|
|
322
|
+
}, [engine, streaming?.viewDistance, streaming?.maxTiles, streaming?.concurrency]);
|
|
323
|
+
const ctx = useMemo(
|
|
324
|
+
() => ({
|
|
325
|
+
viewer: engine,
|
|
326
|
+
status: s.status,
|
|
327
|
+
error: s.error,
|
|
328
|
+
info: s.info,
|
|
329
|
+
biomes: s.biomes,
|
|
330
|
+
biomeLayerEnabled: s.biomeLayerEnabled,
|
|
331
|
+
highlightedBiome: s.highlightedBiome,
|
|
332
|
+
hoveredBiome: s.hoveredBiome
|
|
333
|
+
}),
|
|
334
|
+
[engine, s]
|
|
335
|
+
);
|
|
336
|
+
return /* @__PURE__ */ jsx(VantageContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs("div", { className: className ? `vtg-root ${className}` : "vtg-root", style, children: [
|
|
337
|
+
/* @__PURE__ */ jsx("div", { className: "vtg-canvas", ref: canvasRef }),
|
|
338
|
+
s.status === "loading" && (loading ?? /* @__PURE__ */ jsx("div", { className: "vtg-status", children: "loading\u2026" })),
|
|
339
|
+
s.status === "error" && s.error && /* @__PURE__ */ jsx("div", { className: "vtg-status vtg-error", children: errorFallback ? errorFallback(s.error) : `Error: ${s.error.message}` }),
|
|
340
|
+
children
|
|
341
|
+
] }) });
|
|
342
|
+
});
|
|
343
|
+
function Panel({ icon, title, headerExtra, defaultCollapsed = false, collapsible = true, style, className, children }) {
|
|
344
|
+
const [collapsed, setCollapsed] = useState(defaultCollapsed);
|
|
345
|
+
const classes = ["vtg-panel", "vtg-glass", collapsed && "vtg-collapsed", className].filter(Boolean).join(" ");
|
|
346
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, style, children: [
|
|
347
|
+
/* @__PURE__ */ jsxs(
|
|
348
|
+
"header",
|
|
349
|
+
{
|
|
350
|
+
className: collapsible ? "vtg-click" : void 0,
|
|
351
|
+
onClick: collapsible ? () => setCollapsed((c) => !c) : void 0,
|
|
352
|
+
children: [
|
|
353
|
+
collapsible && /* @__PURE__ */ jsx("span", { className: "vtg-chev", children: collapsed ? "\u25B6" : "\u25BC" }),
|
|
354
|
+
/* @__PURE__ */ jsxs("span", { className: "vtg-title", children: [
|
|
355
|
+
icon != null && /* @__PURE__ */ jsx("span", { className: "vtg-ico", children: icon }),
|
|
356
|
+
title
|
|
357
|
+
] }),
|
|
358
|
+
headerExtra != null && /* @__PURE__ */ jsx("div", { className: "vtg-head-extra", onClick: (e) => e.stopPropagation(), children: headerExtra })
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
),
|
|
362
|
+
!collapsed && /* @__PURE__ */ jsx("div", { className: "vtg-body", children })
|
|
363
|
+
] });
|
|
364
|
+
}
|
|
365
|
+
function isTypingTarget(t) {
|
|
366
|
+
if (!(t instanceof HTMLElement)) return false;
|
|
367
|
+
return t.isContentEditable || t.tagName === "INPUT" || t.tagName === "TEXTAREA";
|
|
368
|
+
}
|
|
369
|
+
function BiomeLayer({
|
|
370
|
+
legend = true,
|
|
371
|
+
hover = true,
|
|
372
|
+
defaultEnabled = false,
|
|
373
|
+
defaultCollapsed = false,
|
|
374
|
+
toggleKey = "b",
|
|
375
|
+
title = "biomes",
|
|
376
|
+
className
|
|
377
|
+
}) {
|
|
378
|
+
const { viewer, biomes, biomeLayerEnabled, highlightedBiome, hoveredBiome } = useVantage();
|
|
379
|
+
const [committed, setCommitted] = useState(null);
|
|
380
|
+
const tipRef = useRef(null);
|
|
381
|
+
const appliedDefault = useRef(false);
|
|
382
|
+
const byId = useMemo(() => new Map(biomes.map((b) => [b.id, b])), [biomes]);
|
|
383
|
+
useEffect(() => {
|
|
384
|
+
if (defaultEnabled && viewer && biomes.length > 0 && !appliedDefault.current) {
|
|
385
|
+
appliedDefault.current = true;
|
|
386
|
+
viewer.setBiomeLayer(true);
|
|
387
|
+
}
|
|
388
|
+
}, [defaultEnabled, viewer, biomes.length]);
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
if (!biomeLayerEnabled) setCommitted(null);
|
|
391
|
+
}, [biomeLayerEnabled]);
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
if (!viewer || !toggleKey) return;
|
|
394
|
+
const onKey = (e) => {
|
|
395
|
+
if (isTypingTarget(e.target)) return;
|
|
396
|
+
if (e.key.toLowerCase() === toggleKey.toLowerCase()) viewer.toggleBiomeLayer();
|
|
397
|
+
};
|
|
398
|
+
window.addEventListener("keydown", onKey);
|
|
399
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
400
|
+
}, [viewer, toggleKey]);
|
|
401
|
+
useEffect(() => {
|
|
402
|
+
if (!hover) return;
|
|
403
|
+
const onMove = (e) => {
|
|
404
|
+
const el = tipRef.current;
|
|
405
|
+
if (el) {
|
|
406
|
+
el.style.left = `${e.clientX + 14}px`;
|
|
407
|
+
el.style.top = `${e.clientY + 14}px`;
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
window.addEventListener("pointermove", onMove);
|
|
411
|
+
return () => window.removeEventListener("pointermove", onMove);
|
|
412
|
+
}, [hover]);
|
|
413
|
+
if (!viewer || biomes.length === 0) return null;
|
|
414
|
+
const selectRow = (id) => {
|
|
415
|
+
const next = committed === id ? null : id;
|
|
416
|
+
setCommitted(next);
|
|
417
|
+
viewer.setHighlightedBiome(next);
|
|
418
|
+
};
|
|
419
|
+
const previewRow = (id) => {
|
|
420
|
+
if (biomeLayerEnabled) viewer.setHighlightedBiome(id);
|
|
421
|
+
};
|
|
422
|
+
const endPreview = () => {
|
|
423
|
+
if (biomeLayerEnabled) viewer.setHighlightedBiome(committed);
|
|
424
|
+
};
|
|
425
|
+
const hovered = biomeLayerEnabled && hoveredBiome != null ? byId.get(hoveredBiome) : void 0;
|
|
426
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
427
|
+
legend && /* @__PURE__ */ jsx(
|
|
428
|
+
Panel,
|
|
429
|
+
{
|
|
430
|
+
icon: "\u25A6",
|
|
431
|
+
title,
|
|
432
|
+
defaultCollapsed,
|
|
433
|
+
className,
|
|
434
|
+
headerExtra: /* @__PURE__ */ jsx(
|
|
435
|
+
"button",
|
|
436
|
+
{
|
|
437
|
+
type: "button",
|
|
438
|
+
className: biomeLayerEnabled ? "vtg-toggle vtg-on" : "vtg-toggle",
|
|
439
|
+
onClick: () => viewer.toggleBiomeLayer(),
|
|
440
|
+
title: `Toggle biome view${toggleKey ? ` (${toggleKey.toUpperCase()})` : ""}`,
|
|
441
|
+
children: biomeLayerEnabled ? "on" : "off"
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
children: /* @__PURE__ */ jsx("div", { className: "vtg-legend", children: biomes.map((b) => {
|
|
445
|
+
const sel = biomeLayerEnabled && committed === b.id;
|
|
446
|
+
const dim = biomeLayerEnabled && highlightedBiome != null && highlightedBiome !== b.id;
|
|
447
|
+
const onMesh = hoveredBiome === b.id;
|
|
448
|
+
return /* @__PURE__ */ jsxs(
|
|
449
|
+
"div",
|
|
450
|
+
{
|
|
451
|
+
className: ["vtg-row", sel && "vtg-sel", dim && "vtg-dim", onMesh && "vtg-hover"].filter(Boolean).join(" "),
|
|
452
|
+
onClick: () => selectRow(b.id),
|
|
453
|
+
onMouseEnter: () => previewRow(b.id),
|
|
454
|
+
onMouseLeave: endPreview,
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ jsx("span", { className: "vtg-chip", style: { background: cssRgb(b.color) } }),
|
|
457
|
+
/* @__PURE__ */ jsx("span", { className: "vtg-name", children: b.label }),
|
|
458
|
+
/* @__PURE__ */ jsxs("span", { className: "vtg-pct", children: [
|
|
459
|
+
Math.round(b.fraction * 100),
|
|
460
|
+
"%"
|
|
461
|
+
] })
|
|
462
|
+
]
|
|
463
|
+
},
|
|
464
|
+
b.id
|
|
465
|
+
);
|
|
466
|
+
}) })
|
|
467
|
+
}
|
|
468
|
+
),
|
|
469
|
+
hover && /* @__PURE__ */ jsxs("div", { ref: tipRef, className: "vtg-tip", style: { display: hovered ? "flex" : "none" }, children: [
|
|
470
|
+
/* @__PURE__ */ jsx("span", { className: "vtg-chip", style: { background: hovered ? cssRgb(hovered.color) : "transparent" } }),
|
|
471
|
+
hovered?.label ?? "\u2014"
|
|
472
|
+
] })
|
|
473
|
+
] });
|
|
474
|
+
}
|
|
475
|
+
var KNOBS = [
|
|
476
|
+
{ key: "daylight", label: "daylight", min: 0, max: 1, step: 0.01 },
|
|
477
|
+
{ key: "ambient", label: "ambient", min: 0, max: 0.6, step: 0.01 },
|
|
478
|
+
{ key: "exposure", label: "exposure", min: 0.4, max: 2, step: 0.01 }
|
|
479
|
+
];
|
|
480
|
+
function LightPanel({ title = "lighting", defaultCollapsed = true, className }) {
|
|
481
|
+
const { viewer } = useVantage();
|
|
482
|
+
const [light, setLight] = useState({ ambient: 0.12, daylight: 1, exposure: 1 });
|
|
483
|
+
useEffect(() => {
|
|
484
|
+
if (viewer) setLight(viewer.lightSettings);
|
|
485
|
+
}, [viewer]);
|
|
486
|
+
if (!viewer) return null;
|
|
487
|
+
const update = (key, value) => {
|
|
488
|
+
setLight((p) => ({ ...p, [key]: value }));
|
|
489
|
+
viewer.setLight({ [key]: value });
|
|
490
|
+
};
|
|
491
|
+
return /* @__PURE__ */ jsx(
|
|
492
|
+
Panel,
|
|
493
|
+
{
|
|
494
|
+
icon: "\u2600",
|
|
495
|
+
title,
|
|
496
|
+
defaultCollapsed,
|
|
497
|
+
className,
|
|
498
|
+
style: { top: "auto", right: "auto", bottom: 16, left: 16, width: 214 },
|
|
499
|
+
children: /* @__PURE__ */ jsx("div", { className: "vtg-sliders", children: KNOBS.map((k) => /* @__PURE__ */ jsxs("label", { className: "vtg-slider", children: [
|
|
500
|
+
/* @__PURE__ */ jsxs("span", { className: "vtg-slider-row", children: [
|
|
501
|
+
/* @__PURE__ */ jsx("span", { children: k.label }),
|
|
502
|
+
/* @__PURE__ */ jsx("b", { children: light[k.key].toFixed(2) })
|
|
503
|
+
] }),
|
|
504
|
+
/* @__PURE__ */ jsx(
|
|
505
|
+
"input",
|
|
506
|
+
{
|
|
507
|
+
type: "range",
|
|
508
|
+
min: k.min,
|
|
509
|
+
max: k.max,
|
|
510
|
+
step: k.step,
|
|
511
|
+
value: light[k.key],
|
|
512
|
+
onChange: (e) => update(k.key, Number(e.target.value))
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
] }, k.key)) })
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
var QUALITY_PRESETS = [
|
|
520
|
+
{ name: "low", viewDistance: 448, maxTiles: 44, renderScale: 0.75 },
|
|
521
|
+
{ name: "med", viewDistance: 768, maxTiles: 120, renderScale: 1 },
|
|
522
|
+
{ name: "high", viewDistance: 1152, maxTiles: 264, renderScale: 1 },
|
|
523
|
+
{ name: "ultra", viewDistance: 1408, maxTiles: 400, renderScale: 1 }
|
|
524
|
+
];
|
|
525
|
+
function SettingsPanel({ title = "quality", defaultCollapsed = true, className }) {
|
|
526
|
+
const { viewer } = useVantage();
|
|
527
|
+
const [k, setK] = useState({ viewDistance: 768, maxTiles: 120, renderScale: 1, fog: 1 });
|
|
528
|
+
useEffect(() => {
|
|
529
|
+
if (!viewer) return;
|
|
530
|
+
const s = viewer.streamingSettings;
|
|
531
|
+
const d = viewer.displaySettings;
|
|
532
|
+
setK({ viewDistance: s.viewDistance, maxTiles: s.maxTiles, renderScale: d.renderScale, fog: d.fog });
|
|
533
|
+
}, [viewer]);
|
|
534
|
+
if (!viewer) return null;
|
|
535
|
+
const apply = (next) => {
|
|
536
|
+
const merged = { ...k, ...next };
|
|
537
|
+
setK(merged);
|
|
538
|
+
if (next.viewDistance !== void 0 || next.maxTiles !== void 0) {
|
|
539
|
+
viewer.setStreaming({ viewDistance: merged.viewDistance, maxTiles: merged.maxTiles });
|
|
540
|
+
}
|
|
541
|
+
if (next.renderScale !== void 0 || next.fog !== void 0) {
|
|
542
|
+
viewer.setDisplay({ renderScale: merged.renderScale, fog: merged.fog });
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
const active = QUALITY_PRESETS.find(
|
|
546
|
+
(p) => p.viewDistance === k.viewDistance && p.maxTiles === k.maxTiles && p.renderScale === k.renderScale
|
|
547
|
+
);
|
|
548
|
+
const SLIDERS = [
|
|
549
|
+
{ key: "viewDistance", label: "view distance", min: 256, max: 2048, step: 64, fmt: (v) => `${v}m` },
|
|
550
|
+
{ key: "maxTiles", label: "tile budget", min: 24, max: 512, step: 8, fmt: (v) => `${v}` },
|
|
551
|
+
{ key: "renderScale", label: "render scale", min: 0.5, max: 2, step: 0.05, fmt: (v) => `${v.toFixed(2)}\xD7` },
|
|
552
|
+
{ key: "fog", label: "haze", min: 0, max: 1, step: 0.05, fmt: (v) => v.toFixed(2) }
|
|
553
|
+
];
|
|
554
|
+
return /* @__PURE__ */ jsx(
|
|
555
|
+
Panel,
|
|
556
|
+
{
|
|
557
|
+
icon: "\u2699",
|
|
558
|
+
title,
|
|
559
|
+
defaultCollapsed,
|
|
560
|
+
className,
|
|
561
|
+
style: { top: "auto", bottom: 16, right: 16, width: 232 },
|
|
562
|
+
children: /* @__PURE__ */ jsxs("div", { className: "vtg-sliders", children: [
|
|
563
|
+
/* @__PURE__ */ jsx("div", { className: "vtg-seg vtg-seg-full", children: QUALITY_PRESETS.map((p) => /* @__PURE__ */ jsx(
|
|
564
|
+
"button",
|
|
565
|
+
{
|
|
566
|
+
className: active?.name === p.name ? "vtg-seg-on" : void 0,
|
|
567
|
+
onClick: () => apply({ viewDistance: p.viewDistance, maxTiles: p.maxTiles, renderScale: p.renderScale }),
|
|
568
|
+
children: p.name
|
|
569
|
+
},
|
|
570
|
+
p.name
|
|
571
|
+
)) }),
|
|
572
|
+
SLIDERS.map((s) => /* @__PURE__ */ jsxs("label", { className: "vtg-slider", children: [
|
|
573
|
+
/* @__PURE__ */ jsxs("span", { className: "vtg-slider-row", children: [
|
|
574
|
+
/* @__PURE__ */ jsx("span", { children: s.label }),
|
|
575
|
+
/* @__PURE__ */ jsx("b", { children: s.fmt(k[s.key]) })
|
|
576
|
+
] }),
|
|
577
|
+
/* @__PURE__ */ jsx(
|
|
578
|
+
"input",
|
|
579
|
+
{
|
|
580
|
+
type: "range",
|
|
581
|
+
min: s.min,
|
|
582
|
+
max: s.max,
|
|
583
|
+
step: s.step,
|
|
584
|
+
value: k[s.key],
|
|
585
|
+
onChange: (e) => apply({ [s.key]: Number(e.target.value) })
|
|
586
|
+
}
|
|
587
|
+
)
|
|
588
|
+
] }, s.key))
|
|
589
|
+
] })
|
|
590
|
+
}
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
var TILT_THRESHOLD = 0.12;
|
|
594
|
+
var Icon = {
|
|
595
|
+
minus: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", children: /* @__PURE__ */ jsx("line", { x1: "3.5", y1: "8", x2: "12.5", y2: "8" }) }),
|
|
596
|
+
plus: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", children: [
|
|
597
|
+
/* @__PURE__ */ jsx("line", { x1: "3.5", y1: "8", x2: "12.5", y2: "8" }),
|
|
598
|
+
/* @__PURE__ */ jsx("line", { x1: "8", y1: "3.5", x2: "8", y2: "12.5" })
|
|
599
|
+
] }),
|
|
600
|
+
home: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
601
|
+
/* @__PURE__ */ jsx("path", { d: "M2.5 7.5 8 3l5.5 4.5" }),
|
|
602
|
+
/* @__PURE__ */ jsx("path", { d: "M4 7v5.5h8V7" })
|
|
603
|
+
] }),
|
|
604
|
+
fly: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
605
|
+
/* @__PURE__ */ jsx("path", { d: "M14.5 1.5 1.2 6.6l5 1.7 1.7 5z" }),
|
|
606
|
+
/* @__PURE__ */ jsx("path", { d: "M14.5 1.5 7.9 8.1" })
|
|
607
|
+
] })
|
|
608
|
+
};
|
|
609
|
+
function MapNav({ compass = true, tilt = true, fly = true, zoom = true, home = true, coords = true, className }) {
|
|
610
|
+
const { viewer } = useVantage();
|
|
611
|
+
const needleRef = useRef(null);
|
|
612
|
+
const coordRef = useRef(null);
|
|
613
|
+
const tiltRef = useRef(null);
|
|
614
|
+
const [flying, setFlying] = useState(false);
|
|
615
|
+
useEffect(() => {
|
|
616
|
+
if (!viewer) return;
|
|
617
|
+
setFlying(viewer.isFlying);
|
|
618
|
+
return viewer.on("mode", ({ fly: fly2 }) => setFlying(fly2));
|
|
619
|
+
}, [viewer]);
|
|
620
|
+
useEffect(() => {
|
|
621
|
+
if (!viewer) return;
|
|
622
|
+
let raf = 0;
|
|
623
|
+
let lastDeg = NaN;
|
|
624
|
+
let lastTxt = "";
|
|
625
|
+
let last3d = null;
|
|
626
|
+
const tick = () => {
|
|
627
|
+
const c = viewer.controls;
|
|
628
|
+
const deg = c.rotation * 180 / Math.PI;
|
|
629
|
+
if (needleRef.current && deg !== lastDeg) {
|
|
630
|
+
needleRef.current.setAttribute("transform", `rotate(${(-deg).toFixed(1)})`);
|
|
631
|
+
lastDeg = deg;
|
|
632
|
+
}
|
|
633
|
+
if (coordRef.current) {
|
|
634
|
+
const txt = `${Math.round(c.position.x)}, ${Math.round(c.position.z)}`;
|
|
635
|
+
if (txt !== lastTxt) {
|
|
636
|
+
coordRef.current.textContent = txt;
|
|
637
|
+
lastTxt = txt;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
if (tiltRef.current) {
|
|
641
|
+
const is3d = c.angle > TILT_THRESHOLD;
|
|
642
|
+
if (is3d !== last3d) {
|
|
643
|
+
tiltRef.current.textContent = is3d ? "3D" : "2D";
|
|
644
|
+
tiltRef.current.classList.toggle("vtg-on", is3d);
|
|
645
|
+
tiltRef.current.title = is3d ? "Level to top-down (2D)" : "Tilt to 3D";
|
|
646
|
+
last3d = is3d;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
raf = requestAnimationFrame(tick);
|
|
650
|
+
};
|
|
651
|
+
raf = requestAnimationFrame(tick);
|
|
652
|
+
return () => cancelAnimationFrame(raf);
|
|
653
|
+
}, [viewer]);
|
|
654
|
+
if (!viewer) return null;
|
|
655
|
+
const toggleTilt = () => viewer.tilt > TILT_THRESHOLD ? viewer.flatten() : viewer.setTilt(DEFAULT_ORBIT_ANGLE);
|
|
656
|
+
return /* @__PURE__ */ jsxs("div", { className: className ? `vtg-nav vtg-glass ${className}` : "vtg-nav vtg-glass", role: "group", "aria-label": "map navigation", children: [
|
|
657
|
+
compass && /* @__PURE__ */ jsx("button", { type: "button", className: "vtg-compass", title: "Face north", "aria-label": "Face north", onClick: () => viewer.resetNorth(), children: /* @__PURE__ */ jsxs("svg", { viewBox: "-16 -16 32 32", "aria-hidden": "true", children: [
|
|
658
|
+
/* @__PURE__ */ jsx("circle", { cx: "0", cy: "0", r: "14.5", fill: "none", stroke: "rgba(140,178,238,0.18)", strokeWidth: "1" }),
|
|
659
|
+
/* @__PURE__ */ jsxs("g", { ref: needleRef, children: [
|
|
660
|
+
/* @__PURE__ */ jsx("polygon", { className: "vtg-n", points: "0,-10.5 3.6,0.5 0,-1.8 -3.6,0.5" }),
|
|
661
|
+
/* @__PURE__ */ jsx("polygon", { className: "vtg-s", points: "0,10.5 3.6,-0.5 0,1.8 -3.6,-0.5" }),
|
|
662
|
+
/* @__PURE__ */ jsx("text", { className: "vtg-cn", x: "0", y: "-11.5", textAnchor: "middle", children: "N" })
|
|
663
|
+
] })
|
|
664
|
+
] }) }),
|
|
665
|
+
tilt && !flying && /* @__PURE__ */ jsx("button", { ref: tiltRef, type: "button", className: "vtg-navbtn vtg-navbtn-text", title: "Tilt to 3D", "aria-label": "Toggle tilt", onClick: toggleTilt, children: "3D" }),
|
|
666
|
+
fly && /* @__PURE__ */ jsx(
|
|
667
|
+
"button",
|
|
668
|
+
{
|
|
669
|
+
type: "button",
|
|
670
|
+
className: flying ? "vtg-navbtn vtg-on" : "vtg-navbtn",
|
|
671
|
+
title: flying ? "Exit free-flight (Esc)" : "Free-flight \u2014 fly over the world",
|
|
672
|
+
"aria-label": "Toggle free-flight",
|
|
673
|
+
"aria-pressed": flying,
|
|
674
|
+
onClick: () => viewer.toggleFly(),
|
|
675
|
+
children: Icon.fly
|
|
676
|
+
}
|
|
677
|
+
),
|
|
678
|
+
coords && /* @__PURE__ */ jsxs("span", { className: "vtg-coords", title: "World X, Z at view centre", children: [
|
|
679
|
+
/* @__PURE__ */ jsx("b", { children: "xz" }),
|
|
680
|
+
/* @__PURE__ */ jsx("span", { ref: coordRef, children: "0, 0" })
|
|
681
|
+
] }),
|
|
682
|
+
!flying && (zoom || home) && /* @__PURE__ */ jsx("span", { className: "vtg-nav-sep" }),
|
|
683
|
+
zoom && !flying && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
684
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "vtg-navbtn", title: "Zoom out", "aria-label": "Zoom out", onClick: () => viewer.zoomBy(-1), children: Icon.minus }),
|
|
685
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "vtg-navbtn", title: "Zoom in", "aria-label": "Zoom in", onClick: () => viewer.zoomBy(1), children: Icon.plus })
|
|
686
|
+
] }),
|
|
687
|
+
home && !flying && /* @__PURE__ */ jsx("button", { type: "button", className: "vtg-navbtn", title: "Reset view", "aria-label": "Reset view", onClick: () => viewer.resetView(), children: Icon.home })
|
|
688
|
+
] });
|
|
689
|
+
}
|
|
690
|
+
function Reticle({ className }) {
|
|
691
|
+
const { viewer } = useVantage();
|
|
692
|
+
const ref = useRef(null);
|
|
693
|
+
useEffect(() => {
|
|
694
|
+
if (!viewer) return;
|
|
695
|
+
let raf = 0;
|
|
696
|
+
let active = false;
|
|
697
|
+
const tick = () => {
|
|
698
|
+
const next = viewer.controls.isInteracting;
|
|
699
|
+
if (next !== active && ref.current) {
|
|
700
|
+
ref.current.classList.toggle("vtg-reticle-on", next);
|
|
701
|
+
active = next;
|
|
702
|
+
}
|
|
703
|
+
raf = requestAnimationFrame(tick);
|
|
704
|
+
};
|
|
705
|
+
raf = requestAnimationFrame(tick);
|
|
706
|
+
return () => cancelAnimationFrame(raf);
|
|
707
|
+
}, [viewer]);
|
|
708
|
+
if (!viewer) return null;
|
|
709
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: className ? `vtg-reticle ${className}` : "vtg-reticle", "aria-hidden": "true", children: [
|
|
710
|
+
/* @__PURE__ */ jsx("span", { className: "vtg-ret-ring" }),
|
|
711
|
+
/* @__PURE__ */ jsx("span", { className: "vtg-ret-dot" })
|
|
712
|
+
] });
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export { BiomeLayer, CSS, LightPanel, MapNav, Panel, QUALITY_PRESETS, Reticle, SettingsPanel, VantageViewer2 as VantageViewer, injectStyles, useVantage };
|