@viamrobotics/motion-tools 1.29.0 → 1.29.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.
- package/dist/components/Entities/Arrows/Arrows.svelte +1 -1
- package/dist/components/Entities/Frame.svelte +1 -1
- package/dist/components/Entities/GLTF.svelte +1 -1
- package/dist/components/Entities/Geometry.svelte +1 -1
- package/dist/components/Entities/Line.svelte +1 -1
- package/dist/components/Entities/Points.svelte +1 -1
- package/dist/components/Entities/hooks/useEntityEvents.svelte.js +1 -1
- package/dist/components/SceneProviders.svelte +2 -0
- package/dist/components/overlay/left-pane/TreeNode.svelte +3 -2
- package/dist/ecs/traits.d.ts +7 -0
- package/dist/ecs/traits.js +7 -0
- package/dist/hooks/useInheritedInvisible.svelte.d.ts +3 -0
- package/dist/hooks/useInheritedInvisible.svelte.js +89 -0
- package/package.json +1 -1
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
const { invalidate } = useThrelte()
|
|
22
22
|
const worldMatrix = useTrait(() => entity, traits.WorldMatrix)
|
|
23
|
-
const invisible = useTrait(() => entity, traits.
|
|
23
|
+
const invisible = useTrait(() => entity, traits.InheritedInvisible)
|
|
24
24
|
const showAxesHelper = useTrait(() => entity, traits.ShowAxesHelper)
|
|
25
25
|
|
|
26
26
|
const events = useEntityEvents(() => entity)
|
|
@@ -39,7 +39,7 @@ Renders a Viam Frame object
|
|
|
39
39
|
const entityColor = useTrait(() => entity, traits.Color)
|
|
40
40
|
const worldMatrix = useTrait(() => entity, traits.WorldMatrix)
|
|
41
41
|
const center = useTrait(() => entity, traits.Center)
|
|
42
|
-
const invisible = useTrait(() => entity, traits.
|
|
42
|
+
const invisible = useTrait(() => entity, traits.InheritedInvisible)
|
|
43
43
|
|
|
44
44
|
const events = useEntityEvents(() => entity)
|
|
45
45
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
const worldMatrix = useTrait(() => entity, traits.WorldMatrix)
|
|
37
37
|
const gltfTrait = useTrait(() => entity, traits.GLTF)
|
|
38
|
-
const invisible = useTrait(() => entity, traits.
|
|
38
|
+
const invisible = useTrait(() => entity, traits.InheritedInvisible)
|
|
39
39
|
const showAxesHelper = useTrait(() => entity, traits.ShowAxesHelper)
|
|
40
40
|
const events = useEntityEvents(() => entity)
|
|
41
41
|
|
|
@@ -33,7 +33,7 @@ Renders a Viam Geometry object
|
|
|
33
33
|
const name = useTrait(() => entity, traits.Name)
|
|
34
34
|
const worldMatrix = useTrait(() => entity, traits.WorldMatrix)
|
|
35
35
|
const center = useTrait(() => entity, traits.Center)
|
|
36
|
-
const invisible = useTrait(() => entity, traits.
|
|
36
|
+
const invisible = useTrait(() => entity, traits.InheritedInvisible)
|
|
37
37
|
|
|
38
38
|
const model = $derived.by(() => {
|
|
39
39
|
if (!settings.current.renderArmModels.includes('model')) {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
const renderOrder = useTrait(() => entity, traits.RenderOrder)
|
|
35
35
|
const opacity = useTrait(() => entity, traits.Opacity)
|
|
36
36
|
const screenSpace = useTrait(() => entity, traits.ScreenSpace)
|
|
37
|
-
const invisible = useTrait(() => entity, traits.
|
|
37
|
+
const invisible = useTrait(() => entity, traits.InheritedInvisible)
|
|
38
38
|
const showAxesHelper = useTrait(() => entity, traits.ShowAxesHelper)
|
|
39
39
|
|
|
40
40
|
const events = useEntityEvents(() => entity)
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
const colors = useTrait(() => entity, traits.Colors)
|
|
29
29
|
const entityPointSize = useTrait(() => entity, traits.PointSize)
|
|
30
30
|
const opacity = useTrait(() => entity, traits.Opacity)
|
|
31
|
-
const invisible = useTrait(() => entity, traits.
|
|
31
|
+
const invisible = useTrait(() => entity, traits.InheritedInvisible)
|
|
32
32
|
const showAxesHelper = useTrait(() => entity, traits.ShowAxesHelper)
|
|
33
33
|
const renderOrder = useTrait(() => entity, traits.RenderOrder)
|
|
34
34
|
const materialProps = useTrait(() => entity, traits.Material)
|
|
@@ -18,7 +18,7 @@ export const useEntityEvents = (entity) => {
|
|
|
18
18
|
const selectedEntity = useSelectedEntity();
|
|
19
19
|
const focusedEntity = useFocusedEntity();
|
|
20
20
|
const cursor = useCursor();
|
|
21
|
-
const invisible = useTrait(entity, traits.
|
|
21
|
+
const invisible = useTrait(entity, traits.InheritedInvisible);
|
|
22
22
|
const onpointerenter = (event) => {
|
|
23
23
|
if (invisible.current)
|
|
24
24
|
return;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { provideFramelessComponents } from '../hooks/useFramelessComponents.svelte'
|
|
12
12
|
import { provideFrames } from '../hooks/useFrames.svelte'
|
|
13
13
|
import { provideGeometries } from '../hooks/useGeometries.svelte'
|
|
14
|
+
import { provideInheritedInvisible } from '../hooks/useInheritedInvisible.svelte'
|
|
14
15
|
import { provideLinkedEntities } from '../hooks/useLinked.svelte'
|
|
15
16
|
import { provideLogs } from '../hooks/useLogs.svelte'
|
|
16
17
|
import { usePartID } from '../hooks/usePartID.svelte'
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
|
|
37
38
|
provideHierarchy()
|
|
38
39
|
provideWorldMatrix()
|
|
40
|
+
provideInheritedInvisible()
|
|
39
41
|
provideOrigin()
|
|
40
42
|
|
|
41
43
|
provideRelationships()
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
const name = useTrait(() => node.entity, traits.Name)
|
|
22
22
|
const invisible = useTrait(() => node.entity, traits.Invisible)
|
|
23
|
+
const inheritedInvisible = useTrait(() => node.entity, traits.InheritedInvisible)
|
|
23
24
|
const chunkProgress = useTrait(() => node.entity, traits.ChunkProgress)
|
|
24
25
|
const loading = $derived(chunkProgress.current !== undefined)
|
|
25
26
|
const progress = $derived(
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
class={[
|
|
56
57
|
'w-full',
|
|
57
58
|
{
|
|
58
|
-
'text-disabled':
|
|
59
|
+
'text-disabled': inheritedInvisible.current,
|
|
59
60
|
'bg-medium': nodeState.selected,
|
|
60
61
|
sticky: true,
|
|
61
62
|
},
|
|
@@ -129,7 +130,7 @@
|
|
|
129
130
|
<div
|
|
130
131
|
class={{
|
|
131
132
|
'flex justify-between': true,
|
|
132
|
-
'text-disabled':
|
|
133
|
+
'text-disabled': inheritedInvisible.current,
|
|
133
134
|
'bg-medium': nodeState.selected,
|
|
134
135
|
}}
|
|
135
136
|
{...api.getItemProps(nodeProps)}
|
package/dist/ecs/traits.d.ts
CHANGED
|
@@ -65,6 +65,13 @@ export declare const InstancedMatrix: import("koota").Trait<() => {
|
|
|
65
65
|
}>;
|
|
66
66
|
export declare const Hovered: import("koota").Trait<() => boolean>;
|
|
67
67
|
export declare const Invisible: import("koota").Trait<() => boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* True when the entity itself, or any of its parents up the `ChildOf`
|
|
70
|
+
* chain, has `Invisible`. Maintained by `provideInheritedInvisible`;
|
|
71
|
+
* don't add or remove it by hand — toggle `Invisible` and the cascade
|
|
72
|
+
* follows.
|
|
73
|
+
*/
|
|
74
|
+
export declare const InheritedInvisible: import("koota").Trait<() => boolean>;
|
|
68
75
|
/**
|
|
69
76
|
* Represents that an entity is composed of many instances, so that the treeview and
|
|
70
77
|
* details panel may display all instances
|
package/dist/ecs/traits.js
CHANGED
|
@@ -61,6 +61,13 @@ export const InstancedMatrix = trait(() => ({
|
|
|
61
61
|
}));
|
|
62
62
|
export const Hovered = trait(() => true);
|
|
63
63
|
export const Invisible = trait(() => true);
|
|
64
|
+
/**
|
|
65
|
+
* True when the entity itself, or any of its parents up the `ChildOf`
|
|
66
|
+
* chain, has `Invisible`. Maintained by `provideInheritedInvisible`;
|
|
67
|
+
* don't add or remove it by hand — toggle `Invisible` and the cascade
|
|
68
|
+
* follows.
|
|
69
|
+
*/
|
|
70
|
+
export const InheritedInvisible = trait(() => true);
|
|
64
71
|
/**
|
|
65
72
|
* Represents that an entity is composed of many instances, so that the treeview and
|
|
66
73
|
* details panel may display all instances
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {} from 'koota';
|
|
2
|
+
import { ChildOf } from '../ecs/relations';
|
|
3
|
+
import { InheritedInvisible, Invisible } from '../ecs/traits';
|
|
4
|
+
import { useWorld } from '../ecs/useWorld';
|
|
5
|
+
/**
|
|
6
|
+
* Walks up `ChildOf` and returns true if the entity itself or any
|
|
7
|
+
* ancestor has `Invisible`. Memoizes via `cache` so siblings in the
|
|
8
|
+
* same flush reuse a parent's result.
|
|
9
|
+
*/
|
|
10
|
+
const hasInherited = (entity, cache) => {
|
|
11
|
+
const cached = cache.get(entity);
|
|
12
|
+
if (cached !== undefined)
|
|
13
|
+
return cached;
|
|
14
|
+
if (!entity.isAlive())
|
|
15
|
+
return false;
|
|
16
|
+
if (entity.has(Invisible)) {
|
|
17
|
+
cache.set(entity, true);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
const parent = entity.targetFor(ChildOf);
|
|
21
|
+
const inherited = parent && parent.isAlive() ? hasInherited(parent, cache) : false;
|
|
22
|
+
cache.set(entity, inherited);
|
|
23
|
+
return inherited;
|
|
24
|
+
};
|
|
25
|
+
const flushDirty = (world, dirty) => {
|
|
26
|
+
if (dirty.size === 0)
|
|
27
|
+
return;
|
|
28
|
+
const cache = new Map();
|
|
29
|
+
const allEntities = new Set();
|
|
30
|
+
const collectChildren = (entity) => {
|
|
31
|
+
if (allEntities.has(entity))
|
|
32
|
+
return;
|
|
33
|
+
allEntities.add(entity);
|
|
34
|
+
for (const child of world.query(ChildOf(entity))) {
|
|
35
|
+
collectChildren(child);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
for (const entity of dirty) {
|
|
39
|
+
collectChildren(entity);
|
|
40
|
+
}
|
|
41
|
+
dirty.clear();
|
|
42
|
+
for (const entity of allEntities) {
|
|
43
|
+
if (!entity.isAlive()) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const hasInheritedTrait = hasInherited(entity, cache);
|
|
47
|
+
const hasTrait = entity.has(InheritedInvisible);
|
|
48
|
+
if (hasInheritedTrait && !hasTrait) {
|
|
49
|
+
entity.add(InheritedInvisible);
|
|
50
|
+
}
|
|
51
|
+
else if (!hasInheritedTrait && hasTrait) {
|
|
52
|
+
entity.remove(InheritedInvisible);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export const addInheritedInvisibleListeners = (world) => {
|
|
57
|
+
const dirty = new Set();
|
|
58
|
+
let scheduled = false;
|
|
59
|
+
const enqueue = (entity) => {
|
|
60
|
+
dirty.add(entity);
|
|
61
|
+
if (scheduled)
|
|
62
|
+
return;
|
|
63
|
+
scheduled = true;
|
|
64
|
+
// Microtask-deferred so a burst of changes is grouped into one subtree walk.
|
|
65
|
+
queueMicrotask(() => {
|
|
66
|
+
scheduled = false;
|
|
67
|
+
flushDirty(world, dirty);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
for (const entity of world.query(Invisible)) {
|
|
71
|
+
enqueue(entity);
|
|
72
|
+
}
|
|
73
|
+
const unsubs = [
|
|
74
|
+
world.onAdd(Invisible, enqueue),
|
|
75
|
+
world.onRemove(Invisible, enqueue),
|
|
76
|
+
world.onAdd(ChildOf, enqueue),
|
|
77
|
+
world.onChange(ChildOf, enqueue),
|
|
78
|
+
world.onRemove(ChildOf, enqueue),
|
|
79
|
+
];
|
|
80
|
+
return () => {
|
|
81
|
+
for (const unsub of unsubs) {
|
|
82
|
+
unsub();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export const provideInheritedInvisible = () => {
|
|
87
|
+
const world = useWorld();
|
|
88
|
+
$effect(() => addInheritedInvisibleListeners(world));
|
|
89
|
+
};
|