@viamrobotics/motion-tools 0.19.2 → 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.
- package/README.md +56 -26
- package/dist/FrameConfigUpdater.svelte.d.ts +11 -17
- package/dist/FrameConfigUpdater.svelte.js +109 -109
- package/dist/WorldObject.svelte.js +2 -15
- package/dist/common/v1/common_pb.d.ts +950 -0
- package/dist/common/v1/common_pb.js +1399 -0
- package/dist/components/App.svelte +37 -21
- package/dist/components/App.svelte.d.ts +1 -0
- package/dist/components/BatchedArrows.svelte +102 -0
- package/dist/components/BatchedArrows.svelte.d.ts +3 -0
- package/dist/components/CameraControls.svelte +2 -3
- package/dist/components/Details.svelte +364 -365
- package/dist/components/Entities.svelte +73 -0
- package/dist/components/{WorldObjects.svelte.d.ts → Entities.svelte.d.ts} +3 -3
- package/dist/components/FileDrop.svelte +9 -23
- package/dist/components/Focus.svelte +2 -3
- package/dist/components/Frame.svelte +41 -22
- package/dist/components/Frame.svelte.d.ts +4 -6
- package/dist/components/GLTF.svelte +36 -0
- package/dist/components/GLTF.svelte.d.ts +11 -0
- package/dist/components/Geometry2.svelte +201 -0
- package/dist/components/Geometry2.svelte.d.ts +18 -0
- package/dist/components/KeyboardControls.svelte +3 -3
- package/dist/components/Line.svelte +10 -13
- package/dist/components/Line.svelte.d.ts +2 -2
- package/dist/components/LiveUpdatesBanner.svelte +51 -15
- package/dist/components/MeasureTool.svelte +4 -5
- package/dist/components/Pointcloud.svelte +27 -14
- package/dist/components/Pointcloud.svelte.d.ts +2 -2
- package/dist/components/PointerMissBox.svelte +3 -3
- package/dist/components/Pose.svelte +31 -6
- package/dist/components/Pose.svelte.d.ts +2 -2
- package/dist/components/Scene.svelte +7 -6
- package/dist/components/SceneProviders.svelte +0 -6
- package/dist/components/Selected.svelte +22 -16
- package/dist/components/StaticGeometries.svelte +51 -27
- package/dist/components/Tree/Tree.svelte +28 -22
- package/dist/components/Tree/Tree.svelte.d.ts +2 -3
- package/dist/components/Tree/TreeContainer.svelte +72 -40
- package/dist/components/Tree/Widgets.svelte +2 -5
- package/dist/components/Tree/buildTree.d.ts +3 -6
- package/dist/components/Tree/buildTree.js +19 -39
- package/dist/components/__tests__/__fixtures__/entity.d.ts +2 -0
- package/dist/components/__tests__/__fixtures__/entity.js +20 -0
- package/dist/components/__tests__/__fixtures__/resource.d.ts +17 -0
- package/dist/components/__tests__/__fixtures__/resource.js +13 -0
- package/dist/components/dashboard/Dashboard.svelte +5 -3
- package/dist/components/dashboard/Dashboard.svelte.d.ts +7 -2
- package/dist/components/widgets/ArmPositions.svelte +19 -7
- package/dist/draw/v1/drawing_pb.d.ts +341 -0
- package/dist/draw/v1/drawing_pb.js +417 -0
- package/dist/draw/v1/metadata_pb.d.ts +23 -0
- package/dist/draw/v1/metadata_pb.js +39 -0
- package/dist/draw/v1/scene_pb.d.ts +230 -0
- package/dist/draw/v1/scene_pb.js +298 -0
- package/dist/draw/v1/snapshot_pb.d.ts +42 -0
- package/dist/draw/v1/snapshot_pb.js +61 -0
- package/dist/draw/v1/transforms_pb.d.ts +23 -0
- package/dist/draw/v1/transforms_pb.js +39 -0
- package/dist/ecs/index.d.ts +4 -0
- package/dist/ecs/index.js +4 -0
- package/dist/ecs/traits.d.ts +128 -0
- package/dist/ecs/traits.js +81 -0
- package/dist/ecs/useQuery.svelte.d.ts +4 -0
- package/dist/ecs/useQuery.svelte.js +49 -0
- package/dist/ecs/useTrait.svelte.d.ts +19 -0
- package/dist/ecs/useTrait.svelte.js +40 -0
- package/dist/ecs/useWorld.d.ts +4 -0
- package/dist/ecs/useWorld.js +10 -0
- package/dist/geometry.js +6 -6
- package/dist/hooks/__tests__/fixtures/ResizableTestWrapper.svelte +41 -0
- package/dist/hooks/__tests__/fixtures/ResizableTestWrapper.svelte.d.ts +6 -0
- package/dist/hooks/use3DModels.svelte.js +6 -4
- package/dist/hooks/useDrawAPI.svelte.d.ts +0 -10
- package/dist/hooks/useDrawAPI.svelte.js +143 -267
- package/dist/hooks/useFramelessComponents.svelte.js +1 -1
- package/dist/hooks/useFrames.svelte.d.ts +6 -2
- package/dist/hooks/useFrames.svelte.js +123 -19
- package/dist/hooks/useGeometries.svelte.d.ts +0 -2
- package/dist/hooks/useGeometries.svelte.js +49 -25
- package/dist/hooks/useObjectEvents.svelte.d.ts +3 -2
- package/dist/hooks/useObjectEvents.svelte.js +11 -7
- package/dist/hooks/usePartConfig.svelte.d.ts +1 -1
- package/dist/hooks/usePartConfig.svelte.js +2 -1
- package/dist/hooks/usePointclouds.svelte.d.ts +0 -2
- package/dist/hooks/usePointclouds.svelte.js +52 -21
- package/dist/hooks/usePose.svelte.js +15 -7
- package/dist/hooks/useResizable.svelte.d.ts +12 -0
- package/dist/hooks/useResizable.svelte.js +45 -0
- package/dist/hooks/useResourceByName.svelte.js +8 -5
- package/dist/hooks/useSelection.svelte.d.ts +13 -23
- package/dist/hooks/useSelection.svelte.js +45 -65
- package/dist/hooks/useVisibility.svelte.d.ts +2 -1
- package/dist/hooks/useWeblabs.svelte.d.ts +0 -1
- package/dist/hooks/useWeblabs.svelte.js +0 -1
- package/dist/hooks/useWorldState.svelte.d.ts +9 -0
- package/dist/hooks/useWorldState.svelte.js +158 -107
- package/dist/lib.d.ts +1 -0
- package/dist/lib.js +2 -0
- package/dist/three/BatchedArrow.d.ts +2 -3
- package/dist/three/BatchedArrow.js +3 -11
- package/dist/three/CapsuleGeometry.d.ts +1 -1
- package/dist/three/CapsuleGeometry.js +3 -1
- package/dist/transform.js +0 -15
- package/package.json +12 -7
- package/dist/components/WorldObject.svelte +0 -28
- package/dist/components/WorldObject.svelte.d.ts +0 -11
- package/dist/components/WorldObjects.svelte +0 -159
- package/dist/components/WorldState.svelte +0 -92
- package/dist/components/WorldState.svelte.d.ts +0 -7
- package/dist/components/__tests__/__fixtures__/worldObject.svelte.d.ts +0 -2
- package/dist/components/__tests__/__fixtures__/worldObject.svelte.js +0 -35
- package/dist/components/portal/Portal.svelte +0 -25
- package/dist/components/portal/Portal.svelte.d.ts +0 -8
- package/dist/components/portal/PortalTarget.svelte +0 -18
- package/dist/components/portal/PortalTarget.svelte.d.ts +0 -6
- package/dist/components/portal/index.d.ts +0 -2
- package/dist/components/portal/index.js +0 -2
- package/dist/components/portal/usePortalContext.svelte.d.ts +0 -5
- package/dist/components/portal/usePortalContext.svelte.js +0 -5
- package/dist/hooks/useArrows.svelte.d.ts +0 -3
- package/dist/hooks/useArrows.svelte.js +0 -9
- package/dist/hooks/useDraggable.svelte.d.ts +0 -10
- package/dist/hooks/useDraggable.svelte.js +0 -36
- package/dist/hooks/useObjects.svelte.d.ts +0 -7
- package/dist/hooks/useObjects.svelte.js +0 -35
- package/dist/hooks/usePersistentUUIDs.svelte.d.ts +0 -5
- package/dist/hooks/usePersistentUUIDs.svelte.js +0 -13
- package/dist/hooks/useResourceByName.svelte.d.ts +0 -7
- package/dist/hooks/useStaticGeometries.svelte.d.ts +0 -9
- package/dist/hooks/useStaticGeometries.svelte.js +0 -47
- package/dist/workers/worldStateWorker.d.ts +0 -1
- package/dist/workers/worldStateWorker.js +0 -114
- package/dist/world-state-messages.d.ts +0 -23
- package/dist/world-state-messages.js +0 -1
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import ArmPositions from './widgets/ArmPositions.svelte'
|
|
22
22
|
import { provideEnvironment } from '../hooks/useEnvironment.svelte'
|
|
23
23
|
import type { CameraPose } from '../hooks/useControls.svelte'
|
|
24
|
+
import { provideWorld } from '../ecs'
|
|
24
25
|
|
|
25
26
|
interface LocalConfigProps {
|
|
26
27
|
getLocalPartConfig: () => Struct
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
partID?: string
|
|
34
35
|
enableKeybindings?: boolean
|
|
35
36
|
children?: Snippet
|
|
37
|
+
dashboard?: Snippet
|
|
36
38
|
localConfigProps?: LocalConfigProps
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -44,11 +46,14 @@
|
|
|
44
46
|
let {
|
|
45
47
|
partID = '',
|
|
46
48
|
enableKeybindings = true,
|
|
47
|
-
children: appChildren,
|
|
48
49
|
localConfigProps,
|
|
49
50
|
cameraPose,
|
|
51
|
+
children: appChildren,
|
|
52
|
+
dashboard,
|
|
50
53
|
}: Props = $props()
|
|
51
54
|
|
|
55
|
+
provideWorld()
|
|
56
|
+
|
|
52
57
|
const appClient = useViamClient()
|
|
53
58
|
const settings = provideSettings()
|
|
54
59
|
const environment = provideEnvironment()
|
|
@@ -64,25 +69,33 @@
|
|
|
64
69
|
|
|
65
70
|
let root = $state.raw<HTMLElement>()
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
72
|
+
providePartConfig(() => {
|
|
73
|
+
if (localConfigProps) {
|
|
74
|
+
return {
|
|
75
|
+
appEmbeddedPartConfigProps: {
|
|
76
|
+
isDirty: () => localConfigProps.isDirty(),
|
|
77
|
+
getLocalPartConfig: () => localConfigProps.getLocalPartConfig(),
|
|
78
|
+
setLocalPartConfig: (config: Struct) => localConfigProps.setLocalPartConfig(config),
|
|
79
|
+
getComponentToFragId: () => localConfigProps.getComponentToFragId(),
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
return {
|
|
84
|
+
standalonePartConfigProps: {
|
|
85
|
+
viamClient: () => appClient?.current,
|
|
86
|
+
partID: () => partID,
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
$effect.pre(() => {
|
|
93
|
+
if (localConfigProps) {
|
|
94
|
+
environment.current.isStandalone = false
|
|
95
|
+
} else {
|
|
96
|
+
environment.current.isStandalone = true
|
|
97
|
+
}
|
|
98
|
+
})
|
|
86
99
|
</script>
|
|
87
100
|
|
|
88
101
|
{#if settings.current.enableQueryDevtools}
|
|
@@ -102,7 +115,10 @@
|
|
|
102
115
|
|
|
103
116
|
<XR {@attach domPortal(root)} />
|
|
104
117
|
|
|
105
|
-
<Dashboard
|
|
118
|
+
<Dashboard
|
|
119
|
+
{@attach domPortal(root)}
|
|
120
|
+
{dashboard}
|
|
121
|
+
/>
|
|
106
122
|
<Details {@attach domPortal(root)} />
|
|
107
123
|
{#if environment.current.isStandalone}
|
|
108
124
|
<LiveUpdatesBanner {@attach domPortal(root)} />
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { T } from '@threlte/core'
|
|
3
|
+
import { Portal } from '@threlte/extras'
|
|
4
|
+
import { BatchedArrow } from '../three/BatchedArrow'
|
|
5
|
+
import { traits, useWorld } from '../ecs'
|
|
6
|
+
import type { Entity } from 'koota'
|
|
7
|
+
import { Color, Vector3 } from 'three'
|
|
8
|
+
|
|
9
|
+
const arrowBatchMap = $state<Record<string, BatchedArrow>>({
|
|
10
|
+
world: new BatchedArrow(),
|
|
11
|
+
})
|
|
12
|
+
const batchEntries = $derived(Object.entries(arrowBatchMap))
|
|
13
|
+
|
|
14
|
+
const world = useWorld()
|
|
15
|
+
|
|
16
|
+
const direction = new Vector3()
|
|
17
|
+
const origin = new Vector3()
|
|
18
|
+
const color = new Color()
|
|
19
|
+
|
|
20
|
+
const onAdd = (entity: Entity) => {
|
|
21
|
+
const parent = entity.get(traits.Parent) ?? 'world'
|
|
22
|
+
|
|
23
|
+
arrowBatchMap[parent] ??= new BatchedArrow()
|
|
24
|
+
const batched = arrowBatchMap[parent]
|
|
25
|
+
|
|
26
|
+
const pose = entity.get(traits.Pose)
|
|
27
|
+
const colorRGB = entity.get(traits.Color)
|
|
28
|
+
|
|
29
|
+
const instanceID = batched.addArrow(
|
|
30
|
+
direction.set(pose?.oX ?? 0, pose?.oY ?? 0, pose?.oZ ?? 0),
|
|
31
|
+
origin.set(pose?.x ?? 0, pose?.y ?? 0, pose?.z ?? 0),
|
|
32
|
+
colorRGB ? color.set(colorRGB.r, colorRGB.g, colorRGB.b) : color.set('yellow')
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
entity.add(traits.Instance({ instanceID, meshID: batched.mesh.id }))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const onPoseChange = (entity: Entity) => {
|
|
39
|
+
if (!entity.has(traits.Arrow)) return
|
|
40
|
+
|
|
41
|
+
const parent = entity.get(traits.Parent) ?? 'world'
|
|
42
|
+
const batch = arrowBatchMap[parent]
|
|
43
|
+
const instanceID = entity.get(traits.Instance)?.instanceID
|
|
44
|
+
const pose = entity.get(traits.Pose)
|
|
45
|
+
|
|
46
|
+
if (instanceID && instanceID !== -1 && pose) {
|
|
47
|
+
batch?.updateArrow(
|
|
48
|
+
instanceID,
|
|
49
|
+
direction.set(pose.oX, pose.oY, pose.oZ),
|
|
50
|
+
origin.set(pose.x, pose.y, pose.z)
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const onColorChange = (entity: Entity) => {
|
|
56
|
+
if (!entity.has(traits.Arrow)) return
|
|
57
|
+
|
|
58
|
+
const parent = entity.get(traits.Parent) ?? 'world'
|
|
59
|
+
const batch = arrowBatchMap[parent]
|
|
60
|
+
const instanceID = entity.get(traits.Instance)?.instanceID
|
|
61
|
+
const colorRGB = entity.get(traits.Color)
|
|
62
|
+
|
|
63
|
+
if (instanceID && instanceID !== -1 && colorRGB) {
|
|
64
|
+
color.set(colorRGB.r, colorRGB.g, colorRGB.b)
|
|
65
|
+
batch.mesh.setColorAt(instanceID, color)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const onInstanceRemove = (entity: Entity) => {
|
|
70
|
+
const instance = entity.get(traits.Instance)
|
|
71
|
+
|
|
72
|
+
for (const [, batch] of batchEntries) {
|
|
73
|
+
if (batch.mesh.id === instance?.meshID) {
|
|
74
|
+
batch.removeArrow(instance.instanceID)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
$effect(() => {
|
|
80
|
+
const unsubAdd = world.onAdd(traits.Arrow, onAdd)
|
|
81
|
+
const unsubRemove = world.onRemove(traits.Instance, onInstanceRemove)
|
|
82
|
+
const unsubPoseChange = world.onChange(traits.Pose, onPoseChange)
|
|
83
|
+
const unsubColorChange = world.onChange(traits.Color, onColorChange)
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
unsubAdd()
|
|
87
|
+
unsubRemove()
|
|
88
|
+
unsubPoseChange()
|
|
89
|
+
unsubColorChange()
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
{#each batchEntries as [parent, batch] (parent)}
|
|
95
|
+
<Portal id={parent}>
|
|
96
|
+
<T
|
|
97
|
+
is={batch.mesh}
|
|
98
|
+
dispose={false}
|
|
99
|
+
bvh={{ enabled: false }}
|
|
100
|
+
/>
|
|
101
|
+
</Portal>
|
|
102
|
+
{/each}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { MathUtils } from 'three'
|
|
3
|
-
import { CameraControls, type CameraControlsRef, Gizmo } from '@threlte/extras'
|
|
3
|
+
import { CameraControls, type CameraControlsRef, Gizmo, Portal } from '@threlte/extras'
|
|
4
4
|
import { useCameraControls, useTransformControls } from '../hooks/useControls.svelte'
|
|
5
5
|
import KeyboardControls from './KeyboardControls.svelte'
|
|
6
|
-
import Portal from './portal/Portal.svelte'
|
|
7
6
|
import Button from './dashboard/Button.svelte'
|
|
8
7
|
import { useSettings } from '../hooks/useSettings.svelte'
|
|
9
8
|
|
|
@@ -39,6 +38,6 @@
|
|
|
39
38
|
{#if enableKeybindings}
|
|
40
39
|
<KeyboardControls cameraControls={ref} />
|
|
41
40
|
{/if}
|
|
42
|
-
<Gizmo />
|
|
41
|
+
<Gizmo placement="bottom-right" />
|
|
43
42
|
{/snippet}
|
|
44
43
|
</CameraControls>
|