@viamrobotics/motion-tools 0.9.3 → 0.9.4
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/README.md +2 -1
- package/dist/components/App.svelte +15 -1
- package/dist/components/App.svelte.d.ts +1 -0
- package/dist/components/CameraControls.svelte +9 -1
- package/dist/components/SceneProviders.svelte +0 -2
- package/dist/components/Tree/Settings.svelte +3 -0
- package/dist/components/portal/usePortalContext.svelte.js +2 -5
- package/dist/hooks/useSettings.svelte.d.ts +4 -2
- package/dist/hooks/useSettings.svelte.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## motion-tools
|
|
2
2
|
|
|
3
|
-
`motion-tools`
|
|
3
|
+
`motion-tools` aims to provide a visualization interface for any spatial information using Viam's APIs. This typically means motion-related monitoring, testing, and debugging.
|
|
4
4
|
|
|
5
5
|
### Getting started
|
|
6
6
|
|
|
@@ -30,6 +30,7 @@ VITE_CONFIGS='
|
|
|
30
30
|
"signalingAddress": "https://app.viam.com:443"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
'
|
|
33
34
|
```
|
|
34
35
|
|
|
35
36
|
### Executing drawing commands
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte'
|
|
3
3
|
import { Canvas } from '@threlte/core'
|
|
4
|
+
import { SvelteQueryDevtools } from '@tanstack/svelte-query-devtools'
|
|
5
|
+
|
|
4
6
|
import Scene from './Scene.svelte'
|
|
5
7
|
import TreeContainer from './Tree/TreeContainer.svelte'
|
|
6
8
|
import Details from './Details.svelte'
|
|
@@ -10,19 +12,31 @@
|
|
|
10
12
|
import { createPartIDContext } from '../hooks/usePartID.svelte'
|
|
11
13
|
import Dashboard from './dashboard/Dashboard.svelte'
|
|
12
14
|
import { domPortal } from '../portal'
|
|
15
|
+
import { provideSettings } from '../hooks/useSettings.svelte'
|
|
13
16
|
|
|
14
17
|
interface Props {
|
|
15
18
|
partID?: string
|
|
19
|
+
enableKeybindings?: boolean
|
|
16
20
|
children?: Snippet
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
let { partID = '', children: appChildren }: Props = $props()
|
|
23
|
+
let { partID = '', enableKeybindings = true, children: appChildren }: Props = $props()
|
|
24
|
+
|
|
25
|
+
const settings = provideSettings()
|
|
26
|
+
|
|
27
|
+
$effect(() => {
|
|
28
|
+
settings.current.enableKeybindings = enableKeybindings
|
|
29
|
+
})
|
|
20
30
|
|
|
21
31
|
createPartIDContext(() => partID)
|
|
22
32
|
|
|
23
33
|
let root = $state.raw<HTMLElement>()
|
|
24
34
|
</script>
|
|
25
35
|
|
|
36
|
+
{#if settings.current.enableQueryDevtools}
|
|
37
|
+
<SvelteQueryDevtools initialIsOpen />
|
|
38
|
+
{/if}
|
|
39
|
+
|
|
26
40
|
<div
|
|
27
41
|
class="relative h-full w-full overflow-hidden"
|
|
28
42
|
bind:this={root}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { MathUtils } from 'three'
|
|
2
3
|
import { CameraControls, type CameraControlsRef, Gizmo } from '@threlte/extras'
|
|
3
4
|
import { useTransformControls } from '../hooks/useControls.svelte'
|
|
4
5
|
import KeyboardControls from './KeyboardControls.svelte'
|
|
5
6
|
import Portal from './portal/Portal.svelte'
|
|
6
7
|
import Button from './dashboard/Button.svelte'
|
|
7
8
|
import { useDrawAPI } from '../hooks/useDrawAPI.svelte'
|
|
9
|
+
import { useSettings } from '../hooks/useSettings.svelte'
|
|
8
10
|
|
|
11
|
+
const settings = useSettings()
|
|
9
12
|
const drawAPI = useDrawAPI()
|
|
10
13
|
const transformControls = useTransformControls()
|
|
11
14
|
|
|
15
|
+
const enableKeybindings = $derived(settings.current.enableKeybindings)
|
|
16
|
+
|
|
12
17
|
let ref = $state.raw<CameraControlsRef>()
|
|
13
18
|
|
|
14
19
|
$effect(() => {
|
|
@@ -22,6 +27,7 @@
|
|
|
22
27
|
|
|
23
28
|
$effect(() => {
|
|
24
29
|
if (ref) {
|
|
30
|
+
;(window as unknown as { MathUtils: typeof MathUtils }).MathUtils = MathUtils
|
|
25
31
|
;(window as unknown as { cameraControls: CameraControlsRef }).cameraControls = ref
|
|
26
32
|
}
|
|
27
33
|
})
|
|
@@ -45,7 +51,9 @@
|
|
|
45
51
|
enabled={!transformControls.active}
|
|
46
52
|
>
|
|
47
53
|
{#snippet children({ ref }: { ref: CameraControlsRef })}
|
|
48
|
-
|
|
54
|
+
{#if enableKeybindings}
|
|
55
|
+
<KeyboardControls cameraControls={ref} />
|
|
56
|
+
{/if}
|
|
49
57
|
<Gizmo />
|
|
50
58
|
{/snippet}
|
|
51
59
|
</CameraControls>
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
import { provideObjects } from '../hooks/useObjects.svelte'
|
|
14
14
|
import { provideMotionClient } from '../hooks/useMotionClient.svelte'
|
|
15
15
|
import { provideLogs } from '../hooks/useLogs.svelte'
|
|
16
|
-
import { provideSettings } from '../hooks/useSettings.svelte'
|
|
17
16
|
import { provideOrigin } from './xr/useOrigin.svelte'
|
|
18
17
|
|
|
19
18
|
interface Props {
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
|
|
25
24
|
const partID = usePartID()
|
|
26
25
|
|
|
27
|
-
provideSettings()
|
|
28
26
|
provideTransformControls()
|
|
29
27
|
provideVisibility()
|
|
30
28
|
provideMachineSettings()
|
|
@@ -155,6 +155,9 @@
|
|
|
155
155
|
|
|
156
156
|
<h3 class="pt-2 text-sm"><strong>Misc</strong></h3>
|
|
157
157
|
<div class="flex flex-col gap-2.5">
|
|
158
|
+
<label class="flex items-center justify-between gap-2">
|
|
159
|
+
Query devtools <Switch bind:on={settings.current.enableQueryDevtools} />
|
|
160
|
+
</label>
|
|
158
161
|
<label class="flex items-center justify-between gap-2">
|
|
159
162
|
Render stats <Switch bind:on={settings.current.renderStats} />
|
|
160
163
|
</label>
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { useThrelteUserContext } from '@threlte/core';
|
|
2
1
|
import { SvelteMap, SvelteSet } from 'svelte/reactivity';
|
|
3
|
-
const
|
|
4
|
-
return new SvelteMap();
|
|
5
|
-
};
|
|
2
|
+
const context = new SvelteMap();
|
|
6
3
|
export const usePortalContext = () => {
|
|
7
|
-
return
|
|
4
|
+
return context;
|
|
8
5
|
};
|
|
@@ -11,14 +11,16 @@ interface Settings {
|
|
|
11
11
|
pointColor: string;
|
|
12
12
|
lineWidth: number;
|
|
13
13
|
lineDotSize: number;
|
|
14
|
-
enableXR: boolean;
|
|
15
14
|
enableMeasure: boolean;
|
|
16
15
|
enableLabels: boolean;
|
|
16
|
+
enableKeybindings: boolean;
|
|
17
|
+
enableQueryDevtools: boolean;
|
|
18
|
+
enableXR: boolean;
|
|
17
19
|
renderStats: boolean;
|
|
18
20
|
}
|
|
19
21
|
interface Context {
|
|
20
22
|
current: Settings;
|
|
21
23
|
}
|
|
22
|
-
export declare const provideSettings: () =>
|
|
24
|
+
export declare const provideSettings: () => Context;
|
|
23
25
|
export declare const useSettings: () => Context;
|
|
24
26
|
export {};
|
|
@@ -16,6 +16,8 @@ const defaults = () => ({
|
|
|
16
16
|
lineDotSize: 0.01,
|
|
17
17
|
enableMeasure: false,
|
|
18
18
|
enableLabels: false,
|
|
19
|
+
enableKeybindings: true,
|
|
20
|
+
enableQueryDevtools: false,
|
|
19
21
|
enableXR: false,
|
|
20
22
|
renderStats: false,
|
|
21
23
|
});
|
|
@@ -29,11 +31,13 @@ export const provideSettings = () => {
|
|
|
29
31
|
$effect(() => {
|
|
30
32
|
set('motion-tools-settings', $state.snapshot(settings));
|
|
31
33
|
});
|
|
32
|
-
|
|
34
|
+
const context = {
|
|
33
35
|
get current() {
|
|
34
36
|
return settings;
|
|
35
37
|
},
|
|
36
|
-
}
|
|
38
|
+
};
|
|
39
|
+
setContext(key, context);
|
|
40
|
+
return context;
|
|
37
41
|
};
|
|
38
42
|
export const useSettings = () => {
|
|
39
43
|
return getContext(key);
|