@viamrobotics/motion-tools 1.25.6 → 1.26.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.
@@ -119,7 +119,10 @@
119
119
  class="relative h-full w-full overflow-hidden dark:bg-white"
120
120
  bind:this={root}
121
121
  >
122
- <Canvas renderMode="on-demand">
122
+ <Canvas
123
+ renderMode="on-demand"
124
+ dpr={[1, 2]}
125
+ >
123
126
  <SceneProviders {cameraPose}>
124
127
  {#snippet children({ focus })}
125
128
  <Scene>
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import type { Entity } from 'koota'
2
3
  import type { Snippet } from 'svelte'
3
4
 
4
5
  import { useThrelte } from '@threlte/core'
@@ -6,6 +7,7 @@
6
7
  import { ElementRect } from 'runed'
7
8
 
8
9
  import DashboardButton from '../overlay/dashboard/Button.svelte'
10
+ import { useSelectedEntity } from '../../hooks/useSelection.svelte'
9
11
  import { useSettings } from '../../hooks/useSettings.svelte'
10
12
 
11
13
  import Popover from '../overlay/Popover.svelte'
@@ -17,18 +19,21 @@
17
19
  interface Props {
18
20
  /** Whether to auto-enable lasso mode when the component mounts */
19
21
  enabled?: boolean
22
+ // TODO: remove once a Selected trait exists
23
+ autoSelectNewEntities?: boolean
20
24
  children?: Snippet
21
25
  }
22
26
 
23
27
  type SelectionType = 'lasso' | 'ellipse'
24
28
 
25
- let { enabled = false, children }: Props = $props()
29
+ let { enabled = false, autoSelectNewEntities = false, children }: Props = $props()
26
30
 
27
31
  const { dom } = useThrelte()
28
32
  const settings = useSettings()
29
33
  const isSelectionMode = $derived(settings.current.interactionMode === 'select')
30
34
 
31
- provideSelectionPlugin()
35
+ const selectionPlugin = provideSelectionPlugin()
36
+ const selectedEntity = useSelectedEntity()
32
37
  let selectionType = $state<SelectionType>('lasso')
33
38
 
34
39
  $effect(() => {
@@ -43,6 +48,19 @@
43
48
  }
44
49
  })
45
50
 
51
+ let previousEntities: Entity[] = []
52
+ $effect(() => {
53
+ if (!autoSelectNewEntities) return
54
+
55
+ const current = selectionPlugin.current
56
+ const newEntities = current.filter((entity) => !previousEntities.includes(entity))
57
+ previousEntities = [...current]
58
+
59
+ const newest = newEntities.at(-1)
60
+ if (newest === undefined) return
61
+ selectedEntity.set(newest)
62
+ })
63
+
46
64
  const rect = new ElementRect(() => dom)
47
65
  </script>
48
66
 
@@ -2,6 +2,7 @@ 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
+ autoSelectNewEntities?: boolean;
5
6
  children?: Snippet;
6
7
  }
7
8
  declare const Tool: import("svelte").Component<Props, {}, "">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viamrobotics/motion-tools",
3
- "version": "1.25.6",
3
+ "version": "1.26.1",
4
4
  "description": "Motion visualization with Viam",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -25,10 +25,10 @@
25
25
  "@testing-library/jest-dom": "6.8.0",
26
26
  "@testing-library/svelte": "5.2.8",
27
27
  "@testing-library/user-event": "^14.6.1",
28
- "@threlte/core": "8.5.11",
29
- "@threlte/extras": "9.15.0",
28
+ "@threlte/core": "8.5.13",
29
+ "@threlte/extras": "9.15.2",
30
30
  "@threlte/rapier": "3.4.1",
31
- "@threlte/xr": "1.5.2",
31
+ "@threlte/xr": "1.6.0",
32
32
  "@types/bun": "1.2.21",
33
33
  "@types/earcut": "^3.0.0",
34
34
  "@types/lodash-es": "4.17.12",