@viamrobotics/motion-tools 0.15.3 → 0.15.4
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.
|
@@ -6,7 +6,7 @@ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
|
6
6
|
import { WorldObject } from '../WorldObject.svelte';
|
|
7
7
|
import { useArrows } from './useArrows.svelte';
|
|
8
8
|
import { createGeometry } from '../geometry';
|
|
9
|
-
import { createPoseFromFrame } from '../transform';
|
|
9
|
+
import { createPose, createPoseFromFrame } from '../transform';
|
|
10
10
|
const key = Symbol('draw-api-context-key');
|
|
11
11
|
const tryParse = (json) => {
|
|
12
12
|
try {
|
|
@@ -109,7 +109,7 @@ export const provideDrawAPI = () => {
|
|
|
109
109
|
const drawGeometry = (data, color, parent) => {
|
|
110
110
|
const result = meshes.find((mesh) => mesh.name === data.label);
|
|
111
111
|
if (result) {
|
|
112
|
-
result.pose = data.center;
|
|
112
|
+
result.pose = createPose(data.center);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
const geometry = createGeometry();
|
|
@@ -129,7 +129,7 @@ export const provideDrawAPI = () => {
|
|
|
129
129
|
geometry.geometryType.case = 'capsule';
|
|
130
130
|
geometry.geometryType.value = data.capsule;
|
|
131
131
|
}
|
|
132
|
-
const object = new WorldObject(data.label ?? ++geometryIndex, data.center, parent, geometry, {
|
|
132
|
+
const object = new WorldObject(data.label ?? ++geometryIndex, createPose(data.center), parent, geometry, {
|
|
133
133
|
color: new Color(color),
|
|
134
134
|
});
|
|
135
135
|
meshes.push(object);
|
package/dist/transform.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Geometry, Pose } from '@viamrobotics/sdk';
|
|
2
2
|
import { type Object3D, Matrix4, Quaternion, Vector3 } from 'three';
|
|
3
3
|
import type { Frame } from './frame';
|
|
4
|
-
export declare const createPose: (pose?: Pose) => Pose;
|
|
4
|
+
export declare const createPose: (pose?: Partial<Pose>) => Pose;
|
|
5
5
|
export declare const createPoseFromFrame: (frame: Partial<Frame>) => Pose;
|
|
6
6
|
export declare const quaternionToPose: (quaternion: Quaternion, pose: Partial<Pose>) => void;
|
|
7
7
|
export declare const vector3ToPose: (vec3: Vector3, pose: Partial<Pose>) => void;
|
package/dist/transform.js
CHANGED
|
@@ -6,13 +6,15 @@ const ov = new OrientationVector();
|
|
|
6
6
|
const translation = new Vector3();
|
|
7
7
|
const scale = new Vector3();
|
|
8
8
|
export const createPose = (pose) => {
|
|
9
|
+
// We should only default to the 0,0,1,0 orientation vector if the entire vector component is missing
|
|
10
|
+
const oZ = pose?.oX === undefined && pose?.oY === undefined && pose?.oZ === undefined ? 1 : (pose?.oZ ?? 0);
|
|
9
11
|
return {
|
|
10
12
|
x: pose?.x ?? 0,
|
|
11
13
|
y: pose?.y ?? 0,
|
|
12
14
|
z: pose?.z ?? 0,
|
|
13
15
|
oX: pose?.oX ?? 0,
|
|
14
16
|
oY: pose?.oY ?? 0,
|
|
15
|
-
oZ
|
|
17
|
+
oZ,
|
|
16
18
|
theta: pose?.theta ?? 0,
|
|
17
19
|
};
|
|
18
20
|
};
|
|
@@ -29,10 +31,13 @@ export const createPoseFromFrame = (frame) => {
|
|
|
29
31
|
else if (frame.orientation?.type === 'ov_radians') {
|
|
30
32
|
ov.copy(frame.orientation.value);
|
|
31
33
|
}
|
|
32
|
-
else {
|
|
34
|
+
else if (frame.orientation) {
|
|
33
35
|
const th = MathUtils.degToRad(frame.orientation?.value.th ?? 0);
|
|
34
36
|
ov.set(frame.orientation?.value.x, frame.orientation?.value.y, frame.orientation?.value.z, th);
|
|
35
37
|
}
|
|
38
|
+
else {
|
|
39
|
+
ov.set(0, 0, 1, 0);
|
|
40
|
+
}
|
|
36
41
|
return {
|
|
37
42
|
x: frame.translation?.x ?? 0,
|
|
38
43
|
y: frame.translation?.y ?? 0,
|