@viamrobotics/motion-tools 0.16.1 → 0.16.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
|
-
import { Color, Vector3, Vector4 } from 'three';
|
|
2
|
+
import { Color, MathUtils, Quaternion, Vector3, Vector4 } from 'three';
|
|
3
3
|
import { NURBSCurve } from 'three/addons/curves/NURBSCurve.js';
|
|
4
4
|
import { parsePcdInWorker } from '../loaders/pcd';
|
|
5
5
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
@@ -9,6 +9,10 @@ import { createGeometry } from '../geometry';
|
|
|
9
9
|
import { createPose, createPoseFromFrame } from '../transform';
|
|
10
10
|
import { useCameraControls } from './useControls.svelte';
|
|
11
11
|
import { useThrelte } from '@threlte/core';
|
|
12
|
+
import { OrientationVector } from '../three/OrientationVector';
|
|
13
|
+
const axis = new Vector3();
|
|
14
|
+
const quaternion = new Quaternion();
|
|
15
|
+
const ov = new OrientationVector();
|
|
12
16
|
const key = Symbol('draw-api-context-key');
|
|
13
17
|
const tryParse = (json) => {
|
|
14
18
|
try {
|
|
@@ -173,9 +177,22 @@ export const provideDrawAPI = () => {
|
|
|
173
177
|
pose.x = origin.x;
|
|
174
178
|
pose.y = origin.y;
|
|
175
179
|
pose.z = origin.z;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
if (direction.y > 0.99999) {
|
|
181
|
+
quaternion.set(0, 0, 0, 1);
|
|
182
|
+
}
|
|
183
|
+
else if (direction.y < -0.99999) {
|
|
184
|
+
quaternion.set(1, 0, 0, 0);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
axis.set(direction.z, 0, -direction.x).normalize();
|
|
188
|
+
const radians = Math.acos(direction.y);
|
|
189
|
+
quaternion.setFromAxisAngle(axis, radians);
|
|
190
|
+
}
|
|
191
|
+
ov.setFromQuaternion(quaternion);
|
|
192
|
+
pose.oX = ov.x;
|
|
193
|
+
pose.oY = ov.y;
|
|
194
|
+
pose.oZ = ov.z;
|
|
195
|
+
pose.theta = MathUtils.radToDeg(ov.th);
|
|
179
196
|
poses.push(new WorldObject(`pose ${++poseIndex}`, pose, 'world', undefined, {
|
|
180
197
|
getBoundingBoxAt(box3) {
|
|
181
198
|
return batchedArrow.getBoundingBoxAt(arrowId, box3);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viamrobotics/motion-tools",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Motion visualization with Viam",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"type-fest": "^5.0.1",
|
|
68
68
|
"typescript": "5.9.2",
|
|
69
69
|
"typescript-eslint": "8.42.0",
|
|
70
|
-
"vite": "7.1.
|
|
70
|
+
"vite": "7.1.11",
|
|
71
71
|
"vite-plugin-devtools-json": "1.0.0",
|
|
72
72
|
"vite-plugin-mkcert": "1.17.8",
|
|
73
73
|
"vitest": "3.2.4"
|