@viamrobotics/motion-tools 1.34.4 → 1.34.5
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/plugins/Selection/Ellipse.svelte +9 -26
- package/dist/plugins/Selection/Ellipse.svelte.d.ts +2 -1
- package/dist/plugins/Selection/Lasso.svelte +9 -26
- package/dist/plugins/Selection/Lasso.svelte.d.ts +2 -1
- package/dist/plugins/Selection/SelectionTool.svelte +18 -3
- package/dist/plugins/Selection/SelectionTool.svelte.d.ts +2 -0
- package/dist/plugins/TopDownLock/TopDownLock.svelte +25 -0
- package/dist/plugins/TopDownLock/TopDownLock.svelte.d.ts +3 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.js +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @deprecated MotionTools has been renamed to Visualizer. This export will be removed in v2. */
|
|
2
2
|
export { default as MotionTools } from './components/App.svelte';
|
|
3
3
|
export { default as Visualizer } from './components/App.svelte';
|
|
4
|
+
export { useSettings } from './hooks/useSettings.svelte';
|
|
4
5
|
export { default as PCD } from './components/PCD.svelte';
|
|
5
6
|
export * as relations from './ecs/relations';
|
|
6
7
|
export * as traits from './ecs/traits';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @deprecated MotionTools has been renamed to Visualizer. This export will be removed in v2. */
|
|
2
2
|
export { default as MotionTools } from './components/App.svelte';
|
|
3
3
|
export { default as Visualizer } from './components/App.svelte';
|
|
4
|
+
export { useSettings } from './hooks/useSettings.svelte';
|
|
4
5
|
// Plugins
|
|
5
6
|
export { default as PCD } from './components/PCD.svelte';
|
|
6
7
|
// ECS
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
import { getTriangleBoxesFromIndices, getTriangleFromIndex, raycast } from './utils'
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
|
-
|
|
19
|
+
enabled?: boolean
|
|
20
|
+
selecting?: boolean
|
|
20
21
|
debug?: boolean
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
let {
|
|
24
|
+
let { enabled = false, selecting = false, debug = false }: Props = $props()
|
|
24
25
|
|
|
25
26
|
const world = useWorld()
|
|
26
27
|
const controls = useCameraControls()
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
let drawing = false
|
|
38
39
|
|
|
39
40
|
const onpointerdown = (event: PointerEvent) => {
|
|
40
|
-
if (!event.shiftKey
|
|
41
|
+
if (!selecting && !event.shiftKey) return
|
|
41
42
|
|
|
42
43
|
const { x, y } = raycast(event, camera.current)
|
|
43
44
|
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
const onpointermove = (event: PointerEvent) => {
|
|
64
|
-
if (!drawing
|
|
65
|
+
if (!drawing) return
|
|
65
66
|
|
|
66
67
|
let ellipse = world.query(selectionTraits.Ellipse).at(-1)
|
|
67
68
|
|
|
@@ -129,13 +130,13 @@
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
const onpointerleave = () => {
|
|
132
|
-
if (!drawing
|
|
133
|
+
if (!drawing) return
|
|
133
134
|
|
|
134
135
|
onpointerup()
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
const onpointerup = () => {
|
|
138
|
-
if (!drawing
|
|
139
|
+
if (!drawing) return
|
|
139
140
|
|
|
140
141
|
drawing = false
|
|
141
142
|
|
|
@@ -244,6 +245,8 @@
|
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
$effect(() => {
|
|
248
|
+
if (!enabled) return
|
|
249
|
+
|
|
247
250
|
globalThis.addEventListener('keydown', onkeydown)
|
|
248
251
|
globalThis.addEventListener('keyup', onkeyup)
|
|
249
252
|
dom.addEventListener('pointerdown', onpointerdown)
|
|
@@ -263,26 +266,6 @@
|
|
|
263
266
|
|
|
264
267
|
const ellipses = useQuery(selectionTraits.Ellipse)
|
|
265
268
|
|
|
266
|
-
$effect(() => {
|
|
267
|
-
if (!controls.current) return
|
|
268
|
-
|
|
269
|
-
const currentControls = controls.current
|
|
270
|
-
|
|
271
|
-
if ('minPolarAngle' in currentControls) {
|
|
272
|
-
const { minPolarAngle, maxPolarAngle } = currentControls
|
|
273
|
-
|
|
274
|
-
// Locks the camera to top down while this component is mounted
|
|
275
|
-
currentControls.polarAngle = 0
|
|
276
|
-
currentControls.minPolarAngle = 0
|
|
277
|
-
currentControls.maxPolarAngle = 0
|
|
278
|
-
|
|
279
|
-
return () => {
|
|
280
|
-
currentControls.minPolarAngle = minPolarAngle
|
|
281
|
-
currentControls.maxPolarAngle = maxPolarAngle
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
})
|
|
285
|
-
|
|
286
269
|
// On unmount, destroy all lasso related entities
|
|
287
270
|
$effect(() => {
|
|
288
271
|
return () => {
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
import { getTriangleBoxesFromIndices, getTriangleFromIndex, raycast } from './utils'
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
|
-
|
|
19
|
+
enabled?: boolean
|
|
20
|
+
selecting?: boolean
|
|
20
21
|
debug?: boolean
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
let {
|
|
24
|
+
let { enabled = false, selecting = false, debug = false }: Props = $props()
|
|
24
25
|
|
|
25
26
|
const world = useWorld()
|
|
26
27
|
const controls = useCameraControls()
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
let drawing = false
|
|
38
39
|
|
|
39
40
|
const onpointerdown = (event: PointerEvent) => {
|
|
40
|
-
if (!event.shiftKey
|
|
41
|
+
if (!selecting && !event.shiftKey) return
|
|
41
42
|
|
|
42
43
|
const { x, y } = raycast(event, camera.current)
|
|
43
44
|
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const onpointermove = (event: PointerEvent) => {
|
|
63
|
-
if (!drawing
|
|
64
|
+
if (!drawing) return
|
|
64
65
|
|
|
65
66
|
let lasso = world.query(selectionTraits.Lasso).at(-1)
|
|
66
67
|
|
|
@@ -100,13 +101,13 @@
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
const onpointerleave = () => {
|
|
103
|
-
if (!drawing
|
|
104
|
+
if (!drawing) return
|
|
104
105
|
|
|
105
106
|
onpointerup()
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
const onpointerup = () => {
|
|
109
|
-
if (!drawing
|
|
110
|
+
if (!drawing) return
|
|
110
111
|
|
|
111
112
|
drawing = false
|
|
112
113
|
|
|
@@ -225,6 +226,8 @@
|
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
$effect(() => {
|
|
229
|
+
if (!enabled) return
|
|
230
|
+
|
|
228
231
|
globalThis.addEventListener('keydown', onkeydown)
|
|
229
232
|
globalThis.addEventListener('keyup', onkeyup)
|
|
230
233
|
dom.addEventListener('pointerdown', onpointerdown)
|
|
@@ -244,26 +247,6 @@
|
|
|
244
247
|
|
|
245
248
|
const lassos = useQuery(selectionTraits.Lasso)
|
|
246
249
|
|
|
247
|
-
$effect(() => {
|
|
248
|
-
if (!controls.current) return
|
|
249
|
-
|
|
250
|
-
const currentControls = controls.current
|
|
251
|
-
|
|
252
|
-
if ('minPolarAngle' in currentControls) {
|
|
253
|
-
const { minPolarAngle, maxPolarAngle } = currentControls
|
|
254
|
-
|
|
255
|
-
// Locks the camera to top down while this component is mounted
|
|
256
|
-
currentControls.polarAngle = 0
|
|
257
|
-
currentControls.minPolarAngle = 0
|
|
258
|
-
currentControls.maxPolarAngle = 0
|
|
259
|
-
|
|
260
|
-
return () => {
|
|
261
|
-
currentControls.minPolarAngle = minPolarAngle
|
|
262
|
-
currentControls.maxPolarAngle = maxPolarAngle
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
|
|
267
250
|
// On unmount, destroy all lasso related entities
|
|
268
251
|
$effect(() => {
|
|
269
252
|
return () => {
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
interface Props {
|
|
20
20
|
/** Whether to auto-enable lasso mode when the component mounts */
|
|
21
21
|
enabled?: boolean
|
|
22
|
+
|
|
23
|
+
/** Allow manually going into selection state */
|
|
24
|
+
selecting?: boolean
|
|
25
|
+
|
|
22
26
|
// TODO: remove once a Selected trait exists
|
|
23
27
|
autoSelectNewEntities?: boolean
|
|
24
28
|
children?: Snippet
|
|
@@ -26,7 +30,12 @@
|
|
|
26
30
|
|
|
27
31
|
type SelectionType = 'lasso' | 'ellipse'
|
|
28
32
|
|
|
29
|
-
let {
|
|
33
|
+
let {
|
|
34
|
+
enabled = false,
|
|
35
|
+
selecting = false,
|
|
36
|
+
autoSelectNewEntities = false,
|
|
37
|
+
children,
|
|
38
|
+
}: Props = $props()
|
|
30
39
|
|
|
31
40
|
const { dom } = useThrelte()
|
|
32
41
|
const world = useWorld()
|
|
@@ -113,7 +122,13 @@
|
|
|
113
122
|
</Portal>
|
|
114
123
|
|
|
115
124
|
{#if isSelectionMode && rect.height > 0 && rect.width > 0}
|
|
116
|
-
<Ellipse
|
|
117
|
-
|
|
125
|
+
<Ellipse
|
|
126
|
+
enabled={selectionType === 'ellipse'}
|
|
127
|
+
{selecting}
|
|
128
|
+
/>
|
|
129
|
+
<Lasso
|
|
130
|
+
enabled={selectionType === 'lasso'}
|
|
131
|
+
{selecting}
|
|
132
|
+
/>
|
|
118
133
|
{@render children?.()}
|
|
119
134
|
{/if}
|
|
@@ -2,6 +2,8 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
interface Props {
|
|
3
3
|
/** Whether to auto-enable lasso mode when the component mounts */
|
|
4
4
|
enabled?: boolean;
|
|
5
|
+
/** Allow manually going into selection state */
|
|
6
|
+
selecting?: boolean;
|
|
5
7
|
autoSelectNewEntities?: boolean;
|
|
6
8
|
children?: Snippet;
|
|
7
9
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useCameraControls } from '../../hooks/useControls.svelte'
|
|
3
|
+
|
|
4
|
+
const controls = useCameraControls()
|
|
5
|
+
|
|
6
|
+
$effect(() => {
|
|
7
|
+
if (!controls.current) return
|
|
8
|
+
|
|
9
|
+
const currentControls = controls.current
|
|
10
|
+
|
|
11
|
+
if ('minPolarAngle' in currentControls) {
|
|
12
|
+
const { minPolarAngle, maxPolarAngle } = currentControls
|
|
13
|
+
|
|
14
|
+
// Locks the camera to top down while this component is mounted
|
|
15
|
+
currentControls.polarAngle = 0
|
|
16
|
+
currentControls.minPolarAngle = 0
|
|
17
|
+
currentControls.maxPolarAngle = 0
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
currentControls.minPolarAngle = minPolarAngle
|
|
21
|
+
currentControls.maxPolarAngle = maxPolarAngle
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
</script>
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * as selectionTraits from './Selection/traits';
|
|
|
3
3
|
export * as selectionRelations from './Selection/relations';
|
|
4
4
|
export { useSelectionPlugin } from './Selection/useSelectionPlugin.svelte';
|
|
5
5
|
export { default as MeasureTool } from './MeasureTool/MeasureTool.svelte';
|
|
6
|
+
export { default as TopDownLock } from './TopDownLock/TopDownLock.svelte';
|
|
6
7
|
export { default as DrawService } from './DrawService/DrawService.svelte';
|
|
7
8
|
export { default as Skybox } from './Skybox/Skybox.svelte';
|
|
8
9
|
export { default as Debug } from './Debug/Debug.svelte';
|
package/dist/plugins/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * as selectionTraits from './Selection/traits';
|
|
|
4
4
|
export * as selectionRelations from './Selection/relations';
|
|
5
5
|
export { useSelectionPlugin } from './Selection/useSelectionPlugin.svelte';
|
|
6
6
|
export { default as MeasureTool } from './MeasureTool/MeasureTool.svelte';
|
|
7
|
+
export { default as TopDownLock } from './TopDownLock/TopDownLock.svelte';
|
|
7
8
|
// DrawService
|
|
8
9
|
export { default as DrawService } from './DrawService/DrawService.svelte';
|
|
9
10
|
// Skybox
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.5",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@testing-library/svelte": "5.2.8",
|
|
31
31
|
"@testing-library/user-event": "^14.6.1",
|
|
32
32
|
"@threlte/core": "8.5.14",
|
|
33
|
-
"@threlte/extras": "9.
|
|
33
|
+
"@threlte/extras": "9.21.0",
|
|
34
34
|
"@threlte/rapier": "3.4.1",
|
|
35
35
|
"@threlte/xr": "1.6.0",
|
|
36
36
|
"@types/bun": "1.2.21",
|