@viamrobotics/motion-tools 1.12.1 → 1.12.3

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.
@@ -17,7 +17,6 @@
17
17
  import FileDrop from './FileDrop/FileDrop.svelte'
18
18
  import { provideWeblabs } from '../hooks/useWeblabs.svelte'
19
19
  import { providePartConfig } from '../hooks/usePartConfig.svelte'
20
- import { useViamClient } from '@viamrobotics/svelte-sdk'
21
20
  import LiveUpdatesBanner from './overlay/LiveUpdatesBanner.svelte'
22
21
  import ArmPositions from './overlay/widgets/ArmPositions.svelte'
23
22
  import { provideEnvironment } from '../hooks/useEnvironment.svelte'
@@ -33,10 +32,10 @@
33
32
  import { useXR } from '@threlte/xr'
34
33
 
35
34
  interface LocalConfigProps {
36
- getLocalPartConfig: () => Struct
35
+ current: Struct
36
+ isDirty: boolean
37
+ componentToFragId: Record<string, string>
37
38
  setLocalPartConfig: (config: Struct) => void
38
- isDirty: () => boolean
39
- getComponentToFragId: () => Record<string, string>
40
39
  }
41
40
 
42
41
  interface Props {
@@ -65,7 +64,6 @@
65
64
 
66
65
  provideWorld()
67
66
 
68
- const appClient = useViamClient()
69
67
  const settings = provideSettings()
70
68
  const environment = provideEnvironment()
71
69
  const currentRobotCameraWidgets = $derived(settings.current.openCameraWidgets[partID] || [])
@@ -82,25 +80,10 @@
82
80
 
83
81
  let root = $state.raw<HTMLElement>()
84
82
 
85
- providePartConfig(() => {
86
- if (localConfigProps) {
87
- return {
88
- appEmbeddedPartConfigProps: {
89
- isDirty: () => localConfigProps.isDirty(),
90
- getLocalPartConfig: () => localConfigProps.getLocalPartConfig(),
91
- setLocalPartConfig: (config: Struct) => localConfigProps.setLocalPartConfig(config),
92
- getComponentToFragId: () => localConfigProps.getComponentToFragId(),
93
- },
94
- }
95
- } else {
96
- return {
97
- standalonePartConfigProps: {
98
- viamClient: () => appClient?.current,
99
- partID: () => partID,
100
- },
101
- }
102
- }
103
- })
83
+ providePartConfig(
84
+ () => partID,
85
+ () => localConfigProps
86
+ )
104
87
 
105
88
  $effect.pre(() => {
106
89
  if (localConfigProps) {
@@ -3,10 +3,10 @@ import type { Struct } from '@viamrobotics/sdk';
3
3
  import type { CameraPose } from '../hooks/useControls.svelte';
4
4
  import { type DrawConnectionConfig } from '../hooks/useDrawConnectionConfig.svelte';
5
5
  interface LocalConfigProps {
6
- getLocalPartConfig: () => Struct;
6
+ current: Struct;
7
+ isDirty: boolean;
8
+ componentToFragId: Record<string, string>;
7
9
  setLocalPartConfig: (config: Struct) => void;
8
- isDirty: () => boolean;
9
- getComponentToFragId: () => Record<string, string>;
10
10
  }
11
11
  interface Props {
12
12
  partID?: string;
@@ -1,5 +1,5 @@
1
1
  import type { Snapshot } from '../../buf/draw/v1/snapshot_pb';
2
- import type { SuccessMessage } from '../../loaders/pcd/worker';
2
+ import type { SuccessMessage } from '../../loaders/pcd/messages';
3
3
  import type { BufferGeometry } from 'three';
4
4
  interface FileDropSuccess {
5
5
  success: true;
@@ -175,7 +175,7 @@
175
175
  is={LineMaterial}
176
176
  {color}
177
177
  width={lineWidth.current ? lineWidth.current * 0.001 : 0.5}
178
- depthTest={materialProps.current?.depthTest}
178
+ depthTest={materialProps.current?.depthTest ?? true}
179
179
  />
180
180
  {:else}
181
181
  {@const currentOpacity = opacity.current ?? 0.7}
@@ -185,7 +185,7 @@
185
185
  transparent={currentOpacity < 1}
186
186
  depthWrite={currentOpacity === 1}
187
187
  opacity={currentOpacity}
188
- depthTest={materialProps.current?.depthTest}
188
+ depthTest={materialProps.current?.depthTest ?? true}
189
189
  />
190
190
 
191
191
  {#if geo && (renderMode.includes('colliders') || !model)}
@@ -54,6 +54,12 @@
54
54
  }
55
55
  }
56
56
 
57
+ $effect(() => {
58
+ if (isLassoMode) {
59
+ settings.current.cameraMode = 'orthographic'
60
+ }
61
+ })
62
+
57
63
  $effect(() => {
58
64
  if (enabled) {
59
65
  settings.current.interactionMode = 'lasso'
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { ShaderMaterial, Vector3 } from 'three'
3
3
  import { T } from '@threlte/core'
4
- import { Grid, interactivity, PerfMonitor, PortalTarget } from '@threlte/extras'
4
+ import { Environment, Grid, interactivity, PerfMonitor, PortalTarget } from '@threlte/extras'
5
5
  import Entities from './Entities.svelte'
6
6
  import Selected from './Selected.svelte'
7
7
  import Focus from './Focus.svelte'
@@ -18,6 +18,7 @@
18
18
  import PointerMissBox from './PointerMissBox.svelte'
19
19
  import BatchedArrows from './BatchedArrows.svelte'
20
20
  import Arrows from './Arrows/ArrowGroups.svelte'
21
+ import hdrImage from '../assets/ferndale_studio_11_1k.hdr'
21
22
 
22
23
  interface Props {
23
24
  children?: Snippet
@@ -54,6 +55,8 @@
54
55
  <PerfMonitor anchorX="right" />
55
56
  {/if}
56
57
 
58
+ <Environment url={hdrImage} />
59
+
57
60
  <T.Group
58
61
  position={origin.position}
59
62
  rotation.x={$isPresenting ? -Math.PI / 2 : 0}
@@ -17,7 +17,7 @@
17
17
  if (event.key.toLowerCase() === 's') {
18
18
  event.preventDefault()
19
19
  event.stopImmediatePropagation()
20
- partConfig.saveLocalPartConfig()
20
+ partConfig.save()
21
21
  }
22
22
  }
23
23
  }}
@@ -43,7 +43,7 @@
43
43
  <Button
44
44
  class="cursor-pointer text-blue-600"
45
45
  onclick={() => {
46
- partConfig.resetLocalPartConfig()
46
+ partConfig.discardChanges()
47
47
  }}
48
48
  >
49
49
  Discard
@@ -54,7 +54,7 @@
54
54
  aria-label="Save"
55
55
  class="cursor-pointer text-blue-600"
56
56
  onclick={() => {
57
- partConfig.saveLocalPartConfig()
57
+ partConfig.save()
58
58
  }}
59
59
  >
60
60
  <div class="flex gap-2">
@@ -7,8 +7,17 @@ export declare const resource: {
7
7
  y: number;
8
8
  z: number;
9
9
  };
10
+ orientation: {
11
+ type: "ov_degrees";
12
+ value: {
13
+ x: number;
14
+ y: number;
15
+ z: number;
16
+ th: number;
17
+ };
18
+ };
10
19
  geometry: {
11
- type: string;
20
+ type: "box";
12
21
  x: number;
13
22
  y: number;
14
23
  z: number;
@@ -3,6 +3,7 @@ export const resource = {
3
3
  frame: {
4
4
  parent: 'parent_frame',
5
5
  translation: { x: 10, y: 20, z: 30 },
6
+ orientation: { type: 'ov_degrees', value: { x: 0, y: 0, z: 1, th: 0 } },
6
7
  geometry: {
7
8
  type: 'box',
8
9
  x: 10,
@@ -9,7 +9,7 @@
9
9
  </script>
10
10
 
11
11
  <div
12
- class="absolute top-2 z-4 flex w-full justify-center gap-2"
12
+ class="absolute top-2 z-4 flex w-full items-center justify-center gap-2"
13
13
  {...rest}
14
14
  >
15
15
  <!-- camera view -->
@@ -4,6 +4,7 @@ import { getContext, setContext } from 'svelte';
4
4
  import { useSettings } from './useSettings.svelte';
5
5
  import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
6
6
  import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
7
+ import { isInstanceOf } from '@threlte/core';
7
8
  const gltfLoader = new GLTFLoader();
8
9
  const dracoLoader = new DRACOLoader();
9
10
  dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.6/');
@@ -38,6 +39,16 @@ export const provide3DModels = (partID) => {
38
39
  const arrayBuffer = model.mesh.buffer.slice(model.mesh.byteOffset, model.mesh.byteOffset + model.mesh.byteLength);
39
40
  const gltfModel = await gltfLoader.parseAsync(arrayBuffer, '');
40
41
  next[prefix][id] = gltfModel.scene;
42
+ gltfModel.scene.traverse((object) => {
43
+ if (isInstanceOf(object, 'Mesh')) {
44
+ const { material } = object;
45
+ console.log(material);
46
+ if (isInstanceOf(material, 'MeshStandardMaterial')) {
47
+ material.roughness = 0.3;
48
+ material.metalness = 0.1;
49
+ }
50
+ }
51
+ });
41
52
  }
42
53
  current = next;
43
54
  }
@@ -6,7 +6,7 @@ export const provideFramelessComponents = () => {
6
6
  const partConfig = usePartConfig();
7
7
  const frames = useFrames();
8
8
  const current = $derived.by(() => {
9
- const components = partConfig.localPartConfig.toJson()?.components;
9
+ const { components } = partConfig.current;
10
10
  const partComponentsWIthNoFrame = components
11
11
  ?.filter((component) => component.frame === undefined)
12
12
  .map((component) => component.name) ?? [];
@@ -52,7 +52,7 @@ export const provideFrames = (partID) => {
52
52
  return frames;
53
53
  });
54
54
  const [configFrames, configUnsetFrameNames] = $derived.by(() => {
55
- const components = partConfig.localPartConfig.toJson().components;
55
+ const { components } = partConfig.current;
56
56
  const results = {};
57
57
  const unsetResults = [];
58
58
  for (const { name, frame } of components ?? []) {
@@ -68,7 +68,7 @@ export const provideFrames = (partID) => {
68
68
  return [results, unsetResults];
69
69
  });
70
70
  const [fragmentFrames, fragmentUnsetFrameNames] = $derived.by(() => {
71
- const { fragment_mods: fragmentMods = [] } = partConfig.localPartConfig.toJson() ?? {};
71
+ const { fragment_mods: fragmentMods = [] } = partConfig.current;
72
72
  const fragmentDefinedComponents = Object.keys(partConfig.componentNameToFragmentId);
73
73
  const results = {};
74
74
  const unsetResults = [];
@@ -1,6 +1,5 @@
1
1
  import { type Frame } from '../frame';
2
2
  import { Struct, Pose } from '@viamrobotics/sdk';
3
- import type { ViamClient } from '@viamrobotics/sdk';
4
3
  export interface PartConfig {
5
4
  components: {
6
5
  name: string;
@@ -11,31 +10,23 @@ export interface PartConfig {
11
10
  mods: any[];
12
11
  }[];
13
12
  }
14
- interface PartConfigParams {
15
- appEmbeddedPartConfigProps?: AppEmbeddedPartConfigProps;
16
- standalonePartConfigProps?: StandalonePartConfigProps;
17
- }
18
13
  interface PartConfigContext {
14
+ current: PartConfig;
15
+ isDirty: boolean;
16
+ hasEditPermissions: boolean;
17
+ componentNameToFragmentId: Record<string, string>;
19
18
  updateFrame: (componentName: string, referenceFrame: string, pose: Pose, geometry?: Frame['geometry']) => void;
20
- saveLocalPartConfig: () => void;
21
- resetLocalPartConfig: () => void;
22
19
  deleteFrame: (componentName: string) => void;
23
20
  createFrame: (componentName: string) => void;
24
- componentNameToFragmentId: Record<string, string>;
25
- localPartConfig: Struct;
26
- isDirty: boolean;
27
- hasEditPermissions: boolean;
21
+ save: () => void;
22
+ discardChanges: () => void;
28
23
  }
29
- export declare const providePartConfig: (params: () => PartConfigParams) => void;
24
+ export declare const providePartConfig: (partID: () => string, params: () => AppEmbeddedPartConfigProps | undefined) => void;
30
25
  export declare const usePartConfig: () => PartConfigContext;
31
26
  interface AppEmbeddedPartConfigProps {
32
- isDirty: () => boolean;
33
- getLocalPartConfig: () => Struct;
27
+ current: Struct;
28
+ isDirty: boolean;
29
+ componentToFragId: Record<string, string>;
34
30
  setLocalPartConfig: (config: Struct) => void;
35
- getComponentToFragId: () => Record<string, string>;
36
- }
37
- interface StandalonePartConfigProps {
38
- viamClient: () => ViamClient | undefined;
39
- partID: () => string;
40
31
  }
41
32
  export {};