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