@viamrobotics/motion-tools 1.12.0 → 1.12.1
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.
|
@@ -39,8 +39,10 @@
|
|
|
39
39
|
const point = new Vector3()
|
|
40
40
|
|
|
41
41
|
const raycast = (event: PointerEvent) => {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const element = event.target as HTMLElement
|
|
43
|
+
const rect = element.getBoundingClientRect()
|
|
44
|
+
mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1
|
|
45
|
+
mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1
|
|
44
46
|
|
|
45
47
|
raycaster.setFromCamera(mouse, camera.current)
|
|
46
48
|
raycaster.ray.intersectPlane(plane, point)
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
import { BufferGeometryUtils } from 'three/examples/jsm/Addons.js'
|
|
11
11
|
import { createBinaryPCD } from '../../pcd'
|
|
12
12
|
import type { BufferGeometry } from 'three'
|
|
13
|
+
import { useThrelte } from '@threlte/core'
|
|
14
|
+
import { ElementRect } from 'runed'
|
|
13
15
|
|
|
14
16
|
interface Props {
|
|
15
17
|
/** Whether to auto-enable lasso mode when the component mounts */
|
|
@@ -21,6 +23,7 @@
|
|
|
21
23
|
|
|
22
24
|
let { enabled = false, onSelection }: Props = $props()
|
|
23
25
|
|
|
26
|
+
const { dom } = useThrelte()
|
|
24
27
|
const world = useWorld()
|
|
25
28
|
const settings = useSettings()
|
|
26
29
|
const isLassoMode = $derived(settings.current.interactionMode === 'lasso')
|
|
@@ -56,6 +59,8 @@
|
|
|
56
59
|
settings.current.interactionMode = 'lasso'
|
|
57
60
|
}
|
|
58
61
|
})
|
|
62
|
+
|
|
63
|
+
const rect = new ElementRect(() => dom)
|
|
59
64
|
</script>
|
|
60
65
|
|
|
61
66
|
<Portal id="dashboard">
|
|
@@ -71,7 +76,7 @@
|
|
|
71
76
|
</fieldset>
|
|
72
77
|
</Portal>
|
|
73
78
|
|
|
74
|
-
{#if isLassoMode}
|
|
79
|
+
{#if isLassoMode && rect.height > 0 && rect.width > 0}
|
|
75
80
|
<Lasso />
|
|
76
81
|
|
|
77
82
|
<Portal id="dom">
|
|
@@ -79,8 +84,9 @@
|
|
|
79
84
|
isOpen
|
|
80
85
|
exitable={false}
|
|
81
86
|
title="Lasso"
|
|
87
|
+
strategy="absolute"
|
|
82
88
|
defaultSize={{ width: 445, height: 100 }}
|
|
83
|
-
defaultPosition={{ x:
|
|
89
|
+
defaultPosition={{ x: rect.width / 2 - 200, y: rect.height - 10 - 100 }}
|
|
84
90
|
>
|
|
85
91
|
<div class="flex items-center gap-4 p-4 text-xs">
|
|
86
92
|
Shift + click and drag to make a lasso selection.
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
defaultSize?: { width: number; height: number }
|
|
11
11
|
defaultPosition?: { x: number; y: number }
|
|
12
12
|
exitable?: boolean
|
|
13
|
+
strategy?: 'absolute' | 'fixed'
|
|
13
14
|
isOpen?: boolean
|
|
14
15
|
children: Snippet
|
|
15
16
|
}
|
|
@@ -17,20 +18,20 @@
|
|
|
17
18
|
let {
|
|
18
19
|
title = '',
|
|
19
20
|
defaultSize = { width: 700, height: 500 },
|
|
20
|
-
defaultPosition,
|
|
21
21
|
exitable = true,
|
|
22
22
|
isOpen = $bindable(false),
|
|
23
23
|
children,
|
|
24
|
+
...props
|
|
24
25
|
}: Props = $props()
|
|
25
26
|
|
|
26
27
|
const id = $props.id()
|
|
27
28
|
const floatingPanelService = useMachine(floatingPanel.machine, () => ({
|
|
28
29
|
id,
|
|
29
30
|
defaultSize,
|
|
30
|
-
defaultPosition,
|
|
31
31
|
resizable: false,
|
|
32
32
|
allowOverflow: false,
|
|
33
33
|
open: isOpen,
|
|
34
|
+
...props,
|
|
34
35
|
}))
|
|
35
36
|
|
|
36
37
|
const api = $derived(floatingPanel.connect(floatingPanelService, normalizeProps))
|