@viamrobotics/motion-tools 0.9.1 → 0.9.3
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 +15 -3
- package/dist/components/Camera.svelte +7 -1
- package/dist/components/Camera.svelte.d.ts +1 -0
- package/dist/components/CameraControls.svelte +6 -0
- package/dist/components/PointerMissBox.svelte +34 -0
- package/dist/components/PointerMissBox.svelte.d.ts +18 -0
- package/dist/components/Scene.svelte +2 -0
- package/dist/components/Selected.svelte +37 -29
- package/dist/hooks/useObjectEvents.svelte.d.ts +0 -1
- package/dist/hooks/useObjectEvents.svelte.js +0 -6
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
##
|
|
1
|
+
## motion-tools
|
|
2
|
+
|
|
3
|
+
`motion-tools` is visualizer for motion-related monitoring, testing, and debugging.
|
|
4
|
+
|
|
5
|
+
### Getting started
|
|
2
6
|
|
|
3
7
|
1. [Install pnpm](https://pnpm.io/installation)
|
|
4
8
|
2. [Install bun](https://bun.sh/docs/installation)
|
|
5
9
|
3. Install dependencies: `pnpm i`
|
|
6
10
|
4. Run local app server: `pnpm dev`
|
|
7
11
|
|
|
12
|
+
### Running the visualizer
|
|
13
|
+
|
|
8
14
|
To visit the visualizer, go to `http://localhost:5173/`
|
|
9
15
|
|
|
10
|
-
Open the machine config page (bottom right) and enter in connection details to visualize a specific machine.
|
|
16
|
+
Open the machine config page (bottom right) and enter in connection details to visualize a specific machine. You can also add machine configs from an env file (see below).
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
### Env files for machine configs
|
|
13
19
|
|
|
14
20
|
To add a list of connection configs in an `.env.local` file, use the following format:
|
|
15
21
|
|
|
@@ -25,3 +31,9 @@ VITE_CONFIGS='
|
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
```
|
|
34
|
+
|
|
35
|
+
### Executing drawing commands
|
|
36
|
+
|
|
37
|
+
The visualizer includes a golang package that allows executing commands to the visualizer.
|
|
38
|
+
|
|
39
|
+
The list of available commands [can be found here](https://pkg.go.dev/github.com/viam-labs/motion-tools@v0.9.0/client/client).
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { T } from '@threlte/core'
|
|
2
|
+
import { T, useThrelte } from '@threlte/core'
|
|
3
3
|
import { useSettings } from '../hooks/useSettings.svelte'
|
|
4
|
+
import type { Camera } from 'three'
|
|
4
5
|
|
|
5
6
|
let { children, ...rest } = $props()
|
|
6
7
|
|
|
8
|
+
const { camera } = useThrelte()
|
|
7
9
|
const settings = useSettings()
|
|
8
10
|
const mode = $derived(settings.current.cameraMode)
|
|
11
|
+
|
|
12
|
+
$effect(() => {
|
|
13
|
+
;(window as unknown as { camera: Camera }).camera = $camera
|
|
14
|
+
})
|
|
9
15
|
</script>
|
|
10
16
|
|
|
11
17
|
{#if mode === 'perspective'}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { BackSide, Vector3 } from 'three'
|
|
3
|
+
import { T, useThrelte } from '@threlte/core'
|
|
4
|
+
import { MeshDiscardMaterial } from '@threlte/extras'
|
|
5
|
+
import { useSelected } from '../hooks/useSelection.svelte'
|
|
6
|
+
import { useTransformControls } from '../hooks/useControls.svelte'
|
|
7
|
+
|
|
8
|
+
const { camera } = useThrelte()
|
|
9
|
+
const selected = useSelected()
|
|
10
|
+
const transformControls = useTransformControls()
|
|
11
|
+
const cameraDown = new Vector3()
|
|
12
|
+
|
|
13
|
+
const size = 1_000
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<T.Mesh
|
|
17
|
+
onpointerdown={() => {
|
|
18
|
+
cameraDown.copy(camera.current.position)
|
|
19
|
+
}}
|
|
20
|
+
onpointerup={() => {
|
|
21
|
+
if (transformControls.active) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (cameraDown.distanceToSquared(camera.current.position) > 0.2) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
selected.set()
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<T.BoxGeometry args={[size, size, size]} />
|
|
33
|
+
<MeshDiscardMaterial side={BackSide} />
|
|
34
|
+
</T.Mesh>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const PointerMissBox: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type PointerMissBox = InstanceType<typeof PointerMissBox>;
|
|
18
|
+
export default PointerMissBox;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { useSettings } from '../hooks/useSettings.svelte'
|
|
17
17
|
import CameraControls from './CameraControls.svelte'
|
|
18
18
|
import MeasureTool from './MeasureTool.svelte'
|
|
19
|
+
import PointerMissBox from './PointerMissBox.svelte'
|
|
19
20
|
|
|
20
21
|
interface Props {
|
|
21
22
|
children?: Snippet
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
<StaticGeometries />
|
|
67
68
|
|
|
68
69
|
<WorldObjects />
|
|
70
|
+
<PointerMissBox />
|
|
69
71
|
|
|
70
72
|
<Selected />
|
|
71
73
|
|
|
@@ -1,48 +1,56 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Box3, Object3D } from 'three'
|
|
3
|
-
import { T, useTask
|
|
4
|
-
import { useSelectedObject } from '../hooks/useSelection.svelte'
|
|
3
|
+
import { T, useTask } from '@threlte/core'
|
|
4
|
+
import { useSelectedObject, useSelectedObject3d } from '../hooks/useSelection.svelte'
|
|
5
5
|
import { BoxHelper } from '../three/BoxHelper'
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const box3 = new Box3()
|
|
9
8
|
const box = new BoxHelper(new Object3D(), 0x000000)
|
|
10
9
|
const selected = useSelectedObject()
|
|
10
|
+
const selectedObject3d = useSelectedObject3d()
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// Create a clone so that our bounding box doesn't include children
|
|
13
|
+
const clone = $derived.by(() => {
|
|
14
|
+
if (selected.current?.metadata.batched) {
|
|
15
|
+
return
|
|
16
|
+
}
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
return selectedObject3d.current?.clone(false)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const { start, stop } = useTask(
|
|
22
|
+
() => {
|
|
23
|
+
if (selected.current === undefined) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (selected.current.metadata.batched) {
|
|
28
|
+
selected.current.metadata.getBoundingBoxAt?.(box3)
|
|
29
|
+
box.setFromBox3(box3)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (clone) {
|
|
34
|
+
selectedObject3d.current?.getWorldPosition(clone.position)
|
|
35
|
+
selectedObject3d.current?.getWorldQuaternion(clone.quaternion)
|
|
36
|
+
box.setFromObject(clone)
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{ autoStart: false }
|
|
40
|
+
)
|
|
15
41
|
|
|
16
42
|
$effect.pre(() => {
|
|
17
43
|
if (selected.current) {
|
|
18
44
|
start()
|
|
45
|
+
box.visible = true
|
|
19
46
|
} else {
|
|
20
47
|
stop()
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
$effect.pre(() => {
|
|
25
|
-
if (!selected.current) {
|
|
26
48
|
box.visible = false
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
box.visible = true
|
|
31
|
-
|
|
32
|
-
if (selected.current.metadata.batched) {
|
|
33
|
-
selected.current.metadata.getBoundingBoxAt?.(box3)
|
|
34
|
-
box.setFromBox3(box3)
|
|
35
|
-
} else {
|
|
36
|
-
const object3d = scene.getObjectByProperty('uuid', selected.current.uuid)
|
|
37
|
-
if (object3d) {
|
|
38
|
-
// Create a clone so that our bounding box doesn't include children
|
|
39
|
-
const clone = object3d.clone(false)
|
|
40
|
-
object3d.getWorldPosition(clone.position)
|
|
41
|
-
object3d.getWorldQuaternion(clone.quaternion)
|
|
42
|
-
box.setFromObject(clone)
|
|
43
|
-
}
|
|
44
49
|
}
|
|
45
50
|
})
|
|
46
51
|
</script>
|
|
47
52
|
|
|
48
|
-
<T
|
|
53
|
+
<T
|
|
54
|
+
is={box}
|
|
55
|
+
raycast={() => null}
|
|
56
|
+
/>
|
|
@@ -6,5 +6,4 @@ export declare const useObjectEvents: (uuid: () => string) => {
|
|
|
6
6
|
ondblclick: (event: IntersectionEvent<MouseEvent>) => void;
|
|
7
7
|
onpointerdown: (event: IntersectionEvent<MouseEvent>) => void;
|
|
8
8
|
onclick: (event: IntersectionEvent<MouseEvent>) => void;
|
|
9
|
-
onpointermissed: () => void;
|
|
10
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -87,7 +87,6 @@
|
|
|
87
87
|
"svelte": ">=5",
|
|
88
88
|
"svelte-virtuallists": ">=1"
|
|
89
89
|
},
|
|
90
|
-
"packageManager": "pnpm@8.15.6+sha256.01c01eeb990e379b31ef19c03e9d06a14afa5250b82e81303f88721c99ff2e6f",
|
|
91
90
|
"svelte": "./dist/index.js",
|
|
92
91
|
"types": "./dist/index.d.ts",
|
|
93
92
|
"exports": {
|