@jkwd/inbase 0.1.13 → 0.1.15
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.
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from './layout'
|
|
15
15
|
import { World } from './scene/World'
|
|
16
16
|
import { HUD } from './ui/HUD'
|
|
17
|
+
import { CanvasErrorBoundary } from './ui/CanvasErrorBoundary'
|
|
17
18
|
import {
|
|
18
19
|
MapContextMenu,
|
|
19
20
|
type MapContextMenuState,
|
|
@@ -1262,6 +1263,7 @@ function Explorer({
|
|
|
1262
1263
|
return (
|
|
1263
1264
|
<>
|
|
1264
1265
|
<div className="stage">
|
|
1266
|
+
<CanvasErrorBoundary>
|
|
1265
1267
|
<Canvas
|
|
1266
1268
|
shadows={false}
|
|
1267
1269
|
dpr={[1, 1.5]}
|
|
@@ -1317,6 +1319,7 @@ function Explorer({
|
|
|
1317
1319
|
}
|
|
1318
1320
|
/>
|
|
1319
1321
|
</Canvas>
|
|
1322
|
+
</CanvasErrorBoundary>
|
|
1320
1323
|
</div>
|
|
1321
1324
|
<HUD
|
|
1322
1325
|
graph={displayGraph}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useMemo, useRef
|
|
2
|
-
import { createPortal } from 'react-dom'
|
|
1
|
+
import { useEffect, useLayoutEffect, useMemo, useRef } from 'react'
|
|
3
2
|
import { useFrame, useThree } from '@react-three/fiber'
|
|
4
3
|
import { Html, MapControls, OrthographicCamera } from '@react-three/drei'
|
|
5
4
|
import * as THREE from 'three'
|
|
@@ -355,13 +354,40 @@ function MapFolderLabels({
|
|
|
355
354
|
const camera = useThree((state) => state.camera)
|
|
356
355
|
const gl = useThree((state) => state.gl)
|
|
357
356
|
const size = useThree((state) => state.size)
|
|
358
|
-
const layerRef = useRef<HTMLDivElement>(null)
|
|
357
|
+
const layerRef = useRef<HTMLDivElement | null>(null)
|
|
359
358
|
const items = useMemo(() => Object.values(folders), [folders])
|
|
360
|
-
const [host, setHost] = useState<HTMLElement | null>(null)
|
|
361
359
|
|
|
362
360
|
useLayoutEffect(() => {
|
|
363
|
-
|
|
364
|
-
|
|
361
|
+
const parent = gl.domElement.parentElement
|
|
362
|
+
if (!parent) return
|
|
363
|
+
const layer = document.createElement('div')
|
|
364
|
+
layer.className = 'map-folder-label-layer'
|
|
365
|
+
layer.style.cssText =
|
|
366
|
+
'position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:80;background:transparent;'
|
|
367
|
+
for (const folder of items) {
|
|
368
|
+
const el = document.createElement('div')
|
|
369
|
+
el.className = folderLabelClass(folder, highlightedFolders, selectedFolder)
|
|
370
|
+
el.style.position = 'absolute'
|
|
371
|
+
el.style.top = '0'
|
|
372
|
+
el.style.left = '0'
|
|
373
|
+
el.style.visibility = 'hidden'
|
|
374
|
+
const name = document.createElement('span')
|
|
375
|
+
name.className = 'map-folder-name'
|
|
376
|
+
name.textContent = folderKindLabel(
|
|
377
|
+
folder.name,
|
|
378
|
+
highlightedFolders?.[folder.path] ?? null,
|
|
379
|
+
folder.added ?? false,
|
|
380
|
+
)
|
|
381
|
+
el.appendChild(name)
|
|
382
|
+
layer.appendChild(el)
|
|
383
|
+
}
|
|
384
|
+
parent.appendChild(layer)
|
|
385
|
+
layerRef.current = layer
|
|
386
|
+
return () => {
|
|
387
|
+
layer.remove()
|
|
388
|
+
layerRef.current = null
|
|
389
|
+
}
|
|
390
|
+
}, [gl, highlightedFolders, items, selectedFolder])
|
|
365
391
|
|
|
366
392
|
useFrame(() => {
|
|
367
393
|
const layer = layerRef.current
|
|
@@ -401,27 +427,7 @@ function MapFolderLabels({
|
|
|
401
427
|
}
|
|
402
428
|
})
|
|
403
429
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return createPortal(
|
|
407
|
-
<div ref={layerRef} className="map-folder-label-layer">
|
|
408
|
-
{items.map((folder) => (
|
|
409
|
-
<div
|
|
410
|
-
key={folder.path}
|
|
411
|
-
className={folderLabelClass(folder, highlightedFolders, selectedFolder)}
|
|
412
|
-
>
|
|
413
|
-
<span className="map-folder-name">
|
|
414
|
-
{folderKindLabel(
|
|
415
|
-
folder.name,
|
|
416
|
-
highlightedFolders?.[folder.path] ?? null,
|
|
417
|
-
folder.added ?? false,
|
|
418
|
-
)}
|
|
419
|
-
</span>
|
|
420
|
-
</div>
|
|
421
|
-
))}
|
|
422
|
-
</div>,
|
|
423
|
-
host,
|
|
424
|
-
)
|
|
430
|
+
return null
|
|
425
431
|
}
|
|
426
432
|
|
|
427
433
|
function folderKindLabel(
|