@wandelbots/wandelbots-js-react-components 5.5.2-pr.fix-performance-issues.594.1df0675 → 5.5.2-pr.fix-performance-issues.594.b1018c5
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/3d.cjs +1 -1
- package/dist/3d.js +1 -1
- package/dist/chunks/{MotionGroupVisualizer-om9U-U7G.js → MotionGroupVisualizer-BXDggjVD.js} +196 -198
- package/dist/chunks/MotionGroupVisualizer-EN8Nw5xP.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/MotionGroupVisualizer-4AcH6kaR.cjs +0 -1
package/dist/3d.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/MotionGroupVisualizer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/MotionGroupVisualizer-EN8Nw5xP.cjs");exports.CollisionSceneRenderer=e.CollisionSceneRenderer;exports.LinearAxis=e.LinearAxis;exports.MANUFACTURER_HOME_CONFIGS=e.MANUFACTURER_HOME_CONFIGS;exports.MotionGroupVisualizer=e.MotionGroupVisualizer;exports.PresetEnvironment=e.PresetEnvironment;exports.Robot=e.Robot;exports.RobotCard=e.RobotCard;exports.SafetyZonesRenderer=e.SafetyZonesRenderer;exports.SupportedLinearAxis=e.SupportedLinearAxis;exports.SupportedRobot=e.SupportedRobot;exports.TrajectoryRenderer=e.TrajectoryRenderer;exports.defaultAxisConfig=e.defaultAxisConfig;exports.defaultGetModel=e.defaultGetModel;exports.extractManufacturer=e.extractManufacturer;exports.getDefaultHomeConfig=e.getDefaultHomeConfig;
|
package/dist/3d.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as o, L as r, M as s, h as t, P as n, b as i, R as d, S as f, c as u, f as R, T as l, a as C, d as p, e as M, g as S } from "./chunks/MotionGroupVisualizer-
|
|
1
|
+
import { C as o, L as r, M as s, h as t, P as n, b as i, R as d, S as f, c as u, f as R, T as l, a as C, d as p, e as M, g as S } from "./chunks/MotionGroupVisualizer-BXDggjVD.js";
|
|
2
2
|
export {
|
|
3
3
|
o as CollisionSceneRenderer,
|
|
4
4
|
r as LinearAxis,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { Matrix4 as R, Vector3 as
|
|
4
|
-
import { ConvexGeometry as se, RoundedBoxGeometry as
|
|
5
|
-
import
|
|
6
|
-
import { d as
|
|
7
|
-
import { Environment as
|
|
1
|
+
import { jsx as r, jsxs as b, Fragment as U } from "react/jsx-runtime";
|
|
2
|
+
import * as g from "three";
|
|
3
|
+
import { Matrix4 as R, Vector3 as k, Quaternion as W } from "three";
|
|
4
|
+
import { ConvexGeometry as se, RoundedBoxGeometry as ke } from "three-stdlib";
|
|
5
|
+
import Ge, { useMemo as I, useRef as M, useEffect as T, useState as G, useCallback as L, Suspense as ae } from "react";
|
|
6
|
+
import { d as Le, v as Ae, o as Ie, e as J } from "./externalizeComponent-D6S3WLFc.js";
|
|
7
|
+
import { Environment as Pe, Lightformer as A, Line as $, useGLTF as Fe, Bounds as Z } from "@react-three/drei";
|
|
8
8
|
import { useTheme as De } from "@mui/material/styles";
|
|
9
9
|
import v from "@mui/material/Box";
|
|
10
10
|
import Q from "@mui/material/Button";
|
|
@@ -13,16 +13,16 @@ import z from "@mui/material/Divider";
|
|
|
13
13
|
import ee from "@mui/material/Typography";
|
|
14
14
|
import { useThree as le, useFrame as ce, Canvas as te } from "@react-three/fiber";
|
|
15
15
|
import { observer as Ve } from "mobx-react-lite";
|
|
16
|
-
import { useTranslation as
|
|
16
|
+
import { useTranslation as Ee } from "react-i18next";
|
|
17
17
|
import { V as ue, c as fe, b as re } from "./interpolation-D9WFd-j_.js";
|
|
18
18
|
import { NovaClient as Ce, Manufacturer as _, JointTypeEnum as C } from "@wandelbots/nova-js/v2";
|
|
19
19
|
import { ErrorBoundary as pe } from "react-error-boundary";
|
|
20
|
-
function
|
|
20
|
+
function Ue(e) {
|
|
21
21
|
switch (e.shape_type) {
|
|
22
22
|
case "convex_hull":
|
|
23
23
|
return new se(
|
|
24
24
|
e.vertices.map(
|
|
25
|
-
(t) => new
|
|
25
|
+
(t) => new g.Vector3(
|
|
26
26
|
t[0] / 1e3,
|
|
27
27
|
t[1] / 1e3,
|
|
28
28
|
t[2] / 1e3
|
|
@@ -30,31 +30,31 @@ function Ee(e) {
|
|
|
30
30
|
)
|
|
31
31
|
);
|
|
32
32
|
case "box":
|
|
33
|
-
return new
|
|
33
|
+
return new g.BoxGeometry(
|
|
34
34
|
e.size_x / 1e3,
|
|
35
35
|
e.size_y / 1e3,
|
|
36
36
|
e.size_z / 1e3
|
|
37
37
|
);
|
|
38
38
|
case "sphere":
|
|
39
|
-
return new
|
|
39
|
+
return new g.SphereGeometry(e.radius / 1e3);
|
|
40
40
|
case "capsule":
|
|
41
|
-
return new
|
|
41
|
+
return new g.CapsuleGeometry(
|
|
42
42
|
e.radius / 1e3,
|
|
43
43
|
e.cylinder_height / 1e3
|
|
44
44
|
);
|
|
45
45
|
case "cylinder":
|
|
46
|
-
return new
|
|
46
|
+
return new g.CylinderGeometry(
|
|
47
47
|
e.radius / 1e3,
|
|
48
48
|
e.radius / 1e3,
|
|
49
49
|
e.height / 1e3
|
|
50
50
|
);
|
|
51
51
|
case "rectangle":
|
|
52
|
-
return new
|
|
52
|
+
return new g.BoxGeometry(e.size_x / 1e3, e.size_y / 1e3, 0);
|
|
53
53
|
default:
|
|
54
|
-
return console.warn(`${e.shape_type} is not supported`), new
|
|
54
|
+
return console.warn(`${e.shape_type} is not supported`), new g.BufferGeometry();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Je({
|
|
58
58
|
name: e,
|
|
59
59
|
collider: n,
|
|
60
60
|
children: t
|
|
@@ -65,25 +65,25 @@ function je({
|
|
|
65
65
|
"mesh",
|
|
66
66
|
{
|
|
67
67
|
name: e,
|
|
68
|
-
position: new
|
|
68
|
+
position: new g.Vector3(
|
|
69
69
|
l[0],
|
|
70
70
|
l[1],
|
|
71
71
|
l[2]
|
|
72
72
|
).divideScalar(1e3),
|
|
73
|
-
rotation: new
|
|
74
|
-
geometry:
|
|
73
|
+
rotation: new g.Euler(i[0], i[1], i[2], "XYZ"),
|
|
74
|
+
geometry: Ue(n.shape),
|
|
75
75
|
children: t
|
|
76
76
|
}
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function je({
|
|
80
80
|
name: e,
|
|
81
81
|
colliders: n,
|
|
82
82
|
meshChildrenProvider: t,
|
|
83
83
|
...l
|
|
84
84
|
}) {
|
|
85
85
|
return /* @__PURE__ */ r("group", { name: e, ...l, children: Object.entries(n).map(([i, f]) => /* @__PURE__ */ r(
|
|
86
|
-
|
|
86
|
+
Je,
|
|
87
87
|
{
|
|
88
88
|
name: i,
|
|
89
89
|
collider: f,
|
|
@@ -92,13 +92,13 @@ function Je({
|
|
|
92
92
|
i
|
|
93
93
|
)) });
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function wt({
|
|
96
96
|
scene: e,
|
|
97
97
|
meshChildrenProvider: n
|
|
98
98
|
}) {
|
|
99
99
|
const t = e.colliders;
|
|
100
100
|
return /* @__PURE__ */ r("group", { children: t && /* @__PURE__ */ r(
|
|
101
|
-
|
|
101
|
+
je,
|
|
102
102
|
{
|
|
103
103
|
meshChildrenProvider: n,
|
|
104
104
|
colliders: t
|
|
@@ -106,13 +106,13 @@ function bt({
|
|
|
106
106
|
) });
|
|
107
107
|
}
|
|
108
108
|
function ne() {
|
|
109
|
-
return /* @__PURE__ */ r(
|
|
109
|
+
return /* @__PURE__ */ r(Pe, { frames: 1, children: /* @__PURE__ */ r(We, {}) });
|
|
110
110
|
}
|
|
111
111
|
const Be = [2, 0, 2, 0, 2, 0, 2, 0];
|
|
112
112
|
function We({ positions: e = Be }) {
|
|
113
|
-
return /* @__PURE__ */
|
|
113
|
+
return /* @__PURE__ */ b(U, { children: [
|
|
114
114
|
/* @__PURE__ */ r(
|
|
115
|
-
|
|
115
|
+
A,
|
|
116
116
|
{
|
|
117
117
|
intensity: 5,
|
|
118
118
|
"rotation-x": Math.PI / 2,
|
|
@@ -121,7 +121,7 @@ function We({ positions: e = Be }) {
|
|
|
121
121
|
}
|
|
122
122
|
),
|
|
123
123
|
/* @__PURE__ */ r("group", { rotation: [0, 0.5, 0], children: /* @__PURE__ */ r("group", { children: e.map((n, t) => /* @__PURE__ */ r(
|
|
124
|
-
|
|
124
|
+
A,
|
|
125
125
|
{
|
|
126
126
|
form: "circle",
|
|
127
127
|
intensity: 5,
|
|
@@ -132,7 +132,7 @@ function We({ positions: e = Be }) {
|
|
|
132
132
|
t
|
|
133
133
|
)) }) }),
|
|
134
134
|
/* @__PURE__ */ r(
|
|
135
|
-
|
|
135
|
+
A,
|
|
136
136
|
{
|
|
137
137
|
intensity: 40,
|
|
138
138
|
"rotation-y": Math.PI / 2,
|
|
@@ -141,7 +141,7 @@ function We({ positions: e = Be }) {
|
|
|
141
141
|
}
|
|
142
142
|
),
|
|
143
143
|
/* @__PURE__ */ r(
|
|
144
|
-
|
|
144
|
+
A,
|
|
145
145
|
{
|
|
146
146
|
intensity: 20,
|
|
147
147
|
"rotation-y": -Math.PI,
|
|
@@ -150,7 +150,7 @@ function We({ positions: e = Be }) {
|
|
|
150
150
|
}
|
|
151
151
|
),
|
|
152
152
|
/* @__PURE__ */ r(
|
|
153
|
-
|
|
153
|
+
A,
|
|
154
154
|
{
|
|
155
155
|
"rotation-y": Math.PI / 2,
|
|
156
156
|
position: [-5, -1, -1],
|
|
@@ -159,7 +159,7 @@ function We({ positions: e = Be }) {
|
|
|
159
159
|
}
|
|
160
160
|
),
|
|
161
161
|
/* @__PURE__ */ r(
|
|
162
|
-
|
|
162
|
+
A,
|
|
163
163
|
{
|
|
164
164
|
"rotation-y": -Math.PI / 2,
|
|
165
165
|
position: [10, 1, 0],
|
|
@@ -168,7 +168,7 @@ function We({ positions: e = Be }) {
|
|
|
168
168
|
}
|
|
169
169
|
),
|
|
170
170
|
/* @__PURE__ */ r(
|
|
171
|
-
|
|
171
|
+
A,
|
|
172
172
|
{
|
|
173
173
|
form: "ring",
|
|
174
174
|
color: "white",
|
|
@@ -189,50 +189,50 @@ const oe = {
|
|
|
189
189
|
transparent: !0,
|
|
190
190
|
polygonOffset: !0
|
|
191
191
|
};
|
|
192
|
-
function
|
|
192
|
+
function bt({
|
|
193
193
|
safetyZones: e,
|
|
194
194
|
dhParameters: n,
|
|
195
195
|
...t
|
|
196
196
|
}) {
|
|
197
|
-
const l =
|
|
198
|
-
() =>
|
|
197
|
+
const l = I(
|
|
198
|
+
() => Le(n ?? []),
|
|
199
199
|
[n]
|
|
200
200
|
), i = (c, o) => {
|
|
201
201
|
var u, d;
|
|
202
202
|
if (!((u = o == null ? void 0 : o.pose) != null && u.position) || !((d = o == null ? void 0 : o.pose) != null && d.orientation))
|
|
203
203
|
return null;
|
|
204
|
-
const y = new
|
|
204
|
+
const y = new g.Vector3(
|
|
205
205
|
o.pose.position[0] / 1e3,
|
|
206
206
|
o.pose.position[1] / 1e3,
|
|
207
207
|
o.pose.position[2] / 1e3
|
|
208
|
-
), s = new
|
|
208
|
+
), s = new g.Vector3(
|
|
209
209
|
o.pose.orientation[0],
|
|
210
210
|
o.pose.orientation[1],
|
|
211
211
|
o.pose.orientation[2]
|
|
212
212
|
);
|
|
213
|
-
let
|
|
214
|
-
const a = o.shape.shape_type === "plane" ? { ...oe, side:
|
|
213
|
+
let h;
|
|
214
|
+
const a = o.shape.shape_type === "plane" ? { ...oe, side: g.DoubleSide } : { ...oe, side: g.FrontSide };
|
|
215
215
|
switch (o.shape.shape_type) {
|
|
216
216
|
/**
|
|
217
217
|
* Plane shape, uses DH parameters to calculate the size of the plane (reach distance of a robot)
|
|
218
218
|
*/
|
|
219
219
|
case "plane":
|
|
220
|
-
|
|
220
|
+
h = /* @__PURE__ */ r("planeGeometry", { args: [l, l] });
|
|
221
221
|
break;
|
|
222
222
|
/**
|
|
223
223
|
* Sphere shape
|
|
224
224
|
*/
|
|
225
225
|
case "sphere": {
|
|
226
226
|
const p = (o == null ? void 0 : o.shape).radius / 1e3;
|
|
227
|
-
|
|
227
|
+
h = /* @__PURE__ */ r("sphereGeometry", { args: [p] });
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
231
|
* Capsule shape
|
|
232
232
|
*/
|
|
233
233
|
case "capsule": {
|
|
234
|
-
const p = (o == null ? void 0 : o.shape).radius / 1e3,
|
|
235
|
-
|
|
234
|
+
const p = (o == null ? void 0 : o.shape).radius / 1e3, m = (o == null ? void 0 : o.shape).cylinder_height / 1e3;
|
|
235
|
+
h = /* @__PURE__ */ r("capsuleGeometry", { args: [p, m] });
|
|
236
236
|
break;
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
@@ -241,25 +241,25 @@ function wt({
|
|
|
241
241
|
*/
|
|
242
242
|
case "convex_hull": {
|
|
243
243
|
const p = (o == null ? void 0 : o.shape).vertices.map(
|
|
244
|
-
(
|
|
245
|
-
),
|
|
246
|
-
if (
|
|
247
|
-
const x = new
|
|
244
|
+
(w) => new g.Vector3(w[0] / 1e3, w[1] / 1e3, w[2] / 1e3)
|
|
245
|
+
), m = Ae(p);
|
|
246
|
+
if (m.isCoplanar && m.normal) {
|
|
247
|
+
const x = new g.Vector3().addVectors(
|
|
248
248
|
p[0],
|
|
249
|
-
|
|
249
|
+
m.normal.multiplyScalar(1e-4)
|
|
250
250
|
);
|
|
251
251
|
p.push(x);
|
|
252
252
|
}
|
|
253
253
|
try {
|
|
254
|
-
|
|
254
|
+
h = /* @__PURE__ */ r(
|
|
255
255
|
"primitive",
|
|
256
256
|
{
|
|
257
257
|
object: new se(p),
|
|
258
258
|
attach: "geometry"
|
|
259
259
|
}
|
|
260
260
|
);
|
|
261
|
-
} catch (
|
|
262
|
-
return console.log("Error creating ConvexGeometry:",
|
|
261
|
+
} catch (w) {
|
|
262
|
+
return console.log("Error creating ConvexGeometry:", w), null;
|
|
263
263
|
}
|
|
264
264
|
break;
|
|
265
265
|
}
|
|
@@ -271,11 +271,11 @@ function wt({
|
|
|
271
271
|
* Basically a rounded box with a rectangular cross-section.
|
|
272
272
|
*/
|
|
273
273
|
case "rectangular_capsule": {
|
|
274
|
-
const p = o.shape,
|
|
275
|
-
|
|
274
|
+
const p = o.shape, m = p.radius / 1e3, w = p.sphere_center_distance_x / 1e3, x = p.sphere_center_distance_y / 1e3, P = m * 2;
|
|
275
|
+
h = /* @__PURE__ */ r(
|
|
276
276
|
"primitive",
|
|
277
277
|
{
|
|
278
|
-
object: new
|
|
278
|
+
object: new ke(w, x, P, 2, m),
|
|
279
279
|
attach: "geometry"
|
|
280
280
|
}
|
|
281
281
|
);
|
|
@@ -285,22 +285,22 @@ function wt({
|
|
|
285
285
|
console.warn(
|
|
286
286
|
"Unsupported safety zone shape type:",
|
|
287
287
|
o.shape.shape_type
|
|
288
|
-
),
|
|
288
|
+
), h = null;
|
|
289
289
|
}
|
|
290
|
-
return /* @__PURE__ */
|
|
290
|
+
return /* @__PURE__ */ b(
|
|
291
291
|
"mesh",
|
|
292
292
|
{
|
|
293
293
|
renderOrder: c,
|
|
294
294
|
position: y,
|
|
295
|
-
quaternion:
|
|
295
|
+
quaternion: Ie(s),
|
|
296
296
|
children: [
|
|
297
|
-
|
|
297
|
+
h,
|
|
298
298
|
/* @__PURE__ */ r("meshStandardMaterial", { ...a, polygonOffsetFactor: -c })
|
|
299
299
|
]
|
|
300
300
|
},
|
|
301
301
|
`safety-zone-${o.shape.shape_type}-${c}`
|
|
302
302
|
);
|
|
303
|
-
}, f =
|
|
303
|
+
}, f = I(() => Object.values(e ?? {}).map(
|
|
304
304
|
(c, o) => i(o, c)
|
|
305
305
|
), [e, l]);
|
|
306
306
|
return /* @__PURE__ */ r("group", { ...t, children: f });
|
|
@@ -313,7 +313,7 @@ function xt({
|
|
|
313
313
|
if (l.position && l.position.length >= 3) {
|
|
314
314
|
const [i, f, c] = l.position;
|
|
315
315
|
if (Number.isFinite(i) && Number.isFinite(f) && Number.isFinite(c))
|
|
316
|
-
return new
|
|
316
|
+
return new g.Vector3(i / 1e3, c / 1e3, -f / 1e3);
|
|
317
317
|
}
|
|
318
318
|
return null;
|
|
319
319
|
}).filter((l) => l !== null)) || [];
|
|
@@ -329,7 +329,7 @@ function xt({
|
|
|
329
329
|
) });
|
|
330
330
|
}
|
|
331
331
|
const B = /* @__PURE__ */ new Map();
|
|
332
|
-
async function
|
|
332
|
+
async function j(e, n) {
|
|
333
333
|
if (B.has(e))
|
|
334
334
|
return B.get(e);
|
|
335
335
|
const t = (async () => {
|
|
@@ -417,11 +417,11 @@ function ye({
|
|
|
417
417
|
t(i.current, a);
|
|
418
418
|
else
|
|
419
419
|
for (const [d, p] of i.current.entries()) {
|
|
420
|
-
const
|
|
421
|
-
p.rotation.y = x * (a[d] || 0) +
|
|
420
|
+
const m = n[d], w = m.theta || 0, x = m.reverse_rotation_direction ? -1 : 1;
|
|
421
|
+
p.rotation.y = x * (a[d] || 0) + w;
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
-
function
|
|
424
|
+
function h(a) {
|
|
425
425
|
var d;
|
|
426
426
|
const u = a.joint_position.filter(
|
|
427
427
|
(p) => p !== void 0
|
|
@@ -429,9 +429,9 @@ function ye({
|
|
|
429
429
|
(d = f.current) == null || d.setTarget(u), c();
|
|
430
430
|
}
|
|
431
431
|
return fe(() => {
|
|
432
|
-
|
|
432
|
+
h(o.current);
|
|
433
433
|
}), T(() => {
|
|
434
|
-
|
|
434
|
+
h(e);
|
|
435
435
|
}, [e]), /* @__PURE__ */ r("group", { ref: y, children: l });
|
|
436
436
|
}
|
|
437
437
|
const Ne = "line", He = "mesh";
|
|
@@ -441,31 +441,31 @@ function Ye({
|
|
|
441
441
|
...t
|
|
442
442
|
}) {
|
|
443
443
|
const l = new R(), i = M([]), f = M([]);
|
|
444
|
-
|
|
444
|
+
Ge.useEffect(() => {
|
|
445
445
|
i.current = new Array(n.length).fill(null), f.current = new Array(n.length).fill(null);
|
|
446
446
|
}, [n.length]);
|
|
447
|
-
function c(s,
|
|
448
|
-
const a = new
|
|
447
|
+
function c(s, h) {
|
|
448
|
+
const a = new k(), u = new W(), d = new k();
|
|
449
449
|
l.decompose(a, u, d);
|
|
450
|
-
const p = a.clone(),
|
|
451
|
-
s.theta +
|
|
450
|
+
const p = a.clone(), m = new R().makeRotationY(
|
|
451
|
+
s.theta + h * (s.reverse_rotation_direction ? -1 : 1)
|
|
452
452
|
).multiply(new R().makeTranslation(0, s.d / 1e3, 0)).multiply(new R().makeTranslation(s.a / 1e3, 0, 0)).multiply(new R().makeRotationX(s.alpha));
|
|
453
|
-
return l.multiply(
|
|
453
|
+
return l.multiply(m), l.decompose(a, u, d), { a: p, b: a };
|
|
454
454
|
}
|
|
455
|
-
function o(s,
|
|
455
|
+
function o(s, h, a, u) {
|
|
456
456
|
if (!n)
|
|
457
457
|
return;
|
|
458
458
|
const d = n[s];
|
|
459
459
|
if (!d)
|
|
460
460
|
return;
|
|
461
|
-
const { a: p, b:
|
|
462
|
-
|
|
461
|
+
const { a: p, b: m } = c(d, u);
|
|
462
|
+
h.geometry.setPositions([p.toArray(), m.toArray()].flat()), a.position.set(m.x, m.y, m.z);
|
|
463
463
|
}
|
|
464
|
-
function y(s,
|
|
464
|
+
function y(s, h) {
|
|
465
465
|
l.identity();
|
|
466
|
-
for (let a = 0; a < Math.min(s.length,
|
|
466
|
+
for (let a = 0; a < Math.min(s.length, h.length); a++) {
|
|
467
467
|
const u = i.current[a], d = f.current[a];
|
|
468
|
-
u && d && o(a, u, d,
|
|
468
|
+
u && d && o(a, u, d, h[a]);
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
return /* @__PURE__ */ r(
|
|
@@ -474,22 +474,22 @@ function Ye({
|
|
|
474
474
|
rapidlyChangingMotionState: e,
|
|
475
475
|
dhParameters: n,
|
|
476
476
|
onRotationChanged: y,
|
|
477
|
-
children: /* @__PURE__ */
|
|
478
|
-
/* @__PURE__ */
|
|
477
|
+
children: /* @__PURE__ */ b("group", { ...t, name: "Scene", children: [
|
|
478
|
+
/* @__PURE__ */ b("mesh", { children: [
|
|
479
479
|
/* @__PURE__ */ r("sphereGeometry", { args: [0.01, 32, 32] }),
|
|
480
480
|
/* @__PURE__ */ r("meshStandardMaterial", { color: "black", depthTest: !0 })
|
|
481
481
|
] }),
|
|
482
|
-
n == null ? void 0 : n.map((s,
|
|
482
|
+
n == null ? void 0 : n.map((s, h) => {
|
|
483
483
|
const { a, b: u } = c(
|
|
484
484
|
s,
|
|
485
|
-
e.joint_position[
|
|
486
|
-
), d = `dhrobot_J0${
|
|
487
|
-
return /* @__PURE__ */
|
|
485
|
+
e.joint_position[h] ?? 0
|
|
486
|
+
), d = `dhrobot_J0${h}`;
|
|
487
|
+
return /* @__PURE__ */ b("group", { name: d, children: [
|
|
488
488
|
/* @__PURE__ */ r(
|
|
489
489
|
$,
|
|
490
490
|
{
|
|
491
491
|
ref: (p) => {
|
|
492
|
-
i.current[
|
|
492
|
+
i.current[h] = p;
|
|
493
493
|
},
|
|
494
494
|
name: Ne,
|
|
495
495
|
points: [a, u],
|
|
@@ -497,11 +497,11 @@ function Ye({
|
|
|
497
497
|
lineWidth: 5
|
|
498
498
|
}
|
|
499
499
|
),
|
|
500
|
-
/* @__PURE__ */
|
|
500
|
+
/* @__PURE__ */ b(
|
|
501
501
|
"mesh",
|
|
502
502
|
{
|
|
503
503
|
ref: (p) => {
|
|
504
|
-
f.current[
|
|
504
|
+
f.current[h] = p;
|
|
505
505
|
},
|
|
506
506
|
name: He,
|
|
507
507
|
position: u,
|
|
@@ -510,7 +510,7 @@ function Ye({
|
|
|
510
510
|
/* @__PURE__ */ r("meshStandardMaterial", { color: "black", depthTest: !0 })
|
|
511
511
|
]
|
|
512
512
|
},
|
|
513
|
-
`mesh_${
|
|
513
|
+
`mesh_${h}`
|
|
514
514
|
)
|
|
515
515
|
] }, d);
|
|
516
516
|
})
|
|
@@ -535,7 +535,7 @@ function Ke({
|
|
|
535
535
|
postModelRender: t,
|
|
536
536
|
...l
|
|
537
537
|
}) {
|
|
538
|
-
const i = Fe(e), c = $e(i, "robot.glb").gltf, o =
|
|
538
|
+
const i = Fe(e), c = $e(i, "robot.glb").gltf, o = L(
|
|
539
539
|
(s) => {
|
|
540
540
|
s && t && t();
|
|
541
541
|
},
|
|
@@ -572,19 +572,19 @@ function Ke({
|
|
|
572
572
|
},
|
|
573
573
|
s.uuid
|
|
574
574
|
);
|
|
575
|
-
} catch (
|
|
576
|
-
return console.warn("Error rendering node", s.name,
|
|
575
|
+
} catch (h) {
|
|
576
|
+
return console.warn("Error rendering node", s.name, h), null;
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
return /* @__PURE__ */ r("group", { ...l, dispose: null, ref: o, children: y(c.scene) });
|
|
580
580
|
}
|
|
581
|
-
function
|
|
581
|
+
function we({
|
|
582
582
|
modelURL: e,
|
|
583
583
|
flangeRef: n,
|
|
584
584
|
postModelRender: t,
|
|
585
585
|
...l
|
|
586
586
|
}) {
|
|
587
|
-
const [i, f] =
|
|
587
|
+
const [i, f] = G(null);
|
|
588
588
|
return T(() => {
|
|
589
589
|
let c = !1;
|
|
590
590
|
return (async () => {
|
|
@@ -607,19 +607,19 @@ function be({
|
|
|
607
607
|
}
|
|
608
608
|
) : null;
|
|
609
609
|
}
|
|
610
|
-
const
|
|
610
|
+
const be = (e, n) => {
|
|
611
611
|
e.userData.isGhost || (e.traverse((t) => {
|
|
612
|
-
if (t instanceof
|
|
613
|
-
t.material instanceof
|
|
612
|
+
if (t instanceof g.Mesh) {
|
|
613
|
+
t.material instanceof g.Material && (t.material.colorWrite = !1);
|
|
614
614
|
const l = t.clone(), i = t.clone();
|
|
615
|
-
l.material = new
|
|
615
|
+
l.material = new g.MeshStandardMaterial({
|
|
616
616
|
depthTest: !0,
|
|
617
617
|
depthWrite: !0,
|
|
618
618
|
colorWrite: !1,
|
|
619
619
|
polygonOffset: !0,
|
|
620
620
|
polygonOffsetFactor: -1,
|
|
621
|
-
side:
|
|
622
|
-
}), l.userData.isGhost = !0, i.material = new
|
|
621
|
+
side: g.DoubleSide
|
|
622
|
+
}), l.userData.isGhost = !0, i.material = new g.MeshStandardMaterial({
|
|
623
623
|
color: n,
|
|
624
624
|
opacity: 0.3,
|
|
625
625
|
depthTest: !0,
|
|
@@ -627,7 +627,7 @@ const we = (e, n) => {
|
|
|
627
627
|
transparent: !0,
|
|
628
628
|
polygonOffset: !0,
|
|
629
629
|
polygonOffsetFactor: -2,
|
|
630
|
-
side:
|
|
630
|
+
side: g.DoubleSide
|
|
631
631
|
}), i.userData.isGhost = !0, t.parent && (t.parent.add(l), t.parent.add(i));
|
|
632
632
|
}
|
|
633
633
|
}), e.userData.isGhost = !0);
|
|
@@ -636,36 +636,34 @@ const we = (e, n) => {
|
|
|
636
636
|
const n = [];
|
|
637
637
|
e.traverse((t) => {
|
|
638
638
|
var l;
|
|
639
|
-
t instanceof
|
|
639
|
+
t instanceof g.Mesh && ((l = t.userData) != null && l.isGhost ? n.push(t) : t.material instanceof g.Material && (t.material.colorWrite = !0));
|
|
640
640
|
}), n.forEach((t) => {
|
|
641
641
|
t.parent && t.parent.remove(t);
|
|
642
642
|
}), e.userData.isGhost = !1;
|
|
643
|
-
}, Re =
|
|
643
|
+
}, Re = J(
|
|
644
644
|
({
|
|
645
645
|
rapidlyChangingMotionState: e,
|
|
646
646
|
modelFromController: n,
|
|
647
647
|
dhParameters: t,
|
|
648
|
-
getModel: l =
|
|
648
|
+
getModel: l = j,
|
|
649
649
|
flangeRef: i,
|
|
650
650
|
postModelRender: f,
|
|
651
651
|
transparentColor: c,
|
|
652
652
|
instanceUrl: o,
|
|
653
653
|
...y
|
|
654
654
|
}) => {
|
|
655
|
-
const [s,
|
|
656
|
-
|
|
655
|
+
const [s, h] = G(null), a = L((p) => {
|
|
656
|
+
h(p);
|
|
657
657
|
}, []);
|
|
658
658
|
T(() => {
|
|
659
|
-
s && (c ?
|
|
659
|
+
s && (c ? be(s, c) : xe(s));
|
|
660
660
|
}, [s, c]);
|
|
661
|
-
const u =
|
|
661
|
+
const u = I(() => {
|
|
662
662
|
const p = l(n, o);
|
|
663
|
-
if (!p)
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
return Promise.resolve(URL.createObjectURL(g));
|
|
668
|
-
}
|
|
663
|
+
if (!p)
|
|
664
|
+
throw new Error(
|
|
665
|
+
`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`
|
|
666
|
+
);
|
|
669
667
|
return p;
|
|
670
668
|
}, [n, o, l]), d = /* @__PURE__ */ r(
|
|
671
669
|
Ye,
|
|
@@ -675,7 +673,7 @@ const we = (e, n) => {
|
|
|
675
673
|
...y
|
|
676
674
|
}
|
|
677
675
|
);
|
|
678
|
-
return /* @__PURE__ */
|
|
676
|
+
return /* @__PURE__ */ b(
|
|
679
677
|
pe,
|
|
680
678
|
{
|
|
681
679
|
fallback: d,
|
|
@@ -689,7 +687,7 @@ const we = (e, n) => {
|
|
|
689
687
|
rapidlyChangingMotionState: e,
|
|
690
688
|
dhParameters: t,
|
|
691
689
|
children: /* @__PURE__ */ r(
|
|
692
|
-
|
|
690
|
+
we,
|
|
693
691
|
{
|
|
694
692
|
modelURL: u,
|
|
695
693
|
postModelRender: f,
|
|
@@ -707,7 +705,7 @@ const we = (e, n) => {
|
|
|
707
705
|
);
|
|
708
706
|
function Ze({
|
|
709
707
|
connectedMotionGroup: e,
|
|
710
|
-
getModel: n =
|
|
708
|
+
getModel: n = j,
|
|
711
709
|
flangeRef: t,
|
|
712
710
|
transparentColor: l,
|
|
713
711
|
postModelRender: i,
|
|
@@ -727,7 +725,7 @@ function Ze({
|
|
|
727
725
|
}
|
|
728
726
|
) : null;
|
|
729
727
|
}
|
|
730
|
-
const Rt =
|
|
728
|
+
const Rt = J(
|
|
731
729
|
Ve(
|
|
732
730
|
({
|
|
733
731
|
robotName: e,
|
|
@@ -740,37 +738,37 @@ const Rt = j(
|
|
|
740
738
|
connectedMotionGroup: o,
|
|
741
739
|
robotComponent: y = Ze,
|
|
742
740
|
customContentComponent: s,
|
|
743
|
-
className:
|
|
741
|
+
className: h
|
|
744
742
|
}) => {
|
|
745
743
|
var Y;
|
|
746
|
-
const a = De(), { t: u } =
|
|
744
|
+
const a = De(), { t: u } = Ee(), [d, p] = G(!1), m = M(null), w = M(null), [x, P] = G(!1), [F, Te] = G({ width: 400, height: 600 }), [ze, Se] = G(0);
|
|
747
745
|
T(() => {
|
|
748
|
-
const
|
|
749
|
-
if (
|
|
750
|
-
const { offsetWidth: X, offsetHeight: K } =
|
|
751
|
-
|
|
746
|
+
const E = () => {
|
|
747
|
+
if (w.current) {
|
|
748
|
+
const { offsetWidth: X, offsetHeight: K } = w.current;
|
|
749
|
+
P(X > K), Te({ width: X, height: K });
|
|
752
750
|
}
|
|
753
751
|
};
|
|
754
|
-
|
|
755
|
-
const q = new ResizeObserver(
|
|
756
|
-
return
|
|
752
|
+
E();
|
|
753
|
+
const q = new ResizeObserver(E);
|
|
754
|
+
return w.current && q.observe(w.current), () => {
|
|
757
755
|
q.disconnect();
|
|
758
756
|
};
|
|
759
757
|
}, []);
|
|
760
|
-
const N =
|
|
761
|
-
|
|
762
|
-
}, []), D =
|
|
758
|
+
const N = L(() => {
|
|
759
|
+
Se((E) => E + 1);
|
|
760
|
+
}, []), D = L(() => {
|
|
763
761
|
!i || !f || (p(!0), f());
|
|
764
|
-
}, [i, f]), O =
|
|
762
|
+
}, [i, f]), O = L(() => {
|
|
765
763
|
!i || !c || (p(!1), c());
|
|
766
|
-
}, [i, c]), H =
|
|
764
|
+
}, [i, c]), H = L(() => {
|
|
767
765
|
d && c && (p(!1), c());
|
|
768
|
-
}, [d, c]),
|
|
766
|
+
}, [d, c]), S = x ? F.width < 350 : F.height < 200, V = x ? F.height < 310 : F.height < 450;
|
|
769
767
|
return /* @__PURE__ */ r(
|
|
770
768
|
Oe,
|
|
771
769
|
{
|
|
772
|
-
ref:
|
|
773
|
-
className:
|
|
770
|
+
ref: w,
|
|
771
|
+
className: h,
|
|
774
772
|
sx: {
|
|
775
773
|
width: "100%",
|
|
776
774
|
height: "100%",
|
|
@@ -788,7 +786,7 @@ const Rt = j(
|
|
|
788
786
|
backgroundImage: "none"
|
|
789
787
|
// Override any gradient from elevation
|
|
790
788
|
},
|
|
791
|
-
children: x ? /* @__PURE__ */
|
|
789
|
+
children: x ? /* @__PURE__ */ b(U, { children: [
|
|
792
790
|
/* @__PURE__ */ r(
|
|
793
791
|
v,
|
|
794
792
|
{
|
|
@@ -803,9 +801,9 @@ const Rt = j(
|
|
|
803
801
|
mr: { xs: 0.75, sm: 1, md: 1.5 },
|
|
804
802
|
overflow: "hidden",
|
|
805
803
|
// Prevent content from affecting container size
|
|
806
|
-
display:
|
|
804
|
+
display: S ? "none" : "block"
|
|
807
805
|
},
|
|
808
|
-
children: !
|
|
806
|
+
children: !S && /* @__PURE__ */ b(
|
|
809
807
|
te,
|
|
810
808
|
{
|
|
811
809
|
orthographic: !0,
|
|
@@ -840,7 +838,7 @@ const Rt = j(
|
|
|
840
838
|
)
|
|
841
839
|
}
|
|
842
840
|
),
|
|
843
|
-
/* @__PURE__ */
|
|
841
|
+
/* @__PURE__ */ b(
|
|
844
842
|
v,
|
|
845
843
|
{
|
|
846
844
|
sx: {
|
|
@@ -848,10 +846,10 @@ const Rt = j(
|
|
|
848
846
|
display: "flex",
|
|
849
847
|
flexDirection: "column",
|
|
850
848
|
justifyContent: "flex-start",
|
|
851
|
-
width:
|
|
849
|
+
width: S ? "100%" : "50%"
|
|
852
850
|
},
|
|
853
851
|
children: [
|
|
854
|
-
/* @__PURE__ */
|
|
852
|
+
/* @__PURE__ */ b(
|
|
855
853
|
v,
|
|
856
854
|
{
|
|
857
855
|
sx: {
|
|
@@ -872,7 +870,7 @@ const Rt = j(
|
|
|
872
870
|
]
|
|
873
871
|
}
|
|
874
872
|
),
|
|
875
|
-
/* @__PURE__ */
|
|
873
|
+
/* @__PURE__ */ b(
|
|
876
874
|
v,
|
|
877
875
|
{
|
|
878
876
|
sx: {
|
|
@@ -884,7 +882,7 @@ const Rt = j(
|
|
|
884
882
|
justifyContent: "space-between"
|
|
885
883
|
},
|
|
886
884
|
children: [
|
|
887
|
-
!V && s && /* @__PURE__ */
|
|
885
|
+
!V && s && /* @__PURE__ */ b(v, { children: [
|
|
888
886
|
/* @__PURE__ */ r(s, {}),
|
|
889
887
|
/* @__PURE__ */ r(
|
|
890
888
|
z,
|
|
@@ -916,7 +914,7 @@ const Rt = j(
|
|
|
916
914
|
children: /* @__PURE__ */ r(
|
|
917
915
|
Q,
|
|
918
916
|
{
|
|
919
|
-
ref:
|
|
917
|
+
ref: m,
|
|
920
918
|
variant: "contained",
|
|
921
919
|
color: "secondary",
|
|
922
920
|
size: "small",
|
|
@@ -944,7 +942,7 @@ const Rt = j(
|
|
|
944
942
|
]
|
|
945
943
|
}
|
|
946
944
|
)
|
|
947
|
-
] }) : /* @__PURE__ */ r(
|
|
945
|
+
] }) : /* @__PURE__ */ r(U, { children: /* @__PURE__ */ b(
|
|
948
946
|
v,
|
|
949
947
|
{
|
|
950
948
|
sx: {
|
|
@@ -954,7 +952,7 @@ const Rt = j(
|
|
|
954
952
|
flexDirection: "column"
|
|
955
953
|
},
|
|
956
954
|
children: [
|
|
957
|
-
/* @__PURE__ */
|
|
955
|
+
/* @__PURE__ */ b(v, { children: [
|
|
958
956
|
/* @__PURE__ */ r(ee, { variant: "h6", component: "h2", sx: { mb: 1 }, children: e }),
|
|
959
957
|
/* @__PURE__ */ r(
|
|
960
958
|
re,
|
|
@@ -969,15 +967,15 @@ const Rt = j(
|
|
|
969
967
|
v,
|
|
970
968
|
{
|
|
971
969
|
sx: {
|
|
972
|
-
flex:
|
|
970
|
+
flex: S ? 0 : 1,
|
|
973
971
|
position: "relative",
|
|
974
|
-
minHeight:
|
|
975
|
-
height:
|
|
972
|
+
minHeight: S ? 0 : { xs: 120, sm: 150, md: 200 },
|
|
973
|
+
height: S ? 0 : "auto",
|
|
976
974
|
borderRadius: 1,
|
|
977
975
|
overflow: "hidden",
|
|
978
|
-
display:
|
|
976
|
+
display: S ? "none" : "block"
|
|
979
977
|
},
|
|
980
|
-
children: !
|
|
978
|
+
children: !S && /* @__PURE__ */ b(
|
|
981
979
|
te,
|
|
982
980
|
{
|
|
983
981
|
orthographic: !0,
|
|
@@ -1010,8 +1008,8 @@ const Rt = j(
|
|
|
1010
1008
|
)
|
|
1011
1009
|
}
|
|
1012
1010
|
),
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
!V && s && /* @__PURE__ */
|
|
1011
|
+
/* @__PURE__ */ b(v, { children: [
|
|
1012
|
+
!V && s && /* @__PURE__ */ b(U, { children: [
|
|
1015
1013
|
/* @__PURE__ */ r(s, {}),
|
|
1016
1014
|
/* @__PURE__ */ r(
|
|
1017
1015
|
z,
|
|
@@ -1037,7 +1035,7 @@ const Rt = j(
|
|
|
1037
1035
|
children: /* @__PURE__ */ r(
|
|
1038
1036
|
Q,
|
|
1039
1037
|
{
|
|
1040
|
-
ref:
|
|
1038
|
+
ref: m,
|
|
1041
1039
|
variant: "contained",
|
|
1042
1040
|
color: "secondary",
|
|
1043
1041
|
size: "small",
|
|
@@ -1103,11 +1101,11 @@ function ve({
|
|
|
1103
1101
|
t(f.current, a);
|
|
1104
1102
|
else
|
|
1105
1103
|
for (const [d, p] of f.current.entries()) {
|
|
1106
|
-
const
|
|
1107
|
-
p.position.y =
|
|
1104
|
+
const w = n[d].reverse_rotation_direction ? -1 : 1;
|
|
1105
|
+
p.position.y = w * (a[d] || 0) / 1e3;
|
|
1108
1106
|
}
|
|
1109
1107
|
}
|
|
1110
|
-
const
|
|
1108
|
+
const h = L(() => {
|
|
1111
1109
|
const a = e.joint_position.filter(
|
|
1112
1110
|
(u) => u !== void 0
|
|
1113
1111
|
);
|
|
@@ -1117,9 +1115,9 @@ function ve({
|
|
|
1117
1115
|
});
|
|
1118
1116
|
}, [e]);
|
|
1119
1117
|
return T(() => {
|
|
1120
|
-
|
|
1121
|
-
}, [e,
|
|
1122
|
-
|
|
1118
|
+
h();
|
|
1119
|
+
}, [e, h]), fe(() => {
|
|
1120
|
+
h();
|
|
1123
1121
|
}), /* @__PURE__ */ r("group", { ref: y, children: l });
|
|
1124
1122
|
}
|
|
1125
1123
|
function Me({
|
|
@@ -1129,44 +1127,44 @@ function Me({
|
|
|
1129
1127
|
}) {
|
|
1130
1128
|
const l = new R(), i = M(null), f = M(null);
|
|
1131
1129
|
function c(s) {
|
|
1132
|
-
const
|
|
1130
|
+
const h = new R();
|
|
1133
1131
|
for (let p = 0; p < n.length; p++) {
|
|
1134
|
-
const
|
|
1132
|
+
const m = n[p], w = s[p] ?? 0, x = new R().makeRotationY(m.theta).multiply(
|
|
1135
1133
|
new R().makeTranslation(
|
|
1136
|
-
|
|
1137
|
-
(
|
|
1134
|
+
m.a / 1e3,
|
|
1135
|
+
(m.d + w * (m.reverse_rotation_direction ? -1 : 1)) / 1e3,
|
|
1138
1136
|
0
|
|
1139
1137
|
)
|
|
1140
|
-
).multiply(new R().makeRotationX(
|
|
1141
|
-
|
|
1138
|
+
).multiply(new R().makeRotationX(m.alpha));
|
|
1139
|
+
h.multiply(x);
|
|
1142
1140
|
}
|
|
1143
|
-
const a = new
|
|
1144
|
-
return
|
|
1141
|
+
const a = new k(), u = new W(), d = new k();
|
|
1142
|
+
return h.decompose(a, u, d), a;
|
|
1145
1143
|
}
|
|
1146
1144
|
const o = c(
|
|
1147
1145
|
e.joint_position
|
|
1148
1146
|
);
|
|
1149
|
-
function y(s,
|
|
1147
|
+
function y(s, h) {
|
|
1150
1148
|
l.identity();
|
|
1151
|
-
let a = new
|
|
1152
|
-
for (let
|
|
1153
|
-
const
|
|
1149
|
+
let a = new k();
|
|
1150
|
+
for (let m = 0; m < n.length; m++) {
|
|
1151
|
+
const w = h[m] ?? 0, x = n[m], P = new R().makeRotationY(x.theta).multiply(
|
|
1154
1152
|
new R().makeTranslation(
|
|
1155
1153
|
x.a / 1e3,
|
|
1156
|
-
(x.d +
|
|
1154
|
+
(x.d + w * (x.reverse_rotation_direction ? -1 : 1)) / 1e3,
|
|
1157
1155
|
0
|
|
1158
1156
|
)
|
|
1159
1157
|
).multiply(new R().makeRotationX(x.alpha));
|
|
1160
|
-
l.multiply(
|
|
1158
|
+
l.multiply(P);
|
|
1161
1159
|
}
|
|
1162
|
-
const u = new
|
|
1160
|
+
const u = new k(), d = new W(), p = new k();
|
|
1163
1161
|
if (l.decompose(u, d, p), a = u, i.current && i.current.position.set(
|
|
1164
1162
|
a.x,
|
|
1165
1163
|
a.y,
|
|
1166
1164
|
a.z
|
|
1167
1165
|
), f.current) {
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1166
|
+
const m = f.current.geometry;
|
|
1167
|
+
m != null && m.setPositions && m.setPositions([
|
|
1170
1168
|
0,
|
|
1171
1169
|
0,
|
|
1172
1170
|
0,
|
|
@@ -1182,8 +1180,8 @@ function Me({
|
|
|
1182
1180
|
rapidlyChangingMotionState: e,
|
|
1183
1181
|
dhParameters: n,
|
|
1184
1182
|
onTranslationChanged: y,
|
|
1185
|
-
children: /* @__PURE__ */
|
|
1186
|
-
/* @__PURE__ */
|
|
1183
|
+
children: /* @__PURE__ */ b("group", { ...t, name: "Scene", children: [
|
|
1184
|
+
/* @__PURE__ */ b("mesh", { name: "Base", position: [0, 0, 0], children: [
|
|
1187
1185
|
/* @__PURE__ */ r("sphereGeometry", { args: [0.02, 32, 32] }),
|
|
1188
1186
|
/* @__PURE__ */ r("meshStandardMaterial", { color: "green", depthTest: !0 })
|
|
1189
1187
|
] }),
|
|
@@ -1191,12 +1189,12 @@ function Me({
|
|
|
1191
1189
|
$,
|
|
1192
1190
|
{
|
|
1193
1191
|
ref: f,
|
|
1194
|
-
points: [new
|
|
1192
|
+
points: [new k(0, 0, 0), o],
|
|
1195
1193
|
color: "White",
|
|
1196
1194
|
lineWidth: 5
|
|
1197
1195
|
}
|
|
1198
1196
|
),
|
|
1199
|
-
/* @__PURE__ */
|
|
1197
|
+
/* @__PURE__ */ b("mesh", { ref: i, name: "TCP", position: o, children: [
|
|
1200
1198
|
/* @__PURE__ */ r("sphereGeometry", { args: [0.025, 32, 32] }),
|
|
1201
1199
|
/* @__PURE__ */ r("meshStandardMaterial", { color: "red", depthTest: !0 })
|
|
1202
1200
|
] })
|
|
@@ -1204,23 +1202,23 @@ function Me({
|
|
|
1204
1202
|
}
|
|
1205
1203
|
);
|
|
1206
1204
|
}
|
|
1207
|
-
const _e =
|
|
1205
|
+
const _e = J(
|
|
1208
1206
|
({
|
|
1209
1207
|
rapidlyChangingMotionState: e,
|
|
1210
1208
|
modelFromController: n,
|
|
1211
1209
|
dhParameters: t,
|
|
1212
|
-
getModel: l =
|
|
1210
|
+
getModel: l = j,
|
|
1213
1211
|
flangeRef: i,
|
|
1214
1212
|
postModelRender: f,
|
|
1215
1213
|
transparentColor: c,
|
|
1216
1214
|
instanceUrl: o,
|
|
1217
1215
|
...y
|
|
1218
1216
|
}) => {
|
|
1219
|
-
const [s,
|
|
1220
|
-
|
|
1217
|
+
const [s, h] = G(null), a = L((d) => {
|
|
1218
|
+
h(d);
|
|
1221
1219
|
}, []);
|
|
1222
1220
|
T(() => {
|
|
1223
|
-
s && (c ?
|
|
1221
|
+
s && (c ? be(s, c) : xe(s));
|
|
1224
1222
|
}, [s, c]);
|
|
1225
1223
|
const u = /* @__PURE__ */ r(
|
|
1226
1224
|
Me,
|
|
@@ -1230,7 +1228,7 @@ const _e = j(
|
|
|
1230
1228
|
...y
|
|
1231
1229
|
}
|
|
1232
1230
|
);
|
|
1233
|
-
return /* @__PURE__ */
|
|
1231
|
+
return /* @__PURE__ */ b(
|
|
1234
1232
|
pe,
|
|
1235
1233
|
{
|
|
1236
1234
|
fallback: u,
|
|
@@ -1244,17 +1242,17 @@ const _e = j(
|
|
|
1244
1242
|
rapidlyChangingMotionState: e,
|
|
1245
1243
|
dhParameters: t,
|
|
1246
1244
|
children: /* @__PURE__ */ r(
|
|
1247
|
-
|
|
1245
|
+
we,
|
|
1248
1246
|
{
|
|
1249
1247
|
modelURL: (() => {
|
|
1250
1248
|
const d = l(n, o);
|
|
1251
1249
|
if (!d) {
|
|
1252
|
-
const p = new Blob([], { type: "model/gltf-binary" }),
|
|
1250
|
+
const p = new Blob([], { type: "model/gltf-binary" }), m = new File(
|
|
1253
1251
|
[p],
|
|
1254
1252
|
`${n}.glb`,
|
|
1255
1253
|
{ type: "model/gltf-binary" }
|
|
1256
1254
|
);
|
|
1257
|
-
return Promise.resolve(URL.createObjectURL(
|
|
1255
|
+
return Promise.resolve(URL.createObjectURL(m));
|
|
1258
1256
|
}
|
|
1259
1257
|
return d;
|
|
1260
1258
|
})(),
|
|
@@ -1273,7 +1271,7 @@ const _e = j(
|
|
|
1273
1271
|
);
|
|
1274
1272
|
function Mt({
|
|
1275
1273
|
connectedMotionGroup: e,
|
|
1276
|
-
getModel: n =
|
|
1274
|
+
getModel: n = j,
|
|
1277
1275
|
flangeRef: t,
|
|
1278
1276
|
transparentColor: l,
|
|
1279
1277
|
postModelRender: i,
|
|
@@ -1347,28 +1345,28 @@ function _t(e, n) {
|
|
|
1347
1345
|
const t = Qe(e);
|
|
1348
1346
|
return t && t in ie ? ie[t] : n || null;
|
|
1349
1347
|
}
|
|
1350
|
-
const Tt =
|
|
1351
|
-
const { inverseSolver: n, dhParameters: t, ...l } = e, [i, f] =
|
|
1348
|
+
const Tt = J((e) => {
|
|
1349
|
+
const { inverseSolver: n, dhParameters: t, ...l } = e, [i, f] = G(
|
|
1352
1350
|
C.RevoluteJoint
|
|
1353
1351
|
);
|
|
1354
1352
|
T(() => {
|
|
1355
1353
|
t.length && f(t[0].type ?? C.RevoluteJoint);
|
|
1356
1354
|
}, [t]);
|
|
1357
|
-
const c =
|
|
1358
|
-
return
|
|
1355
|
+
const c = I(() => n === null && i === C.RevoluteJoint, [n, i]), o = I(() => n === null && i === C.PrismaticJoint, [n, i]);
|
|
1356
|
+
return I(() => !!n, [n]) || c ? /* @__PURE__ */ r(Re, { dhParameters: t, ...l }) : o ? /* @__PURE__ */ r(_e, { dhParameters: t, ...l }) : null;
|
|
1359
1357
|
});
|
|
1360
1358
|
export {
|
|
1361
|
-
|
|
1359
|
+
wt as C,
|
|
1362
1360
|
Mt as L,
|
|
1363
1361
|
ie as M,
|
|
1364
1362
|
ne as P,
|
|
1365
1363
|
Rt as R,
|
|
1366
|
-
|
|
1364
|
+
bt as S,
|
|
1367
1365
|
xt as T,
|
|
1368
1366
|
vt as a,
|
|
1369
1367
|
Ze as b,
|
|
1370
1368
|
_e as c,
|
|
1371
|
-
|
|
1369
|
+
j as d,
|
|
1372
1370
|
Qe as e,
|
|
1373
1371
|
Re as f,
|
|
1374
1372
|
_t as g,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),g=require("three"),V=require("three-stdlib"),d=require("react"),S=require("./externalizeComponent-BHZdH14U.cjs"),M=require("@react-three/drei"),pe=require("@mui/material/styles"),v=require("@mui/material/Box"),Y=require("@mui/material/Button"),he=require("@mui/material/Card"),Q=require("@mui/material/Divider"),X=require("@mui/material/Typography"),T=require("@react-three/fiber"),me=require("mobx-react-lite"),xe=require("react-i18next"),L=require("./interpolation-B84QX33C.cjs"),R=require("@wandelbots/nova-js/v2"),K=require("react-error-boundary");function ye(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const j=ye(g);function ge(e){switch(e.shape_type){case"convex_hull":return new V.ConvexGeometry(e.vertices.map(r=>new j.Vector3(r[0]/1e3,r[1]/1e3,r[2]/1e3)));case"box":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new j.SphereGeometry(e.radius/1e3);case"capsule":return new j.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new j.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new j.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new j.BufferGeometry}}function je({name:e,collider:n,children:r}){var f,u;const o=((f=n.pose)==null?void 0:f.position)??[0,0,0],i=((u=n.pose)==null?void 0:u.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),t.jsx("mesh",{name:e,position:new j.Vector3(o[0],o[1],o[2]).divideScalar(1e3),rotation:new j.Euler(i[0],i[1],i[2],"XYZ"),geometry:ge(n.shape),children:r})}function be({name:e,colliders:n,meshChildrenProvider:r,...o}){return t.jsx("group",{name:e,...o,children:Object.entries(n).map(([i,f])=>t.jsx(je,{name:i,collider:f,children:r(i,f)},i))})}function we({scene:e,meshChildrenProvider:n}){const r=e.colliders;return t.jsx("group",{children:r&&t.jsx(be,{meshChildrenProvider:n,colliders:r})})}function O(){return t.jsx(M.Environment,{frames:1,children:t.jsx(Me,{})})}const Re=[2,0,2,0,2,0,2,0];function Me({positions:e=Re}){return t.jsxs(t.Fragment,{children:[t.jsx(M.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsx("group",{rotation:[0,.5,0],children:t.jsx("group",{children:e.map((n,r)=>t.jsx(M.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,r*4],scale:[3,1,1]},r))})}),t.jsx(M.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsx(M.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsx(M.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const Z={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function ve({safetyZones:e,dhParameters:n,...r}){const o=d.useMemo(()=>S.dhParametersToPlaneSize(n??[]),[n]),i=(u,s)=>{var l,h;if(!((l=s==null?void 0:s.pose)!=null&&l.position)||!((h=s==null?void 0:s.pose)!=null&&h.orientation))return null;const y=new j.Vector3(s.pose.position[0]/1e3,s.pose.position[1]/1e3,s.pose.position[2]/1e3),a=new j.Vector3(s.pose.orientation[0],s.pose.orientation[1],s.pose.orientation[2]);let m;const c=s.shape.shape_type==="plane"?{...Z,side:j.DoubleSide}:{...Z,side:j.FrontSide};switch(s.shape.shape_type){case"plane":m=t.jsx("planeGeometry",{args:[o,o]});break;case"sphere":{const p=(s==null?void 0:s.shape).radius/1e3;m=t.jsx("sphereGeometry",{args:[p]});break}case"capsule":{const p=(s==null?void 0:s.shape).radius/1e3,x=(s==null?void 0:s.shape).cylinder_height/1e3;m=t.jsx("capsuleGeometry",{args:[p,x]});break}case"convex_hull":{const p=(s==null?void 0:s.shape).vertices.map(b=>new j.Vector3(b[0]/1e3,b[1]/1e3,b[2]/1e3)),x=S.verticesToCoplanarity(p);if(x.isCoplanar&&x.normal){const w=new j.Vector3().addVectors(p[0],x.normal.multiplyScalar(1e-4));p.push(w)}try{m=t.jsx("primitive",{object:new V.ConvexGeometry(p),attach:"geometry"})}catch(b){return console.log("Error creating ConvexGeometry:",b),null}break}case"rectangular_capsule":{const p=s.shape,x=p.radius/1e3,b=p.sphere_center_distance_x/1e3,w=p.sphere_center_distance_y/1e3,k=x*2;m=t.jsx("primitive",{object:new V.RoundedBoxGeometry(b,w,k,2,x),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",s.shape.shape_type),m=null}return t.jsxs("mesh",{renderOrder:u,position:y,quaternion:S.orientationToQuaternion(a),children:[m,t.jsx("meshStandardMaterial",{...c,polygonOffsetFactor:-u})]},`safety-zone-${s.shape.shape_type}-${u}`)},f=d.useMemo(()=>Object.values(e??{}).map((u,s)=>i(s,u)),[e,o]);return t.jsx("group",{...r,children:f})}function _e({trajectory:e,...n}){const r=(e==null?void 0:e.map(o=>{if(o.position&&o.position.length>=3){const[i,f,u]=o.position;if(Number.isFinite(i)&&Number.isFinite(f)&&Number.isFinite(u))return new j.Vector3(i/1e3,u/1e3,-f/1e3)}return null}).filter(o=>o!==null))||[];return t.jsx("group",{...n,children:r.length>0&&t.jsx(M.Line,{points:r,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const P=new Map;async function E(e,n){if(P.has(e))return P.get(e);const r=(async()=>{var u;const o=n||"",i=new R.NovaClient({instanceUrl:o}),f=i.api.motionGroupModels;(u=f.axios)!=null&&u.interceptors&&f.axios.interceptors.request.use(s=>{var y;return(y=s.url)!=null&&y.includes("/glb")&&(s.responseType="blob"),s});try{const s=await i.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(s)}catch(s){throw console.error("Failed to fetch model:",s),s}})();return P.set(e,r),r}function z(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(o=>n(o))]}return n(e).filter(r=>te(r))}function ee(e){return e.name.endsWith("_FLG")}function te(e){return/_J[0-9]+$/.test(e.name)}function Se(e,n){let r;function o(i){if(ee(i)){if(r)throw Error(`Found multiple flange groups in robot model ${n}; first ${r.name} then ${i.name}. Only one _FLG group is allowed.`);r=i}te(i),i.children.map(o)}if(o(e.scene),!r)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}function re({rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef(null),{invalidate:u}=T.useThree(),s=d.useRef(e);s.current=e,d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return f.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=f.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(f.current){const h=f.current.update(l);a(),h||u()}});function y(c){c&&(i.current=z(c),a(),u())}function a(){var l;const c=((l=f.current)==null?void 0:l.getCurrentValues())||[];if(r)r(i.current,c);else for(const[h,p]of i.current.entries()){const x=n[h],b=x.theta||0,w=x.reverse_rotation_direction?-1:1;p.rotation.y=w*(c[h]||0)+b}}function m(c){var h;const l=c.joint_position.filter(p=>p!==void 0);(h=f.current)==null||h.setTarget(l),u()}return L.useAutorun(()=>{m(s.current)}),d.useEffect(()=>{m(e)},[e]),t.jsx("group",{ref:y,children:o})}const Te="line",Le="mesh";function ke({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new g.Matrix4,i=d.useRef([]),f=d.useRef([]);d.useEffect(()=>{i.current=new Array(n.length).fill(null),f.current=new Array(n.length).fill(null)},[n.length]);function u(a,m){const c=new g.Vector3,l=new g.Quaternion,h=new g.Vector3;o.decompose(c,l,h);const p=c.clone(),x=new g.Matrix4().makeRotationY(a.theta+m*(a.reverse_rotation_direction?-1:1)).multiply(new g.Matrix4().makeTranslation(0,a.d/1e3,0)).multiply(new g.Matrix4().makeTranslation(a.a/1e3,0,0)).multiply(new g.Matrix4().makeRotationX(a.alpha));return o.multiply(x),o.decompose(c,l,h),{a:p,b:c}}function s(a,m,c,l){if(!n)return;const h=n[a];if(!h)return;const{a:p,b:x}=u(h,l);m.geometry.setPositions([p.toArray(),x.toArray()].flat()),c.position.set(x.x,x.y,x.z)}function y(a,m){o.identity();for(let c=0;c<Math.min(a.length,m.length);c++){const l=i.current[c],h=f.current[c];l&&h&&s(c,l,h,m[c])}}return t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((a,m)=>{const{a:c,b:l}=u(a,e.joint_position[m]??0),h=`dhrobot_J0${m}`;return t.jsxs("group",{name:h,children:[t.jsx(M.Line,{ref:p=>{i.current[m]=p},name:Te,points:[c,l],color:"white",lineWidth:5}),t.jsxs("mesh",{ref:p=>{f.current[m]=p},name:Le,position:l,children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${m}`)]},h)})]})})}const Ee=console.warn;function ne(){return d.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ee(e)}},[]),null}function Ge(e){return e.type==="Mesh"}function Ce({url:e,flangeRef:n,postModelRender:r,...o}){const i=M.useGLTF(e),u=Se(i,"robot.glb").gltf,s=d.useCallback(a=>{a&&r&&r()},[r]);function y(a){try{return Ge(a)?a.geometry?t.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:ee(a)?n:void 0,children:a.children.map(y)},a.uuid)}catch(m){return console.warn("Error rendering node",a.name,m),null}}return t.jsx("group",{...o,dispose:null,ref:s,children:y(u.scene)})}function se({modelURL:e,flangeRef:n,postModelRender:r,...o}){const[i,f]=d.useState(null);return d.useEffect(()=>{let u=!1;return(async()=>{try{const y=typeof e=="string"?e:await e;u||f(a=>a===y?a:y)}catch(y){console.error("Failed to resolve model URL:",y)}})(),()=>{u=!0}},[e]),i?t.jsx(Ce,{url:i,flangeRef:n,postModelRender:r,...o}):null}const oe=(e,n)=>{e.userData.isGhost||(e.traverse(r=>{if(r instanceof j.Mesh){r.material instanceof j.Material&&(r.material.colorWrite=!1);const o=r.clone(),i=r.clone();o.material=new j.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:j.DoubleSide}),o.userData.isGhost=!0,i.material=new j.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:j.DoubleSide}),i.userData.isGhost=!0,r.parent&&(r.parent.add(o),r.parent.add(i))}}),e.userData.isGhost=!0)},ie=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(r=>{var o;r instanceof j.Mesh&&((o=r.userData)!=null&&o.isGhost?n.push(r):r.material instanceof j.Material&&(r.material.colorWrite=!0))}),n.forEach(r=>{r.parent&&r.parent.remove(r)}),e.userData.isGhost=!1},q=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=E,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,m]=d.useState(null),c=d.useCallback(p=>{m(p)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=d.useMemo(()=>{const p=o(n,s);if(!p)throw new Error(`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`);return p},[n,s,o]),h=t.jsx(ke,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:h,onError:p=>{console.warn(p)},children:[t.jsx(d.Suspense,{fallback:h,children:t.jsx("group",{ref:c,children:t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:l,postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function ae({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:o,postModelRender:i,...f}){return e.dhParameters?t.jsx(q,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):null}const Ae=S.externalizeComponent(me.observer(({robotName:e,programState:n,safetyState:r,operationMode:o,driveToHomeEnabled:i=!1,onDriveToHomePress:f,onDriveToHomeRelease:u,connectedMotionGroup:s,robotComponent:y=ae,customContentComponent:a,className:m})=>{var N;const c=pe.useTheme(),{t:l}=xe.useTranslation(),[h,p]=d.useState(!1),x=d.useRef(null),b=d.useRef(null),[w,k]=d.useState(!1),[G,fe]=d.useState({width:400,height:600}),[Oe,de]=d.useState(0);d.useEffect(()=>{const F=()=>{if(b.current){const{offsetWidth:$,offsetHeight:H}=b.current;k($>H),fe({width:$,height:H})}};F();const W=new ResizeObserver(F);return b.current&&W.observe(b.current),()=>{W.disconnect()}},[]);const J=d.useCallback(()=>{de(F=>F+1)},[]),C=d.useCallback(()=>{!i||!f||(p(!0),f())},[i,f]),A=d.useCallback(()=>{!i||!u||(p(!1),u())},[i,u]),B=d.useCallback(()=>{h&&u&&(p(!1),u())},[h,u]),_=w?G.width<350:G.height<200,I=w?G.height<310:G.height<450;return t.jsx(he,{ref:b,className:m,sx:{width:"100%",height:"100%",display:"flex",flexDirection:w?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:w?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${c.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:((N=c.palette.backgroundPaperElevation)==null?void 0:N[8])||"#2A2A3F",backgroundImage:"none"},children:w?t.jsxs(t.Fragment,{children:[t.jsx(v,{sx:{flex:"0 0 50%",position:"relative",height:"100%",minHeight:"100%",maxHeight:"100%",borderRadius:1,m:{xs:1.5,sm:2,md:3},mr:{xs:.75,sm:1,md:1.5},overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(O,{}),t.jsx(M.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:_?"100%":"50%"},children:[t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!I&&a&&t.jsxs(v,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{mt:!I&&a?"auto":0},children:t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:x,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:B,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsx(t.Fragment,{children:t.jsxs(v,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxs(v,{children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsx(v,{sx:{flex:_?0:1,position:"relative",minHeight:_?0:{xs:120,sm:150,md:200},height:_?0:"auto",borderRadius:1,overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(O,{}),t.jsx(M.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{children:[!I&&a&&t.jsxs(t.Fragment,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:!I&&a?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:x,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:C,onMouseUp:A,onMouseLeave:B,onTouchStart:C,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})]})]})})})})),Ie=Array(6).fill(2*Math.PI);function ce({rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef([]),u=d.useRef(null),{invalidate:s}=T.useThree();d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return u.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=u.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(u.current){const h=u.current.update(l);a(),h||s()}});function y(c){c&&(f.current=z(c),a(),s())}function a(){var l;const c=((l=u.current)==null?void 0:l.getCurrentValues())||[];if(r)r(f.current,c);else for(const[h,p]of f.current.entries()){const b=n[h].reverse_rotation_direction?-1:1;p.position.y=b*(c[h]||0)/1e3}}const m=d.useCallback(()=>{const c=e.joint_position.filter(l=>l!==void 0);requestAnimationFrame(()=>{var l;i.current=c,(l=u.current)==null||l.setTarget(c)})},[e]);return d.useEffect(()=>{m()},[e,m]),L.useAutorun(()=>{m()}),t.jsx("group",{ref:y,children:o})}function ue({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new g.Matrix4,i=d.useRef(null),f=d.useRef(null);function u(a){const m=new g.Matrix4;for(let p=0;p<n.length;p++){const x=n[p],b=a[p]??0,w=new g.Matrix4().makeRotationY(x.theta).multiply(new g.Matrix4().makeTranslation(x.a/1e3,(x.d+b*(x.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(x.alpha));m.multiply(w)}const c=new g.Vector3,l=new g.Quaternion,h=new g.Vector3;return m.decompose(c,l,h),c}const s=u(e.joint_position);function y(a,m){o.identity();let c=new g.Vector3;for(let x=0;x<n.length;x++){const b=m[x]??0,w=n[x],k=new g.Matrix4().makeRotationY(w.theta).multiply(new g.Matrix4().makeTranslation(w.a/1e3,(w.d+b*(w.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new g.Matrix4().makeRotationX(w.alpha));o.multiply(k)}const l=new g.Vector3,h=new g.Quaternion,p=new g.Vector3;if(o.decompose(l,h,p),c=l,i.current&&i.current.position.set(c.x,c.y,c.z),f.current){const x=f.current.geometry;x!=null&&x.setPositions&&x.setPositions([0,0,0,c.x,c.y,c.z])}}return t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsx(M.Line,{ref:f,points:[new g.Vector3(0,0,0),s],color:"White",lineWidth:5}),t.jsxs("mesh",{ref:i,name:"TCP",position:s,children:[t.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const U=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=E,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,m]=d.useState(null),c=d.useCallback(h=>{m(h)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=t.jsx(ue,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:l,onError:h=>{console.warn(h)},children:[t.jsx(d.Suspense,{fallback:l,children:t.jsx("group",{ref:c,children:t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:(()=>{const h=o(n,s);if(!h){const p=new Blob([],{type:"model/gltf-binary"}),x=new File([p],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(x))}return h})(),postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function Fe({connectedMotionGroup:e,getModel:n=E,flangeRef:r,transparentColor:o,postModelRender:i,...f}){if(!e.dhParameters)return null;const u=e.modelFromController||"";return u&&n(u)?t.jsx(U,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:u,dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):t.jsx(ue,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,...f})}const D={[R.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[R.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[R.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0]};function le(e){const[n]=e.split("_");switch(n){case"ABB":return R.Manufacturer.Abb;case"FANUC":return R.Manufacturer.Fanuc;case"YASKAWA":return R.Manufacturer.Yaskawa;case"KUKA":return R.Manufacturer.Kuka;case"UniversalRobots":return R.Manufacturer.Universalrobots;default:return null}}function Pe(e,n){const r=le(e);return r&&r in D?D[r]:n||null}const Ve=S.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:r,...o}=e,[i,f]=d.useState(R.JointTypeEnum.RevoluteJoint);d.useEffect(()=>{r.length&&f(r[0].type??R.JointTypeEnum.RevoluteJoint)},[r]);const u=d.useMemo(()=>n===null&&i===R.JointTypeEnum.RevoluteJoint,[n,i]),s=d.useMemo(()=>n===null&&i===R.JointTypeEnum.PrismaticJoint,[n,i]);return d.useMemo(()=>!!n,[n])||u?t.jsx(q,{dhParameters:r,...o}):s?t.jsx(U,{dhParameters:r,...o}):null});exports.CollisionSceneRenderer=we;exports.LinearAxis=Fe;exports.MANUFACTURER_HOME_CONFIGS=D;exports.MotionGroupVisualizer=Ve;exports.PresetEnvironment=O;exports.Robot=ae;exports.RobotCard=Ae;exports.SafetyZonesRenderer=ve;exports.SupportedLinearAxis=U;exports.SupportedRobot=q;exports.TrajectoryRenderer=_e;exports.defaultAxisConfig=Ie;exports.defaultGetModel=E;exports.extractManufacturer=le;exports.getDefaultHomeConfig=Pe;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/MotionGroupVisualizer-EN8Nw5xP.cjs"),e=require("./chunks/theming-CovKBJaN.cjs"),t=require("./chunks/interpolation-B84QX33C.cjs"),i=require("./chunks/externalizeComponent-BHZdH14U.cjs"),s=require("./chunks/SafetyBar-CLm3UQRA.cjs"),a=require("./chunks/robot-SEtfVAmf.cjs"),n=require("./chunks/wbLogo-G_IfZ03l.cjs"),r=require("./chunks/safety-state-stop-CgPfwC18.cjs");exports.CollisionSceneRenderer=o.CollisionSceneRenderer;exports.LinearAxis=o.LinearAxis;exports.MANUFACTURER_HOME_CONFIGS=o.MANUFACTURER_HOME_CONFIGS;exports.MotionGroupVisualizer=o.MotionGroupVisualizer;exports.PresetEnvironment=o.PresetEnvironment;exports.Robot=o.Robot;exports.RobotCard=o.RobotCard;exports.SafetyZonesRenderer=o.SafetyZonesRenderer;exports.SupportedLinearAxis=o.SupportedLinearAxis;exports.SupportedRobot=o.SupportedRobot;exports.TrajectoryRenderer=o.TrajectoryRenderer;exports.defaultAxisConfig=o.defaultAxisConfig;exports.defaultGetModel=o.defaultGetModel;exports.extractManufacturer=o.extractManufacturer;exports.getDefaultHomeConfig=o.getDefaultHomeConfig;exports.AppHeader=e.AppHeader;exports.ConnectedMotionGroup=e.ConnectedMotionGroup;exports.CycleTimer=e.CycleTimer;exports.JoggerConnection=e.JoggerConnection;exports.JoggingCartesianAxisControl=e.JoggingCartesianAxisControl;exports.JoggingJointValueControl=e.JoggingJointValueControl;exports.JoggingPanel=e.JoggingPanel;exports.JoggingStore=e.JoggingStore;exports.LoadingCover=e.LoadingCover;exports.LoadingErrorMessage=e.LoadingErrorMessage;exports.LogPanel=e.LogPanel;exports.LogStore=e.LogStore;exports.LogViewer=e.LogViewer;exports.MotionStreamConnection=e.MotionStreamConnection;exports.NoMotionGroupModal=e.NoMotionGroupModal;exports.PoseCartesianValues=e.PoseCartesianValues;exports.PoseJointValues=e.PoseJointValues;exports.RobotListItem=e.RobotListItem;exports.RobotSetupReadinessIndicator=e.RobotSetupReadinessIndicator;exports.RobotSetupReadinessState=e.RobotSetupReadinessState;exports.SelectableFab=e.SelectableFab;exports.TabBar=e.TabBar;exports.Timer=e.Timer;exports.VelocitySlider=e.VelocitySlider;exports.VelocitySliderLabel=e.VelocitySliderLabel;exports.WandelbotsDataGrid=e.WandelbotsDataGrid;exports.createDebugMessage=e.createDebugMessage;exports.createErrorMessage=e.createErrorMessage;exports.createInfoMessage=e.createInfoMessage;exports.createLogMessage=e.createLogMessage;exports.createNovaMuiTheme=e.createNovaMuiTheme;exports.createWarningMessage=e.createWarningMessage;exports.jointValuesEqual=e.jointValuesEqual;exports.poseEqual=e.poseEqual;exports.tcpMotionEqual=e.tcpMotionEqual;exports.unwrapRotationVector=e.unwrapRotationVector;exports.ProgramControl=t.ProgramControl;exports.ProgramState=t.ProgramState;exports.ProgramStateIndicator=t.ProgramStateIndicator;exports.ValueInterpolator=t.ValueInterpolator;exports.useAnimationFrame=t.useAnimationFrame;exports.useAutorun=t.useAutorun;exports.useInterpolation=t.useInterpolation;exports.useMounted=t.useMounted;exports.useReaction=t.useReaction;exports.i18n=i.i18n;exports.SafetyBar=s.SafetyBar;exports.AxisXIcon=a.ForwardRef;exports.AxisYIcon=a.ForwardRef$1;exports.AxisZIcon=a.ForwardRef$2;exports.JogMinusIcon=a.ForwardRef$3;exports.JogPlusIcon=a.ForwardRef$4;exports.RobotIcon=a.ForwardRef$5;exports.RotationIcon=a.ForwardRef$6;exports.HomeIcon=n.ForwardRef;exports.JoggingIcon=n.ForwardRef$1;exports.OrientationCoordSystemIcon=n.ForwardRef$2;exports.OrientationToolIcon=n.ForwardRef$3;exports.WBLogoIcon=n.ForwardRef$4;exports.ControllerTypePhysicalIcon=r.ForwardRef;exports.ControllerTypeVirtualIcon=r.ForwardRef$1;exports.OperationModeAutomaticIcon=r.ForwardRef$2;exports.OperationModeErrorIcon=r.ForwardRef$3;exports.OperationModeManualIcon=r.ForwardRef$4;exports.SafetyStateErrorIcon=r.ForwardRef$5;exports.SafetyStateEstopIcon=r.ForwardRef$6;exports.SafetyStateManualActionRequiredIcon=r.ForwardRef$7;exports.SafetyStateNormalIcon=r.ForwardRef$8;exports.SafetyStateStopIcon=r.ForwardRef$9;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as e, L as s, M as t, h as r, P as n, b as i, R as c, S as l, c as g, f as u, T as d, a as p, d as S, e as I, g as f } from "./chunks/MotionGroupVisualizer-
|
|
1
|
+
import { C as e, L as s, M as t, h as r, P as n, b as i, R as c, S as l, c as g, f as u, T as d, a as p, d as S, e as I, g as f } from "./chunks/MotionGroupVisualizer-BXDggjVD.js";
|
|
2
2
|
import { A as m, s as C, C as R, t as b, a as x, b as y, d as A, J as L, f as P, g as V, h as E, L as J, n as T, M as F, N as O, P as G, e as N, R as h, p as q, o as v, S as H, T as W, q as j, V as w, r as B, W as D, j as U, m as Z, k as _, i as k, c as z, l as X, u as Y, v as K, w as Q, x as $ } from "./chunks/theming-naqCEdJP.js";
|
|
3
3
|
import { a as oa, P as ea, b as sa, V as ta, e as ra, c as na, f as ia, u as ca, d as la } from "./chunks/interpolation-D9WFd-j_.js";
|
|
4
4
|
import { i as ua } from "./chunks/externalizeComponent-D6S3WLFc.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "5.5.2-pr.fix-performance-issues.594.
|
|
3
|
+
"version": "5.5.2-pr.fix-performance-issues.594.b1018c5",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),j=require("three"),O=require("three-stdlib"),d=require("react"),S=require("./externalizeComponent-BHZdH14U.cjs"),M=require("@react-three/drei"),pe=require("@mui/material/styles"),v=require("@mui/material/Box"),Y=require("@mui/material/Button"),he=require("@mui/material/Card"),Q=require("@mui/material/Divider"),X=require("@mui/material/Typography"),T=require("@react-three/fiber"),me=require("mobx-react-lite"),xe=require("react-i18next"),L=require("./interpolation-B84QX33C.cjs"),R=require("@wandelbots/nova-js/v2"),K=require("react-error-boundary");function ye(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const b=ye(j);function ge(e){switch(e.shape_type){case"convex_hull":return new O.ConvexGeometry(e.vertices.map(r=>new b.Vector3(r[0]/1e3,r[1]/1e3,r[2]/1e3)));case"box":return new b.BoxGeometry(e.size_x/1e3,e.size_y/1e3,e.size_z/1e3);case"sphere":return new b.SphereGeometry(e.radius/1e3);case"capsule":return new b.CapsuleGeometry(e.radius/1e3,e.cylinder_height/1e3);case"cylinder":return new b.CylinderGeometry(e.radius/1e3,e.radius/1e3,e.height/1e3);case"rectangle":return new b.BoxGeometry(e.size_x/1e3,e.size_y/1e3,0);default:return console.warn(`${e.shape_type} is not supported`),new b.BufferGeometry}}function je({name:e,collider:n,children:r}){var f,u;const o=((f=n.pose)==null?void 0:f.position)??[0,0,0],i=((u=n.pose)==null?void 0:u.orientation)??[0,0,0];return n.margin&&console.warn(`${e} margin is not supported`),t.jsx("mesh",{name:e,position:new b.Vector3(o[0],o[1],o[2]).divideScalar(1e3),rotation:new b.Euler(i[0],i[1],i[2],"XYZ"),geometry:ge(n.shape),children:r})}function be({name:e,colliders:n,meshChildrenProvider:r,...o}){return t.jsx("group",{name:e,...o,children:Object.entries(n).map(([i,f])=>t.jsx(je,{name:i,collider:f,children:r(i,f)},i))})}function we({scene:e,meshChildrenProvider:n}){const r=e.colliders;return t.jsx("group",{children:r&&t.jsx(be,{meshChildrenProvider:n,colliders:r})})}function V(){return t.jsx(M.Environment,{frames:1,children:t.jsx(Me,{})})}const Re=[2,0,2,0,2,0,2,0];function Me({positions:e=Re}){return t.jsxs(t.Fragment,{children:[t.jsx(M.Lightformer,{intensity:5,"rotation-x":Math.PI/2,position:[0,5,-9],scale:[10,10,1]}),t.jsx("group",{rotation:[0,.5,0],children:t.jsx("group",{children:e.map((n,r)=>t.jsx(M.Lightformer,{form:"circle",intensity:5,rotation:[Math.PI/2,0,0],position:[n,4,r*4],scale:[3,1,1]},r))})}),t.jsx(M.Lightformer,{intensity:40,"rotation-y":Math.PI/2,position:[-5,1,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{intensity:20,"rotation-y":-Math.PI,position:[-5,-2,-1],scale:[20,.1,1]}),t.jsx(M.Lightformer,{"rotation-y":Math.PI/2,position:[-5,-1,-1],scale:[20,.5,1],intensity:5}),t.jsx(M.Lightformer,{"rotation-y":-Math.PI/2,position:[10,1,0],scale:[20,1,1],intensity:10}),t.jsx(M.Lightformer,{form:"ring",color:"white",intensity:5,scale:10,position:[-15,4,-18],target:[0,0,0]})]})}const Z={attach:"material",color:"#009f4d",opacity:.2,depthTest:!1,depthWrite:!1,transparent:!0,polygonOffset:!0};function ve({safetyZones:e,dhParameters:n,...r}){const o=d.useMemo(()=>S.dhParametersToPlaneSize(n??[]),[n]),i=(u,s)=>{var l,h;if(!((l=s==null?void 0:s.pose)!=null&&l.position)||!((h=s==null?void 0:s.pose)!=null&&h.orientation))return null;const y=new b.Vector3(s.pose.position[0]/1e3,s.pose.position[1]/1e3,s.pose.position[2]/1e3),a=new b.Vector3(s.pose.orientation[0],s.pose.orientation[1],s.pose.orientation[2]);let x;const c=s.shape.shape_type==="plane"?{...Z,side:b.DoubleSide}:{...Z,side:b.FrontSide};switch(s.shape.shape_type){case"plane":x=t.jsx("planeGeometry",{args:[o,o]});break;case"sphere":{const p=(s==null?void 0:s.shape).radius/1e3;x=t.jsx("sphereGeometry",{args:[p]});break}case"capsule":{const p=(s==null?void 0:s.shape).radius/1e3,m=(s==null?void 0:s.shape).cylinder_height/1e3;x=t.jsx("capsuleGeometry",{args:[p,m]});break}case"convex_hull":{const p=(s==null?void 0:s.shape).vertices.map(g=>new b.Vector3(g[0]/1e3,g[1]/1e3,g[2]/1e3)),m=S.verticesToCoplanarity(p);if(m.isCoplanar&&m.normal){const w=new b.Vector3().addVectors(p[0],m.normal.multiplyScalar(1e-4));p.push(w)}try{x=t.jsx("primitive",{object:new O.ConvexGeometry(p),attach:"geometry"})}catch(g){return console.log("Error creating ConvexGeometry:",g),null}break}case"rectangular_capsule":{const p=s.shape,m=p.radius/1e3,g=p.sphere_center_distance_x/1e3,w=p.sphere_center_distance_y/1e3,k=m*2;x=t.jsx("primitive",{object:new O.RoundedBoxGeometry(g,w,k,2,m),attach:"geometry"});break}default:console.warn("Unsupported safety zone shape type:",s.shape.shape_type),x=null}return t.jsxs("mesh",{renderOrder:u,position:y,quaternion:S.orientationToQuaternion(a),children:[x,t.jsx("meshStandardMaterial",{...c,polygonOffsetFactor:-u})]},`safety-zone-${s.shape.shape_type}-${u}`)},f=d.useMemo(()=>Object.values(e??{}).map((u,s)=>i(s,u)),[e,o]);return t.jsx("group",{...r,children:f})}function _e({trajectory:e,...n}){const r=(e==null?void 0:e.map(o=>{if(o.position&&o.position.length>=3){const[i,f,u]=o.position;if(Number.isFinite(i)&&Number.isFinite(f)&&Number.isFinite(u))return new b.Vector3(i/1e3,u/1e3,-f/1e3)}return null}).filter(o=>o!==null))||[];return t.jsx("group",{...n,children:r.length>0&&t.jsx(M.Line,{points:r,lineWidth:3,polygonOffset:!0,polygonOffsetFactor:10,polygonOffsetUnits:10})})}const P=new Map;async function G(e,n){if(P.has(e))return P.get(e);const r=(async()=>{var u;const o=n||"",i=new R.NovaClient({instanceUrl:o}),f=i.api.motionGroupModels;(u=f.axios)!=null&&u.interceptors&&f.axios.interceptors.request.use(s=>{var y;return(y=s.url)!=null&&y.includes("/glb")&&(s.responseType="blob"),s});try{const s=await i.api.motionGroupModels.getMotionGroupGlbModel(e);return URL.createObjectURL(s)}catch(s){throw console.error("Failed to fetch model:",s),s}})();return P.set(e,r),r}function z(e){function n(r){return r.children.length===0?[r]:[r,...r.children.flatMap(o=>n(o))]}return n(e).filter(r=>te(r))}function ee(e){return e.name.endsWith("_FLG")}function te(e){return/_J[0-9]+$/.test(e.name)}function Se(e,n){let r;function o(i){if(ee(i)){if(r)throw Error(`Found multiple flange groups in robot model ${n}; first ${r.name} then ${i.name}. Only one _FLG group is allowed.`);r=i}te(i),i.children.map(o)}if(o(e.scene),!r)throw Error(`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`);return{gltf:e}}function re({rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef(null),{invalidate:u}=T.useThree(),s=d.useRef(e);s.current=e,d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return f.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=f.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(f.current){const h=f.current.update(l);a(),h||u()}});function y(c){c&&(i.current=z(c),a(),u())}function a(){var l;const c=((l=f.current)==null?void 0:l.getCurrentValues())||[];if(r)r(i.current,c);else for(const[h,p]of i.current.entries()){const m=n[h],g=m.theta||0,w=m.reverse_rotation_direction?-1:1;p.rotation.y=w*(c[h]||0)+g}}function x(c){var h;const l=c.joint_position.filter(p=>p!==void 0);(h=f.current)==null||h.setTarget(l),u()}return L.useAutorun(()=>{x(s.current)}),d.useEffect(()=>{x(e)},[e]),t.jsx("group",{ref:y,children:o})}const Te="line",Le="mesh";function ke({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new j.Matrix4,i=d.useRef([]),f=d.useRef([]);d.useEffect(()=>{i.current=new Array(n.length).fill(null),f.current=new Array(n.length).fill(null)},[n.length]);function u(a,x){const c=new j.Vector3,l=new j.Quaternion,h=new j.Vector3;o.decompose(c,l,h);const p=c.clone(),m=new j.Matrix4().makeRotationY(a.theta+x*(a.reverse_rotation_direction?-1:1)).multiply(new j.Matrix4().makeTranslation(0,a.d/1e3,0)).multiply(new j.Matrix4().makeTranslation(a.a/1e3,0,0)).multiply(new j.Matrix4().makeRotationX(a.alpha));return o.multiply(m),o.decompose(c,l,h),{a:p,b:c}}function s(a,x,c,l){if(!n)return;const h=n[a];if(!h)return;const{a:p,b:m}=u(h,l);x.geometry.setPositions([p.toArray(),m.toArray()].flat()),c.position.set(m.x,m.y,m.z)}function y(a,x){o.identity();for(let c=0;c<Math.min(a.length,x.length);c++){const l=i.current[c],h=f.current[c];l&&h&&s(c,l,h,x[c])}}return t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:n,onRotationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]}),n==null?void 0:n.map((a,x)=>{const{a:c,b:l}=u(a,e.joint_position[x]??0),h=`dhrobot_J0${x}`;return t.jsxs("group",{name:h,children:[t.jsx(M.Line,{ref:p=>{i.current[x]=p},name:Te,points:[c,l],color:"white",lineWidth:5}),t.jsxs("mesh",{ref:p=>{f.current[x]=p},name:Le,position:l,children:[t.jsx("sphereGeometry",{args:[.01,32,32]}),t.jsx("meshStandardMaterial",{color:"black",depthTest:!0})]},`mesh_${x}`)]},h)})]})})}const Ge=console.warn;function ne(){return d.useEffect(()=>{console.warn=e=>{e!=="Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"&&Ge(e)}},[]),null}function Ce(e){return e.type==="Mesh"}function Ee({url:e,flangeRef:n,postModelRender:r,...o}){const i=M.useGLTF(e),u=Se(i,"robot.glb").gltf,s=d.useCallback(a=>{a&&r&&r()},[r]);function y(a){try{return Ce(a)?a.geometry?t.jsx("mesh",{name:a.name,geometry:a.geometry,material:a.material,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation},a.uuid):t.jsx("group",{name:a.name,position:a.position,rotation:a.rotation,ref:ee(a)?n:void 0,children:a.children.map(y)},a.uuid)}catch(x){return console.warn("Error rendering node",a.name,x),null}}return t.jsx("group",{...o,dispose:null,ref:s,children:y(u.scene)})}function se({modelURL:e,flangeRef:n,postModelRender:r,...o}){const[i,f]=d.useState(null);return d.useEffect(()=>{let u=!1;return(async()=>{try{const y=typeof e=="string"?e:await e;u||f(a=>a===y?a:y)}catch(y){console.error("Failed to resolve model URL:",y)}})(),()=>{u=!0}},[e]),i?t.jsx(Ee,{url:i,flangeRef:n,postModelRender:r,...o}):null}const oe=(e,n)=>{e.userData.isGhost||(e.traverse(r=>{if(r instanceof b.Mesh){r.material instanceof b.Material&&(r.material.colorWrite=!1);const o=r.clone(),i=r.clone();o.material=new b.MeshStandardMaterial({depthTest:!0,depthWrite:!0,colorWrite:!1,polygonOffset:!0,polygonOffsetFactor:-1,side:b.DoubleSide}),o.userData.isGhost=!0,i.material=new b.MeshStandardMaterial({color:n,opacity:.3,depthTest:!0,depthWrite:!1,transparent:!0,polygonOffset:!0,polygonOffsetFactor:-2,side:b.DoubleSide}),i.userData.isGhost=!0,r.parent&&(r.parent.add(o),r.parent.add(i))}}),e.userData.isGhost=!0)},ie=e=>{if(!e.userData.isGhost)return;const n=[];e.traverse(r=>{var o;r instanceof b.Mesh&&((o=r.userData)!=null&&o.isGhost?n.push(r):r.material instanceof b.Material&&(r.material.colorWrite=!0))}),n.forEach(r=>{r.parent&&r.parent.remove(r)}),e.userData.isGhost=!1},q=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=G,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,x]=d.useState(null),c=d.useCallback(p=>{x(p)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=d.useMemo(()=>{const p=o(n,s);if(!p){const m=new Blob([],{type:"model/gltf-binary"}),g=new File([m],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(g))}return p},[n,s,o]),h=t.jsx(ke,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:h,onError:p=>{console.warn(p)},children:[t.jsx(d.Suspense,{fallback:h,children:t.jsx("group",{ref:c,children:t.jsx(re,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:l,postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function ae({connectedMotionGroup:e,getModel:n=G,flangeRef:r,transparentColor:o,postModelRender:i,...f}){return e.dhParameters?t.jsx(q,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:e.modelFromController||"",dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):null}const Ae=S.externalizeComponent(me.observer(({robotName:e,programState:n,safetyState:r,operationMode:o,driveToHomeEnabled:i=!1,onDriveToHomePress:f,onDriveToHomeRelease:u,connectedMotionGroup:s,robotComponent:y=ae,customContentComponent:a,className:x})=>{var W;const c=pe.useTheme(),{t:l}=xe.useTranslation(),[h,p]=d.useState(!1),m=d.useRef(null),g=d.useRef(null),[w,k]=d.useState(!1),[C,fe]=d.useState({width:400,height:600}),[Ve,de]=d.useState(0);d.useEffect(()=>{const I=()=>{if(g.current){const{offsetWidth:$,offsetHeight:H}=g.current;k($>H),fe({width:$,height:H})}};I();const N=new ResizeObserver(I);return g.current&&N.observe(g.current),()=>{N.disconnect()}},[]);const J=d.useCallback(()=>{de(I=>I+1)},[]),E=d.useCallback(()=>{!i||!f||(p(!0),f())},[i,f]),A=d.useCallback(()=>{!i||!u||(p(!1),u())},[i,u]),B=d.useCallback(()=>{h&&u&&(p(!1),u())},[h,u]),_=w?C.width<350:C.height<200,F=w?C.height<310:C.height<450;return t.jsx(he,{ref:g,className:x,sx:{width:"100%",height:"100%",display:"flex",flexDirection:w?"row":"column",position:"relative",overflow:"hidden",minWidth:{xs:180,sm:220,md:250},minHeight:w?{xs:200,sm:240,md:260}:{xs:150,sm:180,md:220},border:`1px solid ${c.palette.divider}`,borderRadius:"18px",boxShadow:"none",backgroundColor:((W=c.palette.backgroundPaperElevation)==null?void 0:W[8])||"#2A2A3F",backgroundImage:"none"},children:w?t.jsxs(t.Fragment,{children:[t.jsx(v,{sx:{flex:"0 0 50%",position:"relative",height:"100%",minHeight:"100%",maxHeight:"100%",borderRadius:1,m:{xs:1.5,sm:2,md:3},mr:{xs:.75,sm:1,md:1.5},overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute",top:0,left:0},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(V,{}),t.jsx(M.Bounds,{fit:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{sx:{flex:"1",display:"flex",flexDirection:"column",justifyContent:"flex-start",width:_?"100%":"50%"},children:[t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pb:{xs:1,sm:1.5,md:2},textAlign:"left"},children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsxs(v,{sx:{p:{xs:1.5,sm:2,md:3},pt:0,flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[!F&&a&&t.jsxs(v,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{mt:!F&&a?"auto":0},children:t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:{xs:1,sm:1.5,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:m,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:E,onMouseUp:A,onMouseLeave:B,onTouchStart:E,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})})]})]})]}):t.jsx(t.Fragment,{children:t.jsxs(v,{sx:{p:3,height:"100%",display:"flex",flexDirection:"column"},children:[t.jsxs(v,{children:[t.jsx(X,{variant:"h6",component:"h2",sx:{mb:1},children:e}),t.jsx(L.ProgramStateIndicator,{programState:n,safetyState:r,operationMode:o})]}),t.jsx(v,{sx:{flex:_?0:1,position:"relative",minHeight:_?0:{xs:120,sm:150,md:200},height:_?0:"auto",borderRadius:1,overflow:"hidden",display:_?"none":"block"},children:!_&&t.jsxs(T.Canvas,{orthographic:!0,camera:{position:[3,2,3],zoom:1},shadows:!0,frameloop:"demand",style:{borderRadius:c.shape.borderRadius,width:"100%",height:"100%",background:"transparent",position:"absolute"},dpr:[1,2],gl:{alpha:!0,antialias:!0},children:[t.jsx(V,{}),t.jsx(M.Bounds,{fit:!0,clip:!0,observe:!0,margin:1,maxDuration:1,children:t.jsx(y,{connectedMotionGroup:s,postModelRender:J})})]})}),t.jsxs(v,{children:[!F&&a&&t.jsxs(t.Fragment,{children:[t.jsx(a,{}),t.jsx(Q,{sx:{mt:1,mb:0,borderColor:c.palette.divider,opacity:.5}})]}),t.jsx(v,{sx:{display:"flex",justifyContent:"flex-start",mt:!F&&a?{xs:1,sm:2,md:5}:{xs:.5,sm:1,md:2},mb:{xs:.5,sm:.75,md:1}},children:t.jsx(Y,{ref:m,variant:"contained",color:"secondary",size:"small",disabled:!i,onMouseDown:E,onMouseUp:A,onMouseLeave:B,onTouchStart:E,onTouchEnd:A,sx:{textTransform:"none",px:1.5,py:.5},children:l("RobotCard.DriveToHome.bt")})})]})]})})})})),Fe=Array(6).fill(2*Math.PI);function ce({rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:r,children:o}){const i=d.useRef([]),f=d.useRef([]),u=d.useRef(null),{invalidate:s}=T.useThree();d.useEffect(()=>{const c=e.joint_position.filter(l=>l!==void 0);return u.current=new L.ValueInterpolator(c,{tension:120,friction:20,threshold:.001}),()=>{var l;(l=u.current)==null||l.destroy()}},[]),T.useFrame((c,l)=>{if(u.current){const h=u.current.update(l);a(),h||s()}});function y(c){c&&(f.current=z(c),a(),s())}function a(){var l;const c=((l=u.current)==null?void 0:l.getCurrentValues())||[];if(r)r(f.current,c);else for(const[h,p]of f.current.entries()){const g=n[h].reverse_rotation_direction?-1:1;p.position.y=g*(c[h]||0)/1e3}}const x=d.useCallback(()=>{const c=e.joint_position.filter(l=>l!==void 0);requestAnimationFrame(()=>{var l;i.current=c,(l=u.current)==null||l.setTarget(c)})},[e]);return d.useEffect(()=>{x()},[e,x]),L.useAutorun(()=>{x()}),t.jsx("group",{ref:y,children:o})}function ue({rapidlyChangingMotionState:e,dhParameters:n,...r}){const o=new j.Matrix4,i=d.useRef(null),f=d.useRef(null);function u(a){const x=new j.Matrix4;for(let p=0;p<n.length;p++){const m=n[p],g=a[p]??0,w=new j.Matrix4().makeRotationY(m.theta).multiply(new j.Matrix4().makeTranslation(m.a/1e3,(m.d+g*(m.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new j.Matrix4().makeRotationX(m.alpha));x.multiply(w)}const c=new j.Vector3,l=new j.Quaternion,h=new j.Vector3;return x.decompose(c,l,h),c}const s=u(e.joint_position);function y(a,x){o.identity();let c=new j.Vector3;for(let m=0;m<n.length;m++){const g=x[m]??0,w=n[m],k=new j.Matrix4().makeRotationY(w.theta).multiply(new j.Matrix4().makeTranslation(w.a/1e3,(w.d+g*(w.reverse_rotation_direction?-1:1))/1e3,0)).multiply(new j.Matrix4().makeRotationX(w.alpha));o.multiply(k)}const l=new j.Vector3,h=new j.Quaternion,p=new j.Vector3;if(o.decompose(l,h,p),c=l,i.current&&i.current.position.set(c.x,c.y,c.z),f.current){const m=f.current.geometry;m!=null&&m.setPositions&&m.setPositions([0,0,0,c.x,c.y,c.z])}}return t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:n,onTranslationChanged:y,children:t.jsxs("group",{...r,name:"Scene",children:[t.jsxs("mesh",{name:"Base",position:[0,0,0],children:[t.jsx("sphereGeometry",{args:[.02,32,32]}),t.jsx("meshStandardMaterial",{color:"green",depthTest:!0})]}),t.jsx(M.Line,{ref:f,points:[new j.Vector3(0,0,0),s],color:"White",lineWidth:5}),t.jsxs("mesh",{ref:i,name:"TCP",position:s,children:[t.jsx("sphereGeometry",{args:[.025,32,32]}),t.jsx("meshStandardMaterial",{color:"red",depthTest:!0})]})]})})}const U=S.externalizeComponent(({rapidlyChangingMotionState:e,modelFromController:n,dhParameters:r,getModel:o=G,flangeRef:i,postModelRender:f,transparentColor:u,instanceUrl:s,...y})=>{const[a,x]=d.useState(null),c=d.useCallback(h=>{x(h)},[]);d.useEffect(()=>{a&&(u?oe(a,u):ie(a))},[a,u]);const l=t.jsx(ue,{rapidlyChangingMotionState:e,dhParameters:r,...y});return t.jsxs(K.ErrorBoundary,{fallback:l,onError:h=>{console.warn(h)},children:[t.jsx(d.Suspense,{fallback:l,children:t.jsx("group",{ref:c,children:t.jsx(ce,{rapidlyChangingMotionState:e,dhParameters:r,children:t.jsx(se,{modelURL:(()=>{const h=o(n,s);if(!h){const p=new Blob([],{type:"model/gltf-binary"}),m=new File([p],`${n}.glb`,{type:"model/gltf-binary"});return Promise.resolve(URL.createObjectURL(m))}return h})(),postModelRender:f,flangeRef:i,...y})})})}),t.jsx(ne,{})]})});function Ie({connectedMotionGroup:e,getModel:n=G,flangeRef:r,transparentColor:o,postModelRender:i,...f}){if(!e.dhParameters)return null;const u=e.modelFromController||"";return u&&n(u)?t.jsx(U,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,modelFromController:u,dhParameters:e.dhParameters,getModel:n,flangeRef:r,transparentColor:o,postModelRender:i,...f}):t.jsx(ue,{rapidlyChangingMotionState:e.rapidlyChangingMotionState,dhParameters:e.dhParameters,...f})}const D={[R.Manufacturer.Abb]:[0,0,0,0,Math.PI/2,0,0],[R.Manufacturer.Fanuc]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Yaskawa]:[0,0,0,0,-Math.PI/2,0,0],[R.Manufacturer.Kuka]:[0,-Math.PI/2,Math.PI/2,0,Math.PI/2,0,0],[R.Manufacturer.Universalrobots]:[0,-Math.PI/2,-Math.PI/2,-Math.PI/2,Math.PI/2,-Math.PI/2,0]};function le(e){const[n]=e.split("_");switch(n){case"ABB":return R.Manufacturer.Abb;case"FANUC":return R.Manufacturer.Fanuc;case"YASKAWA":return R.Manufacturer.Yaskawa;case"KUKA":return R.Manufacturer.Kuka;case"UniversalRobots":return R.Manufacturer.Universalrobots;default:return null}}function Pe(e,n){const r=le(e);return r&&r in D?D[r]:n||null}const Oe=S.externalizeComponent(e=>{const{inverseSolver:n,dhParameters:r,...o}=e,[i,f]=d.useState(R.JointTypeEnum.RevoluteJoint);d.useEffect(()=>{r.length&&f(r[0].type??R.JointTypeEnum.RevoluteJoint)},[r]);const u=d.useMemo(()=>n===null&&i===R.JointTypeEnum.RevoluteJoint,[n,i]),s=d.useMemo(()=>n===null&&i===R.JointTypeEnum.PrismaticJoint,[n,i]);return d.useMemo(()=>!!n,[n])||u?t.jsx(q,{dhParameters:r,...o}):s?t.jsx(U,{dhParameters:r,...o}):null});exports.CollisionSceneRenderer=we;exports.LinearAxis=Ie;exports.MANUFACTURER_HOME_CONFIGS=D;exports.MotionGroupVisualizer=Oe;exports.PresetEnvironment=V;exports.Robot=ae;exports.RobotCard=Ae;exports.SafetyZonesRenderer=ve;exports.SupportedLinearAxis=U;exports.SupportedRobot=q;exports.TrajectoryRenderer=_e;exports.defaultAxisConfig=Fe;exports.defaultGetModel=G;exports.extractManufacturer=le;exports.getDefaultHomeConfig=Pe;
|