@viamrobotics/motion-tools 1.25.1 → 1.25.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.
@@ -19,6 +19,7 @@ Renders a Snapshot protobuf by spawning its transforms and drawings as entities
19
19
 
20
20
  import type { Snapshot as SnapshotProto } from '../buf/draw/v1/snapshot_pb'
21
21
 
22
+ import { uuidBytesToString } from '../draw'
22
23
  import { traits, useWorld } from '../ecs'
23
24
  import { useCameraControls } from '../hooks/useControls.svelte'
24
25
  import { useRelationships } from '../hooks/useRelationships.svelte'
@@ -38,6 +39,7 @@ Renders a Snapshot protobuf by spawning its transforms and drawings as entities
38
39
 
39
40
  let entitiesByUuid = new Map<string, SnapshotEntity>()
40
41
  let unkeyedEntities: SnapshotEntity[] = []
42
+ let lastSnapshotUuid: string | undefined = undefined
41
43
 
42
44
  $effect(() => {
43
45
  void snapshot
@@ -46,10 +48,20 @@ Renders a Snapshot protobuf by spawning its transforms and drawings as entities
46
48
  for (const entry of unkeyedEntities) {
47
49
  if (world.has(entry.entity)) entry.entity.destroy()
48
50
  }
51
+ unkeyedEntities = []
52
+
53
+ const nextSnapshotUuid = uuidBytesToString(snapshot.uuid)
54
+ if (lastSnapshotUuid !== undefined && nextSnapshotUuid !== lastSnapshotUuid) {
55
+ for (const entry of entitiesByUuid.values()) {
56
+ if (world.has(entry.entity)) entry.entity.destroy()
57
+ }
58
+ entitiesByUuid = new Map()
59
+ }
49
60
 
50
61
  const result = reconcileSnapshotEntities(world, snapshot, entitiesByUuid)
51
62
  entitiesByUuid = result.current
52
63
  unkeyedEntities = result.unkeyed
64
+ lastSnapshotUuid = nextSnapshotUuid
53
65
 
54
66
  for (const entry of [...result.spawned, ...result.updated]) {
55
67
  relationships.apply(entry.entity, entry.relationships)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viamrobotics/motion-tools",
3
- "version": "1.25.1",
3
+ "version": "1.25.2",
4
4
  "description": "Motion visualization with Viam",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",