@viamrobotics/motion-tools 0.6.0 → 0.6.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.
@@ -22,6 +22,7 @@
22
22
  import { useTransformControls } from '../hooks/useControls.svelte'
23
23
  import KeyboardControls from './KeyboardControls.svelte'
24
24
  import { useOrigin } from './xr/useOrigin.svelte'
25
+ import { useSettings } from '../hooks/useSettings.svelte'
25
26
 
26
27
  interface Props {
27
28
  children?: Snippet
@@ -39,6 +40,7 @@
39
40
  },
40
41
  })
41
42
 
43
+ const settings = useSettings()
42
44
  const focusedObject3d = useFocusedObject3d()
43
45
  const transformControls = useTransformControls()
44
46
  const origin = useOrigin()
@@ -81,15 +83,15 @@
81
83
 
82
84
  <Selected />
83
85
 
84
- {#if !$isPresenting}
86
+ {#if !$isPresenting && settings.current.grid}
85
87
  <Grid
86
88
  plane="xy"
87
89
  sectionColor="#333"
88
90
  infiniteGrid
89
- cellSize={0.5}
90
- sectionSize={10}
91
+ cellSize={settings.current.gridCellSize}
92
+ sectionSize={settings.current.gridSectionSize}
91
93
  fadeOrigin={new Vector3()}
92
- fadeDistance={25}
94
+ fadeDistance={settings.current.gridFadeDistance}
93
95
  />
94
96
  {/if}
95
97
  {/if}
@@ -23,6 +23,12 @@
23
23
 
24
24
  keys.onKeys('=', () => geometries.add())
25
25
  keys.onKeys('-', () => geometries.remove(selected.current ?? ''))
26
+
27
+ $effect(() => {
28
+ settings.current.transforming = geometries.current.some(
29
+ (geometry) => selected.current === geometry.uuid
30
+ )
31
+ })
26
32
  </script>
27
33
 
28
34
  {#each geometries.current as object (object.uuid)}
@@ -39,6 +45,9 @@
39
45
  <TransformControls
40
46
  object={ref}
41
47
  {mode}
48
+ translationSnap={settings.current.snapping ? 0.1 : undefined}
49
+ rotationSnap={settings.current.snapping ? Math.PI / 24 : undefined}
50
+ scaleSnap={settings.current.snapping ? 0.1 : undefined}
42
51
  onmouseDown={() => {
43
52
  transformControls.setActive(true)
44
53
  }}
@@ -1,9 +1,11 @@
1
1
  <script lang="ts">
2
- import { Select } from '@viamrobotics/prime-core'
2
+ import { Select, Switch, Input } from '@viamrobotics/prime-core'
3
3
  import RefreshRate from '../RefreshRate.svelte'
4
4
  import { useMotionClient } from '../../hooks/useMotionClient.svelte'
5
5
  import Drawer from './Drawer.svelte'
6
+ import { useSettings } from '../../hooks/useSettings.svelte'
6
7
 
8
+ const settings = useSettings()
7
9
  const motionClient = useMotionClient()
8
10
  </script>
9
11
 
@@ -11,7 +13,9 @@
11
13
  name="Settings"
12
14
  defaultOpen
13
15
  >
14
- <div class="flex flex-col gap-2 p-3">
16
+ <div class="flex h-100 flex-col gap-2 overflow-scroll p-3">
17
+ <h3 class="text-base"><strong>Refresh rates</strong></h3>
18
+
15
19
  <RefreshRate name="Frames">
16
20
  <option value="0">Do not fetch</option>
17
21
  <option value="1">Fetch on reconfigure</option>
@@ -20,8 +24,10 @@
20
24
  <RefreshRate name="Geometries" />
21
25
  <RefreshRate name="Poses" />
22
26
 
27
+ <h3 class="text-base"><strong>Motion</strong></h3>
28
+
23
29
  <label class="flex flex-col gap-1">
24
- Motion client
30
+ Client
25
31
  <Select
26
32
  onchange={(event: InputEvent) => {
27
33
  if (event.target instanceof HTMLSelectElement) {
@@ -35,5 +41,45 @@
35
41
  {/each}
36
42
  </Select>
37
43
  </label>
44
+
45
+ <h3 class="text-base"><strong>Grid</strong></h3>
46
+ <div class="flex flex-col gap-2.5">
47
+ <label class="flex items-center justify-between gap-2">
48
+ Enabled <Switch bind:on={settings.current.grid} />
49
+ </label>
50
+
51
+ <label class="flex items-center justify-between gap-2">
52
+ Cell size (m)
53
+
54
+ <div class="w-20">
55
+ <Input
56
+ bind:value={settings.current.gridCellSize}
57
+ on:keydown={(event) => event.stopImmediatePropagation()}
58
+ />
59
+ </div>
60
+ </label>
61
+
62
+ <label class="flex items-center justify-between gap-2">
63
+ Section size (m)
64
+
65
+ <div class="w-20">
66
+ <Input
67
+ bind:value={settings.current.gridSectionSize}
68
+ on:keydown={(event) => event.stopImmediatePropagation()}
69
+ />
70
+ </div>
71
+ </label>
72
+
73
+ <label class="flex items-center justify-between gap-2">
74
+ Fade distance (m)
75
+
76
+ <div class="w-20">
77
+ <Input
78
+ bind:value={settings.current.gridFadeDistance}
79
+ on:keydown={(event) => event.stopImmediatePropagation()}
80
+ />
81
+ </div>
82
+ </label>
83
+ </div>
38
84
  </div>
39
85
  </Drawer>
@@ -5,7 +5,7 @@
5
5
  icon: IconName
6
6
  active?: boolean
7
7
  description: string
8
- hotkey: string
8
+ hotkey?: string
9
9
  class?: string
10
10
  onclick?: () => void
11
11
  }
@@ -14,7 +14,7 @@
14
14
  icon,
15
15
  active = false,
16
16
  description,
17
- hotkey,
17
+ hotkey = '',
18
18
  class: className = '',
19
19
  onclick,
20
20
  }: Props = $props()
@@ -3,7 +3,7 @@ interface Props {
3
3
  icon: IconName;
4
4
  active?: boolean;
5
5
  description: string;
6
- hotkey: string;
6
+ hotkey?: string;
7
7
  class?: string;
8
8
  onclick?: () => void;
9
9
  }
@@ -5,44 +5,7 @@
5
5
  const settings = useSettings()
6
6
  </script>
7
7
 
8
- <div class="absolute top-2 flex w-full justify-center">
9
- <!-- transform -->
10
- <!-- <fieldset>
11
- <Button
12
- icon="cursor-move"
13
- active={$transformMode === TransformModes.TRANSLATE}
14
- description="Translate"
15
- hotkey="T"
16
- onclick={() => transformMode.set(TransformModes.TRANSLATE)}
17
- />
18
- <Button
19
- icon="sync"
20
- active={$transformMode === TransformModes.ROTATE}
21
- description="Rotate"
22
- hotkey="R"
23
- class="-my-px"
24
- onclick={() => transformMode.set(TransformModes.ROTATE)}
25
- />
26
- <Button
27
- icon="resize"
28
- active={$transformMode === TransformModes.SCALE}
29
- description="Scale"
30
- hotkey="S"
31
- onclick={() => transformMode.set(TransformModes.SCALE)}
32
- />
33
- </fieldset> -->
34
-
35
- <!-- snapping -->
36
- <!-- <fieldset>
37
- <Button
38
- icon={$snapMode ? 'magnet' : 'magnet-off'}
39
- active={$snapMode === true}
40
- description="Snapping"
41
- hotkey="Spacebar"
42
- onClick={() => snapMode.set(!$snapMode)}
43
- />
44
- </fieldset> -->
45
-
8
+ <div class="absolute top-2 flex w-full justify-center gap-2">
46
9
  <!-- camera view -->
47
10
  <fieldset class="flex">
48
11
  <Button
@@ -65,4 +28,51 @@
65
28
  }}
66
29
  />
67
30
  </fieldset>
31
+
32
+ <!-- transform -->
33
+ {#if settings.current.transforming}
34
+ <fieldset class="flex">
35
+ <Button
36
+ icon="cursor-move"
37
+ active={settings.current.transformMode === 'translate'}
38
+ description="Translate"
39
+ hotkey="1"
40
+ onclick={() => {
41
+ settings.current.transformMode = 'translate'
42
+ }}
43
+ />
44
+ <Button
45
+ icon="sync"
46
+ active={settings.current.transformMode === 'rotate'}
47
+ description="Rotate"
48
+ hotkey="2"
49
+ class="-ml-px"
50
+ onclick={() => {
51
+ settings.current.transformMode = 'rotate'
52
+ }}
53
+ />
54
+ <Button
55
+ icon="resize"
56
+ active={settings.current.transformMode === 'scale'}
57
+ description="Scale"
58
+ hotkey="3"
59
+ class="-ml-px"
60
+ onclick={() => {
61
+ settings.current.transformMode = 'scale'
62
+ }}
63
+ />
64
+ </fieldset>
65
+
66
+ <!-- snapping -->
67
+ <fieldset class="flex">
68
+ <Button
69
+ icon={settings.current.snapping ? 'magnet' : 'magnet-off'}
70
+ active={settings.current.snapping}
71
+ description="Snapping"
72
+ onclick={() => {
73
+ settings.current.snapping = !settings.current.snapping
74
+ }}
75
+ />
76
+ </fieldset>
77
+ {/if}
68
78
  </div>
@@ -1,6 +1,12 @@
1
1
  interface Settings {
2
2
  cameraMode: 'orthographic' | 'perspective';
3
+ transforming: boolean;
4
+ snapping: boolean;
3
5
  transformMode: 'translate' | 'rotate' | 'scale';
6
+ grid: boolean;
7
+ gridCellSize: number;
8
+ gridSectionSize: number;
9
+ gridFadeDistance: number;
4
10
  enableXR: boolean;
5
11
  }
6
12
  interface Context {
@@ -3,7 +3,13 @@ import { getContext, setContext } from 'svelte';
3
3
  const key = Symbol('dashboard-context');
4
4
  const defaults = () => ({
5
5
  cameraMode: 'perspective',
6
+ transforming: false,
7
+ snapping: false,
6
8
  transformMode: 'translate',
9
+ grid: true,
10
+ gridCellSize: 0.5,
11
+ gridSectionSize: 10,
12
+ gridFadeDistance: 25,
7
13
  enableXR: false,
8
14
  });
9
15
  export const provideSettings = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viamrobotics/motion-tools",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Motion visualization with Viam",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",