@wandelbots/wandelbots-js-react-components 6.3.0 → 6.4.0-pr.ci-release-guard.668.ec1f74f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +185 -124
- package/dist/3d.cjs +1 -1
- package/dist/3d.d.ts +0 -3
- package/dist/3d.js +16 -21
- package/dist/SafetyBar/index.cjs +1 -1
- package/dist/SafetyBar/index.js +1 -1
- package/dist/chunks/ConnectedMotionGroup-BewSDQvD.cjs +4 -0
- package/dist/chunks/ConnectedMotionGroup-D6-4wBkk.js +2654 -0
- package/dist/chunks/Robot-C0uICTOn.js +1271 -0
- package/dist/chunks/Robot-D6RUDXEz.cjs +1 -0
- package/dist/chunks/{SafetyBar-Cy9DiXp9.js → SafetyBar-C2-H1ifP.js} +1 -1
- package/dist/chunks/{SafetyBar-DPrv_OQA.cjs → SafetyBar-Cq_WsuK2.cjs} +1 -1
- package/dist/chunks/externalizeComponent-Bue3-Wra.cjs +2 -0
- package/dist/chunks/{externalizeComponent-EDymnaGR.js → externalizeComponent-C0cVcPE2.js} +29 -107
- package/dist/chunks/useSmoothedMotionState-COMJRcOt.js +214 -0
- package/dist/chunks/useSmoothedMotionState-Con0E5Bx.cjs +1 -0
- package/dist/components/AppHeader.d.ts +1 -1
- package/dist/components/jogging/JoggingCartesianAxisControl.d.ts +1 -1
- package/dist/components/jogging/JoggingJointTab.d.ts +1 -1
- package/dist/components/jogging/JoggingPanel.d.ts +6 -3
- package/dist/components/jogging/JoggingStore.d.ts +5 -1
- package/dist/components/jogging/joggingColors.d.ts +18 -0
- package/dist/components/robots/GenericRobot.d.ts +2 -1
- package/dist/components/robots/LinearAxis.d.ts +1 -1
- package/dist/components/robots/LinearAxisAnimator.d.ts +11 -2
- package/dist/components/robots/Robot.d.ts +1 -1
- package/dist/components/robots/robotModelLogic.d.ts +11 -9
- package/dist/components/utils/hooks.d.ts +1 -6
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +3 -18
- package/dist/core.js +27 -54
- package/dist/index.cjs +1 -1
- package/dist/index.js +39 -71
- package/dist/lib/ConnectedMotionGroup.d.ts +5 -7
- package/dist/lib/JoggerConnection.d.ts +29 -5
- package/dist/lib/MotionStreamConnection.d.ts +4 -6
- package/dist/lib/novaConnection.d.ts +23 -0
- package/package.json +32 -66
- package/dist/Setup.d.ts +0 -11
- package/dist/chunks/MotionGroupVisualizer-DshWR1wY.js +0 -1653
- package/dist/chunks/MotionGroupVisualizer-eD7yFEcF.cjs +0 -1
- package/dist/chunks/externalizeComponent-OO4jcrz5.cjs +0 -2
- package/dist/chunks/theming-DfSy4-Ic.cjs +0 -4
- package/dist/chunks/theming-mF9Rt8SS.js +0 -5542
- package/dist/chunks/useSmoothedMotionState-DyDgSVYX.js +0 -478
- package/dist/chunks/useSmoothedMotionState-VYxEIyfr.cjs +0 -1
- package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +0 -11
- package/dist/components/AdornedTextField.d.ts +0 -7
- package/dist/components/CopyableText.d.ts +0 -6
- package/dist/components/CycleTimer/CycleTimer.d.ts +0 -3
- package/dist/components/CycleTimer/DefaultVariant.d.ts +0 -9
- package/dist/components/CycleTimer/SmallVariant.d.ts +0 -10
- package/dist/components/CycleTimer/index.d.ts +0 -27
- package/dist/components/CycleTimer/types.d.ts +0 -49
- package/dist/components/CycleTimer/useAnimations.d.ts +0 -14
- package/dist/components/CycleTimer/useTimerLogic.d.ts +0 -24
- package/dist/components/CycleTimer/utils.d.ts +0 -21
- package/dist/components/CycleTimer.d.ts +0 -3
- package/dist/components/DataGrid.d.ts +0 -66
- package/dist/components/LogPanel.d.ts +0 -38
- package/dist/components/LogStore.d.ts +0 -12
- package/dist/components/LogViewer.d.ts +0 -46
- package/dist/components/ProgramControl.d.ts +0 -55
- package/dist/components/ProgramStateIndicator.d.ts +0 -26
- package/dist/components/RobotCard.d.ts +0 -98
- package/dist/components/RobotListItem.d.ts +0 -34
- package/dist/components/RobotSetupReadinessIndicator.d.ts +0 -37
- package/dist/components/SelectableFab.d.ts +0 -7
- package/dist/components/TabBar.d.ts +0 -45
- package/dist/components/ThemeSelect.d.ts +0 -6
- package/dist/components/Timer/Timer.d.ts +0 -3
- package/dist/components/Timer/TimerDefaultVariant.d.ts +0 -9
- package/dist/components/Timer/TimerSmallVariant.d.ts +0 -10
- package/dist/components/Timer/index.d.ts +0 -19
- package/dist/components/Timer/types.d.ts +0 -35
- package/dist/components/Timer/useTimerAnimations.d.ts +0 -10
- package/dist/components/Timer/useTimerLogic.d.ts +0 -19
- package/dist/components/Timer/utils.d.ts +0 -17
- package/dist/components/Timer.d.ts +0 -3
- package/dist/components/TransparentOverlay.d.ts +0 -4
- package/dist/components/jogging/JoggingFreedriveTab.d.ts +0 -1
- package/dist/components/jogging/PoseCartesianValues.d.ts +0 -9
- package/dist/components/jogging/PoseJointValues.d.ts +0 -8
- package/dist/components/robots/AxisConfig.d.ts +0 -2
- package/dist/components/robots/manufacturerHomePositions.d.ts +0 -20
- package/dist/icons/DropdownArrowIcon.d.ts +0 -2
- package/dist/icons/index.d.ts +0 -12
- package/dist/lib/novaCompat.d.ts +0 -16
- package/dist/themes/createDarkTheme.d.ts +0 -7
- package/dist/themes/themeTypes.d.ts +0 -40
- package/dist/themes/theming.d.ts +0 -24
|
@@ -0,0 +1,1271 @@
|
|
|
1
|
+
import { jsx as s, jsxs as T, Fragment as ft } from "react/jsx-runtime";
|
|
2
|
+
import * as R from "three";
|
|
3
|
+
import { Matrix4 as b, Vector3 as x, Quaternion as k } from "three";
|
|
4
|
+
import { ConvexGeometry as H, RoundedBoxGeometry as mt } from "three-stdlib";
|
|
5
|
+
import { Line as V, Environment as ht, Lightformer as G, useGLTF as dt } from "@react-three/drei";
|
|
6
|
+
import gt, { useMemo as L, forwardRef as Q, useRef as S, useImperativeHandle as B, useEffect as P, useState as C, useCallback as A, Suspense as X } from "react";
|
|
7
|
+
import { d as yt, v as wt, o as Rt, e as E } from "./externalizeComponent-C0cVcPE2.js";
|
|
8
|
+
import { JointTypeEnum as I } from "@wandelbots/nova-js/v2";
|
|
9
|
+
import { c as _t, b as Y, a as j } from "./useSmoothedMotionState-COMJRcOt.js";
|
|
10
|
+
import { ErrorBoundary as Z } from "react-error-boundary";
|
|
11
|
+
import { useThree as K } from "@react-three/fiber";
|
|
12
|
+
function bt(t) {
|
|
13
|
+
switch (t.shape_type) {
|
|
14
|
+
case "convex_hull":
|
|
15
|
+
return new H(
|
|
16
|
+
t.vertices.map(
|
|
17
|
+
(e) => new R.Vector3(
|
|
18
|
+
e[0] / 1e3,
|
|
19
|
+
e[1] / 1e3,
|
|
20
|
+
e[2] / 1e3
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
case "box":
|
|
25
|
+
return new R.BoxGeometry(
|
|
26
|
+
t.size_x / 1e3,
|
|
27
|
+
t.size_y / 1e3,
|
|
28
|
+
t.size_z / 1e3
|
|
29
|
+
);
|
|
30
|
+
case "sphere":
|
|
31
|
+
return new R.SphereGeometry(t.radius / 1e3);
|
|
32
|
+
case "capsule":
|
|
33
|
+
return new R.CapsuleGeometry(
|
|
34
|
+
t.radius / 1e3,
|
|
35
|
+
t.cylinder_height / 1e3
|
|
36
|
+
);
|
|
37
|
+
case "cylinder":
|
|
38
|
+
return new R.CylinderGeometry(
|
|
39
|
+
t.radius / 1e3,
|
|
40
|
+
t.radius / 1e3,
|
|
41
|
+
t.height / 1e3
|
|
42
|
+
);
|
|
43
|
+
case "rectangle":
|
|
44
|
+
return new R.BoxGeometry(t.size_x / 1e3, t.size_y / 1e3, 0);
|
|
45
|
+
default:
|
|
46
|
+
return console.warn(`${t.shape_type} is not supported`), new R.BufferGeometry();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function vt({
|
|
50
|
+
name: t,
|
|
51
|
+
collider: n,
|
|
52
|
+
children: e
|
|
53
|
+
}) {
|
|
54
|
+
var c, l;
|
|
55
|
+
const o = ((c = n.pose) == null ? void 0 : c.position) ?? [0, 0, 0], r = ((l = n.pose) == null ? void 0 : l.orientation) ?? [0, 0, 0];
|
|
56
|
+
return n.margin && console.warn(`${t} margin is not supported`), /* @__PURE__ */ s(
|
|
57
|
+
"mesh",
|
|
58
|
+
{
|
|
59
|
+
name: t,
|
|
60
|
+
position: new R.Vector3(
|
|
61
|
+
o[0],
|
|
62
|
+
o[1],
|
|
63
|
+
o[2]
|
|
64
|
+
).divideScalar(1e3),
|
|
65
|
+
rotation: new R.Euler(r[0], r[1], r[2], "XYZ"),
|
|
66
|
+
geometry: bt(n.shape),
|
|
67
|
+
children: e
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
function St({
|
|
72
|
+
name: t,
|
|
73
|
+
colliders: n,
|
|
74
|
+
meshChildrenProvider: e,
|
|
75
|
+
...o
|
|
76
|
+
}) {
|
|
77
|
+
return /* @__PURE__ */ s("group", { name: t, ...o, children: Object.entries(n).map(([r, c]) => /* @__PURE__ */ s(
|
|
78
|
+
vt,
|
|
79
|
+
{
|
|
80
|
+
name: r,
|
|
81
|
+
collider: c,
|
|
82
|
+
children: e(r, c)
|
|
83
|
+
},
|
|
84
|
+
r
|
|
85
|
+
)) });
|
|
86
|
+
}
|
|
87
|
+
function ie({
|
|
88
|
+
scene: t,
|
|
89
|
+
meshChildrenProvider: n
|
|
90
|
+
}) {
|
|
91
|
+
const e = t.colliders;
|
|
92
|
+
return /* @__PURE__ */ s("group", { children: e && /* @__PURE__ */ s(
|
|
93
|
+
St,
|
|
94
|
+
{
|
|
95
|
+
meshChildrenProvider: n,
|
|
96
|
+
colliders: e
|
|
97
|
+
}
|
|
98
|
+
) });
|
|
99
|
+
}
|
|
100
|
+
function Tt(t) {
|
|
101
|
+
const n = (t == null ? void 0 : t.position) ?? [], e = (t == null ? void 0 : t.orientation) ?? [], o = new x(
|
|
102
|
+
e[0] ?? 0,
|
|
103
|
+
e[1] ?? 0,
|
|
104
|
+
e[2] ?? 0
|
|
105
|
+
), r = o.length(), c = r > 0 ? new k().setFromAxisAngle(o.normalize(), r) : new k();
|
|
106
|
+
return new b().compose(
|
|
107
|
+
new x(
|
|
108
|
+
n[0] ?? 0,
|
|
109
|
+
n[1] ?? 0,
|
|
110
|
+
n[2] ?? 0
|
|
111
|
+
).divideScalar(1e3),
|
|
112
|
+
c,
|
|
113
|
+
new x(1, 1, 1)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
function Mt(t, n = null, e = []) {
|
|
117
|
+
const o = Tt(n);
|
|
118
|
+
return t.map((r, c) => {
|
|
119
|
+
const l = o.clone(), i = (r.reverse_rotation_direction ? -1 : 1) * (e[c] ?? 0), a = r.type === "PRISMATIC_JOINT", p = (r.theta ?? 0) + (a ? 0 : i), f = (r.d ?? 0) + (a ? i : 0);
|
|
120
|
+
return o.multiply(new b().makeRotationZ(p)).multiply(
|
|
121
|
+
new b().makeTranslation((r.a ?? 0) / 1e3, 0, f / 1e3)
|
|
122
|
+
).multiply(new b().makeRotationX(r.alpha ?? 0)), l;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const N = "#ff4b4b", U = "#2fa8ff", xt = "#8a8d9e", Lt = 96, Ot = 0.15, Gt = new R.Vector3(0, 1, 0), Pt = 0.2, At = 2;
|
|
126
|
+
function Et(t) {
|
|
127
|
+
const { lower_limit: n, upper_limit: e } = t ?? {};
|
|
128
|
+
return typeof n != "number" || typeof e != "number" || !Number.isFinite(n) || !Number.isFinite(e) || !(n < e) ? null : { lower_limit: n, upper_limit: e };
|
|
129
|
+
}
|
|
130
|
+
function D({
|
|
131
|
+
base: t,
|
|
132
|
+
direction: n,
|
|
133
|
+
size: e,
|
|
134
|
+
color: o,
|
|
135
|
+
opacity: r
|
|
136
|
+
}) {
|
|
137
|
+
const c = new R.Quaternion().setFromUnitVectors(
|
|
138
|
+
Gt,
|
|
139
|
+
n.clone().normalize()
|
|
140
|
+
), l = t.clone().addScaledVector(n.clone().normalize(), e / 2);
|
|
141
|
+
return /* @__PURE__ */ T("mesh", { position: l, quaternion: c, renderOrder: 10, children: [
|
|
142
|
+
/* @__PURE__ */ s("coneGeometry", { args: [e * 0.35, e, 16] }),
|
|
143
|
+
/* @__PURE__ */ s(
|
|
144
|
+
"meshBasicMaterial",
|
|
145
|
+
{
|
|
146
|
+
color: o,
|
|
147
|
+
depthTest: !1,
|
|
148
|
+
transparent: !0,
|
|
149
|
+
opacity: r
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
154
|
+
function $({
|
|
155
|
+
points: t,
|
|
156
|
+
color: n,
|
|
157
|
+
width: e,
|
|
158
|
+
opacity: o
|
|
159
|
+
}) {
|
|
160
|
+
return /* @__PURE__ */ s(
|
|
161
|
+
V,
|
|
162
|
+
{
|
|
163
|
+
points: t,
|
|
164
|
+
color: n,
|
|
165
|
+
lineWidth: e,
|
|
166
|
+
depthTest: !1,
|
|
167
|
+
transparent: !0,
|
|
168
|
+
opacity: o,
|
|
169
|
+
renderOrder: 10
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
function W(t, n) {
|
|
174
|
+
const e = [...t];
|
|
175
|
+
let o = n;
|
|
176
|
+
for (; e.length > 1; ) {
|
|
177
|
+
const r = e[e.length - 1], c = e[e.length - 2], l = r.distanceTo(c);
|
|
178
|
+
if (l > o)
|
|
179
|
+
return e[e.length - 1] = r.clone().lerp(c, o / l), e;
|
|
180
|
+
o -= l, e.pop();
|
|
181
|
+
}
|
|
182
|
+
return e;
|
|
183
|
+
}
|
|
184
|
+
function kt(t, n, e, o) {
|
|
185
|
+
const r = e * t, c = e * n, l = Math.abs(c - r), i = Math.max(
|
|
186
|
+
2,
|
|
187
|
+
Math.ceil(l / (2 * Math.PI) * Lt)
|
|
188
|
+
);
|
|
189
|
+
return Array.from({ length: i + 1 }, (a, p) => {
|
|
190
|
+
const f = r + (c - r) * p / i, u = l * p / i / (2 * Math.PI), y = o * (1 + Ot * u);
|
|
191
|
+
return new R.Vector3(
|
|
192
|
+
Math.cos(f) * y,
|
|
193
|
+
Math.sin(f) * y,
|
|
194
|
+
0
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function It(t, n, e, o) {
|
|
199
|
+
const r = t.theta ?? 0, c = t.d ?? 0, l = t.type === "PRISMATIC_JOINT", i = t.reverse_rotation_direction ? -1 : 1, { lower_limit: a, upper_limit: p } = n;
|
|
200
|
+
return L(() => {
|
|
201
|
+
const f = new R.Matrix4().makeRotationZ(r).multiply(
|
|
202
|
+
new R.Matrix4().makeTranslation(0, 0, l ? c / 1e3 : 0)
|
|
203
|
+
), u = (v, M, O) => new R.Vector3(v, M, O).applyMatrix4(f), y = new R.Vector3().applyMatrix4(f), w = u(0, 0, e), h = (l ? [
|
|
204
|
+
u(e * 0.25, 0, i * a / 1e3),
|
|
205
|
+
u(e * 0.25, 0, i * p / 1e3)
|
|
206
|
+
] : kt(a, p, i, e * 0.6)).map((v) => l ? v : v.applyMatrix4(f)), m = u(l ? e * 0.25 : e * 0.6, 0, 0), _ = h.slice(1).reduce((v, M, O) => v + M.distanceTo(h[O]), 0), d = Math.min(o, _ / 3), g = W(
|
|
207
|
+
W(h, d).reverse(),
|
|
208
|
+
d
|
|
209
|
+
).reverse();
|
|
210
|
+
return {
|
|
211
|
+
axisPoints: [y, w],
|
|
212
|
+
axisTip: w,
|
|
213
|
+
origin: y,
|
|
214
|
+
restPoints: [y, m],
|
|
215
|
+
range: h,
|
|
216
|
+
limitPoints: g,
|
|
217
|
+
rangeStart: g[0],
|
|
218
|
+
rangeEnd: g[g.length - 1]
|
|
219
|
+
};
|
|
220
|
+
}, [r, c, l, i, e, a, p, o]);
|
|
221
|
+
}
|
|
222
|
+
function Ft({
|
|
223
|
+
frame: t,
|
|
224
|
+
dh: n,
|
|
225
|
+
limit: e,
|
|
226
|
+
size: o,
|
|
227
|
+
emphasis: r
|
|
228
|
+
}) {
|
|
229
|
+
const c = r === "highlighted" ? At : 1, l = r === "dimmed" ? Pt : 1, i = o * 0.2 * (r === "highlighted" ? 1.4 : 1), a = 2 * c, {
|
|
230
|
+
axisPoints: p,
|
|
231
|
+
axisTip: f,
|
|
232
|
+
origin: u,
|
|
233
|
+
restPoints: y,
|
|
234
|
+
range: w,
|
|
235
|
+
limitPoints: h,
|
|
236
|
+
rangeStart: m,
|
|
237
|
+
rangeEnd: _
|
|
238
|
+
} = It(n, e, o, i), { position: d, quaternion: g } = L(() => {
|
|
239
|
+
const v = new R.Vector3(), M = new R.Quaternion();
|
|
240
|
+
return t.decompose(v, M, new R.Vector3()), { position: v, quaternion: M };
|
|
241
|
+
}, [t]);
|
|
242
|
+
return /* @__PURE__ */ T("group", { position: d, quaternion: g, children: [
|
|
243
|
+
/* @__PURE__ */ s(
|
|
244
|
+
$,
|
|
245
|
+
{
|
|
246
|
+
points: p,
|
|
247
|
+
color: U,
|
|
248
|
+
width: a,
|
|
249
|
+
opacity: l
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
/* @__PURE__ */ s(
|
|
253
|
+
D,
|
|
254
|
+
{
|
|
255
|
+
base: f,
|
|
256
|
+
direction: f.clone().sub(u),
|
|
257
|
+
size: i,
|
|
258
|
+
color: U,
|
|
259
|
+
opacity: l
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
/* @__PURE__ */ s(
|
|
263
|
+
$,
|
|
264
|
+
{
|
|
265
|
+
points: y,
|
|
266
|
+
color: xt,
|
|
267
|
+
width: 1.5 * c,
|
|
268
|
+
opacity: l
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
/* @__PURE__ */ s(
|
|
272
|
+
$,
|
|
273
|
+
{
|
|
274
|
+
points: h,
|
|
275
|
+
color: N,
|
|
276
|
+
width: a,
|
|
277
|
+
opacity: l
|
|
278
|
+
}
|
|
279
|
+
),
|
|
280
|
+
/* @__PURE__ */ s(
|
|
281
|
+
D,
|
|
282
|
+
{
|
|
283
|
+
base: m,
|
|
284
|
+
direction: w[0].clone().sub(m),
|
|
285
|
+
size: m.distanceTo(w[0]),
|
|
286
|
+
color: N,
|
|
287
|
+
opacity: l
|
|
288
|
+
}
|
|
289
|
+
),
|
|
290
|
+
/* @__PURE__ */ s(
|
|
291
|
+
D,
|
|
292
|
+
{
|
|
293
|
+
base: _,
|
|
294
|
+
direction: w[w.length - 1].clone().sub(_),
|
|
295
|
+
size: _.distanceTo(w[w.length - 1]),
|
|
296
|
+
color: N,
|
|
297
|
+
opacity: l
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
] });
|
|
301
|
+
}
|
|
302
|
+
function se({
|
|
303
|
+
dhParameters: t,
|
|
304
|
+
chainOffset: n = null,
|
|
305
|
+
limits: e,
|
|
306
|
+
jointPositions: o,
|
|
307
|
+
size: r = 0.15,
|
|
308
|
+
highlightedJoint: c = null
|
|
309
|
+
}) {
|
|
310
|
+
const l = L(
|
|
311
|
+
() => Mt(t, n, o),
|
|
312
|
+
[t, n, o]
|
|
313
|
+
);
|
|
314
|
+
return /* @__PURE__ */ s("group", { children: l.map((i, a) => {
|
|
315
|
+
const p = Et(e[a]);
|
|
316
|
+
return p ? /* @__PURE__ */ s(
|
|
317
|
+
Ft,
|
|
318
|
+
{
|
|
319
|
+
frame: i,
|
|
320
|
+
dh: t[a],
|
|
321
|
+
limit: p,
|
|
322
|
+
size: r,
|
|
323
|
+
emphasis: c === null ? "normal" : c === a ? "highlighted" : "dimmed"
|
|
324
|
+
},
|
|
325
|
+
a
|
|
326
|
+
) : null;
|
|
327
|
+
}) });
|
|
328
|
+
}
|
|
329
|
+
function ae() {
|
|
330
|
+
return /* @__PURE__ */ s(ht, { frames: 1, children: /* @__PURE__ */ s(Ct, {}) });
|
|
331
|
+
}
|
|
332
|
+
const Vt = [2, 0, 2, 0, 2, 0, 2, 0];
|
|
333
|
+
function Ct({ positions: t = Vt }) {
|
|
334
|
+
return /* @__PURE__ */ T(ft, { children: [
|
|
335
|
+
/* @__PURE__ */ s(
|
|
336
|
+
G,
|
|
337
|
+
{
|
|
338
|
+
intensity: 5,
|
|
339
|
+
"rotation-x": Math.PI / 2,
|
|
340
|
+
position: [0, 5, -9],
|
|
341
|
+
scale: [10, 10, 1]
|
|
342
|
+
}
|
|
343
|
+
),
|
|
344
|
+
/* @__PURE__ */ s("group", { rotation: [0, 0.5, 0], children: /* @__PURE__ */ s("group", { children: t.map((n, e) => /* @__PURE__ */ s(
|
|
345
|
+
G,
|
|
346
|
+
{
|
|
347
|
+
form: "circle",
|
|
348
|
+
intensity: 5,
|
|
349
|
+
rotation: [Math.PI / 2, 0, 0],
|
|
350
|
+
position: [n, 4, e * 4],
|
|
351
|
+
scale: [3, 1, 1]
|
|
352
|
+
},
|
|
353
|
+
e
|
|
354
|
+
)) }) }),
|
|
355
|
+
/* @__PURE__ */ s(
|
|
356
|
+
G,
|
|
357
|
+
{
|
|
358
|
+
intensity: 40,
|
|
359
|
+
"rotation-y": Math.PI / 2,
|
|
360
|
+
position: [-5, 1, -1],
|
|
361
|
+
scale: [20, 0.1, 1]
|
|
362
|
+
}
|
|
363
|
+
),
|
|
364
|
+
/* @__PURE__ */ s(
|
|
365
|
+
G,
|
|
366
|
+
{
|
|
367
|
+
intensity: 20,
|
|
368
|
+
"rotation-y": -Math.PI,
|
|
369
|
+
position: [-5, -2, -1],
|
|
370
|
+
scale: [20, 0.1, 1]
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ s(
|
|
374
|
+
G,
|
|
375
|
+
{
|
|
376
|
+
"rotation-y": Math.PI / 2,
|
|
377
|
+
position: [-5, -1, -1],
|
|
378
|
+
scale: [20, 0.5, 1],
|
|
379
|
+
intensity: 5
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
/* @__PURE__ */ s(
|
|
383
|
+
G,
|
|
384
|
+
{
|
|
385
|
+
"rotation-y": -Math.PI / 2,
|
|
386
|
+
position: [10, 1, 0],
|
|
387
|
+
scale: [20, 1, 1],
|
|
388
|
+
intensity: 10
|
|
389
|
+
}
|
|
390
|
+
),
|
|
391
|
+
/* @__PURE__ */ s(
|
|
392
|
+
G,
|
|
393
|
+
{
|
|
394
|
+
form: "ring",
|
|
395
|
+
color: "white",
|
|
396
|
+
intensity: 5,
|
|
397
|
+
scale: 10,
|
|
398
|
+
position: [-15, 4, -18],
|
|
399
|
+
target: [0, 0, 0]
|
|
400
|
+
}
|
|
401
|
+
)
|
|
402
|
+
] });
|
|
403
|
+
}
|
|
404
|
+
const q = {
|
|
405
|
+
attach: "material",
|
|
406
|
+
color: "#009f4d",
|
|
407
|
+
opacity: 0.2,
|
|
408
|
+
depthTest: !1,
|
|
409
|
+
depthWrite: !1,
|
|
410
|
+
transparent: !0,
|
|
411
|
+
polygonOffset: !0
|
|
412
|
+
};
|
|
413
|
+
function ce({
|
|
414
|
+
safetyZones: t,
|
|
415
|
+
dhParameters: n,
|
|
416
|
+
...e
|
|
417
|
+
}) {
|
|
418
|
+
const o = L(
|
|
419
|
+
() => yt(n ?? []),
|
|
420
|
+
[n]
|
|
421
|
+
), r = (l, i) => {
|
|
422
|
+
var y, w;
|
|
423
|
+
if (!((y = i == null ? void 0 : i.pose) != null && y.position) || !((w = i == null ? void 0 : i.pose) != null && w.orientation))
|
|
424
|
+
return null;
|
|
425
|
+
const a = new R.Vector3(
|
|
426
|
+
i.pose.position[0] / 1e3,
|
|
427
|
+
i.pose.position[1] / 1e3,
|
|
428
|
+
i.pose.position[2] / 1e3
|
|
429
|
+
), p = new R.Vector3(
|
|
430
|
+
i.pose.orientation[0],
|
|
431
|
+
i.pose.orientation[1],
|
|
432
|
+
i.pose.orientation[2]
|
|
433
|
+
);
|
|
434
|
+
let f;
|
|
435
|
+
const u = i.shape.shape_type === "plane" ? { ...q, side: R.DoubleSide } : { ...q, side: R.FrontSide };
|
|
436
|
+
switch (i.shape.shape_type) {
|
|
437
|
+
/**
|
|
438
|
+
* Plane shape, uses DH parameters to calculate the size of the plane (reach distance of a robot)
|
|
439
|
+
*/
|
|
440
|
+
case "plane":
|
|
441
|
+
f = /* @__PURE__ */ s("planeGeometry", { args: [o, o] });
|
|
442
|
+
break;
|
|
443
|
+
/**
|
|
444
|
+
* Sphere shape
|
|
445
|
+
*/
|
|
446
|
+
case "sphere": {
|
|
447
|
+
const h = (i == null ? void 0 : i.shape).radius / 1e3;
|
|
448
|
+
f = /* @__PURE__ */ s("sphereGeometry", { args: [h] });
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Capsule shape
|
|
453
|
+
*/
|
|
454
|
+
case "capsule": {
|
|
455
|
+
const h = (i == null ? void 0 : i.shape).radius / 1e3, m = (i == null ? void 0 : i.shape).cylinder_height / 1e3;
|
|
456
|
+
f = /* @__PURE__ */ s("capsuleGeometry", { args: [h, m] });
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Convex hull, checks at first if the vertices are coplanar - if yes, adds a small offset for
|
|
461
|
+
* renderer to be able to visualize the convex hull.
|
|
462
|
+
*/
|
|
463
|
+
case "convex_hull": {
|
|
464
|
+
const h = (i == null ? void 0 : i.shape).vertices.map(
|
|
465
|
+
(_) => new R.Vector3(_[0] / 1e3, _[1] / 1e3, _[2] / 1e3)
|
|
466
|
+
), m = wt(h);
|
|
467
|
+
if (m.isCoplanar && m.normal) {
|
|
468
|
+
const d = new R.Vector3().addVectors(
|
|
469
|
+
h[0],
|
|
470
|
+
m.normal.multiplyScalar(1e-4)
|
|
471
|
+
);
|
|
472
|
+
h.push(d);
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
f = /* @__PURE__ */ s(
|
|
476
|
+
"primitive",
|
|
477
|
+
{
|
|
478
|
+
object: new H(h),
|
|
479
|
+
attach: "geometry"
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
} catch (_) {
|
|
483
|
+
return console.log("Error creating ConvexGeometry:", _), null;
|
|
484
|
+
}
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Convex hull around four spheres. Sphere center points in x/y-plane,
|
|
489
|
+
* offset by either combination "+/- sizeX" or "+/- sizeY".
|
|
490
|
+
* Alternative description: Rectangle in x/y-plane with a 3D padding (source: nova-api docs)
|
|
491
|
+
*
|
|
492
|
+
* Basically a rounded box with a rectangular cross-section.
|
|
493
|
+
*/
|
|
494
|
+
case "rectangular_capsule": {
|
|
495
|
+
const h = i.shape, m = h.radius / 1e3, _ = h.sphere_center_distance_x / 1e3, d = h.sphere_center_distance_y / 1e3, g = m * 2;
|
|
496
|
+
f = /* @__PURE__ */ s(
|
|
497
|
+
"primitive",
|
|
498
|
+
{
|
|
499
|
+
object: new mt(_, d, g, 2, m),
|
|
500
|
+
attach: "geometry"
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
default:
|
|
506
|
+
console.warn(
|
|
507
|
+
"Unsupported safety zone shape type:",
|
|
508
|
+
i.shape.shape_type
|
|
509
|
+
), f = null;
|
|
510
|
+
}
|
|
511
|
+
return /* @__PURE__ */ T(
|
|
512
|
+
"mesh",
|
|
513
|
+
{
|
|
514
|
+
renderOrder: l,
|
|
515
|
+
position: a,
|
|
516
|
+
quaternion: Rt(p),
|
|
517
|
+
children: [
|
|
518
|
+
f,
|
|
519
|
+
/* @__PURE__ */ s("meshStandardMaterial", { ...u, polygonOffsetFactor: -l })
|
|
520
|
+
]
|
|
521
|
+
},
|
|
522
|
+
`safety-zone-${i.shape.shape_type}-${l}`
|
|
523
|
+
);
|
|
524
|
+
}, c = L(() => Object.values(t ?? {}).map(
|
|
525
|
+
(l, i) => r(i, l)
|
|
526
|
+
), [t, o]);
|
|
527
|
+
return /* @__PURE__ */ s("group", { ...e, children: c });
|
|
528
|
+
}
|
|
529
|
+
function le({
|
|
530
|
+
trajectory: t,
|
|
531
|
+
...n
|
|
532
|
+
}) {
|
|
533
|
+
const e = (t == null ? void 0 : t.map((o) => {
|
|
534
|
+
if (o.position && o.position.length >= 3) {
|
|
535
|
+
const [r, c, l] = o.position;
|
|
536
|
+
if (Number.isFinite(r) && Number.isFinite(c) && Number.isFinite(l))
|
|
537
|
+
return new R.Vector3(r / 1e3, l / 1e3, -c / 1e3);
|
|
538
|
+
}
|
|
539
|
+
return null;
|
|
540
|
+
}).filter((o) => o !== null)) || [];
|
|
541
|
+
return /* @__PURE__ */ s("group", { ...n, children: e.length > 0 && /* @__PURE__ */ s(
|
|
542
|
+
V,
|
|
543
|
+
{
|
|
544
|
+
points: e,
|
|
545
|
+
lineWidth: 3,
|
|
546
|
+
polygonOffset: !0,
|
|
547
|
+
polygonOffsetFactor: 10,
|
|
548
|
+
polygonOffsetUnits: 10
|
|
549
|
+
}
|
|
550
|
+
) });
|
|
551
|
+
}
|
|
552
|
+
const F = /* @__PURE__ */ new Map();
|
|
553
|
+
async function J(t, n) {
|
|
554
|
+
const e = n || "";
|
|
555
|
+
if (!e)
|
|
556
|
+
throw new Error(
|
|
557
|
+
`Cannot download the model "${t}": no NOVA instance. Give defaultGetModel the URL of the instance or a NOVA client, or give the component its instanceUrl or getModel.`
|
|
558
|
+
);
|
|
559
|
+
const o = `${Jt(e)} ${t}`, r = F.get(o);
|
|
560
|
+
if (r) return r;
|
|
561
|
+
const c = (async () => {
|
|
562
|
+
const l = _t(e);
|
|
563
|
+
try {
|
|
564
|
+
const i = await l.api.motionGroupModels.getMotionGroupGlbModel(
|
|
565
|
+
t,
|
|
566
|
+
{ responseType: "blob" }
|
|
567
|
+
);
|
|
568
|
+
return URL.createObjectURL(i);
|
|
569
|
+
} catch (i) {
|
|
570
|
+
throw console.error("Failed to fetch model:", i), i;
|
|
571
|
+
}
|
|
572
|
+
})();
|
|
573
|
+
return F.set(o, c), c.catch(() => {
|
|
574
|
+
F.get(o) === c && F.delete(o);
|
|
575
|
+
}), c;
|
|
576
|
+
}
|
|
577
|
+
function Jt(t) {
|
|
578
|
+
return typeof t == "string" ? t : t.config.instanceUrl;
|
|
579
|
+
}
|
|
580
|
+
function z(t) {
|
|
581
|
+
function n(e) {
|
|
582
|
+
return e.children.length === 0 ? [e] : [e, ...e.children.flatMap((o) => n(o))];
|
|
583
|
+
}
|
|
584
|
+
return n(t).filter((e) => et(e));
|
|
585
|
+
}
|
|
586
|
+
function tt(t) {
|
|
587
|
+
return t.name.endsWith("_FLG");
|
|
588
|
+
}
|
|
589
|
+
function et(t) {
|
|
590
|
+
return /_J[0-9]+$/.test(t.name);
|
|
591
|
+
}
|
|
592
|
+
function Nt(t, n) {
|
|
593
|
+
let e;
|
|
594
|
+
function o(r) {
|
|
595
|
+
if (tt(r)) {
|
|
596
|
+
if (e)
|
|
597
|
+
throw Error(
|
|
598
|
+
`Found multiple flange groups in robot model ${n}; first ${e.name} then ${r.name}. Only one _FLG group is allowed.`
|
|
599
|
+
);
|
|
600
|
+
e = r;
|
|
601
|
+
}
|
|
602
|
+
et(r), r.children.map(o);
|
|
603
|
+
}
|
|
604
|
+
if (o(t.scene), !e)
|
|
605
|
+
throw Error(
|
|
606
|
+
`No flange group found in robot model ${n}. Flange must be identified with a name ending in _FLG.`
|
|
607
|
+
);
|
|
608
|
+
return { gltf: t };
|
|
609
|
+
}
|
|
610
|
+
const nt = Q(function({
|
|
611
|
+
rapidlyChangingMotionState: n,
|
|
612
|
+
dhParameters: e,
|
|
613
|
+
chainOffsetPosition: o,
|
|
614
|
+
chainOffsetQuaternion: r,
|
|
615
|
+
onTranslationChanged: c,
|
|
616
|
+
children: l
|
|
617
|
+
}, i) {
|
|
618
|
+
const a = S(null), p = S([]), f = S(
|
|
619
|
+
n.joint_position.filter(
|
|
620
|
+
(d) => d !== void 0
|
|
621
|
+
)
|
|
622
|
+
), { invalidate: u } = K(), y = S(n);
|
|
623
|
+
y.current = n;
|
|
624
|
+
function w(d) {
|
|
625
|
+
a.current = d, d && h();
|
|
626
|
+
}
|
|
627
|
+
function h() {
|
|
628
|
+
a.current && (p.current = z(a.current), m(), u());
|
|
629
|
+
}
|
|
630
|
+
B(i, () => ({ recollectJoints: h }));
|
|
631
|
+
function m() {
|
|
632
|
+
const d = f.current;
|
|
633
|
+
if (c)
|
|
634
|
+
c(p.current, d);
|
|
635
|
+
else
|
|
636
|
+
for (const [g, v] of p.current.entries()) {
|
|
637
|
+
const O = e[g].reverse_rotation_direction ? -1 : 1;
|
|
638
|
+
v.position.y = O * (d[g] || 0) / 1e3;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function _(d) {
|
|
642
|
+
f.current = d.joint_position.filter(
|
|
643
|
+
(g) => g !== void 0
|
|
644
|
+
), m(), u();
|
|
645
|
+
}
|
|
646
|
+
return Y(() => {
|
|
647
|
+
_(y.current);
|
|
648
|
+
}), /* @__PURE__ */ s(
|
|
649
|
+
"group",
|
|
650
|
+
{
|
|
651
|
+
ref: w,
|
|
652
|
+
position: o,
|
|
653
|
+
quaternion: r,
|
|
654
|
+
children: l
|
|
655
|
+
}
|
|
656
|
+
);
|
|
657
|
+
});
|
|
658
|
+
function ot({
|
|
659
|
+
rapidlyChangingMotionState: t,
|
|
660
|
+
dhParameters: n,
|
|
661
|
+
...e
|
|
662
|
+
}) {
|
|
663
|
+
const o = new b(), r = S(null), c = S(null);
|
|
664
|
+
function l(p) {
|
|
665
|
+
const f = new b();
|
|
666
|
+
for (let h = 0; h < n.length; h++) {
|
|
667
|
+
const m = n[h], _ = p[h] ?? 0, d = new b().makeRotationY(m.theta).multiply(
|
|
668
|
+
new b().makeTranslation(
|
|
669
|
+
m.a / 1e3,
|
|
670
|
+
(m.d + _ * (m.reverse_rotation_direction ? -1 : 1)) / 1e3,
|
|
671
|
+
0
|
|
672
|
+
)
|
|
673
|
+
).multiply(new b().makeRotationX(m.alpha));
|
|
674
|
+
f.multiply(d);
|
|
675
|
+
}
|
|
676
|
+
const u = new x(), y = new k(), w = new x();
|
|
677
|
+
return f.decompose(u, y, w), u;
|
|
678
|
+
}
|
|
679
|
+
const i = l(
|
|
680
|
+
t.joint_position
|
|
681
|
+
);
|
|
682
|
+
function a(p, f) {
|
|
683
|
+
o.identity();
|
|
684
|
+
let u = new x();
|
|
685
|
+
for (let m = 0; m < n.length; m++) {
|
|
686
|
+
const _ = f[m] ?? 0, d = n[m], g = new b().makeRotationY(d.theta).multiply(
|
|
687
|
+
new b().makeTranslation(
|
|
688
|
+
d.a / 1e3,
|
|
689
|
+
(d.d + _ * (d.reverse_rotation_direction ? -1 : 1)) / 1e3,
|
|
690
|
+
0
|
|
691
|
+
)
|
|
692
|
+
).multiply(new b().makeRotationX(d.alpha));
|
|
693
|
+
o.multiply(g);
|
|
694
|
+
}
|
|
695
|
+
const y = new x(), w = new k(), h = new x();
|
|
696
|
+
if (o.decompose(y, w, h), u = y, r.current && r.current.position.set(
|
|
697
|
+
u.x,
|
|
698
|
+
u.y,
|
|
699
|
+
u.z
|
|
700
|
+
), c.current) {
|
|
701
|
+
const m = c.current.geometry;
|
|
702
|
+
m != null && m.setPositions && m.setPositions([
|
|
703
|
+
0,
|
|
704
|
+
0,
|
|
705
|
+
0,
|
|
706
|
+
u.x,
|
|
707
|
+
u.y,
|
|
708
|
+
u.z
|
|
709
|
+
]);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return /* @__PURE__ */ s(
|
|
713
|
+
nt,
|
|
714
|
+
{
|
|
715
|
+
rapidlyChangingMotionState: t,
|
|
716
|
+
dhParameters: n,
|
|
717
|
+
onTranslationChanged: a,
|
|
718
|
+
children: /* @__PURE__ */ T("group", { ...e, name: "Scene", children: [
|
|
719
|
+
/* @__PURE__ */ T("mesh", { name: "Base", position: [0, 0, 0], children: [
|
|
720
|
+
/* @__PURE__ */ s("sphereGeometry", { args: [0.02, 32, 32] }),
|
|
721
|
+
/* @__PURE__ */ s("meshStandardMaterial", { color: "green", depthTest: !0 })
|
|
722
|
+
] }),
|
|
723
|
+
/* @__PURE__ */ s(
|
|
724
|
+
V,
|
|
725
|
+
{
|
|
726
|
+
ref: c,
|
|
727
|
+
points: [new x(0, 0, 0), i],
|
|
728
|
+
color: "White",
|
|
729
|
+
lineWidth: 5
|
|
730
|
+
}
|
|
731
|
+
),
|
|
732
|
+
/* @__PURE__ */ T("mesh", { ref: r, name: "TCP", position: i, children: [
|
|
733
|
+
/* @__PURE__ */ s("sphereGeometry", { args: [0.025, 32, 32] }),
|
|
734
|
+
/* @__PURE__ */ s("meshStandardMaterial", { color: "red", depthTest: !0 })
|
|
735
|
+
] })
|
|
736
|
+
] })
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
const Dt = console.warn;
|
|
741
|
+
function rt() {
|
|
742
|
+
return P(() => {
|
|
743
|
+
console.warn = (t) => {
|
|
744
|
+
t !== "Cannot call the manual advancement of rafz whilst frameLoop is not set as demand" && Dt(t);
|
|
745
|
+
};
|
|
746
|
+
}, []), null;
|
|
747
|
+
}
|
|
748
|
+
function $t(t) {
|
|
749
|
+
return t.type === "Mesh";
|
|
750
|
+
}
|
|
751
|
+
function jt({
|
|
752
|
+
url: t,
|
|
753
|
+
flangeRef: n,
|
|
754
|
+
postModelRender: e,
|
|
755
|
+
...o
|
|
756
|
+
}) {
|
|
757
|
+
const r = dt(t), l = Nt(r, "robot.glb").gltf;
|
|
758
|
+
P(() => {
|
|
759
|
+
e == null || e();
|
|
760
|
+
}, [t, e]);
|
|
761
|
+
function i(a) {
|
|
762
|
+
try {
|
|
763
|
+
return $t(a) ? a.geometry ? /* @__PURE__ */ s(
|
|
764
|
+
"mesh",
|
|
765
|
+
{
|
|
766
|
+
name: a.name,
|
|
767
|
+
geometry: a.geometry,
|
|
768
|
+
material: a.material,
|
|
769
|
+
position: a.position,
|
|
770
|
+
rotation: a.rotation
|
|
771
|
+
},
|
|
772
|
+
a.uuid
|
|
773
|
+
) : /* @__PURE__ */ s(
|
|
774
|
+
"group",
|
|
775
|
+
{
|
|
776
|
+
name: a.name,
|
|
777
|
+
position: a.position,
|
|
778
|
+
rotation: a.rotation
|
|
779
|
+
},
|
|
780
|
+
a.uuid
|
|
781
|
+
) : /* @__PURE__ */ s(
|
|
782
|
+
"group",
|
|
783
|
+
{
|
|
784
|
+
name: a.name,
|
|
785
|
+
position: a.position,
|
|
786
|
+
rotation: a.rotation,
|
|
787
|
+
ref: tt(a) ? n : void 0,
|
|
788
|
+
children: a.children.map(i)
|
|
789
|
+
},
|
|
790
|
+
a.uuid
|
|
791
|
+
);
|
|
792
|
+
} catch (p) {
|
|
793
|
+
return console.warn("Error rendering node", a.name, p), null;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return /* @__PURE__ */ s("group", { ...o, dispose: null, children: i(l.scene) });
|
|
797
|
+
}
|
|
798
|
+
function it({
|
|
799
|
+
modelURL: t,
|
|
800
|
+
flangeRef: n,
|
|
801
|
+
postModelRender: e,
|
|
802
|
+
...o
|
|
803
|
+
}) {
|
|
804
|
+
const [r, c] = C(null);
|
|
805
|
+
return P(() => {
|
|
806
|
+
let l = !1;
|
|
807
|
+
return (async () => {
|
|
808
|
+
try {
|
|
809
|
+
const a = typeof t == "string" ? t : await t;
|
|
810
|
+
l || c((p) => p === a ? p : a);
|
|
811
|
+
} catch (a) {
|
|
812
|
+
console.error("Failed to resolve model URL:", a);
|
|
813
|
+
}
|
|
814
|
+
})(), () => {
|
|
815
|
+
l = !0;
|
|
816
|
+
};
|
|
817
|
+
}, [t]), r ? /* @__PURE__ */ s(
|
|
818
|
+
jt,
|
|
819
|
+
{
|
|
820
|
+
url: r,
|
|
821
|
+
flangeRef: n,
|
|
822
|
+
postModelRender: e,
|
|
823
|
+
...o
|
|
824
|
+
}
|
|
825
|
+
) : null;
|
|
826
|
+
}
|
|
827
|
+
const st = (t, n) => {
|
|
828
|
+
t.userData.isGhost || (t.traverse((e) => {
|
|
829
|
+
if (e instanceof R.Mesh) {
|
|
830
|
+
e.material instanceof R.Material && (e.material.colorWrite = !1);
|
|
831
|
+
const o = e.clone(), r = e.clone();
|
|
832
|
+
o.material = new R.MeshStandardMaterial({
|
|
833
|
+
depthTest: !0,
|
|
834
|
+
depthWrite: !0,
|
|
835
|
+
colorWrite: !1,
|
|
836
|
+
polygonOffset: !0,
|
|
837
|
+
polygonOffsetFactor: -1,
|
|
838
|
+
side: R.DoubleSide
|
|
839
|
+
}), o.userData.isGhost = !0, r.material = new R.MeshStandardMaterial({
|
|
840
|
+
color: n,
|
|
841
|
+
opacity: 0.3,
|
|
842
|
+
depthTest: !0,
|
|
843
|
+
depthWrite: !1,
|
|
844
|
+
transparent: !0,
|
|
845
|
+
polygonOffset: !0,
|
|
846
|
+
polygonOffsetFactor: -2,
|
|
847
|
+
side: R.DoubleSide
|
|
848
|
+
}), r.userData.isGhost = !0, e.parent && (e.parent.add(o), e.parent.add(r));
|
|
849
|
+
}
|
|
850
|
+
}), t.userData.isGhost = !0);
|
|
851
|
+
}, at = (t) => {
|
|
852
|
+
if (!t.userData.isGhost) return;
|
|
853
|
+
const n = [];
|
|
854
|
+
t.traverse((e) => {
|
|
855
|
+
var o;
|
|
856
|
+
e instanceof R.Mesh && ((o = e.userData) != null && o.isGhost ? n.push(e) : e.material instanceof R.Material && (e.material.colorWrite = !0));
|
|
857
|
+
}), n.forEach((e) => {
|
|
858
|
+
e.parent && e.parent.remove(e);
|
|
859
|
+
}), t.userData.isGhost = !1;
|
|
860
|
+
}, ct = E(
|
|
861
|
+
({
|
|
862
|
+
rapidlyChangingMotionState: t,
|
|
863
|
+
modelFromController: n,
|
|
864
|
+
dhParameters: e,
|
|
865
|
+
chainOffsetPosition: o,
|
|
866
|
+
chainOffsetQuaternion: r,
|
|
867
|
+
getModel: c = J,
|
|
868
|
+
flangeRef: l,
|
|
869
|
+
postModelRender: i,
|
|
870
|
+
transparentColor: a,
|
|
871
|
+
instanceUrl: p,
|
|
872
|
+
...f
|
|
873
|
+
}) => {
|
|
874
|
+
const [u, y] = C(null), w = S(null), h = A((g) => {
|
|
875
|
+
y(g);
|
|
876
|
+
}, []), m = A(() => {
|
|
877
|
+
var g;
|
|
878
|
+
(g = w.current) == null || g.recollectJoints(), i == null || i();
|
|
879
|
+
}, [i]);
|
|
880
|
+
P(() => {
|
|
881
|
+
u && (a ? st(u, a) : at(u));
|
|
882
|
+
}, [u, a]);
|
|
883
|
+
const _ = L(() => {
|
|
884
|
+
const g = c(n, p);
|
|
885
|
+
if (!g) {
|
|
886
|
+
const v = new Blob([], { type: "model/gltf-binary" }), M = new File([v], `${n}.glb`, {
|
|
887
|
+
type: "model/gltf-binary"
|
|
888
|
+
});
|
|
889
|
+
return Promise.resolve(URL.createObjectURL(M));
|
|
890
|
+
}
|
|
891
|
+
return g;
|
|
892
|
+
}, [n, p, c]), d = /* @__PURE__ */ s(
|
|
893
|
+
ot,
|
|
894
|
+
{
|
|
895
|
+
rapidlyChangingMotionState: t,
|
|
896
|
+
dhParameters: e,
|
|
897
|
+
...f
|
|
898
|
+
}
|
|
899
|
+
);
|
|
900
|
+
return /* @__PURE__ */ T(
|
|
901
|
+
Z,
|
|
902
|
+
{
|
|
903
|
+
fallback: d,
|
|
904
|
+
onError: (g) => {
|
|
905
|
+
console.warn(g);
|
|
906
|
+
},
|
|
907
|
+
children: [
|
|
908
|
+
/* @__PURE__ */ s(X, { fallback: d, children: /* @__PURE__ */ s("group", { ref: h, children: /* @__PURE__ */ s(
|
|
909
|
+
nt,
|
|
910
|
+
{
|
|
911
|
+
ref: w,
|
|
912
|
+
rapidlyChangingMotionState: t,
|
|
913
|
+
dhParameters: e,
|
|
914
|
+
chainOffsetPosition: o,
|
|
915
|
+
chainOffsetQuaternion: r,
|
|
916
|
+
children: /* @__PURE__ */ s(
|
|
917
|
+
it,
|
|
918
|
+
{
|
|
919
|
+
modelURL: _,
|
|
920
|
+
postModelRender: m,
|
|
921
|
+
flangeRef: l,
|
|
922
|
+
...f
|
|
923
|
+
}
|
|
924
|
+
)
|
|
925
|
+
}
|
|
926
|
+
) }) }),
|
|
927
|
+
/* @__PURE__ */ s(rt, {})
|
|
928
|
+
]
|
|
929
|
+
}
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
), Ut = E(
|
|
933
|
+
({ rapidlyChangingMotionState: t, ...n }) => {
|
|
934
|
+
const e = j(
|
|
935
|
+
t
|
|
936
|
+
);
|
|
937
|
+
return /* @__PURE__ */ s(
|
|
938
|
+
ct,
|
|
939
|
+
{
|
|
940
|
+
rapidlyChangingMotionState: e,
|
|
941
|
+
...n
|
|
942
|
+
}
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
);
|
|
946
|
+
function ue({
|
|
947
|
+
connectedMotionGroup: t,
|
|
948
|
+
getModel: n,
|
|
949
|
+
flangeRef: e,
|
|
950
|
+
transparentColor: o,
|
|
951
|
+
postModelRender: r,
|
|
952
|
+
...c
|
|
953
|
+
}) {
|
|
954
|
+
const l = A(
|
|
955
|
+
(y) => J(y, t.nova),
|
|
956
|
+
[t]
|
|
957
|
+
), i = n ?? l;
|
|
958
|
+
if (!t.dhParameters)
|
|
959
|
+
return null;
|
|
960
|
+
const a = t.mountingPosition, p = t.mountingQuaternion, f = t.modelFromController || "";
|
|
961
|
+
return f ? /* @__PURE__ */ s(
|
|
962
|
+
Ut,
|
|
963
|
+
{
|
|
964
|
+
rapidlyChangingMotionState: t.rapidlyChangingMotionState,
|
|
965
|
+
modelFromController: f,
|
|
966
|
+
dhParameters: t.dhParameters,
|
|
967
|
+
getModel: i,
|
|
968
|
+
flangeRef: e,
|
|
969
|
+
transparentColor: o,
|
|
970
|
+
postModelRender: r,
|
|
971
|
+
chainOffsetPosition: a,
|
|
972
|
+
chainOffsetQuaternion: p,
|
|
973
|
+
...c
|
|
974
|
+
}
|
|
975
|
+
) : /* @__PURE__ */ s(
|
|
976
|
+
ot,
|
|
977
|
+
{
|
|
978
|
+
rapidlyChangingMotionState: t.rapidlyChangingMotionState,
|
|
979
|
+
dhParameters: t.dhParameters,
|
|
980
|
+
chainOffsetPosition: a,
|
|
981
|
+
chainOffsetQuaternion: p,
|
|
982
|
+
...c
|
|
983
|
+
}
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
const lt = Q(
|
|
987
|
+
function({
|
|
988
|
+
rapidlyChangingMotionState: n,
|
|
989
|
+
dhParameters: e,
|
|
990
|
+
chainOffsetPosition: o,
|
|
991
|
+
chainOffsetQuaternion: r,
|
|
992
|
+
onRotationChanged: c,
|
|
993
|
+
children: l
|
|
994
|
+
}, i) {
|
|
995
|
+
const a = S(null), p = S([]), f = S(
|
|
996
|
+
n.joint_position.filter(
|
|
997
|
+
(d) => d !== void 0
|
|
998
|
+
)
|
|
999
|
+
), { invalidate: u } = K(), y = S(n);
|
|
1000
|
+
y.current = n;
|
|
1001
|
+
function w(d) {
|
|
1002
|
+
a.current = d, d && h();
|
|
1003
|
+
}
|
|
1004
|
+
function h() {
|
|
1005
|
+
a.current && (p.current = z(a.current), m(), u());
|
|
1006
|
+
}
|
|
1007
|
+
B(i, () => ({ recollectJoints: h }));
|
|
1008
|
+
function m() {
|
|
1009
|
+
const d = f.current;
|
|
1010
|
+
if (c)
|
|
1011
|
+
c(p.current, d);
|
|
1012
|
+
else
|
|
1013
|
+
for (const [g, v] of p.current.entries()) {
|
|
1014
|
+
const M = e[g], O = M.theta || 0, pt = M.reverse_rotation_direction ? -1 : 1;
|
|
1015
|
+
v.rotation.y = pt * (d[g] || 0) + O;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
function _(d) {
|
|
1019
|
+
f.current = d.joint_position.filter(
|
|
1020
|
+
(g) => g !== void 0
|
|
1021
|
+
), m(), u();
|
|
1022
|
+
}
|
|
1023
|
+
return Y(() => {
|
|
1024
|
+
_(y.current);
|
|
1025
|
+
}), P(() => {
|
|
1026
|
+
_(n);
|
|
1027
|
+
}, [n]), /* @__PURE__ */ s(
|
|
1028
|
+
"group",
|
|
1029
|
+
{
|
|
1030
|
+
ref: w,
|
|
1031
|
+
position: o,
|
|
1032
|
+
quaternion: r,
|
|
1033
|
+
children: l
|
|
1034
|
+
}
|
|
1035
|
+
);
|
|
1036
|
+
}
|
|
1037
|
+
), Wt = "line", qt = "mesh";
|
|
1038
|
+
function Ht({
|
|
1039
|
+
rapidlyChangingMotionState: t,
|
|
1040
|
+
dhParameters: n,
|
|
1041
|
+
...e
|
|
1042
|
+
}) {
|
|
1043
|
+
const o = new b(), r = S([]), c = S([]);
|
|
1044
|
+
gt.useEffect(() => {
|
|
1045
|
+
r.current = new Array(n.length).fill(null), c.current = new Array(n.length).fill(null);
|
|
1046
|
+
}, [n.length]);
|
|
1047
|
+
function l(p, f) {
|
|
1048
|
+
const u = new x(), y = new k(), w = new x();
|
|
1049
|
+
o.decompose(u, y, w);
|
|
1050
|
+
const h = u.clone(), m = new b().makeRotationY(
|
|
1051
|
+
p.theta + f * (p.reverse_rotation_direction ? -1 : 1)
|
|
1052
|
+
).multiply(new b().makeTranslation(0, p.d / 1e3, 0)).multiply(new b().makeTranslation(p.a / 1e3, 0, 0)).multiply(new b().makeRotationX(p.alpha));
|
|
1053
|
+
return o.multiply(m), o.decompose(u, y, w), { a: h, b: u };
|
|
1054
|
+
}
|
|
1055
|
+
function i(p, f, u, y) {
|
|
1056
|
+
if (!n)
|
|
1057
|
+
return;
|
|
1058
|
+
const w = n[p];
|
|
1059
|
+
if (!w)
|
|
1060
|
+
return;
|
|
1061
|
+
const { a: h, b: m } = l(w, y);
|
|
1062
|
+
f.geometry.setPositions([h.toArray(), m.toArray()].flat()), u.position.set(m.x, m.y, m.z);
|
|
1063
|
+
}
|
|
1064
|
+
function a(p, f) {
|
|
1065
|
+
o.identity();
|
|
1066
|
+
for (let u = 0; u < Math.min(p.length, f.length); u++) {
|
|
1067
|
+
const y = r.current[u], w = c.current[u];
|
|
1068
|
+
y && w && i(u, y, w, f[u]);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return /* @__PURE__ */ s(
|
|
1072
|
+
lt,
|
|
1073
|
+
{
|
|
1074
|
+
rapidlyChangingMotionState: t,
|
|
1075
|
+
dhParameters: n,
|
|
1076
|
+
onRotationChanged: a,
|
|
1077
|
+
children: /* @__PURE__ */ T("group", { ...e, name: "Scene", children: [
|
|
1078
|
+
/* @__PURE__ */ T("mesh", { children: [
|
|
1079
|
+
/* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
|
|
1080
|
+
/* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
|
|
1081
|
+
] }),
|
|
1082
|
+
n == null ? void 0 : n.map((p, f) => {
|
|
1083
|
+
const { a: u, b: y } = l(
|
|
1084
|
+
p,
|
|
1085
|
+
t.joint_position[f] ?? 0
|
|
1086
|
+
), w = `dhrobot_J0${f}`;
|
|
1087
|
+
return /* @__PURE__ */ T("group", { name: w, children: [
|
|
1088
|
+
/* @__PURE__ */ s(
|
|
1089
|
+
V,
|
|
1090
|
+
{
|
|
1091
|
+
ref: (h) => {
|
|
1092
|
+
r.current[f] = h;
|
|
1093
|
+
},
|
|
1094
|
+
name: Wt,
|
|
1095
|
+
points: [u, y],
|
|
1096
|
+
color: "white",
|
|
1097
|
+
lineWidth: 5
|
|
1098
|
+
}
|
|
1099
|
+
),
|
|
1100
|
+
/* @__PURE__ */ T(
|
|
1101
|
+
"mesh",
|
|
1102
|
+
{
|
|
1103
|
+
ref: (h) => {
|
|
1104
|
+
c.current[f] = h;
|
|
1105
|
+
},
|
|
1106
|
+
name: qt,
|
|
1107
|
+
position: y,
|
|
1108
|
+
children: [
|
|
1109
|
+
/* @__PURE__ */ s("sphereGeometry", { args: [0.01, 32, 32] }),
|
|
1110
|
+
/* @__PURE__ */ s("meshStandardMaterial", { color: "black", depthTest: !0 })
|
|
1111
|
+
]
|
|
1112
|
+
},
|
|
1113
|
+
`mesh_${f}`
|
|
1114
|
+
)
|
|
1115
|
+
] }, w);
|
|
1116
|
+
})
|
|
1117
|
+
] })
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
const ut = E(
|
|
1122
|
+
({
|
|
1123
|
+
rapidlyChangingMotionState: t,
|
|
1124
|
+
modelFromController: n,
|
|
1125
|
+
dhParameters: e,
|
|
1126
|
+
chainOffsetPosition: o,
|
|
1127
|
+
chainOffsetQuaternion: r,
|
|
1128
|
+
getModel: c = J,
|
|
1129
|
+
flangeRef: l,
|
|
1130
|
+
postModelRender: i,
|
|
1131
|
+
transparentColor: a,
|
|
1132
|
+
instanceUrl: p,
|
|
1133
|
+
...f
|
|
1134
|
+
}) => {
|
|
1135
|
+
const [u, y] = C(null), w = S(null), h = A((g) => {
|
|
1136
|
+
y(g);
|
|
1137
|
+
}, []), m = A(() => {
|
|
1138
|
+
var g;
|
|
1139
|
+
(g = w.current) == null || g.recollectJoints(), i == null || i();
|
|
1140
|
+
}, [i]);
|
|
1141
|
+
P(() => {
|
|
1142
|
+
u && (a ? st(u, a) : at(u));
|
|
1143
|
+
}, [u, a]);
|
|
1144
|
+
const _ = L(() => {
|
|
1145
|
+
const g = c(n, p);
|
|
1146
|
+
if (!g)
|
|
1147
|
+
throw new Error(
|
|
1148
|
+
`No model found for robot "${n}". Ensure the model is available or provide a custom getModel function.`
|
|
1149
|
+
);
|
|
1150
|
+
return g;
|
|
1151
|
+
}, [n, p, c]), d = /* @__PURE__ */ s(
|
|
1152
|
+
Ht,
|
|
1153
|
+
{
|
|
1154
|
+
rapidlyChangingMotionState: t,
|
|
1155
|
+
dhParameters: e,
|
|
1156
|
+
...f
|
|
1157
|
+
}
|
|
1158
|
+
);
|
|
1159
|
+
return /* @__PURE__ */ T(
|
|
1160
|
+
Z,
|
|
1161
|
+
{
|
|
1162
|
+
fallback: d,
|
|
1163
|
+
onError: (g) => {
|
|
1164
|
+
console.warn(g);
|
|
1165
|
+
},
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ s(X, { fallback: d, children: /* @__PURE__ */ s("group", { ref: h, children: /* @__PURE__ */ s(
|
|
1168
|
+
lt,
|
|
1169
|
+
{
|
|
1170
|
+
ref: w,
|
|
1171
|
+
rapidlyChangingMotionState: t,
|
|
1172
|
+
dhParameters: e,
|
|
1173
|
+
chainOffsetPosition: o,
|
|
1174
|
+
chainOffsetQuaternion: r,
|
|
1175
|
+
children: /* @__PURE__ */ s(
|
|
1176
|
+
it,
|
|
1177
|
+
{
|
|
1178
|
+
modelURL: _,
|
|
1179
|
+
postModelRender: m,
|
|
1180
|
+
flangeRef: l,
|
|
1181
|
+
...f
|
|
1182
|
+
}
|
|
1183
|
+
)
|
|
1184
|
+
}
|
|
1185
|
+
) }) }),
|
|
1186
|
+
/* @__PURE__ */ s(rt, {})
|
|
1187
|
+
]
|
|
1188
|
+
}
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
), Qt = E(
|
|
1192
|
+
({ rapidlyChangingMotionState: t, ...n }) => {
|
|
1193
|
+
const e = j(
|
|
1194
|
+
t
|
|
1195
|
+
);
|
|
1196
|
+
return /* @__PURE__ */ s(
|
|
1197
|
+
ut,
|
|
1198
|
+
{
|
|
1199
|
+
rapidlyChangingMotionState: e,
|
|
1200
|
+
...n
|
|
1201
|
+
}
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
1204
|
+
), Bt = E((t) => {
|
|
1205
|
+
const { inverseSolver: n, dhParameters: e, ...o } = t, [r, c] = C(
|
|
1206
|
+
I.RevoluteJoint
|
|
1207
|
+
);
|
|
1208
|
+
P(() => {
|
|
1209
|
+
e.length && c(e[0].type ?? I.RevoluteJoint);
|
|
1210
|
+
}, [e]);
|
|
1211
|
+
const l = L(() => n === null && r === I.RevoluteJoint, [n, r]), i = L(() => n === null && r === I.PrismaticJoint, [n, r]);
|
|
1212
|
+
return L(() => !!n, [n]) || l ? /* @__PURE__ */ s(ut, { dhParameters: e, ...o }) : i ? /* @__PURE__ */ s(ct, { dhParameters: e, ...o }) : null;
|
|
1213
|
+
}), pe = E((t) => {
|
|
1214
|
+
const n = j(
|
|
1215
|
+
t.rapidlyChangingMotionState
|
|
1216
|
+
);
|
|
1217
|
+
return /* @__PURE__ */ s(
|
|
1218
|
+
Bt,
|
|
1219
|
+
{
|
|
1220
|
+
...t,
|
|
1221
|
+
rapidlyChangingMotionState: n
|
|
1222
|
+
}
|
|
1223
|
+
);
|
|
1224
|
+
});
|
|
1225
|
+
function fe({
|
|
1226
|
+
connectedMotionGroup: t,
|
|
1227
|
+
getModel: n,
|
|
1228
|
+
flangeRef: e,
|
|
1229
|
+
transparentColor: o,
|
|
1230
|
+
postModelRender: r,
|
|
1231
|
+
...c
|
|
1232
|
+
}) {
|
|
1233
|
+
const l = A(
|
|
1234
|
+
(p) => J(p, t.nova),
|
|
1235
|
+
[t]
|
|
1236
|
+
);
|
|
1237
|
+
if (!t.dhParameters)
|
|
1238
|
+
return null;
|
|
1239
|
+
const i = t.mountingPosition, a = t.mountingQuaternion;
|
|
1240
|
+
return /* @__PURE__ */ s(
|
|
1241
|
+
Qt,
|
|
1242
|
+
{
|
|
1243
|
+
rapidlyChangingMotionState: t.rapidlyChangingMotionState,
|
|
1244
|
+
modelFromController: t.modelFromController || "",
|
|
1245
|
+
dhParameters: t.dhParameters,
|
|
1246
|
+
getModel: n ?? l,
|
|
1247
|
+
flangeRef: e,
|
|
1248
|
+
transparentColor: o,
|
|
1249
|
+
postModelRender: r,
|
|
1250
|
+
chainOffsetPosition: i,
|
|
1251
|
+
chainOffsetQuaternion: a,
|
|
1252
|
+
...c
|
|
1253
|
+
}
|
|
1254
|
+
);
|
|
1255
|
+
}
|
|
1256
|
+
export {
|
|
1257
|
+
ie as C,
|
|
1258
|
+
se as J,
|
|
1259
|
+
ue as L,
|
|
1260
|
+
pe as M,
|
|
1261
|
+
ae as P,
|
|
1262
|
+
fe as R,
|
|
1263
|
+
ce as S,
|
|
1264
|
+
le as T,
|
|
1265
|
+
Bt as a,
|
|
1266
|
+
Ut as b,
|
|
1267
|
+
ct as c,
|
|
1268
|
+
Qt as d,
|
|
1269
|
+
ut as e,
|
|
1270
|
+
J as f
|
|
1271
|
+
};
|