@celestia-island/hikari 0.55.97 → 0.55.99
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/package.json +5 -1
- package/src/board3dSurface.test.ts +74 -0
- package/src/components/HkBoard3D.scss +63 -0
- package/src/components/HkBoard3D.test.tsx +481 -0
- package/src/components/HkBoard3D.tsx +620 -0
- package/src/components/HkErrorLanding.scss +13 -6
- package/src/components/HkErrorLanding.standingframe.contract.test.ts +80 -0
- package/src/components/HkErrorLanding.test.tsx +2 -1
- package/src/components/HkErrorLanding.tsx +7 -5
- package/src/components/HkJsonTree.contract.test.ts +28 -0
- package/src/components/HkJsonTree.scss +18 -0
- package/src/components/HkJsonTree.test.tsx +19 -0
- package/src/components/HkJsonTree.tsx +6 -1
- package/src/components/HkMinimap3D.scss +13 -0
- package/src/components/HkMinimap3D.test.tsx +361 -0
- package/src/components/HkMinimap3D.tsx +501 -0
- package/src/i18n/locales/ar/components.json +3 -1
- package/src/i18n/locales/de/components.json +3 -1
- package/src/i18n/locales/en/components.json +3 -1
- package/src/i18n/locales/es/components.json +3 -1
- package/src/i18n/locales/fr/components.json +3 -1
- package/src/i18n/locales/ja/components.json +3 -1
- package/src/i18n/locales/ko/components.json +3 -1
- package/src/i18n/locales/pt/components.json +3 -1
- package/src/i18n/locales/ru/components.json +3 -1
- package/src/i18n/locales/zh-Hans/components.json +3 -1
- package/src/i18n/locales/zh-Hant/components.json +3 -1
- package/src/index.ts +24 -0
- package/src/utils/scene3d.test.ts +163 -0
- package/src/utils/scene3d.ts +175 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HkMinimap3D — the stereoscopic minimap for HkBoard3D.
|
|
3
|
+
*
|
|
4
|
+
* Same chrome as the 2D HkMinimap (corner card + zoom bar), but the map
|
|
5
|
+
* itself is a second, tiny 3D renderer onto the SAME scene:
|
|
6
|
+
*
|
|
7
|
+
* - MAIN CAMERA is a first-class object in the map: a glyph cone at its
|
|
8
|
+
* position plus the view-plane frame (the "查看平面范围" — a quad at
|
|
9
|
+
* the orbit-target distance with edges back to the eye);
|
|
10
|
+
* - CONTENT shows up as small light dots / holographic cubes at each
|
|
11
|
+
* registered object's world position;
|
|
12
|
+
* - DRAG orbits the map eye on a SPHERE CENTRED ON THE MAIN CAMERA —
|
|
13
|
+
* the map always looks AT the camera-as-an-object, so dragging reads
|
|
14
|
+
* as walking around the operator's viewpoint (never pans the scene);
|
|
15
|
+
* - ZOOM is an auto-fit radius (content ∪ view plane) with a ± ladder
|
|
16
|
+
* on top: 100% = everything fits, higher = closer;
|
|
17
|
+
* - the helper layer never leaks into the main render (helpers sit on
|
|
18
|
+
* BOARD3D_HELPERS_LAYER, which only the minimap camera enables).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { Maximize2, ZoomIn, ZoomOut } from "lucide-vue-next";
|
|
22
|
+
import {
|
|
23
|
+
computed,
|
|
24
|
+
defineComponent,
|
|
25
|
+
onBeforeUnmount,
|
|
26
|
+
onMounted,
|
|
27
|
+
ref,
|
|
28
|
+
watch,
|
|
29
|
+
type PropType,
|
|
30
|
+
} from "vue";
|
|
31
|
+
|
|
32
|
+
import * as THREE from "three";
|
|
33
|
+
|
|
34
|
+
import HSlider from "./HkSlider";
|
|
35
|
+
import { useI18n } from "../i18n/context";
|
|
36
|
+
import {
|
|
37
|
+
BOARD3D_HELPERS_LAYER,
|
|
38
|
+
clampMinimapZoom,
|
|
39
|
+
fitDistance,
|
|
40
|
+
MINIMAP_MAX_POLAR,
|
|
41
|
+
MINIMAP_MAX_ZOOM_PERCENT,
|
|
42
|
+
MINIMAP_MIN_POLAR,
|
|
43
|
+
MINIMAP_MIN_ZOOM_PERCENT,
|
|
44
|
+
MINIMAP_ZOOM_STEP_PERCENT,
|
|
45
|
+
orbitDelta,
|
|
46
|
+
planeCorners,
|
|
47
|
+
sphericalPosition,
|
|
48
|
+
viewPlaneHalfExtents,
|
|
49
|
+
type Vec3,
|
|
50
|
+
} from "../utils/scene3d";
|
|
51
|
+
import type { Board3DEngine } from "./HkBoard3D";
|
|
52
|
+
import "./HkMinimap.scss";
|
|
53
|
+
import "./HkMinimap3D.scss";
|
|
54
|
+
|
|
55
|
+
const MAP_W = 160;
|
|
56
|
+
const MAP_H = 110;
|
|
57
|
+
/** Re-fit the auto radius at ~3 Hz — content orbits move objects every
|
|
58
|
+
* frame, but the fit only needs to track the envelope. */
|
|
59
|
+
const REFIT_MS = 300;
|
|
60
|
+
|
|
61
|
+
export default defineComponent({
|
|
62
|
+
name: "HkMinimap3D",
|
|
63
|
+
props: {
|
|
64
|
+
engine: { type: Object as PropType<Board3DEngine>, required: true },
|
|
65
|
+
},
|
|
66
|
+
setup(props) {
|
|
67
|
+
const { t } = useI18n();
|
|
68
|
+
const rootRef = ref<HTMLElement | null>(null);
|
|
69
|
+
const canvasRef = ref<HTMLCanvasElement | null>(null);
|
|
70
|
+
const dragging = ref(false);
|
|
71
|
+
const sliderOpen = ref(false);
|
|
72
|
+
const zoomPercent = ref(100);
|
|
73
|
+
|
|
74
|
+
let renderer: THREE.WebGLRenderer | null = null;
|
|
75
|
+
let mapCamera: THREE.PerspectiveCamera | null = null;
|
|
76
|
+
let removePostRender: (() => void) | null = null;
|
|
77
|
+
let theta = 0;
|
|
78
|
+
let phi = 1.1;
|
|
79
|
+
let seeded = false;
|
|
80
|
+
let fitRadius = 10;
|
|
81
|
+
let lastRefit = 0;
|
|
82
|
+
let dragStart: { x: number; y: number } | null = null;
|
|
83
|
+
|
|
84
|
+
// Helper layer objects (main-camera glyph + view-plane frame).
|
|
85
|
+
let glyph: THREE.Group | null = null;
|
|
86
|
+
let planeFrame: THREE.LineSegments | null = null;
|
|
87
|
+
const markerMeshes = new Map<string, THREE.Mesh>();
|
|
88
|
+
|
|
89
|
+
const scene = computed(() => props.engine.scene);
|
|
90
|
+
|
|
91
|
+
function buildHelpers(): void {
|
|
92
|
+
const s = scene.value;
|
|
93
|
+
if (!s) return;
|
|
94
|
+
|
|
95
|
+
glyph = new THREE.Group();
|
|
96
|
+
// Cone pointing forward (-Z, the camera's look direction): the
|
|
97
|
+
// glyph reads as a little holographic camera/drone.
|
|
98
|
+
const cone = new THREE.Mesh(
|
|
99
|
+
new THREE.ConeGeometry(0.9, 2.2, 4, 1, true),
|
|
100
|
+
new THREE.MeshBasicMaterial({
|
|
101
|
+
color: 0x7ecbff,
|
|
102
|
+
wireframe: true,
|
|
103
|
+
transparent: true,
|
|
104
|
+
opacity: 0.9,
|
|
105
|
+
depthTest: false,
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
cone.rotation.x = -Math.PI / 2;
|
|
109
|
+
cone.position.z = -1.4;
|
|
110
|
+
glyph.add(cone);
|
|
111
|
+
const body = new THREE.Mesh(
|
|
112
|
+
new THREE.OctahedronGeometry(0.7),
|
|
113
|
+
new THREE.MeshBasicMaterial({
|
|
114
|
+
color: 0x7ecbff,
|
|
115
|
+
transparent: true,
|
|
116
|
+
opacity: 0.55,
|
|
117
|
+
depthTest: false,
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
120
|
+
glyph.add(body);
|
|
121
|
+
|
|
122
|
+
planeFrame = new THREE.LineSegments(
|
|
123
|
+
new THREE.BufferGeometry(),
|
|
124
|
+
new THREE.LineBasicMaterial({
|
|
125
|
+
color: 0x7ecbff,
|
|
126
|
+
transparent: true,
|
|
127
|
+
opacity: 0.6,
|
|
128
|
+
depthTest: false,
|
|
129
|
+
}),
|
|
130
|
+
);
|
|
131
|
+
planeFrame.frustumCulled = false;
|
|
132
|
+
|
|
133
|
+
for (const obj of [glyph, planeFrame]) {
|
|
134
|
+
obj.layers.set(BOARD3D_HELPERS_LAYER);
|
|
135
|
+
obj.traverse((c) => c.layers.set(BOARD3D_HELPERS_LAYER));
|
|
136
|
+
obj.renderOrder = 999;
|
|
137
|
+
s.add(obj);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function markerFor(id: string, def: { marker?: "dot" | "cube" | "none"; markerColor?: string }): THREE.Mesh | null {
|
|
142
|
+
if (def.marker === "none") return null;
|
|
143
|
+
const color = new THREE.Color(def.markerColor ?? "#7ecbff");
|
|
144
|
+
let mesh: THREE.Mesh;
|
|
145
|
+
if (def.marker === "cube") {
|
|
146
|
+
mesh = new THREE.Mesh(
|
|
147
|
+
new THREE.BoxGeometry(1.6, 1.6, 1.6),
|
|
148
|
+
new THREE.MeshBasicMaterial({
|
|
149
|
+
color,
|
|
150
|
+
wireframe: true,
|
|
151
|
+
transparent: true,
|
|
152
|
+
opacity: 0.85,
|
|
153
|
+
depthTest: false,
|
|
154
|
+
}),
|
|
155
|
+
);
|
|
156
|
+
} else {
|
|
157
|
+
mesh = new THREE.Mesh(
|
|
158
|
+
new THREE.SphereGeometry(0.9, 8, 6),
|
|
159
|
+
new THREE.MeshBasicMaterial({
|
|
160
|
+
color,
|
|
161
|
+
transparent: true,
|
|
162
|
+
opacity: 0.9,
|
|
163
|
+
depthTest: false,
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
mesh.layers.set(BOARD3D_HELPERS_LAYER);
|
|
168
|
+
mesh.renderOrder = 999;
|
|
169
|
+
mesh.userData.mm3dId = id;
|
|
170
|
+
return mesh;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const tmpVec = new THREE.Vector3();
|
|
174
|
+
|
|
175
|
+
/** Dispose every geometry/material under a subtree (the camera glyph
|
|
176
|
+
* is a group: cone + octahedron + their materials). */
|
|
177
|
+
function disposeNode(root: THREE.Object3D): void {
|
|
178
|
+
root.traverse((obj) => {
|
|
179
|
+
const mesh = obj as THREE.Mesh;
|
|
180
|
+
mesh.geometry?.dispose();
|
|
181
|
+
const mat = (mesh as unknown as { material?: THREE.Material | THREE.Material[] }).material;
|
|
182
|
+
if (Array.isArray(mat)) mat.forEach((m) => m.dispose());
|
|
183
|
+
else mat?.dispose();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function syncMarkers(): void {
|
|
188
|
+
const s = scene.value;
|
|
189
|
+
if (!s) return;
|
|
190
|
+
const reg = props.engine.objects();
|
|
191
|
+
for (const [id, mesh] of markerMeshes) {
|
|
192
|
+
if (!reg.has(id)) {
|
|
193
|
+
s.remove(mesh);
|
|
194
|
+
mesh.geometry.dispose();
|
|
195
|
+
(mesh.material as THREE.Material).dispose();
|
|
196
|
+
markerMeshes.delete(id);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const [id, def] of reg) {
|
|
200
|
+
let mesh = markerMeshes.get(id);
|
|
201
|
+
if (!mesh) {
|
|
202
|
+
const made = markerFor(id, def);
|
|
203
|
+
if (!made) continue;
|
|
204
|
+
mesh = made;
|
|
205
|
+
markerMeshes.set(id, mesh);
|
|
206
|
+
s.add(mesh);
|
|
207
|
+
}
|
|
208
|
+
def.object.getWorldPosition(tmpVec);
|
|
209
|
+
mesh.position.copy(tmpVec);
|
|
210
|
+
// Marker size tracks the object's own bounding sphere (clamped):
|
|
211
|
+
// a star reads bigger than a satellite in the map.
|
|
212
|
+
const box = new THREE.Box3().setFromObject(def.object);
|
|
213
|
+
const sphere = box.getBoundingSphere(new THREE.Sphere());
|
|
214
|
+
const scale = Math.min(3, Math.max(0.6, sphere.radius * 0.25));
|
|
215
|
+
mesh.scale.setScalar(scale);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function refit(): void {
|
|
220
|
+
const { camera, controls } = props.engine;
|
|
221
|
+
const center = camera.position;
|
|
222
|
+
let r = controls.target.distanceTo(center) * 1.05;
|
|
223
|
+
for (const def of props.engine.objects().values()) {
|
|
224
|
+
if (def.content === false) continue;
|
|
225
|
+
def.object.getWorldPosition(tmpVec);
|
|
226
|
+
const box = new THREE.Box3().setFromObject(def.object);
|
|
227
|
+
const sphere = box.getBoundingSphere(new THREE.Sphere());
|
|
228
|
+
r = Math.max(r, tmpVec.distanceTo(center) + sphere.radius);
|
|
229
|
+
}
|
|
230
|
+
fitRadius = Math.max(r, 1);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function updateHelpersAndCamera(): void {
|
|
234
|
+
const { camera, controls } = props.engine;
|
|
235
|
+
if (!mapCamera || !glyph || !planeFrame) return;
|
|
236
|
+
|
|
237
|
+
// Camera glyph rides the main camera pose.
|
|
238
|
+
glyph.position.copy(camera.position);
|
|
239
|
+
glyph.quaternion.copy(camera.quaternion);
|
|
240
|
+
|
|
241
|
+
// View-plane frame: quad at the orbit-target distance + edges back
|
|
242
|
+
// to the eye (the minimap's "查看平面范围").
|
|
243
|
+
const dist = Math.max(camera.position.distanceTo(controls.target), 0.001);
|
|
244
|
+
const forward = tmpVec.set(0, 0, -1).applyQuaternion(camera.quaternion).clone();
|
|
245
|
+
const up = new THREE.Vector3(0, 1, 0).applyQuaternion(camera.quaternion);
|
|
246
|
+
const right = new THREE.Vector3().crossVectors(forward, up).normalize();
|
|
247
|
+
const trueUp = new THREE.Vector3().crossVectors(right, forward).normalize();
|
|
248
|
+
const planeCenter: Vec3 = [
|
|
249
|
+
camera.position.x + forward.x * dist,
|
|
250
|
+
camera.position.y + forward.y * dist,
|
|
251
|
+
camera.position.z + forward.z * dist,
|
|
252
|
+
];
|
|
253
|
+
const { halfW, halfH } = viewPlaneHalfExtents(camera.fov, camera.aspect, dist);
|
|
254
|
+
const corners = planeCorners(
|
|
255
|
+
planeCenter,
|
|
256
|
+
[right.x, right.y, right.z],
|
|
257
|
+
[trueUp.x, trueUp.y, trueUp.z],
|
|
258
|
+
halfW,
|
|
259
|
+
halfH,
|
|
260
|
+
);
|
|
261
|
+
const eye: Vec3 = [camera.position.x, camera.position.y, camera.position.z];
|
|
262
|
+
const pts: number[] = [];
|
|
263
|
+
for (const c of corners) pts.push(...eye, ...c); // 4 edges
|
|
264
|
+
for (let i = 0; i < 4; i++) pts.push(...corners[i], ...corners[(i + 1) % 4]); // quad
|
|
265
|
+
planeFrame.geometry.setAttribute("position", new THREE.Float32BufferAttribute(pts, 3));
|
|
266
|
+
|
|
267
|
+
// Map eye on the sphere centred on the main camera.
|
|
268
|
+
if (!seeded) {
|
|
269
|
+
const off = camera.position.clone().sub(controls.target);
|
|
270
|
+
theta = Math.atan2(off.x, off.z);
|
|
271
|
+
phi = Math.min(
|
|
272
|
+
MINIMAP_MAX_POLAR,
|
|
273
|
+
Math.max(
|
|
274
|
+
MINIMAP_MIN_POLAR,
|
|
275
|
+
Math.acos(Math.min(1, Math.max(-1, off.y / Math.max(off.length(), 1e-6)))),
|
|
276
|
+
),
|
|
277
|
+
);
|
|
278
|
+
seeded = true;
|
|
279
|
+
}
|
|
280
|
+
const center: Vec3 = [camera.position.x, camera.position.y, camera.position.z];
|
|
281
|
+
const base = fitDistance(fitRadius, mapCamera.fov, mapCamera.aspect);
|
|
282
|
+
const radius = Math.max(base * (100 / zoomPercent.value), 1);
|
|
283
|
+
const eyePos = sphericalPosition(center, theta, phi, radius);
|
|
284
|
+
mapCamera.position.set(...eyePos);
|
|
285
|
+
mapCamera.up.set(0, 1, 0);
|
|
286
|
+
mapCamera.lookAt(...center);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function onFrame(): void {
|
|
290
|
+
if (!renderer || !mapCamera || !scene.value) return;
|
|
291
|
+
const now = performance.now();
|
|
292
|
+
if (now - lastRefit >= REFIT_MS) {
|
|
293
|
+
lastRefit = now;
|
|
294
|
+
refit();
|
|
295
|
+
}
|
|
296
|
+
syncMarkers();
|
|
297
|
+
updateHelpersAndCamera();
|
|
298
|
+
renderer.render(scene.value, mapCamera);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// ── gestures ────────────────────────────────────────────────────────
|
|
302
|
+
function onDown(e: PointerEvent): void {
|
|
303
|
+
const target = e.target as HTMLElement;
|
|
304
|
+
if (target.closest(".hk-mm-zoom-bar") || target.closest(".hk-mm-zoom-pop")) return;
|
|
305
|
+
sliderOpen.value = false;
|
|
306
|
+
e.stopPropagation();
|
|
307
|
+
e.preventDefault();
|
|
308
|
+
dragging.value = true;
|
|
309
|
+
dragStart = { x: e.clientX, y: e.clientY };
|
|
310
|
+
rootRef.value?.setPointerCapture(e.pointerId);
|
|
311
|
+
}
|
|
312
|
+
function onMove(e: PointerEvent): void {
|
|
313
|
+
if (!dragging.value || !dragStart) return;
|
|
314
|
+
e.stopPropagation();
|
|
315
|
+
const next = orbitDelta(theta, phi, e.clientX - dragStart.x, e.clientY - dragStart.y);
|
|
316
|
+
theta = next.theta;
|
|
317
|
+
phi = next.phi;
|
|
318
|
+
dragStart = { x: e.clientX, y: e.clientY };
|
|
319
|
+
}
|
|
320
|
+
function onUp(e: PointerEvent): void {
|
|
321
|
+
if (!dragging.value) return;
|
|
322
|
+
e.stopPropagation();
|
|
323
|
+
dragging.value = false;
|
|
324
|
+
dragStart = null;
|
|
325
|
+
rootRef.value?.releasePointerCapture(e.pointerId);
|
|
326
|
+
}
|
|
327
|
+
function onWheel(e: WheelEvent): void {
|
|
328
|
+
e.stopPropagation();
|
|
329
|
+
e.preventDefault();
|
|
330
|
+
zoomPercent.value = clampMinimapZoom(
|
|
331
|
+
zoomPercent.value + (e.deltaY < 0 ? MINIMAP_ZOOM_STEP_PERCENT : -MINIMAP_ZOOM_STEP_PERCENT),
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// ── zoom bar ────────────────────────────────────────────────────────
|
|
336
|
+
const canStepIn = computed(() => zoomPercent.value < MINIMAP_MAX_ZOOM_PERCENT - 1e-9);
|
|
337
|
+
const canStepOut = computed(() => zoomPercent.value > MINIMAP_MIN_ZOOM_PERCENT + 1e-9);
|
|
338
|
+
function stepZoom(dir: number): void {
|
|
339
|
+
zoomPercent.value = clampMinimapZoom(zoomPercent.value + dir * MINIMAP_ZOOM_STEP_PERCENT);
|
|
340
|
+
}
|
|
341
|
+
function resetView(): void {
|
|
342
|
+
seeded = false;
|
|
343
|
+
zoomPercent.value = 100;
|
|
344
|
+
sliderOpen.value = false;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Slider pop dismissal (same shield as the 2D minimap).
|
|
348
|
+
function onDocPointerDown(e: PointerEvent): void {
|
|
349
|
+
if (!rootRef.value?.contains(e.target as Node)) sliderOpen.value = false;
|
|
350
|
+
}
|
|
351
|
+
function onDocKeydown(e: KeyboardEvent): void {
|
|
352
|
+
if (e.key === "Escape") sliderOpen.value = false;
|
|
353
|
+
}
|
|
354
|
+
watch(sliderOpen, (open) => {
|
|
355
|
+
if (open) {
|
|
356
|
+
document.addEventListener("pointerdown", onDocPointerDown, true);
|
|
357
|
+
document.addEventListener("keydown", onDocKeydown, true);
|
|
358
|
+
} else {
|
|
359
|
+
document.removeEventListener("pointerdown", onDocPointerDown, true);
|
|
360
|
+
document.removeEventListener("keydown", onDocKeydown, true);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
onMounted(() => {
|
|
365
|
+
const canvas = canvasRef.value;
|
|
366
|
+
const el = rootRef.value;
|
|
367
|
+
if (!canvas || !el) return;
|
|
368
|
+
try {
|
|
369
|
+
renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
|
|
370
|
+
} catch {
|
|
371
|
+
renderer = null; // no WebGL: the map quietly stays empty
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
|
|
375
|
+
renderer.setSize(MAP_W, MAP_H);
|
|
376
|
+
renderer.setClearColor(0x000000, 0);
|
|
377
|
+
|
|
378
|
+
mapCamera = new THREE.PerspectiveCamera(48, MAP_W / MAP_H, 0.1, 10000);
|
|
379
|
+
mapCamera.layers.enable(BOARD3D_HELPERS_LAYER);
|
|
380
|
+
|
|
381
|
+
buildHelpers();
|
|
382
|
+
refit();
|
|
383
|
+
removePostRender = props.engine.addPostRender(onFrame);
|
|
384
|
+
|
|
385
|
+
el.addEventListener("pointerdown", onDown);
|
|
386
|
+
el.addEventListener("pointermove", onMove);
|
|
387
|
+
el.addEventListener("pointerup", onUp);
|
|
388
|
+
el.addEventListener("pointercancel", onUp);
|
|
389
|
+
el.addEventListener("wheel", onWheel, { passive: false });
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
onBeforeUnmount(() => {
|
|
393
|
+
removePostRender?.();
|
|
394
|
+
const el = rootRef.value;
|
|
395
|
+
if (el) {
|
|
396
|
+
el.removeEventListener("pointerdown", onDown);
|
|
397
|
+
el.removeEventListener("pointermove", onMove);
|
|
398
|
+
el.removeEventListener("pointerup", onUp);
|
|
399
|
+
el.removeEventListener("pointercancel", onUp);
|
|
400
|
+
el.removeEventListener("wheel", onWheel);
|
|
401
|
+
}
|
|
402
|
+
document.removeEventListener("pointerdown", onDocPointerDown, true);
|
|
403
|
+
document.removeEventListener("keydown", onDocKeydown, true);
|
|
404
|
+
const s = scene.value;
|
|
405
|
+
if (s) {
|
|
406
|
+
if (glyph) {
|
|
407
|
+
s.remove(glyph);
|
|
408
|
+
disposeNode(glyph);
|
|
409
|
+
}
|
|
410
|
+
if (planeFrame) {
|
|
411
|
+
s.remove(planeFrame);
|
|
412
|
+
planeFrame.geometry.dispose();
|
|
413
|
+
(planeFrame.material as THREE.Material).dispose();
|
|
414
|
+
}
|
|
415
|
+
for (const mesh of markerMeshes.values()) {
|
|
416
|
+
s.remove(mesh);
|
|
417
|
+
mesh.geometry.dispose();
|
|
418
|
+
(mesh.material as THREE.Material).dispose();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
markerMeshes.clear();
|
|
422
|
+
renderer?.dispose();
|
|
423
|
+
// Free the GL context eagerly (mirrors HkBoard3D): repeated mounts
|
|
424
|
+
// in one SPA would otherwise brush the live-context cap.
|
|
425
|
+
renderer?.forceContextLoss?.();
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
return () => (
|
|
429
|
+
<div
|
|
430
|
+
ref={rootRef}
|
|
431
|
+
class="hk-minimap hk-minimap3d"
|
|
432
|
+
data-dragging={dragging.value ? "" : undefined}
|
|
433
|
+
>
|
|
434
|
+
<canvas ref={canvasRef} class="hk-minimap3d-canvas" width={MAP_W} height={MAP_H} />
|
|
435
|
+
<div class="hk-mm-zoom-bar">
|
|
436
|
+
<button
|
|
437
|
+
class="hk-mm-zoom-btn"
|
|
438
|
+
type="button"
|
|
439
|
+
onClick={() => stepZoom(-1)}
|
|
440
|
+
disabled={!canStepOut.value}
|
|
441
|
+
aria-label={t("hikari::zoomToolbar.zoomOut", "Zoom out")}
|
|
442
|
+
title={t("hikari::zoomToolbar.zoomOut", "Zoom out")}
|
|
443
|
+
>
|
|
444
|
+
<ZoomOut size={12} />
|
|
445
|
+
</button>
|
|
446
|
+
<button
|
|
447
|
+
class="hk-mm-zoom-label"
|
|
448
|
+
type="button"
|
|
449
|
+
aria-haspopup="dialog"
|
|
450
|
+
aria-expanded={sliderOpen.value ? "true" : "false"}
|
|
451
|
+
onClick={() => {
|
|
452
|
+
sliderOpen.value = !sliderOpen.value;
|
|
453
|
+
}}
|
|
454
|
+
title={t("hikari::zoomToolbar.zoomSlider", "Zoom level")}
|
|
455
|
+
>
|
|
456
|
+
{zoomPercent.value}%
|
|
457
|
+
</button>
|
|
458
|
+
<button
|
|
459
|
+
class="hk-mm-zoom-btn"
|
|
460
|
+
type="button"
|
|
461
|
+
onClick={() => stepZoom(1)}
|
|
462
|
+
disabled={!canStepIn.value}
|
|
463
|
+
aria-label={t("hikari::zoomToolbar.zoomIn", "Zoom in")}
|
|
464
|
+
title={t("hikari::zoomToolbar.zoomIn", "Zoom in")}
|
|
465
|
+
>
|
|
466
|
+
<ZoomIn size={12} />
|
|
467
|
+
</button>
|
|
468
|
+
<button
|
|
469
|
+
class="hk-mm-zoom-btn hk-mm-zoom-reset-btn"
|
|
470
|
+
type="button"
|
|
471
|
+
onClick={resetView}
|
|
472
|
+
aria-label={t("hikari::board3d.resetView", "Reset view")}
|
|
473
|
+
title={t("hikari::board3d.resetView", "Reset view")}
|
|
474
|
+
>
|
|
475
|
+
<Maximize2 size={11} />
|
|
476
|
+
</button>
|
|
477
|
+
</div>
|
|
478
|
+
{sliderOpen.value && (
|
|
479
|
+
<div class="hk-mm-zoom-pop">
|
|
480
|
+
<HSlider
|
|
481
|
+
modelValue={zoomPercent.value}
|
|
482
|
+
min={MINIMAP_MIN_ZOOM_PERCENT}
|
|
483
|
+
max={MINIMAP_MAX_ZOOM_PERCENT}
|
|
484
|
+
step={MINIMAP_ZOOM_STEP_PERCENT}
|
|
485
|
+
size="sm"
|
|
486
|
+
ariaLabel={t("hikari::zoomToolbar.zoomSlider", "Zoom level")}
|
|
487
|
+
formatValue={(v: number) => `${v}%`}
|
|
488
|
+
onUpdate:modelValue={(v: number) => {
|
|
489
|
+
zoomPercent.value = clampMinimapZoom(v);
|
|
490
|
+
}}
|
|
491
|
+
/>
|
|
492
|
+
<div class="hk-mm-zoom-pop-scale" aria-hidden="true">
|
|
493
|
+
<span>{MINIMAP_MIN_ZOOM_PERCENT}%</span>
|
|
494
|
+
<span>{MINIMAP_MAX_ZOOM_PERCENT}%</span>
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
)}
|
|
498
|
+
</div>
|
|
499
|
+
);
|
|
500
|
+
},
|
|
501
|
+
});
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "التحقق بمفتاح المرور",
|
|
253
253
|
"hikari::mfaVerify.resend": "إعادة إرسال الرمز",
|
|
254
254
|
"hikari::mfaVerify.back": "العودة لتسجيل الدخول",
|
|
255
|
-
"hikari::mfaVerify.loading": "جارٍ التحميل..."
|
|
255
|
+
"hikari::mfaVerify.loading": "جارٍ التحميل...",
|
|
256
|
+
"hikari::board3d.resetView": "إعادة تعيين العرض",
|
|
257
|
+
"hikari::board3d.unavailable": "العرض ثلاثي الأبعاد غير متوفر على هذا الجهاز"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "Mit Passkey verifizieren",
|
|
253
253
|
"hikari::mfaVerify.resend": "Code erneut senden",
|
|
254
254
|
"hikari::mfaVerify.back": "Zurück zur Anmeldung",
|
|
255
|
-
"hikari::mfaVerify.loading": "Laden..."
|
|
255
|
+
"hikari::mfaVerify.loading": "Laden...",
|
|
256
|
+
"hikari::board3d.resetView": "Ansicht zurücksetzen",
|
|
257
|
+
"hikari::board3d.unavailable": "3D ist auf diesem Gerät nicht verfügbar"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "Verify with Passkey",
|
|
253
253
|
"hikari::mfaVerify.resend": "Resend code",
|
|
254
254
|
"hikari::mfaVerify.back": "Back to sign in",
|
|
255
|
-
"hikari::mfaVerify.loading": "Loading..."
|
|
255
|
+
"hikari::mfaVerify.loading": "Loading...",
|
|
256
|
+
"hikari::board3d.resetView": "Reset view",
|
|
257
|
+
"hikari::board3d.unavailable": "3D is unavailable on this device"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "Verificar con llave de acceso",
|
|
253
253
|
"hikari::mfaVerify.resend": "Reenviar código",
|
|
254
254
|
"hikari::mfaVerify.back": "Volver al inicio de sesión",
|
|
255
|
-
"hikari::mfaVerify.loading": "Cargando..."
|
|
255
|
+
"hikari::mfaVerify.loading": "Cargando...",
|
|
256
|
+
"hikari::board3d.resetView": "Restablecer vista",
|
|
257
|
+
"hikari::board3d.unavailable": "El 3D no está disponible en este dispositivo"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "Vérifier avec une clé d'accès",
|
|
253
253
|
"hikari::mfaVerify.resend": "Renvoyer le code",
|
|
254
254
|
"hikari::mfaVerify.back": "Retour à la connexion",
|
|
255
|
-
"hikari::mfaVerify.loading": "Chargement..."
|
|
255
|
+
"hikari::mfaVerify.loading": "Chargement...",
|
|
256
|
+
"hikari::board3d.resetView": "Réinitialiser la vue",
|
|
257
|
+
"hikari::board3d.unavailable": "La 3D n'est pas disponible sur cet appareil"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "パスキーで認証",
|
|
253
253
|
"hikari::mfaVerify.resend": "コードを再送",
|
|
254
254
|
"hikari::mfaVerify.back": "ログインに戻る",
|
|
255
|
-
"hikari::mfaVerify.loading": "読み込み中..."
|
|
255
|
+
"hikari::mfaVerify.loading": "読み込み中...",
|
|
256
|
+
"hikari::board3d.resetView": "視点をリセット",
|
|
257
|
+
"hikari::board3d.unavailable": "このデバイスでは 3D を利用できません"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "패스키로 인증",
|
|
253
253
|
"hikari::mfaVerify.resend": "코드 재전송",
|
|
254
254
|
"hikari::mfaVerify.back": "로그인으로 돌아가기",
|
|
255
|
-
"hikari::mfaVerify.loading": "로딩 중..."
|
|
255
|
+
"hikari::mfaVerify.loading": "로딩 중...",
|
|
256
|
+
"hikari::board3d.resetView": "시점 재설정",
|
|
257
|
+
"hikari::board3d.unavailable": "이 기기에서는 3D를 사용할 수 없습니다"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "Verificar com chave de acesso",
|
|
253
253
|
"hikari::mfaVerify.resend": "Reenviar código",
|
|
254
254
|
"hikari::mfaVerify.back": "Voltar ao login",
|
|
255
|
-
"hikari::mfaVerify.loading": "Carregando..."
|
|
255
|
+
"hikari::mfaVerify.loading": "Carregando...",
|
|
256
|
+
"hikari::board3d.resetView": "Redefinir visualização",
|
|
257
|
+
"hikari::board3d.unavailable": "O 3D não está disponível neste dispositivo"
|
|
256
258
|
}
|
|
@@ -252,5 +252,7 @@
|
|
|
252
252
|
"hikari::mfaVerify.usePasskey": "Подтвердить ключом доступа",
|
|
253
253
|
"hikari::mfaVerify.resend": "Отправить код повторно",
|
|
254
254
|
"hikari::mfaVerify.back": "Вернуться к входу",
|
|
255
|
-
"hikari::mfaVerify.loading": "Загрузка..."
|
|
255
|
+
"hikari::mfaVerify.loading": "Загрузка...",
|
|
256
|
+
"hikari::board3d.resetView": "Сбросить вид",
|
|
257
|
+
"hikari::board3d.unavailable": "3D недоступно на этом устройстве"
|
|
256
258
|
}
|
|
@@ -256,5 +256,7 @@
|
|
|
256
256
|
"hikari::mfaVerify.usePasskey": "使用 Passkey 验证",
|
|
257
257
|
"hikari::mfaVerify.resend": "重新发送验证码",
|
|
258
258
|
"hikari::mfaVerify.back": "返回重新登录",
|
|
259
|
-
"hikari::mfaVerify.loading": "加载中..."
|
|
259
|
+
"hikari::mfaVerify.loading": "加载中...",
|
|
260
|
+
"hikari::board3d.resetView": "重置视角",
|
|
261
|
+
"hikari::board3d.unavailable": "此设备不支持 3D 显示"
|
|
260
262
|
}
|
|
@@ -256,5 +256,7 @@
|
|
|
256
256
|
"hikari::mfaVerify.usePasskey": "使用 Passkey 驗證",
|
|
257
257
|
"hikari::mfaVerify.resend": "重新傳送驗證碼",
|
|
258
258
|
"hikari::mfaVerify.back": "返回重新登入",
|
|
259
|
-
"hikari::mfaVerify.loading": "加載中..."
|
|
259
|
+
"hikari::mfaVerify.loading": "加載中...",
|
|
260
|
+
"hikari::board3d.resetView": "重設視角",
|
|
261
|
+
"hikari::board3d.unavailable": "此裝置不支援 3D 顯示"
|
|
260
262
|
}
|
package/src/index.ts
CHANGED
|
@@ -201,6 +201,28 @@ export { type TreeNode, type TreeSize, type TreeRowScope } from "./components/Hk
|
|
|
201
201
|
export { type DragListItem } from "./components/HkDraggableList";
|
|
202
202
|
export { type GridItem } from "./components/HkDraggableGrid";
|
|
203
203
|
export { type MinimapBox, type MinimapRect } from "./components/HkMinimap";
|
|
204
|
+
export {
|
|
205
|
+
type Board3DEngine,
|
|
206
|
+
type Board3DObjectDef,
|
|
207
|
+
} from "./components/HkBoard3D";
|
|
208
|
+
export {
|
|
209
|
+
hashIdToUnit,
|
|
210
|
+
lerpPalette,
|
|
211
|
+
paletteColorForId,
|
|
212
|
+
orbitDelta,
|
|
213
|
+
sphericalPosition,
|
|
214
|
+
fitDistance,
|
|
215
|
+
viewPlaneHalfExtents,
|
|
216
|
+
planeCorners,
|
|
217
|
+
clampMinimapZoom,
|
|
218
|
+
MINIMAP_MIN_POLAR,
|
|
219
|
+
MINIMAP_MAX_POLAR,
|
|
220
|
+
MINIMAP_DRAG_RADIANS_PER_PX,
|
|
221
|
+
MINIMAP_ZOOM_STEP_PERCENT,
|
|
222
|
+
MINIMAP_MIN_ZOOM_PERCENT,
|
|
223
|
+
MINIMAP_MAX_ZOOM_PERCENT,
|
|
224
|
+
type Vec3,
|
|
225
|
+
} from "./utils/scene3d";
|
|
204
226
|
export { type TrendPen, type TrendPoint, type AlarmThresholds } from "./components/HkTrendChart";
|
|
205
227
|
|
|
206
228
|
// ── Theme decor (theme-provided decorative widgets, host-placed) ──────────
|
|
@@ -724,6 +746,8 @@ export { default as HkMediaVisualizer } from "./components/HkMediaVisualizer";
|
|
|
724
746
|
export { default as HkImageViewer } from "./components/HkImageViewer";
|
|
725
747
|
export { default as HkZoomToolbar } from "./components/HkZoomToolbar";
|
|
726
748
|
export { default as HkMinimap } from "./components/HkMinimap";
|
|
749
|
+
export { default as HkBoard3D, BOARD3D_HELPERS_LAYER } from "./components/HkBoard3D";
|
|
750
|
+
export { default as HkMinimap3D } from "./components/HkMinimap3D";
|
|
727
751
|
export { default as HkTrendChart } from "./components/HkTrendChart";
|
|
728
752
|
export { default as HkErrorBoundary } from "./components/HkErrorBoundary";
|
|
729
753
|
export { default as HkDraggableList } from "./components/HkDraggableList";
|