@viamrobotics/motion-tools 1.2.0 → 1.2.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.
|
@@ -20,6 +20,8 @@ Renders a Snapshot protobuf by spawning its transforms and drawings as entities
|
|
|
20
20
|
import { spawnSnapshotEntities, destroyEntities, applySceneMetadata } from '../snapshot'
|
|
21
21
|
import { useCameraControls } from '../hooks/useControls.svelte'
|
|
22
22
|
import type { Entity } from 'koota'
|
|
23
|
+
import { untrack } from 'svelte'
|
|
24
|
+
import { onDestroy } from 'svelte'
|
|
23
25
|
|
|
24
26
|
interface Props {
|
|
25
27
|
snapshot: SnapshotProto
|
|
@@ -34,14 +36,20 @@ Renders a Snapshot protobuf by spawning its transforms and drawings as entities
|
|
|
34
36
|
let entities: Entity[] = []
|
|
35
37
|
|
|
36
38
|
$effect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
world.id.toString()
|
|
40
|
+
snapshot.uuid.toString()
|
|
39
41
|
|
|
42
|
+
untrack(() => {
|
|
43
|
+
entities = spawnSnapshotEntities(world, snapshot)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
$effect(() => {
|
|
40
48
|
if (snapshot.sceneMetadata) {
|
|
41
|
-
|
|
49
|
+
untrack(() => {
|
|
50
|
+
settings.current = applySceneMetadata(settings.current, snapshot.sceneMetadata!)
|
|
51
|
+
})
|
|
42
52
|
}
|
|
43
|
-
|
|
44
|
-
return () => destroyEntities(entities)
|
|
45
53
|
})
|
|
46
54
|
|
|
47
55
|
$effect(() => {
|
|
@@ -57,4 +65,8 @@ Renders a Snapshot protobuf by spawning its transforms and drawings as entities
|
|
|
57
65
|
})
|
|
58
66
|
}
|
|
59
67
|
})
|
|
68
|
+
|
|
69
|
+
onDestroy(() => {
|
|
70
|
+
destroyEntities(world, entities)
|
|
71
|
+
})
|
|
60
72
|
</script>
|
|
@@ -129,9 +129,21 @@
|
|
|
129
129
|
<div {...api.getBranchContentProps(nodeProps)}>
|
|
130
130
|
<div {...api.getBranchIndentGuideProps(nodeProps)}></div>
|
|
131
131
|
|
|
132
|
-
{#
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
{#if children.length > 200}
|
|
133
|
+
<VirtualList
|
|
134
|
+
class="w-full"
|
|
135
|
+
style="height:{Math.min(8, Math.max(children.length, 5)) * 32}px;"
|
|
136
|
+
items={children}
|
|
137
|
+
>
|
|
138
|
+
{#snippet vl_slot({ index, item })}
|
|
139
|
+
{@render treeNode({ node: item, indexPath: [...indexPath, Number(index)], api })}
|
|
140
|
+
{/snippet}
|
|
141
|
+
</VirtualList>
|
|
142
|
+
{:else}
|
|
143
|
+
{#each children as node, index (node.entity)}
|
|
144
|
+
{@render treeNode({ node, indexPath: [...indexPath, index], api })}
|
|
145
|
+
{/each}
|
|
146
|
+
{/if}
|
|
135
147
|
</div>
|
|
136
148
|
</div>
|
|
137
149
|
{:else}
|
package/dist/snapshot.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ import { type SceneMetadata } from './draw/v1/scene_pb';
|
|
|
4
4
|
import type { Settings } from './hooks/useSettings.svelte';
|
|
5
5
|
export declare const applySceneMetadata: (settings: Settings, metadata: SceneMetadata) => Settings;
|
|
6
6
|
export declare const spawnSnapshotEntities: (world: World, snapshot: Snapshot) => Entity[];
|
|
7
|
-
export declare const destroyEntities: (entities: Entity[]) => void;
|
|
7
|
+
export declare const destroyEntities: (world: World, entities: Entity[]) => void;
|
package/dist/snapshot.js
CHANGED
|
@@ -56,13 +56,18 @@ export const spawnSnapshotEntities = (world, snapshot) => {
|
|
|
56
56
|
entities.push(spawnTransformEntity(world, transform));
|
|
57
57
|
}
|
|
58
58
|
for (const drawing of snapshot.drawings) {
|
|
59
|
-
|
|
59
|
+
const drawingEntities = spawnEntitiesFromDrawing(world, drawing);
|
|
60
|
+
for (const e of drawingEntities) {
|
|
61
|
+
entities.push(e);
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
return entities;
|
|
62
65
|
};
|
|
63
|
-
export const destroyEntities = (entities) => {
|
|
66
|
+
export const destroyEntities = (world, entities) => {
|
|
64
67
|
for (const entity of entities) {
|
|
65
|
-
|
|
68
|
+
if (world.has(entity)) {
|
|
69
|
+
entity.destroy();
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
72
|
};
|
|
68
73
|
const getRenderArmModels = (renderArmModels) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -89,7 +89,11 @@
|
|
|
89
89
|
"lucide-svelte": ">=0.511",
|
|
90
90
|
"runed": ">=0.28",
|
|
91
91
|
"svelte": ">=5",
|
|
92
|
-
"svelte-virtuallists": ">=1"
|
|
92
|
+
"svelte-virtuallists": ">=1",
|
|
93
|
+
"@ag-grid-community/client-side-row-model": ">=32.3.0",
|
|
94
|
+
"@ag-grid-community/core": ">=32.3.0",
|
|
95
|
+
"@ag-grid-community/styles": ">=32.3.0",
|
|
96
|
+
"@zag-js/dialog": ">=1.31"
|
|
93
97
|
},
|
|
94
98
|
"engines": {
|
|
95
99
|
"node": ">=22.12.0"
|