@viamrobotics/motion-tools 0.19.1 → 1.0.2

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.
Files changed (137) hide show
  1. package/README.md +56 -26
  2. package/dist/FrameConfigUpdater.svelte.d.ts +11 -17
  3. package/dist/FrameConfigUpdater.svelte.js +109 -109
  4. package/dist/WorldObject.svelte.js +2 -15
  5. package/dist/common/v1/common_pb.d.ts +950 -0
  6. package/dist/common/v1/common_pb.js +1399 -0
  7. package/dist/components/App.svelte +37 -21
  8. package/dist/components/App.svelte.d.ts +1 -0
  9. package/dist/components/BatchedArrows.svelte +102 -0
  10. package/dist/components/BatchedArrows.svelte.d.ts +3 -0
  11. package/dist/components/CameraControls.svelte +2 -3
  12. package/dist/components/Details.svelte +364 -365
  13. package/dist/components/Entities.svelte +73 -0
  14. package/dist/components/{WorldObjects.svelte.d.ts → Entities.svelte.d.ts} +3 -3
  15. package/dist/components/FileDrop.svelte +9 -23
  16. package/dist/components/Focus.svelte +2 -3
  17. package/dist/components/Frame.svelte +41 -22
  18. package/dist/components/Frame.svelte.d.ts +4 -6
  19. package/dist/components/GLTF.svelte +36 -0
  20. package/dist/components/GLTF.svelte.d.ts +11 -0
  21. package/dist/components/Geometry2.svelte +201 -0
  22. package/dist/components/Geometry2.svelte.d.ts +18 -0
  23. package/dist/components/KeyboardControls.svelte +3 -3
  24. package/dist/components/Line.svelte +10 -13
  25. package/dist/components/Line.svelte.d.ts +2 -2
  26. package/dist/components/LiveUpdatesBanner.svelte +51 -15
  27. package/dist/components/MeasureTool.svelte +4 -5
  28. package/dist/components/Pointcloud.svelte +27 -14
  29. package/dist/components/Pointcloud.svelte.d.ts +2 -2
  30. package/dist/components/PointerMissBox.svelte +3 -3
  31. package/dist/components/Pose.svelte +31 -6
  32. package/dist/components/Pose.svelte.d.ts +2 -2
  33. package/dist/components/Scene.svelte +7 -6
  34. package/dist/components/SceneProviders.svelte +0 -6
  35. package/dist/components/Selected.svelte +22 -16
  36. package/dist/components/StaticGeometries.svelte +51 -27
  37. package/dist/components/Tree/Tree.svelte +28 -22
  38. package/dist/components/Tree/Tree.svelte.d.ts +2 -3
  39. package/dist/components/Tree/TreeContainer.svelte +72 -40
  40. package/dist/components/Tree/Widgets.svelte +2 -5
  41. package/dist/components/Tree/buildTree.d.ts +3 -6
  42. package/dist/components/Tree/buildTree.js +19 -39
  43. package/dist/components/__tests__/__fixtures__/entity.d.ts +2 -0
  44. package/dist/components/__tests__/__fixtures__/entity.js +20 -0
  45. package/dist/components/__tests__/__fixtures__/resource.d.ts +17 -0
  46. package/dist/components/__tests__/__fixtures__/resource.js +13 -0
  47. package/dist/components/dashboard/Dashboard.svelte +5 -3
  48. package/dist/components/dashboard/Dashboard.svelte.d.ts +7 -2
  49. package/dist/components/widgets/ArmPositions.svelte +19 -7
  50. package/dist/draw/v1/drawing_pb.d.ts +341 -0
  51. package/dist/draw/v1/drawing_pb.js +417 -0
  52. package/dist/draw/v1/metadata_pb.d.ts +23 -0
  53. package/dist/draw/v1/metadata_pb.js +39 -0
  54. package/dist/draw/v1/scene_pb.d.ts +230 -0
  55. package/dist/draw/v1/scene_pb.js +298 -0
  56. package/dist/draw/v1/snapshot_pb.d.ts +42 -0
  57. package/dist/draw/v1/snapshot_pb.js +61 -0
  58. package/dist/draw/v1/transforms_pb.d.ts +23 -0
  59. package/dist/draw/v1/transforms_pb.js +39 -0
  60. package/dist/ecs/index.d.ts +4 -0
  61. package/dist/ecs/index.js +4 -0
  62. package/dist/ecs/traits.d.ts +128 -0
  63. package/dist/ecs/traits.js +81 -0
  64. package/dist/ecs/useQuery.svelte.d.ts +4 -0
  65. package/dist/ecs/useQuery.svelte.js +49 -0
  66. package/dist/ecs/useTrait.svelte.d.ts +19 -0
  67. package/dist/ecs/useTrait.svelte.js +40 -0
  68. package/dist/ecs/useWorld.d.ts +4 -0
  69. package/dist/ecs/useWorld.js +10 -0
  70. package/dist/frame.d.ts +2 -0
  71. package/dist/frame.js +14 -0
  72. package/dist/geometry.js +6 -6
  73. package/dist/hooks/__tests__/fixtures/ResizableTestWrapper.svelte +41 -0
  74. package/dist/hooks/__tests__/fixtures/ResizableTestWrapper.svelte.d.ts +6 -0
  75. package/dist/hooks/use3DModels.svelte.js +6 -4
  76. package/dist/hooks/useDrawAPI.svelte.d.ts +0 -10
  77. package/dist/hooks/useDrawAPI.svelte.js +144 -267
  78. package/dist/hooks/useFramelessComponents.svelte.js +1 -1
  79. package/dist/hooks/useFrames.svelte.d.ts +6 -2
  80. package/dist/hooks/useFrames.svelte.js +144 -68
  81. package/dist/hooks/useGeometries.svelte.d.ts +0 -2
  82. package/dist/hooks/useGeometries.svelte.js +49 -25
  83. package/dist/hooks/useObjectEvents.svelte.d.ts +3 -2
  84. package/dist/hooks/useObjectEvents.svelte.js +11 -7
  85. package/dist/hooks/usePartConfig.svelte.d.ts +1 -1
  86. package/dist/hooks/usePartConfig.svelte.js +2 -1
  87. package/dist/hooks/usePointclouds.svelte.d.ts +0 -2
  88. package/dist/hooks/usePointclouds.svelte.js +52 -21
  89. package/dist/hooks/usePose.svelte.js +15 -7
  90. package/dist/hooks/useResizable.svelte.d.ts +12 -0
  91. package/dist/hooks/useResizable.svelte.js +45 -0
  92. package/dist/hooks/useResourceByName.svelte.js +8 -5
  93. package/dist/hooks/useSelection.svelte.d.ts +13 -23
  94. package/dist/hooks/useSelection.svelte.js +45 -65
  95. package/dist/hooks/useVisibility.svelte.d.ts +2 -1
  96. package/dist/hooks/useWeblabs.svelte.d.ts +0 -1
  97. package/dist/hooks/useWeblabs.svelte.js +0 -1
  98. package/dist/hooks/useWorldState.svelte.d.ts +9 -0
  99. package/dist/hooks/useWorldState.svelte.js +158 -107
  100. package/dist/lib.d.ts +1 -0
  101. package/dist/lib.js +2 -0
  102. package/dist/three/BatchedArrow.d.ts +2 -3
  103. package/dist/three/BatchedArrow.js +3 -11
  104. package/dist/three/CapsuleGeometry.d.ts +1 -1
  105. package/dist/three/CapsuleGeometry.js +3 -1
  106. package/dist/transform.js +0 -15
  107. package/package.json +12 -7
  108. package/dist/components/WorldObject.svelte +0 -28
  109. package/dist/components/WorldObject.svelte.d.ts +0 -11
  110. package/dist/components/WorldObjects.svelte +0 -159
  111. package/dist/components/WorldState.svelte +0 -92
  112. package/dist/components/WorldState.svelte.d.ts +0 -7
  113. package/dist/components/__tests__/__fixtures__/worldObject.svelte.d.ts +0 -2
  114. package/dist/components/__tests__/__fixtures__/worldObject.svelte.js +0 -35
  115. package/dist/components/portal/Portal.svelte +0 -25
  116. package/dist/components/portal/Portal.svelte.d.ts +0 -8
  117. package/dist/components/portal/PortalTarget.svelte +0 -18
  118. package/dist/components/portal/PortalTarget.svelte.d.ts +0 -6
  119. package/dist/components/portal/index.d.ts +0 -2
  120. package/dist/components/portal/index.js +0 -2
  121. package/dist/components/portal/usePortalContext.svelte.d.ts +0 -5
  122. package/dist/components/portal/usePortalContext.svelte.js +0 -5
  123. package/dist/hooks/useArrows.svelte.d.ts +0 -3
  124. package/dist/hooks/useArrows.svelte.js +0 -9
  125. package/dist/hooks/useDraggable.svelte.d.ts +0 -10
  126. package/dist/hooks/useDraggable.svelte.js +0 -36
  127. package/dist/hooks/useObjects.svelte.d.ts +0 -7
  128. package/dist/hooks/useObjects.svelte.js +0 -35
  129. package/dist/hooks/usePersistentUUIDs.svelte.d.ts +0 -5
  130. package/dist/hooks/usePersistentUUIDs.svelte.js +0 -13
  131. package/dist/hooks/useResourceByName.svelte.d.ts +0 -7
  132. package/dist/hooks/useStaticGeometries.svelte.d.ts +0 -9
  133. package/dist/hooks/useStaticGeometries.svelte.js +0 -47
  134. package/dist/workers/worldStateWorker.d.ts +0 -1
  135. package/dist/workers/worldStateWorker.js +0 -114
  136. package/dist/world-state-messages.d.ts +0 -23
  137. package/dist/world-state-messages.js +0 -1
@@ -1,159 +0,0 @@
1
- <script lang="ts">
2
- import { T } from '@threlte/core'
3
- import { Portal, PortalTarget } from './portal'
4
- import { useFrames } from '../hooks/useFrames.svelte'
5
- import { useGeometries } from '../hooks/useGeometries.svelte'
6
- import { usePointClouds } from '../hooks/usePointclouds.svelte'
7
- import { useDrawAPI } from '../hooks/useDrawAPI.svelte'
8
- import { useWorldStates } from '../hooks/useWorldState.svelte'
9
- import { useArrows } from '../hooks/useArrows.svelte'
10
- import Pose from './Pose.svelte'
11
- import Frame from './Frame.svelte'
12
- import Line from './Line.svelte'
13
- import Pointcloud from './Pointcloud.svelte'
14
- import Model from './WorldObject.svelte'
15
- import Label from './Label.svelte'
16
- import WorldState from './WorldState.svelte'
17
- import { determinePose } from '../WorldObject.svelte'
18
- import { useWeblabs } from '../hooks/useWeblabs.svelte'
19
- import type { WorldObject } from '../WorldObject.svelte'
20
- import type { Pose as ViamPose } from '@viamrobotics/sdk'
21
- import { WEBLABS_EXPERIMENTS } from '../hooks/useWeblabs.svelte'
22
- const points = usePointClouds()
23
- const drawAPI = useDrawAPI()
24
- const frames = useFrames()
25
- const geometries = useGeometries()
26
- const worldStates = useWorldStates()
27
- const batchedArrow = useArrows()
28
- const weblabs = useWeblabs()
29
-
30
- const weblabedDeterminePose = (object: WorldObject, pose: ViamPose | undefined) => {
31
- if (weblabs.isActive(WEBLABS_EXPERIMENTS.MOTION_TOOLS_EDIT_FRAME)) {
32
- return determinePose(object, pose)
33
- }
34
- return pose ?? object.pose
35
- }
36
- </script>
37
-
38
- {#each frames.current as object (object.uuid)}
39
- <Pose
40
- name={object.name}
41
- parent={object.referenceFrame}
42
- >
43
- {#snippet children({ pose })}
44
- {@const framePose = weblabedDeterminePose(object, pose)}
45
- <Portal id={object.referenceFrame}>
46
- <Frame
47
- uuid={object.uuid}
48
- name={object.name}
49
- pose={framePose}
50
- geometry={object.geometry}
51
- metadata={object.metadata}
52
- >
53
- <PortalTarget id={object.name} />
54
- <Label text={object.name} />
55
- </Frame>
56
- </Portal>
57
- {/snippet}
58
- </Pose>
59
- {/each}
60
-
61
- {#each geometries.current as object (object.uuid)}
62
- <Portal id={object.referenceFrame}>
63
- <Frame
64
- uuid={object.uuid}
65
- name={object.name}
66
- pose={object.pose}
67
- geometry={object.geometry}
68
- metadata={object.metadata}
69
- >
70
- <PortalTarget id={object.name} />
71
- <Label text={object.name} />
72
- </Frame>
73
- </Portal>
74
- {/each}
75
-
76
- {#each worldStates.names as { name } (name)}
77
- <WorldState worldObjects={worldStates.current[name].worldObjects} />
78
- {/each}
79
-
80
- {#each points.current as object (object.uuid)}
81
- <Portal id={object.referenceFrame}>
82
- <Pointcloud {object}>
83
- <Label text={object.name} />
84
- </Pointcloud>
85
- </Portal>
86
- {/each}
87
-
88
- {#each drawAPI.frames as object (object.uuid)}
89
- <Portal id={object.referenceFrame}>
90
- <Frame
91
- uuid={object.uuid}
92
- name={object.name}
93
- pose={object.pose}
94
- geometry={object.geometry}
95
- metadata={object.metadata}
96
- >
97
- <PortalTarget id={object.name} />
98
- <Label text={object.name} />
99
- </Frame>
100
- </Portal>
101
- {/each}
102
-
103
- {#each drawAPI.points as object (object.uuid)}
104
- <Portal id={object.referenceFrame}>
105
- <Pointcloud {object}>
106
- <Label text={object.name} />
107
- </Pointcloud>
108
- </Portal>
109
- {/each}
110
-
111
- <T
112
- name={batchedArrow.object3d.name}
113
- is={batchedArrow.object3d}
114
- dispose={false}
115
- bvh={{ enabled: false }}
116
- />
117
-
118
- {#each drawAPI.meshes as object (object.uuid)}
119
- <Portal id={object.referenceFrame}>
120
- <Frame
121
- uuid={object.uuid}
122
- name={object.name}
123
- pose={object.pose}
124
- geometry={object.geometry}
125
- metadata={object.metadata}
126
- >
127
- <PortalTarget id={object.name} />
128
- <Label text={object.name} />
129
- </Frame>
130
- </Portal>
131
- {/each}
132
-
133
- {#each drawAPI.nurbs as object (object.uuid)}
134
- <Portal id={object.referenceFrame}>
135
- <Frame
136
- uuid={object.uuid}
137
- name={object.name}
138
- pose={object.pose}
139
- geometry={object.geometry}
140
- metadata={object.metadata}
141
- >
142
- <PortalTarget id={object.name} />
143
- <Label text={object.name} />
144
- </Frame>
145
- </Portal>
146
- {/each}
147
-
148
- {#each drawAPI.models as object (object.uuid)}
149
- <Model {object}>
150
- <PortalTarget id={object.name} />
151
- <Label text={object.name} />
152
- </Model>
153
- {/each}
154
-
155
- {#each drawAPI.lines as object (object.uuid)}
156
- <Line {object}>
157
- <Label text={object.name} />
158
- </Line>
159
- {/each}
@@ -1,92 +0,0 @@
1
- <script lang="ts">
2
- import { Color, Vector3 } from 'three'
3
-
4
- import Frame from './Frame.svelte'
5
- import Label from './Label.svelte'
6
- import Portal from './portal/Portal.svelte'
7
- import PortalTarget from './portal/PortalTarget.svelte'
8
- import { WorldObject } from '../WorldObject.svelte'
9
- import { poseToDirection } from '../transform'
10
- import { BatchedArrow } from '../three/BatchedArrow'
11
- import { T } from '@threlte/core'
12
-
13
- interface Props {
14
- worldObjects: WorldObject[]
15
- }
16
-
17
- let { worldObjects }: Props = $props()
18
-
19
- const currentArrows: Record<string, { id: number; arrow: WorldObject }> = {}
20
- const arrowBatches = $state<Record<string, BatchedArrow>>({})
21
-
22
- const arrows = $derived(worldObjects.filter((object) => object.metadata?.shape === 'arrow'))
23
- const objects = $derived(worldObjects.filter((object) => object.metadata?.shape !== 'arrow'))
24
-
25
- const getArrows = () => ({ ...currentArrows })
26
- const getArrow = (referenceFrame: string, uuid: string) =>
27
- currentArrows[`${referenceFrame}:${uuid}`]
28
-
29
- const removeArrow = (referenceFrame: string, uuid: string) => {
30
- delete currentArrows[`${referenceFrame}:${uuid}`]
31
- }
32
-
33
- const setArrow = (arrow: WorldObject) => {
34
- const referenceFrame = arrow.referenceFrame ?? 'world'
35
- const currentArrow = getArrow(referenceFrame, arrow.uuid)
36
- const color = arrow.metadata?.color ?? new Color('yellow')
37
- const direction = poseToDirection(arrow.pose)
38
- const position = new Vector3(arrow.pose.x, arrow.pose.y, arrow.pose.z)
39
-
40
- arrowBatches[referenceFrame] ??= new BatchedArrow()
41
- const batchedArrow = arrowBatches[referenceFrame]
42
-
43
- if (currentArrow) {
44
- batchedArrow.updateArrow(currentArrow.id, direction, position, 0.1, color, true)
45
- currentArrows[`${referenceFrame}:${arrow.uuid}`] = { id: currentArrow.id, arrow }
46
- } else {
47
- const id = batchedArrow.addArrow(direction, position, 0.1, color, true)
48
- currentArrows[`${referenceFrame}:${arrow.uuid}`] = { id, arrow }
49
- }
50
- }
51
-
52
- $effect(() => {
53
- const toRemove = getArrows()
54
- arrows.forEach((arrow) => {
55
- setArrow(arrow)
56
- const referenceFrame = arrow.referenceFrame ?? 'world'
57
- delete toRemove[`${referenceFrame}:${arrow.uuid}`]
58
- })
59
-
60
- Object.values(toRemove).forEach(({ id, arrow }) => {
61
- const referenceFrame = arrow.referenceFrame ?? 'world'
62
- arrowBatches[referenceFrame].removeArrow(id)
63
- removeArrow(referenceFrame, arrow.uuid)
64
- })
65
- })
66
- </script>
67
-
68
- {#each Object.entries(arrowBatches) as [referenceFrame, batch] (referenceFrame)}
69
- <Portal id={referenceFrame}>
70
- <T
71
- name={batch.object3d.name}
72
- is={batch.object3d}
73
- dispose={false}
74
- bvh={{ enabled: false }}
75
- />
76
- </Portal>
77
- {/each}
78
-
79
- {#each objects as object (object.uuid)}
80
- <Portal id={object.referenceFrame}>
81
- <Frame
82
- uuid={object.uuid}
83
- name={object.name}
84
- pose={object.pose}
85
- geometry={object.geometry}
86
- metadata={object.metadata}
87
- >
88
- <PortalTarget id={object.name} />
89
- <Label text={object.name} />
90
- </Frame>
91
- </Portal>
92
- {/each}
@@ -1,7 +0,0 @@
1
- import { WorldObject } from '../WorldObject.svelte';
2
- interface Props {
3
- worldObjects: WorldObject[];
4
- }
5
- declare const WorldState: import("svelte").Component<Props, {}, "">;
6
- type WorldState = ReturnType<typeof WorldState>;
7
- export default WorldState;
@@ -1,2 +0,0 @@
1
- import { WorldObject } from '../../../WorldObject.svelte';
2
- export declare const createWorldObjectFixture: () => WorldObject<import("../../../WorldObject.svelte").Geometries>;
@@ -1,35 +0,0 @@
1
- import { WorldObject } from '../../../WorldObject.svelte';
2
- export const createWorldObjectFixture = () => {
3
- const object = new WorldObject();
4
- object.name = 'Test Object';
5
- object.uuid = '1234-5678';
6
- object.referenceFrame = 'parent_frame';
7
- object.pose = {
8
- x: 10,
9
- y: 20,
10
- z: 30,
11
- oX: 0.1,
12
- oY: 0.2,
13
- oZ: 0.3,
14
- theta: 0.4,
15
- };
16
- object.geometry = {
17
- label: 'my geometry',
18
- geometryType: {
19
- case: 'box',
20
- value: {
21
- dimsMm: { x: 10, y: 20, z: 30 },
22
- },
23
- },
24
- };
25
- object.localEditedPose = {
26
- x: 10,
27
- y: 20,
28
- z: 30,
29
- oX: 0.1,
30
- oY: 0.2,
31
- oZ: 0.3,
32
- theta: 0.4,
33
- };
34
- return object;
35
- };
@@ -1,25 +0,0 @@
1
- <script lang="ts">
2
- import type { Snippet } from 'svelte'
3
- import { usePortalContext } from './usePortalContext.svelte'
4
- import { SvelteSet } from 'svelte/reactivity'
5
-
6
- interface Props {
7
- id?: string
8
- children?: Snippet
9
- }
10
-
11
- let { id = 'default', children }: Props = $props()
12
-
13
- const portals = usePortalContext()
14
-
15
- $effect.pre(() => {
16
- if (!children) return
17
-
18
- if (!portals.has(id)) {
19
- portals.set(id, new SvelteSet())
20
- }
21
-
22
- portals.get(id)?.add(children)
23
- return () => portals.get(id)?.delete(children)
24
- })
25
- </script>
@@ -1,8 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- interface Props {
3
- id?: string;
4
- children?: Snippet;
5
- }
6
- declare const Portal: import("svelte").Component<Props, {}, "">;
7
- type Portal = ReturnType<typeof Portal>;
8
- export default Portal;
@@ -1,18 +0,0 @@
1
- <script lang="ts">
2
- import { usePortalContext } from './usePortalContext.svelte'
3
-
4
- interface Props {
5
- id?: string
6
- }
7
-
8
- let { id = 'default' }: Props = $props()
9
-
10
- const portals = usePortalContext()
11
- const childrenArray = $derived(portals.get(id))
12
- </script>
13
-
14
- {#if childrenArray !== undefined}
15
- {#each childrenArray as children (children)}
16
- {@render children()}
17
- {/each}
18
- {/if}
@@ -1,6 +0,0 @@
1
- interface Props {
2
- id?: string;
3
- }
4
- declare const PortalTarget: import("svelte").Component<Props, {}, "">;
5
- type PortalTarget = ReturnType<typeof PortalTarget>;
6
- export default PortalTarget;
@@ -1,2 +0,0 @@
1
- export { default as Portal } from './Portal.svelte';
2
- export { default as PortalTarget } from './PortalTarget.svelte';
@@ -1,2 +0,0 @@
1
- export { default as Portal } from './Portal.svelte';
2
- export { default as PortalTarget } from './PortalTarget.svelte';
@@ -1,5 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- import { SvelteMap, SvelteSet } from 'svelte/reactivity';
3
- type PortalContext = SvelteMap<string, SvelteSet<Snippet>>;
4
- export declare const usePortalContext: () => PortalContext;
5
- export {};
@@ -1,5 +0,0 @@
1
- import { SvelteMap, SvelteSet } from 'svelte/reactivity';
2
- const context = new SvelteMap();
3
- export const usePortalContext = () => {
4
- return context;
5
- };
@@ -1,3 +0,0 @@
1
- import { BatchedArrow } from '../lib';
2
- export declare const provideArrows: () => void;
3
- export declare const useArrows: () => BatchedArrow;
@@ -1,9 +0,0 @@
1
- import { BatchedArrow } from '../lib';
2
- import { getContext, setContext } from 'svelte';
3
- const key = Symbol('arrow-context');
4
- export const provideArrows = () => {
5
- setContext(key, new BatchedArrow());
6
- };
7
- export const useArrows = () => {
8
- return getContext(key);
9
- };
@@ -1,10 +0,0 @@
1
- interface Context {
2
- onDragStart: (event: MouseEvent) => void;
3
- onDragEnd: (event: MouseEvent) => void;
4
- readonly current: {
5
- x: number;
6
- y: number;
7
- };
8
- }
9
- export declare const useDraggable: (name: string) => Context;
10
- export {};
@@ -1,36 +0,0 @@
1
- import { get, set } from 'idb-keyval';
2
- export const useDraggable = (name) => {
3
- const down = { x: 0, y: 0 };
4
- const last = { x: 0, y: 0 };
5
- let translate = $state({ x: 0, y: 0 });
6
- const onDragMove = (event) => {
7
- translate.x = event.clientX - down.x + last.x;
8
- translate.y = event.clientY - down.y + last.y;
9
- };
10
- const onDragStart = (event) => {
11
- down.x = event.clientX;
12
- down.y = event.clientY;
13
- last.x = translate.x;
14
- last.y = translate.y;
15
- window.addEventListener('pointermove', onDragMove, { passive: true });
16
- };
17
- const onDragEnd = () => {
18
- set(`${name}-draggable`, $state.snapshot(translate));
19
- window.removeEventListener('pointermove', onDragMove);
20
- };
21
- get(`${name}-draggable`).then((response) => {
22
- if (response) {
23
- translate = response;
24
- }
25
- });
26
- $effect(() => {
27
- return () => window.removeEventListener('pointermove', onDragMove);
28
- });
29
- return {
30
- onDragStart,
31
- onDragEnd,
32
- get current() {
33
- return translate;
34
- },
35
- };
36
- };
@@ -1,7 +0,0 @@
1
- import type { WorldObject } from '../WorldObject.svelte';
2
- interface Context {
3
- current: WorldObject[];
4
- }
5
- export declare const provideObjects: () => void;
6
- export declare const useObjects: () => Context;
7
- export {};
@@ -1,35 +0,0 @@
1
- import { getContext, setContext } from 'svelte';
2
- import { useFrames } from './useFrames.svelte';
3
- import { useGeometries } from './useGeometries.svelte';
4
- import { useStaticGeometries } from './useStaticGeometries.svelte';
5
- import { useDrawAPI } from './useDrawAPI.svelte';
6
- import { usePointClouds } from './usePointclouds.svelte';
7
- const key = Symbol('objects-context');
8
- export const provideObjects = () => {
9
- const frames = useFrames();
10
- const geometries = useGeometries();
11
- const statics = useStaticGeometries();
12
- const drawAPI = useDrawAPI();
13
- const points = usePointClouds();
14
- const objects = $derived([
15
- ...frames.current,
16
- ...geometries.current,
17
- ...points.current,
18
- ...statics.current,
19
- ...drawAPI.frames,
20
- ...drawAPI.meshes,
21
- ...drawAPI.models,
22
- ...drawAPI.nurbs,
23
- ...drawAPI.points,
24
- ...drawAPI.lines,
25
- ...drawAPI.poses,
26
- ]);
27
- setContext(key, {
28
- get current() {
29
- return objects;
30
- },
31
- });
32
- };
33
- export const useObjects = () => {
34
- return getContext(key);
35
- };
@@ -1,5 +0,0 @@
1
- import type { WorldObject } from '../WorldObject.svelte';
2
- export declare const usePersistentUUIDs: () => {
3
- uuids: Map<string, string>;
4
- updateUUIDs: (objects: WorldObject[]) => void;
5
- };
@@ -1,13 +0,0 @@
1
- export const usePersistentUUIDs = () => {
2
- const uuids = new Map();
3
- const updateUUIDs = (objects) => {
4
- for (const object of objects) {
5
- const ref = `${object.referenceFrame}-${object.name}`;
6
- if (uuids.has(ref) === false) {
7
- uuids.set(ref, object.uuid);
8
- }
9
- object.uuid = uuids.get(ref) ?? object.uuid;
10
- }
11
- };
12
- return { uuids, updateUUIDs };
13
- };
@@ -1,7 +0,0 @@
1
- import type { ResourceName } from '@viamrobotics/sdk';
2
- interface Context {
3
- current: Record<string, ResourceName | undefined>;
4
- }
5
- export declare const provideResourceByName: (partID: () => string) => void;
6
- export declare const useResourceByName: () => Context;
7
- export {};
@@ -1,9 +0,0 @@
1
- import { WorldObject } from '../WorldObject.svelte';
2
- interface Context {
3
- current: WorldObject[];
4
- add: () => void;
5
- remove: (name: string) => void;
6
- }
7
- export declare const provideStaticGeometries: () => void;
8
- export declare const useStaticGeometries: () => Context;
9
- export {};
@@ -1,47 +0,0 @@
1
- import { getContext, setContext } from 'svelte';
2
- import { get, set } from 'idb-keyval';
3
- import { Debounced } from 'runed';
4
- import { createGeometry } from '../geometry';
5
- import { WorldObject } from '../WorldObject.svelte';
6
- const key = Symbol('static-geometries-context');
7
- export const provideStaticGeometries = () => {
8
- const geometries = $state([]);
9
- let loaded = $state(false);
10
- const debounced = new Debounced(() => geometries, 500);
11
- get('static-geometries').then((response) => {
12
- if (Array.isArray(response)) {
13
- for (const json of response) {
14
- geometries.push(new WorldObject().fromJSON(json));
15
- }
16
- }
17
- loaded = true;
18
- });
19
- $effect(() => {
20
- if (!loaded)
21
- return;
22
- const results = [];
23
- for (const geometry of debounced.current) {
24
- results.push(geometry.toJSON());
25
- }
26
- set('static-geometries', results);
27
- });
28
- setContext(key, {
29
- get current() {
30
- return geometries;
31
- },
32
- add() {
33
- const object = new WorldObject(`custom geometry ${geometries.length + 1}`, undefined, undefined, createGeometry({
34
- case: 'box',
35
- value: { dimsMm: { x: 100, y: 100, z: 100 } },
36
- }));
37
- geometries.push(object);
38
- },
39
- remove(name) {
40
- const index = geometries.findIndex((geo) => geo.name === name);
41
- geometries.splice(index, 1);
42
- },
43
- });
44
- };
45
- export const useStaticGeometries = () => {
46
- return getContext(key);
47
- };
@@ -1 +0,0 @@
1
- export {};