@viamrobotics/motion-tools 0.19.1 → 1.0.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.
- package/README.md +56 -26
- package/dist/FrameConfigUpdater.svelte.d.ts +11 -17
- package/dist/FrameConfigUpdater.svelte.js +109 -109
- package/dist/WorldObject.svelte.js +2 -15
- package/dist/common/v1/common_pb.d.ts +950 -0
- package/dist/common/v1/common_pb.js +1399 -0
- package/dist/components/App.svelte +37 -21
- package/dist/components/App.svelte.d.ts +1 -0
- package/dist/components/BatchedArrows.svelte +102 -0
- package/dist/components/BatchedArrows.svelte.d.ts +3 -0
- package/dist/components/CameraControls.svelte +2 -3
- package/dist/components/Details.svelte +364 -365
- package/dist/components/Entities.svelte +73 -0
- package/dist/components/{WorldObjects.svelte.d.ts → Entities.svelte.d.ts} +3 -3
- package/dist/components/FileDrop.svelte +9 -23
- package/dist/components/Focus.svelte +2 -3
- package/dist/components/Frame.svelte +41 -22
- package/dist/components/Frame.svelte.d.ts +4 -6
- package/dist/components/GLTF.svelte +36 -0
- package/dist/components/GLTF.svelte.d.ts +11 -0
- package/dist/components/Geometry2.svelte +201 -0
- package/dist/components/Geometry2.svelte.d.ts +18 -0
- package/dist/components/KeyboardControls.svelte +3 -3
- package/dist/components/Line.svelte +10 -13
- package/dist/components/Line.svelte.d.ts +2 -2
- package/dist/components/LiveUpdatesBanner.svelte +51 -15
- package/dist/components/MeasureTool.svelte +4 -5
- package/dist/components/Pointcloud.svelte +27 -14
- package/dist/components/Pointcloud.svelte.d.ts +2 -2
- package/dist/components/PointerMissBox.svelte +3 -3
- package/dist/components/Pose.svelte +31 -6
- package/dist/components/Pose.svelte.d.ts +2 -2
- package/dist/components/Scene.svelte +7 -6
- package/dist/components/SceneProviders.svelte +0 -6
- package/dist/components/Selected.svelte +22 -16
- package/dist/components/StaticGeometries.svelte +51 -27
- package/dist/components/Tree/Tree.svelte +28 -22
- package/dist/components/Tree/Tree.svelte.d.ts +2 -3
- package/dist/components/Tree/TreeContainer.svelte +72 -40
- package/dist/components/Tree/Widgets.svelte +2 -5
- package/dist/components/Tree/buildTree.d.ts +3 -6
- package/dist/components/Tree/buildTree.js +19 -39
- package/dist/components/__tests__/__fixtures__/entity.d.ts +2 -0
- package/dist/components/__tests__/__fixtures__/entity.js +20 -0
- package/dist/components/__tests__/__fixtures__/resource.d.ts +17 -0
- package/dist/components/__tests__/__fixtures__/resource.js +13 -0
- package/dist/components/dashboard/Dashboard.svelte +5 -3
- package/dist/components/dashboard/Dashboard.svelte.d.ts +7 -2
- package/dist/components/widgets/ArmPositions.svelte +19 -7
- package/dist/draw/v1/drawing_pb.d.ts +341 -0
- package/dist/draw/v1/drawing_pb.js +417 -0
- package/dist/draw/v1/metadata_pb.d.ts +23 -0
- package/dist/draw/v1/metadata_pb.js +39 -0
- package/dist/draw/v1/scene_pb.d.ts +230 -0
- package/dist/draw/v1/scene_pb.js +298 -0
- package/dist/draw/v1/snapshot_pb.d.ts +42 -0
- package/dist/draw/v1/snapshot_pb.js +61 -0
- package/dist/draw/v1/transforms_pb.d.ts +23 -0
- package/dist/draw/v1/transforms_pb.js +39 -0
- package/dist/ecs/index.d.ts +4 -0
- package/dist/ecs/index.js +4 -0
- package/dist/ecs/traits.d.ts +128 -0
- package/dist/ecs/traits.js +81 -0
- package/dist/ecs/useQuery.svelte.d.ts +4 -0
- package/dist/ecs/useQuery.svelte.js +49 -0
- package/dist/ecs/useTrait.svelte.d.ts +19 -0
- package/dist/ecs/useTrait.svelte.js +40 -0
- package/dist/ecs/useWorld.d.ts +4 -0
- package/dist/ecs/useWorld.js +10 -0
- package/dist/frame.d.ts +2 -0
- package/dist/frame.js +14 -0
- package/dist/geometry.js +6 -6
- package/dist/hooks/__tests__/fixtures/ResizableTestWrapper.svelte +41 -0
- package/dist/hooks/__tests__/fixtures/ResizableTestWrapper.svelte.d.ts +6 -0
- package/dist/hooks/use3DModels.svelte.js +6 -4
- package/dist/hooks/useDrawAPI.svelte.d.ts +0 -10
- package/dist/hooks/useDrawAPI.svelte.js +144 -267
- package/dist/hooks/useFramelessComponents.svelte.js +1 -1
- package/dist/hooks/useFrames.svelte.d.ts +6 -2
- package/dist/hooks/useFrames.svelte.js +144 -68
- package/dist/hooks/useGeometries.svelte.d.ts +0 -2
- package/dist/hooks/useGeometries.svelte.js +49 -25
- package/dist/hooks/useObjectEvents.svelte.d.ts +3 -2
- package/dist/hooks/useObjectEvents.svelte.js +11 -7
- package/dist/hooks/usePartConfig.svelte.d.ts +1 -1
- package/dist/hooks/usePartConfig.svelte.js +2 -1
- package/dist/hooks/usePointclouds.svelte.d.ts +0 -2
- package/dist/hooks/usePointclouds.svelte.js +52 -21
- package/dist/hooks/usePose.svelte.js +15 -7
- package/dist/hooks/useResizable.svelte.d.ts +12 -0
- package/dist/hooks/useResizable.svelte.js +45 -0
- package/dist/hooks/useResourceByName.svelte.js +8 -5
- package/dist/hooks/useSelection.svelte.d.ts +13 -23
- package/dist/hooks/useSelection.svelte.js +45 -65
- package/dist/hooks/useVisibility.svelte.d.ts +2 -1
- package/dist/hooks/useWeblabs.svelte.d.ts +0 -1
- package/dist/hooks/useWeblabs.svelte.js +0 -1
- package/dist/hooks/useWorldState.svelte.d.ts +9 -0
- package/dist/hooks/useWorldState.svelte.js +158 -107
- package/dist/lib.d.ts +1 -0
- package/dist/lib.js +2 -0
- package/dist/three/BatchedArrow.d.ts +2 -3
- package/dist/three/BatchedArrow.js +3 -11
- package/dist/three/CapsuleGeometry.d.ts +1 -1
- package/dist/three/CapsuleGeometry.js +3 -1
- package/dist/transform.js +0 -15
- package/package.json +12 -7
- package/dist/components/WorldObject.svelte +0 -28
- package/dist/components/WorldObject.svelte.d.ts +0 -11
- package/dist/components/WorldObjects.svelte +0 -159
- package/dist/components/WorldState.svelte +0 -92
- package/dist/components/WorldState.svelte.d.ts +0 -7
- package/dist/components/__tests__/__fixtures__/worldObject.svelte.d.ts +0 -2
- package/dist/components/__tests__/__fixtures__/worldObject.svelte.js +0 -35
- package/dist/components/portal/Portal.svelte +0 -25
- package/dist/components/portal/Portal.svelte.d.ts +0 -8
- package/dist/components/portal/PortalTarget.svelte +0 -18
- package/dist/components/portal/PortalTarget.svelte.d.ts +0 -6
- package/dist/components/portal/index.d.ts +0 -2
- package/dist/components/portal/index.js +0 -2
- package/dist/components/portal/usePortalContext.svelte.d.ts +0 -5
- package/dist/components/portal/usePortalContext.svelte.js +0 -5
- package/dist/hooks/useArrows.svelte.d.ts +0 -3
- package/dist/hooks/useArrows.svelte.js +0 -9
- package/dist/hooks/useDraggable.svelte.d.ts +0 -10
- package/dist/hooks/useDraggable.svelte.js +0 -36
- package/dist/hooks/useObjects.svelte.d.ts +0 -7
- package/dist/hooks/useObjects.svelte.js +0 -35
- package/dist/hooks/usePersistentUUIDs.svelte.d.ts +0 -5
- package/dist/hooks/usePersistentUUIDs.svelte.js +0 -13
- package/dist/hooks/useResourceByName.svelte.d.ts +0 -7
- package/dist/hooks/useStaticGeometries.svelte.d.ts +0 -9
- package/dist/hooks/useStaticGeometries.svelte.js +0 -47
- package/dist/workers/worldStateWorker.d.ts +0 -1
- package/dist/workers/worldStateWorker.js +0 -114
- package/dist/world-state-messages.d.ts +0 -23
- package/dist/world-state-messages.js +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# motion-tools
|
|
2
2
|
|
|
3
3
|
`motion-tools` aims to provide a visualization interface for any spatial information using Viam's APIs. This typically means motion-related monitoring, testing, and debugging.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Getting started
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
To run the app, you will need to set your project up by installing the app dependencies and ensuring you can connect
|
|
8
|
+
to your machines if required.
|
|
9
|
+
|
|
10
|
+
### Project setup
|
|
8
11
|
|
|
9
12
|
The easiest way to get started is using our automated setup script:
|
|
10
13
|
|
|
@@ -20,34 +23,15 @@ This single command will:
|
|
|
20
23
|
4. Install **bun** runtime
|
|
21
24
|
5. Install all project dependencies
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
make up
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
#### Manual Setup
|
|
26
|
+
#### Manual setup
|
|
30
27
|
|
|
31
|
-
If you prefer to install dependencies manually:
|
|
28
|
+
If the above does not work for you, or if you prefer to install dependencies manually:
|
|
32
29
|
|
|
33
30
|
1. [Install nvm](https://github.com/nvm-sh/nvm#installing-and-updating)
|
|
34
31
|
2. Install Node.js LTS: `nvm install --lts && nvm use --lts`
|
|
35
32
|
3. [Install pnpm](https://pnpm.io/installation)
|
|
36
33
|
4. [Install bun](https://bun.sh/docs/installation)
|
|
37
34
|
5. Install dependencies: `pnpm i`
|
|
38
|
-
6. Run local app server: `pnpm dev`
|
|
39
|
-
|
|
40
|
-
#### Available Make Commands
|
|
41
|
-
|
|
42
|
-
- `make setup` - Complete development environment setup
|
|
43
|
-
- `make up` - Start the development server
|
|
44
|
-
- `make help` - Show available commands
|
|
45
|
-
|
|
46
|
-
### Running the visualizer
|
|
47
|
-
|
|
48
|
-
To visit the visualizer, go to `http://localhost:5173/`
|
|
49
|
-
|
|
50
|
-
Open the machine config page (bottom right) and enter in connection details to visualize a specific machine. You can also add machine configs from an env file (see below).
|
|
51
35
|
|
|
52
36
|
### Env files for machine configs
|
|
53
37
|
|
|
@@ -67,13 +51,59 @@ VITE_CONFIGS='
|
|
|
67
51
|
'
|
|
68
52
|
```
|
|
69
53
|
|
|
70
|
-
###
|
|
54
|
+
### Running the app locally
|
|
55
|
+
|
|
56
|
+
After setup completes, you can start a local app server with:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
make up
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This starts the app as a static site. The build part of the process will only run if you have not built the app yet as a part of `make up`, or your build is out of date.
|
|
63
|
+
|
|
64
|
+
#### Running multiple apps
|
|
65
|
+
|
|
66
|
+
If you want to be able to run multiple versions of the app, you can configure how the servers run. The `make up` command can accept two options:
|
|
67
|
+
|
|
68
|
+
1. `STATIC_PORT` is the port for the static file server, and defaults to `5173`
|
|
69
|
+
2. `WS_PORT` is the port for the websocket server used to communicate with the draw client API
|
|
70
|
+
|
|
71
|
+
> [!NOTE]
|
|
72
|
+
> The `WS_PORT` is not fully configurable at the moment, so passing it will only affect where the frontend listens for the websocket server, but calls with the draw client API are currently hardcoded to point to `"http://localhost:3000/"`. If this is a feature you require, please submit a request to the viz team!
|
|
73
|
+
|
|
74
|
+
To run two apps using the same web socket server, run:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
# in one terminal
|
|
78
|
+
make up
|
|
79
|
+
|
|
80
|
+
# in another terminal
|
|
81
|
+
make up STATIC_PORT=5174
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The apps should be available on `http://localhost:5173/` and `http://localhost:5174/`, and calls to the draw client API should render in both.
|
|
85
|
+
|
|
86
|
+
### Local development
|
|
87
|
+
|
|
88
|
+
If you are contributing to `motion-tools`, you should just run the development web server with:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
pnpm dev
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Running the visualizer
|
|
95
|
+
|
|
96
|
+
To visit the visualizer, go to `http://localhost:5173/`
|
|
97
|
+
|
|
98
|
+
Open the machine config page (bottom right) and enter in connection details to visualize a specific machine. You can also add machine configs from an env file (see below).
|
|
99
|
+
|
|
100
|
+
## Executing drawing commands
|
|
71
101
|
|
|
72
102
|
The visualizer includes a golang package that allows executing commands to the visualizer.
|
|
73
103
|
|
|
74
104
|
The list of available commands [can be found here](https://pkg.go.dev/github.com/viam-labs/motion-tools@v0.9.0/client/client).
|
|
75
105
|
|
|
76
|
-
|
|
106
|
+
## Programmatic camera control
|
|
77
107
|
|
|
78
108
|
It is possible to programmatically move the viewer camera and even modify the camera settings during runtime.
|
|
79
109
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { WorldObject } from './lib';
|
|
3
|
-
import type { Geometries } from './WorldObject.svelte';
|
|
1
|
+
import type { Entity } from 'koota';
|
|
4
2
|
import type { Pose } from '@viamrobotics/sdk';
|
|
3
|
+
import type { Frame } from './frame';
|
|
4
|
+
import type { Vector3Like } from 'three';
|
|
5
5
|
type UpdateFrameCallback = {
|
|
6
6
|
(componentName: string, referenceFrame: string, pose: Pose, geometry?: Frame['geometry']): void;
|
|
7
7
|
};
|
|
@@ -9,26 +9,20 @@ type RemoveFrameCallback = {
|
|
|
9
9
|
(componentName: string): void;
|
|
10
10
|
};
|
|
11
11
|
export declare class FrameConfigUpdater {
|
|
12
|
-
private object;
|
|
13
|
-
private referenceFrame;
|
|
14
12
|
private updateFrame;
|
|
15
13
|
private removeFrame;
|
|
16
|
-
constructor(
|
|
17
|
-
updateLocalPosition: (
|
|
18
|
-
|
|
19
|
-
y?: number;
|
|
20
|
-
z?: number;
|
|
21
|
-
}) => void;
|
|
22
|
-
updateLocalOrientation: ({ oX, oY, oZ, theta, }: {
|
|
14
|
+
constructor(updateFrame: UpdateFrameCallback, removeFrame: RemoveFrameCallback);
|
|
15
|
+
updateLocalPosition: (entity: Entity, position: Partial<Vector3Like>) => void;
|
|
16
|
+
updateLocalOrientation: (entity: Entity, orientation: {
|
|
23
17
|
oX?: number;
|
|
24
18
|
oY?: number;
|
|
25
19
|
oZ?: number;
|
|
26
20
|
theta?: number;
|
|
27
21
|
}) => void;
|
|
28
|
-
updateGeometry: (geometry: Partial<Frame["geometry"]>) => void;
|
|
29
|
-
setFrameParent: (parentName: string) => void;
|
|
30
|
-
deleteFrame: () => void;
|
|
31
|
-
setGeometryType: (type: "none" | "box" | "sphere" | "capsule") => void;
|
|
32
|
-
private
|
|
22
|
+
updateGeometry: (entity: Entity, geometry: Partial<Frame["geometry"]>) => void;
|
|
23
|
+
setFrameParent: (entity: Entity, parentName: string) => void;
|
|
24
|
+
deleteFrame: (entity: Entity) => void;
|
|
25
|
+
setGeometryType: (entity: Entity, type: "none" | "box" | "sphere" | "capsule") => void;
|
|
26
|
+
private sanitizeFloatValue;
|
|
33
27
|
}
|
|
34
28
|
export {};
|
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { traits } from './ecs';
|
|
2
2
|
export class FrameConfigUpdater {
|
|
3
|
-
object;
|
|
4
|
-
referenceFrame;
|
|
5
3
|
updateFrame;
|
|
6
4
|
removeFrame;
|
|
7
|
-
constructor(
|
|
8
|
-
this.referenceFrame = referenceFrame;
|
|
9
|
-
this.object = object;
|
|
5
|
+
constructor(updateFrame, removeFrame) {
|
|
10
6
|
this.updateFrame = updateFrame;
|
|
11
7
|
this.removeFrame = removeFrame;
|
|
12
8
|
}
|
|
13
|
-
updateLocalPosition = (
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
x = this.sanatizeFloatValue(x);
|
|
18
|
-
y = this.sanatizeFloatValue(y);
|
|
19
|
-
z = this.sanatizeFloatValue(z);
|
|
9
|
+
updateLocalPosition = (entity, position) => {
|
|
10
|
+
const x = this.sanitizeFloatValue(position.x);
|
|
11
|
+
const y = this.sanitizeFloatValue(position.y);
|
|
12
|
+
const z = this.sanitizeFloatValue(position.z);
|
|
20
13
|
if (x === undefined && y === undefined && z === undefined)
|
|
21
14
|
return;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
z
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
const change = {};
|
|
16
|
+
if (x !== undefined)
|
|
17
|
+
change.x = x;
|
|
18
|
+
if (y !== undefined)
|
|
19
|
+
change.y = y;
|
|
20
|
+
if (z !== undefined)
|
|
21
|
+
change.z = z;
|
|
22
|
+
entity.set(traits.EditedPose, change);
|
|
23
|
+
const name = entity.get(traits.Name);
|
|
24
|
+
const parent = entity.get(traits.Parent) ?? 'world';
|
|
25
|
+
const updatedPose = entity.get(traits.EditedPose);
|
|
26
|
+
if (name && updatedPose) {
|
|
27
|
+
this.updateFrame(name, parent, updatedPose);
|
|
28
|
+
}
|
|
34
29
|
};
|
|
35
|
-
updateLocalOrientation = (
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
oY
|
|
41
|
-
oZ = this.sanatizeFloatValue(oZ);
|
|
42
|
-
theta = this.sanatizeFloatValue(theta);
|
|
43
|
-
if (oX === undefined && oY === undefined && oZ === undefined && theta === undefined)
|
|
30
|
+
updateLocalOrientation = (entity, orientation) => {
|
|
31
|
+
const oX = this.sanitizeFloatValue(orientation.oX);
|
|
32
|
+
const oY = this.sanitizeFloatValue(orientation.oY);
|
|
33
|
+
const oZ = this.sanitizeFloatValue(orientation.oZ);
|
|
34
|
+
const theta = this.sanitizeFloatValue(orientation.theta);
|
|
35
|
+
if (oX === undefined && oY === undefined && oZ === undefined && theta === undefined) {
|
|
44
36
|
return;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
oZ
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
37
|
+
}
|
|
38
|
+
const change = {};
|
|
39
|
+
if (oX !== undefined)
|
|
40
|
+
change.oX = oX;
|
|
41
|
+
if (oY !== undefined)
|
|
42
|
+
change.oY = oY;
|
|
43
|
+
if (oZ !== undefined)
|
|
44
|
+
change.oZ = oZ;
|
|
45
|
+
if (theta !== undefined)
|
|
46
|
+
change.theta = theta;
|
|
47
|
+
entity.set(traits.EditedPose, change);
|
|
48
|
+
const name = entity.get(traits.Name);
|
|
49
|
+
const parent = entity.get(traits.Parent) ?? 'world';
|
|
50
|
+
const updatedPose = entity.get(traits.EditedPose);
|
|
51
|
+
if (name && updatedPose) {
|
|
52
|
+
this.updateFrame(name, parent, updatedPose);
|
|
53
|
+
}
|
|
58
54
|
};
|
|
59
|
-
updateGeometry = (geometry) => {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
let geometryObject;
|
|
55
|
+
updateGeometry = (entity, geometry) => {
|
|
56
|
+
const name = entity.get(traits.Name);
|
|
57
|
+
const parent = entity.get(traits.Parent) ?? 'world';
|
|
58
|
+
const pose = entity.get(traits.EditedPose);
|
|
64
59
|
if (geometry?.type === 'box') {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (geometry.x === undefined && geometry.y === undefined && geometry.z === undefined)
|
|
60
|
+
const x = this.sanitizeFloatValue(geometry.x);
|
|
61
|
+
const y = this.sanitizeFloatValue(geometry.y);
|
|
62
|
+
const z = this.sanitizeFloatValue(geometry.z);
|
|
63
|
+
if (x === undefined && y === undefined && z === undefined)
|
|
70
64
|
return;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
const change = {};
|
|
66
|
+
if (x !== undefined)
|
|
67
|
+
change.x = x;
|
|
68
|
+
if (y !== undefined)
|
|
69
|
+
change.y = y;
|
|
70
|
+
if (z !== undefined)
|
|
71
|
+
change.z = z;
|
|
72
|
+
entity.set(traits.Box, change);
|
|
73
|
+
const box = entity.get(traits.Box);
|
|
74
|
+
if (name && box && pose) {
|
|
75
|
+
this.updateFrame(name, parent, pose, { type: 'box', ...box });
|
|
76
|
+
}
|
|
77
77
|
}
|
|
78
78
|
else if (geometry?.type === 'sphere') {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
if (geometry.r === undefined)
|
|
79
|
+
const r = this.sanitizeFloatValue(geometry.r);
|
|
80
|
+
if (r === undefined)
|
|
82
81
|
return;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
entity.set(traits.Sphere, { r });
|
|
83
|
+
const sphere = entity.get(traits.Sphere);
|
|
84
|
+
if (name && sphere && pose) {
|
|
85
|
+
this.updateFrame(name, parent, pose, { type: 'sphere', ...sphere });
|
|
86
|
+
}
|
|
87
87
|
}
|
|
88
88
|
else if (geometry?.type === 'capsule') {
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (geometry.r === undefined && geometry.l === undefined)
|
|
89
|
+
const r = this.sanitizeFloatValue(geometry.r);
|
|
90
|
+
const l = this.sanitizeFloatValue(geometry.l);
|
|
91
|
+
if (r === undefined && l === undefined)
|
|
93
92
|
return;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
const change = {};
|
|
94
|
+
if (r !== undefined)
|
|
95
|
+
change.r = r;
|
|
96
|
+
if (l !== undefined)
|
|
97
|
+
change.l = l;
|
|
98
|
+
entity.set(traits.Capsule, { r, l });
|
|
99
|
+
const capsule = entity.get(traits.Capsule);
|
|
100
|
+
if (name && capsule && pose) {
|
|
101
|
+
this.updateFrame(name, parent, pose, { type: 'capsule', ...capsule });
|
|
102
|
+
}
|
|
99
103
|
}
|
|
100
|
-
this.updateFrame(object.name ?? '', this.referenceFrame(), createPose(object.localEditedPose), geometryObject);
|
|
101
104
|
};
|
|
102
|
-
setFrameParent = (parentName) => {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
setFrameParent = (entity, parentName) => {
|
|
106
|
+
const name = entity.get(traits.Name);
|
|
107
|
+
const pose = entity.get(traits.EditedPose);
|
|
108
|
+
if (name && pose) {
|
|
109
|
+
this.updateFrame(name, parentName, pose);
|
|
110
|
+
}
|
|
107
111
|
};
|
|
108
|
-
deleteFrame = () => {
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
deleteFrame = (entity) => {
|
|
113
|
+
const name = entity.get(traits.Name);
|
|
114
|
+
if (name) {
|
|
115
|
+
this.removeFrame(name);
|
|
116
|
+
}
|
|
113
117
|
};
|
|
114
|
-
setGeometryType = (type) => {
|
|
115
|
-
const
|
|
116
|
-
|
|
118
|
+
setGeometryType = (entity, type) => {
|
|
119
|
+
const name = entity.get(traits.Name);
|
|
120
|
+
const parent = entity.get(traits.Parent) ?? 'world';
|
|
121
|
+
const pose = entity.get(traits.EditedPose);
|
|
122
|
+
if (!name || !pose)
|
|
117
123
|
return;
|
|
118
124
|
if (type === 'none') {
|
|
119
|
-
this.updateFrame(
|
|
125
|
+
this.updateFrame(name, parent, pose, { type: 'none' });
|
|
120
126
|
}
|
|
121
127
|
else if (type === 'box') {
|
|
122
|
-
this.updateFrame(
|
|
128
|
+
this.updateFrame(name, parent, pose, { type: 'box', x: 100, y: 100, z: 100 });
|
|
123
129
|
}
|
|
124
130
|
else if (type === 'sphere') {
|
|
125
|
-
this.updateFrame(
|
|
131
|
+
this.updateFrame(name, parent, pose, { type: 'sphere', r: 100 });
|
|
126
132
|
}
|
|
127
133
|
else if (type === 'capsule') {
|
|
128
|
-
this.updateFrame(
|
|
129
|
-
x: object.localEditedPose.x,
|
|
130
|
-
y: object.localEditedPose.y,
|
|
131
|
-
z: object.localEditedPose.z,
|
|
132
|
-
oX: object.localEditedPose.oX,
|
|
133
|
-
oY: object.localEditedPose.oY,
|
|
134
|
-
oZ: object.localEditedPose.oZ,
|
|
135
|
-
theta: object.localEditedPose.theta,
|
|
136
|
-
}, { type: 'capsule', r: 20, l: 100 });
|
|
134
|
+
this.updateFrame(name, parent, pose, { type: 'capsule', r: 20, l: 100 });
|
|
137
135
|
}
|
|
138
136
|
};
|
|
139
|
-
|
|
140
|
-
if (value === undefined)
|
|
137
|
+
sanitizeFloatValue = (value) => {
|
|
138
|
+
if (value === undefined) {
|
|
141
139
|
return undefined;
|
|
140
|
+
}
|
|
142
141
|
const num = parseFloat(value.toFixed(2));
|
|
143
|
-
if (isNaN(num))
|
|
142
|
+
if (Number.isNaN(num)) {
|
|
144
143
|
return undefined;
|
|
145
|
-
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
146
|
};
|
|
147
147
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BatchedMesh, Color, MathUtils,
|
|
2
|
-
import { createPose
|
|
1
|
+
import { BatchedMesh, Color, MathUtils, Vector3 } from 'three';
|
|
2
|
+
import { createPose } from './transform';
|
|
3
3
|
import { isColorRepresentation, isRGB, parseColor, parseOpacity, parseRGB } from './color';
|
|
4
4
|
export const SupportedShapes = {
|
|
5
5
|
points: 'points',
|
|
@@ -136,16 +136,3 @@ export const fromTransform = (transform) => {
|
|
|
136
136
|
worldObject.uuid = transform.uuidString;
|
|
137
137
|
return worldObject;
|
|
138
138
|
};
|
|
139
|
-
export const determinePose = (object, pose) => {
|
|
140
|
-
if (pose === undefined) {
|
|
141
|
-
return object.localEditedPose;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
const poseNetwork = poseToMatrix(object.pose);
|
|
145
|
-
const poseUsePose = poseToMatrix(pose);
|
|
146
|
-
const poseLocalEditedPose = poseToMatrix(object.localEditedPose);
|
|
147
|
-
const poseNetworkInverse = poseNetwork.invert();
|
|
148
|
-
const resultMatrix = poseUsePose.multiply(poseNetworkInverse).multiply(poseLocalEditedPose);
|
|
149
|
-
return matrixToPose(resultMatrix);
|
|
150
|
-
}
|
|
151
|
-
};
|