@viamrobotics/motion-tools 1.2.0 → 1.2.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.
@@ -113,7 +113,7 @@
113
113
 
114
114
  return () => {
115
115
  geo = undefined
116
- mesh.geometry.dispose()
116
+ mesh?.geometry?.dispose()
117
117
  }
118
118
  }
119
119
  })
@@ -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
- destroyEntities(entities)
38
- entities = spawnSnapshotEntities(world, snapshot)
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
- settings.current = applySceneMetadata(settings.current, snapshot.sceneMetadata)
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
- {#each children as node, index (node.entity)}
133
- {@render treeNode({ node, indexPath: [...indexPath, index], api })}
134
- {/each}
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}
@@ -11,27 +11,3 @@
11
11
  <table class="motion-tools-table">
12
12
  {@render children?.()}
13
13
  </table>
14
-
15
- <style>
16
- @reference "../../../app.css";
17
-
18
- .motion-tools-table {
19
- @apply w-full table-auto;
20
- }
21
- .motion-tools-table :global(thead) {
22
- @apply border-light bg-light border;
23
- }
24
- .motion-tools-table :global(thead th) {
25
- @apply border-light text-subtle-1 border px-2.5 py-1 text-xs font-normal whitespace-nowrap;
26
- }
27
- .motion-tools-table :global(thead th abbr) {
28
- @apply text-disabled;
29
- }
30
-
31
- .motion-tools-table :global(tbody) {
32
- @apply border-light border;
33
- }
34
- .motion-tools-table :global(tbody th) {
35
- @apply border-light font-roboto-mono text-default h-[40px] gap-2 border px-1.5 text-center text-xs font-normal;
36
- }
37
- </style>
@@ -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
- entities.push(...spawnEntitiesFromDrawing(world, drawing));
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
- entity.destroy();
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.0",
3
+ "version": "1.2.2",
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"