@viamrobotics/motion-tools 1.13.0 → 1.14.0
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/FrameConfigUpdater.svelte.js +1 -1
- package/dist/attribute.js +10 -2
- package/dist/buf/draw/v1/service_connect.d.ts +14 -25
- package/dist/buf/draw/v1/service_connect.js +14 -25
- package/dist/buf/draw/v1/service_pb.d.ts +61 -76
- package/dist/buf/draw/v1/service_pb.js +58 -111
- package/dist/buffer.d.ts +56 -7
- package/dist/buffer.js +70 -12
- package/dist/color.js +3 -3
- package/dist/components/App.svelte +1 -5
- package/dist/components/Camera.svelte +1 -7
- package/dist/components/Camera.svelte.d.ts +0 -1
- package/dist/components/CameraControls.svelte +2 -2
- package/dist/components/{Arrows → Entities/Arrows}/ArrowGroups.svelte +3 -3
- package/dist/components/{Arrows → Entities/Arrows}/Arrows.svelte +6 -6
- package/dist/components/{Arrows → Entities/Arrows}/Arrows.svelte.d.ts +1 -1
- package/dist/components/{Entities.svelte → Entities/Entities.svelte} +7 -3
- package/dist/components/Entities/Frame.svelte +86 -0
- package/dist/components/{Frame.svelte.d.ts → Entities/Frame.svelte.d.ts} +1 -0
- package/dist/components/{GLTF.svelte → Entities/GLTF.svelte} +5 -5
- package/dist/components/Entities/Geometry.svelte +75 -0
- package/dist/components/Entities/Geometry.svelte.d.ts +10 -0
- package/dist/components/{Label.svelte → Entities/Label.svelte} +1 -1
- package/dist/components/Entities/Line.svelte +90 -0
- package/dist/components/Entities/Mesh.svelte +130 -0
- package/dist/components/Entities/Mesh.svelte.d.ts +4 -0
- package/dist/components/{Points.svelte → Entities/Points.svelte} +5 -5
- package/dist/components/{Pose.svelte → Entities/Pose.svelte} +3 -3
- package/dist/{hooks/useObjectEvents.svelte.d.ts → components/Entities/hooks/useEntityEvents.svelte.d.ts} +1 -1
- package/dist/{hooks/useObjectEvents.svelte.js → components/Entities/hooks/useEntityEvents.svelte.js} +6 -6
- package/dist/components/FileDrop/file-names.js +6 -3
- package/dist/components/FileDrop/snapshot-dropper.js +8 -4
- package/dist/components/FileDrop/useFileDrop.svelte.js +9 -6
- package/dist/components/Lasso/Lasso.svelte +4 -4
- package/dist/components/PCD.svelte +14 -6
- package/dist/components/PCD.svelte.d.ts +2 -0
- package/dist/components/Scene.svelte +1 -3
- package/dist/components/Selected.svelte +2 -0
- package/dist/components/StaticGeometries.svelte +1 -1
- package/dist/components/overlay/AddRelationship.svelte +1 -1
- package/dist/components/overlay/LiveUpdatesBanner.svelte +4 -6
- package/dist/components/overlay/left-pane/buildTree.js +15 -0
- package/dist/components/overlay/settings/Settings.svelte +11 -13
- package/dist/components/overlay/widgets/Camera.svelte +11 -9
- package/dist/components/xr/ArmTeleop.svelte +33 -33
- package/dist/components/xr/CameraFeed.svelte +21 -23
- package/dist/components/xr/JointLimitsWidget.svelte +19 -5
- package/dist/components/xr/XRConfigPanel.svelte +17 -16
- package/dist/components/xr/XRControllerSettings.svelte +5 -4
- package/dist/components/xr/XRToast.svelte +11 -6
- package/dist/ecs/relations.d.ts +1 -0
- package/dist/ecs/relations.js +1 -0
- package/dist/ecs/traits.d.ts +2 -19
- package/dist/ecs/traits.js +33 -6
- package/dist/ecs/useQuery.svelte.js +3 -3
- package/dist/format.js +1 -1
- package/dist/hooks/use3DModels.svelte.js +36 -38
- package/dist/hooks/useConfigFrames.svelte.js +2 -7
- package/dist/hooks/useDrawAPI.svelte.js +1 -1
- package/dist/hooks/useFramelessComponents.svelte.js +1 -1
- package/dist/hooks/useFrames.svelte.js +62 -56
- package/dist/hooks/useGeometries.svelte.js +59 -36
- package/dist/hooks/useLinked.svelte.js +5 -4
- package/dist/hooks/usePartConfig.svelte.js +16 -17
- package/dist/hooks/usePointcloudObjects.svelte.js +107 -62
- package/dist/hooks/usePointclouds.svelte.js +50 -32
- package/dist/hooks/usePose.svelte.js +3 -7
- package/dist/hooks/useResizable.svelte.js +4 -3
- package/dist/hooks/useSettings.svelte.js +2 -2
- package/dist/hooks/useWeblabs.svelte.js +3 -2
- package/dist/hooks/useWorldState.svelte.js +31 -28
- package/dist/loaders/pcd/index.js +2 -1
- package/dist/loaders/pcd/worker.inline.d.ts +1 -1
- package/dist/loaders/pcd/worker.inline.js +1 -1
- package/dist/loaders/pcd/worker.js +1 -1
- package/dist/metadata.d.ts +22 -0
- package/dist/metadata.js +66 -0
- package/dist/snapshot.d.ts +20 -0
- package/dist/snapshot.js +72 -28
- package/dist/three/InstancedArrows/InstancedArrows.js +1 -1
- package/dist/three/InstancedArrows/box.js +1 -1
- package/dist/three/InstancedArrows/raycast.js +12 -12
- package/dist/three/OBBHelper.d.ts +3 -2
- package/dist/three/OBBHelper.js +17 -5
- package/package.json +19 -11
- package/dist/WorldObject.svelte.d.ts +0 -27
- package/dist/WorldObject.svelte.js +0 -114
- package/dist/components/Frame.svelte +0 -89
- package/dist/components/Geometry.svelte +0 -211
- package/dist/components/Geometry.svelte.d.ts +0 -19
- package/dist/components/Line.svelte +0 -43
- /package/dist/components/{Arrows → Entities/Arrows}/ArrowGroups.svelte.d.ts +0 -0
- /package/dist/components/{Entities.svelte.d.ts → Entities/Entities.svelte.d.ts} +0 -0
- /package/dist/components/{GLTF.svelte.d.ts → Entities/GLTF.svelte.d.ts} +0 -0
- /package/dist/components/{Label.svelte.d.ts → Entities/Label.svelte.d.ts} +0 -0
- /package/dist/components/{Line.svelte.d.ts → Entities/Line.svelte.d.ts} +0 -0
- /package/dist/components/{LineDots.svelte → Entities/LineDots.svelte} +0 -0
- /package/dist/components/{LineDots.svelte.d.ts → Entities/LineDots.svelte.d.ts} +0 -0
- /package/dist/components/{LineGeometry.svelte → Entities/LineGeometry.svelte} +0 -0
- /package/dist/components/{LineGeometry.svelte.d.ts → Entities/LineGeometry.svelte.d.ts} +0 -0
- /package/dist/components/{Points.svelte.d.ts → Entities/Points.svelte.d.ts} +0 -0
- /package/dist/components/{Pose.svelte.d.ts → Entities/Pose.svelte.d.ts} +0 -0
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { BatchedMesh, Color, Vector3 } from 'three';
|
|
2
|
-
import { isColorRepresentation, isRGB, parseColor, parseOpacity, parseRGB } from './color';
|
|
3
|
-
var SupportedShapes;
|
|
4
|
-
(function (SupportedShapes) {
|
|
5
|
-
SupportedShapes["points"] = "points";
|
|
6
|
-
SupportedShapes["line"] = "line";
|
|
7
|
-
SupportedShapes["arrow"] = "arrow";
|
|
8
|
-
})(SupportedShapes || (SupportedShapes = {}));
|
|
9
|
-
const METADATA_KEYS = [
|
|
10
|
-
'colors',
|
|
11
|
-
'color',
|
|
12
|
-
'opacity',
|
|
13
|
-
'gltf',
|
|
14
|
-
'points',
|
|
15
|
-
'pointSize',
|
|
16
|
-
'lineWidth',
|
|
17
|
-
'lineDotColor',
|
|
18
|
-
'batched',
|
|
19
|
-
'shape',
|
|
20
|
-
];
|
|
21
|
-
const isMetadataKey = (key) => {
|
|
22
|
-
return METADATA_KEYS.includes(key);
|
|
23
|
-
};
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
const unwrapValue = (value) => {
|
|
26
|
-
if (!value?.kind)
|
|
27
|
-
return value;
|
|
28
|
-
switch (value.kind.case) {
|
|
29
|
-
case 'numberValue':
|
|
30
|
-
case 'stringValue':
|
|
31
|
-
case 'boolValue':
|
|
32
|
-
return value.kind.value;
|
|
33
|
-
case 'structValue': {
|
|
34
|
-
const result = {};
|
|
35
|
-
for (const [key, val] of Object.entries(value.kind.value.fields || {})) {
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
result[key] = unwrapValue(val);
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
case 'listValue':
|
|
42
|
-
return value.kind.value.values?.map(unwrapValue) || [];
|
|
43
|
-
case 'nullValue':
|
|
44
|
-
return null;
|
|
45
|
-
default:
|
|
46
|
-
return value.kind.value;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
export const parseMetadata = (fields = {}) => {
|
|
50
|
-
const json = {};
|
|
51
|
-
for (const [k, v] of Object.entries(fields)) {
|
|
52
|
-
if (!isMetadataKey(k))
|
|
53
|
-
continue;
|
|
54
|
-
const unwrappedValue = unwrapValue(v);
|
|
55
|
-
switch (k) {
|
|
56
|
-
case 'color':
|
|
57
|
-
case 'lineDotColor':
|
|
58
|
-
json[k] = readColor(unwrappedValue);
|
|
59
|
-
break;
|
|
60
|
-
case 'colors': {
|
|
61
|
-
let colorBytes;
|
|
62
|
-
// Handle base64-encoded string (from protobuf Struct)
|
|
63
|
-
if (typeof unwrappedValue === 'string') {
|
|
64
|
-
const binary = atob(unwrappedValue);
|
|
65
|
-
colorBytes = new Uint8Array(binary.length);
|
|
66
|
-
for (let i = 0; i < binary.length; i++) {
|
|
67
|
-
colorBytes[i] = binary.charCodeAt(i);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else if (Array.isArray(unwrappedValue)) {
|
|
71
|
-
colorBytes = unwrappedValue;
|
|
72
|
-
}
|
|
73
|
-
if (colorBytes && colorBytes.length >= 3) {
|
|
74
|
-
const r = (colorBytes[0] ?? 0) / 255;
|
|
75
|
-
const g = (colorBytes[1] ?? 0) / 255;
|
|
76
|
-
const b = (colorBytes[2] ?? 0) / 255;
|
|
77
|
-
const a = colorBytes.length >= 4 ? (colorBytes[3] ?? 255) / 255 : 1;
|
|
78
|
-
json.color = new Color(r, g, b);
|
|
79
|
-
json.opacity = a;
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case 'opacity':
|
|
84
|
-
json[k] = parseOpacity(unwrappedValue);
|
|
85
|
-
break;
|
|
86
|
-
case 'gltf':
|
|
87
|
-
json[k] = unwrappedValue;
|
|
88
|
-
break;
|
|
89
|
-
case 'points':
|
|
90
|
-
json[k] = unwrappedValue;
|
|
91
|
-
break;
|
|
92
|
-
case 'pointSize':
|
|
93
|
-
json[k] = unwrappedValue;
|
|
94
|
-
break;
|
|
95
|
-
case 'lineWidth':
|
|
96
|
-
json[k] = unwrappedValue;
|
|
97
|
-
break;
|
|
98
|
-
case 'batched':
|
|
99
|
-
json[k] = unwrappedValue;
|
|
100
|
-
break;
|
|
101
|
-
case 'shape':
|
|
102
|
-
json[k] = unwrappedValue;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return json;
|
|
107
|
-
};
|
|
108
|
-
const readColor = (color) => {
|
|
109
|
-
if (isColorRepresentation(color))
|
|
110
|
-
return parseColor(color);
|
|
111
|
-
if (isRGB(color))
|
|
112
|
-
return parseRGB(color);
|
|
113
|
-
return new Color('black');
|
|
114
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte'
|
|
3
|
-
import { useObjectEvents } from '../hooks/useObjectEvents.svelte'
|
|
4
|
-
import { Color, Group, type Object3D } from 'three'
|
|
5
|
-
import Geometry from './Geometry.svelte'
|
|
6
|
-
import { useSelectedEntity } from '../hooks/useSelection.svelte'
|
|
7
|
-
import { useSettings } from '../hooks/useSettings.svelte'
|
|
8
|
-
import { use3DModels } from '../hooks/use3DModels.svelte'
|
|
9
|
-
import { colors, darkenColor, resourceColors } from '../color'
|
|
10
|
-
import type { Entity } from 'koota'
|
|
11
|
-
import { traits, useTrait } from '../ecs'
|
|
12
|
-
import type { Pose } from '@viamrobotics/sdk'
|
|
13
|
-
import { useResourceByName } from '../hooks/useResourceByName.svelte'
|
|
14
|
-
import { Portal, PortalTarget } from '@threlte/extras'
|
|
15
|
-
|
|
16
|
-
interface Props {
|
|
17
|
-
entity: Entity
|
|
18
|
-
pose?: Pose
|
|
19
|
-
children?: Snippet<[{ ref: Object3D }]>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let { entity, pose, children }: Props = $props()
|
|
23
|
-
|
|
24
|
-
let ref = $state<Group>()
|
|
25
|
-
|
|
26
|
-
const colorUtil = new Color()
|
|
27
|
-
|
|
28
|
-
const settings = useSettings()
|
|
29
|
-
const componentModels = use3DModels()
|
|
30
|
-
const selectedEntity = useSelectedEntity()
|
|
31
|
-
const resourceByName = useResourceByName()
|
|
32
|
-
|
|
33
|
-
const name = useTrait(() => entity, traits.Name)
|
|
34
|
-
const parent = useTrait(() => entity, traits.Parent)
|
|
35
|
-
const entityColor = useTrait(() => entity, traits.Color)
|
|
36
|
-
|
|
37
|
-
const events = useObjectEvents(() => entity)
|
|
38
|
-
const resourceColor = $derived.by(() => {
|
|
39
|
-
if (!name.current) {
|
|
40
|
-
return undefined
|
|
41
|
-
}
|
|
42
|
-
const subtype = resourceByName.current[name.current]?.subtype
|
|
43
|
-
return resourceColors[subtype as keyof typeof resourceColors]
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const color = $derived.by(() => {
|
|
47
|
-
if (entityColor.current) {
|
|
48
|
-
return colorUtil.set(entityColor.current.r, entityColor.current.g, entityColor.current.b)
|
|
49
|
-
}
|
|
50
|
-
if (resourceColor) {
|
|
51
|
-
return resourceColor
|
|
52
|
-
}
|
|
53
|
-
return colors.default
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const model = $derived.by(() => {
|
|
57
|
-
if (!name.current) {
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const [componentName, id] = name.current.split(':')
|
|
62
|
-
if (!componentName || !id) {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
return componentModels.current?.[componentName]?.[id].clone()
|
|
66
|
-
})
|
|
67
|
-
</script>
|
|
68
|
-
|
|
69
|
-
<Portal id={parent.current}>
|
|
70
|
-
<Geometry
|
|
71
|
-
bind:ref
|
|
72
|
-
{entity}
|
|
73
|
-
{model}
|
|
74
|
-
{pose}
|
|
75
|
-
renderMode={settings.current.renderArmModels}
|
|
76
|
-
color={selectedEntity.current === entity
|
|
77
|
-
? `#${darkenColor(color, 75).getHexString()}`
|
|
78
|
-
: `#${colorUtil.set(color).getHexString()}`}
|
|
79
|
-
{...events}
|
|
80
|
-
>
|
|
81
|
-
{#if name.current}
|
|
82
|
-
<PortalTarget id={name.current} />
|
|
83
|
-
{/if}
|
|
84
|
-
|
|
85
|
-
{#if ref}
|
|
86
|
-
{@render children?.({ ref })}
|
|
87
|
-
{/if}
|
|
88
|
-
</Geometry>
|
|
89
|
-
</Portal>
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { T, useThrelte, type Props as ThrelteProps } from '@threlte/core'
|
|
3
|
-
import { type Snippet } from 'svelte'
|
|
4
|
-
import { meshBounds } from '@threlte/extras'
|
|
5
|
-
import { BufferGeometry, Color, DoubleSide, FrontSide, Group, Mesh } from 'three'
|
|
6
|
-
import { Line2, LineMaterial } from 'three/examples/jsm/Addons.js'
|
|
7
|
-
import { CapsuleGeometry } from '../three/CapsuleGeometry'
|
|
8
|
-
import { colors, darkenColor } from '../color'
|
|
9
|
-
import AxesHelper from './AxesHelper.svelte'
|
|
10
|
-
import type { Entity } from 'koota'
|
|
11
|
-
import { traits, useTrait } from '../ecs'
|
|
12
|
-
import { poseToObject3d } from '../transform'
|
|
13
|
-
import type { Pose } from '@viamrobotics/sdk'
|
|
14
|
-
import LineGeometry from './LineGeometry.svelte'
|
|
15
|
-
|
|
16
|
-
interface Props extends ThrelteProps<Group> {
|
|
17
|
-
entity: Entity
|
|
18
|
-
color?: string
|
|
19
|
-
model?: Group
|
|
20
|
-
pose?: Pose
|
|
21
|
-
renderMode?: 'model' | 'colliders' | 'colliders+model'
|
|
22
|
-
ref?: Group
|
|
23
|
-
children?: Snippet<[{ ref: Group }]>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let {
|
|
27
|
-
entity,
|
|
28
|
-
color: overrideColor,
|
|
29
|
-
model,
|
|
30
|
-
renderMode = 'colliders',
|
|
31
|
-
pose,
|
|
32
|
-
ref = $bindable(),
|
|
33
|
-
children,
|
|
34
|
-
...rest
|
|
35
|
-
}: Props = $props()
|
|
36
|
-
|
|
37
|
-
const colorUtil = new Color()
|
|
38
|
-
|
|
39
|
-
const { invalidate } = useThrelte()
|
|
40
|
-
const name = useTrait(() => entity, traits.Name)
|
|
41
|
-
const entityColor = useTrait(() => entity, traits.Color)
|
|
42
|
-
const opacity = useTrait(() => entity, traits.Opacity)
|
|
43
|
-
const box = useTrait(() => entity, traits.Box)
|
|
44
|
-
const capsule = useTrait(() => entity, traits.Capsule)
|
|
45
|
-
const sphere = useTrait(() => entity, traits.Sphere)
|
|
46
|
-
const bufferGeometry = useTrait(() => entity, traits.BufferGeometry)
|
|
47
|
-
const linePositions = useTrait(() => entity, traits.LinePositions)
|
|
48
|
-
const lineWidth = useTrait(() => entity, traits.LineWidth)
|
|
49
|
-
const center = useTrait(() => entity, traits.Center)
|
|
50
|
-
const showAxesHelper = useTrait(() => entity, traits.ShowAxesHelper)
|
|
51
|
-
const materialProps = useTrait(() => entity, traits.Material)
|
|
52
|
-
const renderOrder = useTrait(() => entity, traits.RenderOrder)
|
|
53
|
-
|
|
54
|
-
const geometryType = $derived.by(() => {
|
|
55
|
-
if (box.current) return 'box'
|
|
56
|
-
if (capsule.current) return 'capsule'
|
|
57
|
-
if (sphere.current) return 'sphere'
|
|
58
|
-
if (bufferGeometry.current) return 'buffer'
|
|
59
|
-
if (linePositions.current) return 'line'
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
const color = $derived.by(() => {
|
|
63
|
-
if (overrideColor) {
|
|
64
|
-
return overrideColor
|
|
65
|
-
}
|
|
66
|
-
if (entityColor.current) {
|
|
67
|
-
return colorUtil
|
|
68
|
-
.setRGB(entityColor.current.r, entityColor.current.g, entityColor.current.b)
|
|
69
|
-
.getHexString()
|
|
70
|
-
}
|
|
71
|
-
return colors.default
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
const group = new Group()
|
|
75
|
-
ref = group
|
|
76
|
-
|
|
77
|
-
const mesh = $derived.by(() => {
|
|
78
|
-
if (geometryType === undefined) {
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const result = geometryType === 'line' ? new Line2() : new Mesh()
|
|
83
|
-
|
|
84
|
-
if (geometryType === 'line') {
|
|
85
|
-
result.raycast = meshBounds
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return result
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
$effect.pre(() => {
|
|
92
|
-
if (mesh && center.current) {
|
|
93
|
-
poseToObject3d(center.current, mesh)
|
|
94
|
-
invalidate()
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
const entityPose = useTrait(() => entity, traits.Pose)
|
|
99
|
-
const resolvedPose = $derived(pose ?? entityPose.current)
|
|
100
|
-
$effect.pre(() => {
|
|
101
|
-
if (resolvedPose) {
|
|
102
|
-
poseToObject3d(resolvedPose, group)
|
|
103
|
-
invalidate()
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
let geo = $state.raw<BufferGeometry>()
|
|
108
|
-
|
|
109
|
-
const oncreate = (bufferGeometry: BufferGeometry) => {
|
|
110
|
-
geo = bufferGeometry
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
$effect.pre(() => {
|
|
114
|
-
if (mesh && bufferGeometry.current) {
|
|
115
|
-
mesh.geometry = bufferGeometry.current
|
|
116
|
-
oncreate(bufferGeometry.current)
|
|
117
|
-
|
|
118
|
-
return () => {
|
|
119
|
-
geo = undefined
|
|
120
|
-
mesh?.geometry?.dispose()
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
</script>
|
|
125
|
-
|
|
126
|
-
<T
|
|
127
|
-
is={group}
|
|
128
|
-
{...rest}
|
|
129
|
-
>
|
|
130
|
-
{#if geometryType}
|
|
131
|
-
{#if showAxesHelper.current}
|
|
132
|
-
<AxesHelper
|
|
133
|
-
width={3}
|
|
134
|
-
length={0.1}
|
|
135
|
-
/>
|
|
136
|
-
{/if}
|
|
137
|
-
|
|
138
|
-
{#if model && renderMode.includes('model')}
|
|
139
|
-
<T is={model} />
|
|
140
|
-
{/if}
|
|
141
|
-
|
|
142
|
-
{#if !model || renderMode.includes('colliders')}
|
|
143
|
-
<T
|
|
144
|
-
is={mesh}
|
|
145
|
-
name={entity}
|
|
146
|
-
userData.name={name}
|
|
147
|
-
renderOrder={renderOrder.current}
|
|
148
|
-
>
|
|
149
|
-
{#if linePositions.current}
|
|
150
|
-
<LineGeometry positions={linePositions.current} />
|
|
151
|
-
{:else if box.current}
|
|
152
|
-
{@const { x, y, z } = box.current ?? { x: 0, y: 0, z: 0 }}
|
|
153
|
-
<T.BoxGeometry
|
|
154
|
-
args={[x * 0.001, y * 0.001, z * 0.001]}
|
|
155
|
-
{oncreate}
|
|
156
|
-
/>
|
|
157
|
-
{:else if sphere.current}
|
|
158
|
-
{@const { r } = sphere.current ?? { r: 0 }}
|
|
159
|
-
<T.SphereGeometry
|
|
160
|
-
args={[r * 0.001]}
|
|
161
|
-
{oncreate}
|
|
162
|
-
/>
|
|
163
|
-
{:else if capsule.current}
|
|
164
|
-
{@const { r, l } = capsule.current ?? { r: 0, l: 0 }}
|
|
165
|
-
<T
|
|
166
|
-
is={CapsuleGeometry}
|
|
167
|
-
args={[r * 0.001, l * 0.001]}
|
|
168
|
-
{oncreate}
|
|
169
|
-
/>
|
|
170
|
-
{/if}
|
|
171
|
-
|
|
172
|
-
{#if linePositions.current}
|
|
173
|
-
<T
|
|
174
|
-
is={LineMaterial}
|
|
175
|
-
{color}
|
|
176
|
-
width={lineWidth.current ? lineWidth.current * 0.001 : 0.5}
|
|
177
|
-
depthTest={materialProps.current?.depthTest ?? true}
|
|
178
|
-
/>
|
|
179
|
-
{:else}
|
|
180
|
-
{@const currentOpacity = opacity.current ?? 0.7}
|
|
181
|
-
<T.MeshToonMaterial
|
|
182
|
-
{color}
|
|
183
|
-
side={geometryType === 'buffer' ? DoubleSide : FrontSide}
|
|
184
|
-
transparent={currentOpacity < 1}
|
|
185
|
-
depthWrite={currentOpacity === 1}
|
|
186
|
-
opacity={currentOpacity}
|
|
187
|
-
depthTest={materialProps.current?.depthTest ?? true}
|
|
188
|
-
/>
|
|
189
|
-
|
|
190
|
-
{#if geo && (renderMode.includes('colliders') || !model)}
|
|
191
|
-
<T.LineSegments
|
|
192
|
-
raycast={() => null}
|
|
193
|
-
bvh={{ enabled: false }}
|
|
194
|
-
>
|
|
195
|
-
<T.EdgesGeometry args={[geo, 0]} />
|
|
196
|
-
<T.LineBasicMaterial color={darkenColor(color, 10)} />
|
|
197
|
-
</T.LineSegments>
|
|
198
|
-
{/if}
|
|
199
|
-
{/if}
|
|
200
|
-
</T>
|
|
201
|
-
{/if}
|
|
202
|
-
{:else if showAxesHelper.current}
|
|
203
|
-
<AxesHelper
|
|
204
|
-
name={entity}
|
|
205
|
-
width={3}
|
|
206
|
-
length={0.1}
|
|
207
|
-
/>
|
|
208
|
-
{/if}
|
|
209
|
-
|
|
210
|
-
{@render children?.({ ref: group })}
|
|
211
|
-
</T>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type Props as ThrelteProps } from '@threlte/core';
|
|
2
|
-
import { type Snippet } from 'svelte';
|
|
3
|
-
import { Group } from 'three';
|
|
4
|
-
import type { Entity } from 'koota';
|
|
5
|
-
import type { Pose } from '@viamrobotics/sdk';
|
|
6
|
-
interface Props extends ThrelteProps<Group> {
|
|
7
|
-
entity: Entity;
|
|
8
|
-
color?: string;
|
|
9
|
-
model?: Group;
|
|
10
|
-
pose?: Pose;
|
|
11
|
-
renderMode?: 'model' | 'colliders' | 'colliders+model';
|
|
12
|
-
ref?: Group;
|
|
13
|
-
children?: Snippet<[{
|
|
14
|
-
ref: Group;
|
|
15
|
-
}]>;
|
|
16
|
-
}
|
|
17
|
-
declare const Geometry: import("svelte").Component<Props, {}, "ref">;
|
|
18
|
-
type Geometry = ReturnType<typeof Geometry>;
|
|
19
|
-
export default Geometry;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { Color } from 'three'
|
|
3
|
-
|
|
4
|
-
const colorUtil = new Color()
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
<script lang="ts">
|
|
8
|
-
import Frame from './Frame.svelte'
|
|
9
|
-
import type { Snippet } from 'svelte'
|
|
10
|
-
import type { Entity } from 'koota'
|
|
11
|
-
import { traits, useTrait } from '../ecs'
|
|
12
|
-
import LineDots from './LineDots.svelte'
|
|
13
|
-
import { darkenColor } from '../color'
|
|
14
|
-
|
|
15
|
-
interface Props {
|
|
16
|
-
entity: Entity
|
|
17
|
-
children?: Snippet
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let { entity, children }: Props = $props()
|
|
21
|
-
|
|
22
|
-
const linePositions = useTrait(() => entity, traits.LinePositions)
|
|
23
|
-
const color = useTrait(() => entity, traits.Color)
|
|
24
|
-
const pointSize = useTrait(() => entity, traits.PointSize)
|
|
25
|
-
|
|
26
|
-
const resolvedColor = $derived(
|
|
27
|
-
colorUtil
|
|
28
|
-
.setRGB(color.current?.r ?? 1, color.current?.g ?? 0, color.current?.b ?? 0)
|
|
29
|
-
.getHexString()
|
|
30
|
-
)
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<Frame {entity}>
|
|
34
|
-
{@render children?.()}
|
|
35
|
-
</Frame>
|
|
36
|
-
|
|
37
|
-
{#if linePositions.current && pointSize.current}
|
|
38
|
-
<LineDots
|
|
39
|
-
color={darkenColor(resolvedColor, 10)}
|
|
40
|
-
positions={linePositions.current}
|
|
41
|
-
scale={pointSize.current * 0.001}
|
|
42
|
-
/>
|
|
43
|
-
{/if}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|