@wandelbots/wandelbots-js-react-components 1.3.1 → 1.3.2

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.
Files changed (77) hide show
  1. package/package.json +18 -7
  2. package/src/components/3d-viewport/CoordinateSystemTransform.tsx +44 -0
  3. package/src/components/3d-viewport/PresetEnvironment.tsx +78 -0
  4. package/src/components/3d-viewport/SafetyZonesRenderer.tsx +54 -0
  5. package/src/components/LoadingButton.stories.tsx +61 -0
  6. package/src/components/LoadingButton.tsx +19 -0
  7. package/src/components/LoadingCover.tsx +75 -0
  8. package/src/components/ThemeSelect.tsx +49 -0
  9. package/src/components/VelocitySlider.stories.tsx +32 -0
  10. package/src/components/VelocitySlider.tsx +52 -0
  11. package/src/components/jogging/JoggingCartesianAxisControl.stories.tsx +41 -0
  12. package/src/components/jogging/JoggingCartesianAxisControl.tsx +127 -0
  13. package/src/components/jogging/JoggingCartesianTab.tsx +265 -0
  14. package/src/components/jogging/JoggingCartesianValues.tsx +45 -0
  15. package/src/components/jogging/JoggingFreedriveTab.tsx +9 -0
  16. package/src/components/jogging/JoggingJointLimitDetector.tsx +51 -0
  17. package/src/components/jogging/JoggingJointRotationControl.stories.tsx +38 -0
  18. package/src/components/jogging/JoggingJointRotationControl.tsx +197 -0
  19. package/src/components/jogging/JoggingJointTab.tsx +93 -0
  20. package/src/components/jogging/JoggingJointValues.tsx +45 -0
  21. package/src/components/jogging/JoggingOptions.tsx +96 -0
  22. package/src/components/jogging/JoggingPanel.stories.tsx +26 -0
  23. package/src/components/jogging/JoggingPanel.tsx +148 -0
  24. package/src/components/jogging/JoggingStore.tsx +294 -0
  25. package/src/components/jogging/JoggingVelocitySlider.tsx +56 -0
  26. package/src/components/robots/ABB_1200_07_7.tsx +123 -0
  27. package/src/components/robots/AxisConfig.ts +3 -0
  28. package/src/components/robots/DHRobot.tsx +129 -0
  29. package/src/components/robots/FANUC_ARC_Mate_100iD.tsx +187 -0
  30. package/src/components/robots/FANUC_ARC_Mate_120iD.tsx +187 -0
  31. package/src/components/robots/FANUC_CRX10iA.tsx +167 -0
  32. package/src/components/robots/FANUC_CRX25iA.tsx +167 -0
  33. package/src/components/robots/FANUC_CRX25iAL.tsx +178 -0
  34. package/src/components/robots/KUKA_KR210_R2700.tsx +291 -0
  35. package/src/components/robots/KUKA_KR270_R2700.tsx +244 -0
  36. package/src/components/robots/RobotAnimator.tsx +83 -0
  37. package/src/components/robots/SupportedRobot.tsx +131 -0
  38. package/src/components/robots/UniversalRobots_UR10.tsx +112 -0
  39. package/src/components/robots/UniversalRobots_UR10e.tsx +275 -0
  40. package/src/components/robots/UniversalRobots_UR3.tsx +112 -0
  41. package/src/components/robots/UniversalRobots_UR3e.tsx +112 -0
  42. package/src/components/robots/UniversalRobots_UR5.tsx +111 -0
  43. package/src/components/robots/UniversalRobots_UR5e.tsx +280 -0
  44. package/src/components/robots/Yaskawa_AR1440.tsx +152 -0
  45. package/src/components/robots/Yaskawa_AR1730.tsx +165 -0
  46. package/src/components/robots/Yaskawa_AR2010.tsx +159 -0
  47. package/src/components/robots/Yaskawa_AR3120.tsx +160 -0
  48. package/src/components/robots/Yaskawa_AR900.tsx +121 -0
  49. package/src/components/utils/converters.ts +23 -0
  50. package/src/components/utils/errorHandling.ts +30 -0
  51. package/src/components/utils/hooks.tsx +54 -0
  52. package/src/components/utils/robotTreeQuery.ts +27 -0
  53. package/src/components/wandelscript-editor/WandelscriptEditor.stories.tsx +45 -0
  54. package/src/components/wandelscript-editor/WandelscriptEditor.tsx +114 -0
  55. package/src/components/wandelscript-editor/wandelscript.tmLanguage.ts +62 -0
  56. package/src/declarations.d.ts +10 -0
  57. package/src/i18n/config.ts +27 -0
  58. package/src/i18n/locales/de/translations.json +12 -0
  59. package/src/i18n/locales/en/translations.json +12 -0
  60. package/src/icons/arrowForwardFilled.tsx +7 -0
  61. package/src/icons/axis-x.svg +3 -0
  62. package/src/icons/axis-y.svg +3 -0
  63. package/src/icons/axis-z.svg +3 -0
  64. package/src/icons/expandFilled.tsx +11 -0
  65. package/src/icons/home.tsx +12 -0
  66. package/src/icons/index.ts +6 -0
  67. package/src/icons/infoOutlined.tsx +10 -0
  68. package/src/icons/jogging.svg +3 -0
  69. package/src/icons/robot.svg +3 -0
  70. package/src/icons/robot.tsx +14 -0
  71. package/src/icons/rotation.svg +4 -0
  72. package/src/icons/wbLogo.tsx +21 -0
  73. package/src/index.ts +7 -0
  74. package/src/themes/color.tsx +74 -0
  75. package/src/themes/theme.ts +150 -0
  76. package/src/themes/wbTheme.stories.tsx +64 -0
  77. package/src/themes/wbTheme.ts +186 -0
@@ -0,0 +1,291 @@
1
+ import { useGLTF } from "@react-three/drei"
2
+ import type * as THREE from "three"
3
+ import type { RobotProps } from "./SupportedRobot"
4
+ import { animated } from "@react-spring/three"
5
+ import RobotAnimator from "./RobotAnimator"
6
+
7
+ export function KUKA_KR210_R2700({
8
+ modelURL,
9
+ connectedMotionGroup,
10
+ ...props
11
+ }: RobotProps) {
12
+ const gltf = useGLTF(modelURL) as any
13
+
14
+ const nodes = gltf.nodes
15
+ const materials = gltf.materials
16
+
17
+ const rotationOffsets = [0, 0, -Math.PI / 2, 0, 0, 0]
18
+
19
+ function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
20
+ jointObjects.forEach(
21
+ (object, index) =>
22
+ (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
23
+ )
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <RobotAnimator
29
+ connectedMotionGroup={connectedMotionGroup}
30
+ robotRootObjectName="Scene"
31
+ onRotationChanged={setRotation}
32
+ />
33
+ <group {...props} dispose={null}>
34
+ <group name="Scene">
35
+ <group name="kuka_kr210_2700">
36
+ <animated.group name="joint_01">
37
+ <animated.group
38
+ name="joint_02"
39
+ position={[0.33, 0.645, 0]}
40
+ rotation={[-Math.PI / 2, 0, 0]}
41
+ >
42
+ <animated.group
43
+ name="joint_03"
44
+ position={[1.15, 0, 0]}
45
+ rotation={[0, -Math.PI / 2, 0]}
46
+ >
47
+ <animated.group
48
+ name="joint_04"
49
+ position={[0.115, 0, 0]}
50
+ rotation={[Math.PI / 2, 0, 0]}
51
+ >
52
+ <animated.group
53
+ name="joint_05"
54
+ position={[0, -1.22, 0]}
55
+ rotation={[-Math.PI / 2, 0, 0]}
56
+ >
57
+ <animated.group
58
+ name="joint_06"
59
+ rotation={[Math.PI / 2, 0, 0]}
60
+ >
61
+ <group
62
+ name="flange"
63
+ position={[0, -0.215, 0]}
64
+ rotation={[-Math.PI, 0, 0]}
65
+ />
66
+ <group
67
+ name="link_6"
68
+ position={[0, -0.17, 0]}
69
+ rotation={[0, 0, -Math.PI / 2]}
70
+ >
71
+ <mesh
72
+ name="visuals006"
73
+ castShadow
74
+ receiveShadow
75
+ geometry={nodes.visuals006.geometry}
76
+ material={materials.material_Material_Metall_black}
77
+ />
78
+ </group>
79
+ </animated.group>
80
+ <group
81
+ name="link_5"
82
+ position={[0, 0.059, 0]}
83
+ rotation={[Math.PI / 2, 0, -Math.PI / 2]}
84
+ >
85
+ <group name="visuals005">
86
+ <mesh
87
+ name="visuals005_1"
88
+ castShadow
89
+ receiveShadow
90
+ geometry={nodes.visuals005_1.geometry}
91
+ material={materials.material_Material_metal_black}
92
+ />
93
+ <mesh
94
+ name="visuals005_2"
95
+ castShadow
96
+ receiveShadow
97
+ geometry={nodes.visuals005_2.geometry}
98
+ material={materials.material_Material_kuka_orange}
99
+ />
100
+ </group>
101
+ </group>
102
+ </animated.group>
103
+ <group
104
+ name="link_4"
105
+ position={[0, -0.869, 0]}
106
+ rotation={[0, 0, -Math.PI / 2]}
107
+ >
108
+ <group name="visuals004">
109
+ <mesh
110
+ name="visuals004_1"
111
+ castShadow
112
+ receiveShadow
113
+ geometry={nodes.visuals004_1.geometry}
114
+ material={materials.material_Material_metal_black}
115
+ />
116
+ <mesh
117
+ name="visuals004_2"
118
+ castShadow
119
+ receiveShadow
120
+ geometry={nodes.visuals004_2.geometry}
121
+ material={materials.material_Material_kuka_orange}
122
+ />
123
+ </group>
124
+ </group>
125
+ </animated.group>
126
+ <group
127
+ name="link_3"
128
+ position={[0, -0.105, 0]}
129
+ rotation={[Math.PI / 2, 0, -Math.PI / 2]}
130
+ >
131
+ <group name="visuals003">
132
+ <mesh
133
+ name="visuals003_1"
134
+ castShadow
135
+ receiveShadow
136
+ geometry={nodes.visuals003_1.geometry}
137
+ material={materials.material_Material_rubber}
138
+ />
139
+ <mesh
140
+ name="visuals003_2"
141
+ castShadow
142
+ receiveShadow
143
+ geometry={nodes.visuals003_2.geometry}
144
+ material={materials.material_Material_aluminium}
145
+ />
146
+ <mesh
147
+ name="visuals003_3"
148
+ castShadow
149
+ receiveShadow
150
+ geometry={nodes.visuals003_3.geometry}
151
+ material={materials.material_Material_metal_black}
152
+ />
153
+ <mesh
154
+ name="visuals003_4"
155
+ castShadow
156
+ receiveShadow
157
+ geometry={nodes.visuals003_4.geometry}
158
+ material={materials.material_Material_kuka_black}
159
+ />
160
+ <mesh
161
+ name="visuals003_5"
162
+ castShadow
163
+ receiveShadow
164
+ geometry={nodes.visuals003_5.geometry}
165
+ material={materials.material_Material_Rubber_black}
166
+ />
167
+ <mesh
168
+ name="visuals003_6"
169
+ castShadow
170
+ receiveShadow
171
+ geometry={nodes.visuals003_6.geometry}
172
+ material={materials.material_Material_kuka_orange}
173
+ />
174
+ <mesh
175
+ name="visuals003_7"
176
+ castShadow
177
+ receiveShadow
178
+ geometry={nodes.visuals003_7.geometry}
179
+ material={materials.material_Material_stainless_steel}
180
+ />
181
+ </group>
182
+ </group>
183
+ </animated.group>
184
+ <group
185
+ name="link_2"
186
+ position={[0, 0.009, 0]}
187
+ rotation={[Math.PI / 2, 0, 0]}
188
+ >
189
+ <group name="visuals002">
190
+ <mesh
191
+ name="visuals002_1"
192
+ castShadow
193
+ receiveShadow
194
+ geometry={nodes.visuals002_1.geometry}
195
+ material={materials.material_Material_metal_black}
196
+ />
197
+ <mesh
198
+ name="visuals002_2"
199
+ castShadow
200
+ receiveShadow
201
+ geometry={nodes.visuals002_2.geometry}
202
+ material={materials.material_Material_Rubber_black}
203
+ />
204
+ <mesh
205
+ name="visuals002_3"
206
+ castShadow
207
+ receiveShadow
208
+ geometry={nodes.visuals002_3.geometry}
209
+ material={materials.material_Material_kuka_orange}
210
+ />
211
+ </group>
212
+ </group>
213
+ </animated.group>
214
+ <group name="link_1" position={[0, 0.236, 0]}>
215
+ <group name="visuals001">
216
+ <mesh
217
+ name="visuals001_1"
218
+ castShadow
219
+ receiveShadow
220
+ geometry={nodes.visuals001_1.geometry}
221
+ material={materials.material_Material_kuka_black}
222
+ />
223
+ <mesh
224
+ name="visuals001_2"
225
+ castShadow
226
+ receiveShadow
227
+ geometry={nodes.visuals001_2.geometry}
228
+ material={materials.material_Material_kuka_orange}
229
+ />
230
+ <mesh
231
+ name="visuals001_3"
232
+ castShadow
233
+ receiveShadow
234
+ geometry={nodes.visuals001_3.geometry}
235
+ material={materials.material_Material_rubber}
236
+ />
237
+ <mesh
238
+ name="visuals001_4"
239
+ castShadow
240
+ receiveShadow
241
+ geometry={nodes.visuals001_4.geometry}
242
+ material={materials.material_Material_metal_black}
243
+ />
244
+ <mesh
245
+ name="visuals001_5"
246
+ castShadow
247
+ receiveShadow
248
+ geometry={nodes.visuals001_5.geometry}
249
+ material={materials.material_Material_aluminium}
250
+ />
251
+ <mesh
252
+ name="visuals001_6"
253
+ castShadow
254
+ receiveShadow
255
+ geometry={nodes.visuals001_6.geometry}
256
+ material={materials.material_Material_rubber_black}
257
+ />
258
+ <mesh
259
+ name="visuals001_7"
260
+ castShadow
261
+ receiveShadow
262
+ geometry={nodes.visuals001_7.geometry}
263
+ material={materials.material_Material_stainless_steel}
264
+ />
265
+ </group>
266
+ </group>
267
+ </animated.group>
268
+ <group name="link_0">
269
+ <group name="visuals">
270
+ <mesh
271
+ name="visuals_1"
272
+ castShadow
273
+ receiveShadow
274
+ geometry={nodes.visuals_1.geometry}
275
+ material={materials.material_Material_kuka_black}
276
+ />
277
+ <mesh
278
+ name="visuals_2"
279
+ castShadow
280
+ receiveShadow
281
+ geometry={nodes.visuals_2.geometry}
282
+ material={materials.material_Material_metal_black}
283
+ />
284
+ </group>
285
+ </group>
286
+ </group>
287
+ </group>
288
+ </group>
289
+ </>
290
+ )
291
+ }
@@ -0,0 +1,244 @@
1
+ import { useGLTF } from "@react-three/drei"
2
+ import type * as THREE from "three"
3
+ import type { RobotProps } from "./SupportedRobot"
4
+ import { animated } from "@react-spring/three"
5
+ import RobotAnimator from "./RobotAnimator"
6
+
7
+ export function KUKA_KR270_R2700({
8
+ modelURL,
9
+ connectedMotionGroup,
10
+ ...props
11
+ }: RobotProps) {
12
+ const gltf = useGLTF(modelURL) as any
13
+
14
+ const nodes = gltf.nodes
15
+ const materials = gltf.materials
16
+
17
+ const rotationOffsets = [0, 0, -Math.PI / 2, 0, 0, 0]
18
+
19
+ function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
20
+ jointObjects.forEach(
21
+ (object, index) =>
22
+ (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
23
+ )
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <RobotAnimator
29
+ connectedMotionGroup={connectedMotionGroup}
30
+ robotRootObjectName="Scene"
31
+ onRotationChanged={setRotation}
32
+ />
33
+ <group {...props} dispose={null}>
34
+ <group name="Scene">
35
+ <group name="kuka_kr270_2700_ultra">
36
+ <animated.group name="joint_01">
37
+ <animated.group
38
+ name="joint_02"
39
+ position={[0.35, 0.675, 0]}
40
+ rotation={[-Math.PI / 2, 0, 0]}
41
+ >
42
+ <animated.group
43
+ name="joint_03"
44
+ position={[1.15, 0, 0]}
45
+ rotation={[0, -Math.PI / 2, 0]}
46
+ >
47
+ <animated.group
48
+ name="joint_04"
49
+ position={[-0.041, 0, 0]}
50
+ rotation={[Math.PI / 2, 0, 0]}
51
+ >
52
+ <animated.group
53
+ name="joint_05"
54
+ position={[0, -1.2, 0]}
55
+ rotation={[-Math.PI / 2, 0, 0]}
56
+ >
57
+ <animated.group
58
+ name="joint_06"
59
+ rotation={[Math.PI / 2, 0, 0]}
60
+ >
61
+ <group
62
+ name="flange"
63
+ position={[0, -0.24, 0]}
64
+ rotation={[-Math.PI, 0, 0]}
65
+ />
66
+ <group
67
+ name="link_6"
68
+ position={[0, -0.213, 0]}
69
+ rotation={[0, 0, -Math.PI / 2]}
70
+ >
71
+ <group name="visuals006">
72
+ <mesh
73
+ name="visuals006_1"
74
+ castShadow
75
+ receiveShadow
76
+ geometry={nodes.visuals006_1.geometry}
77
+ material={materials.material_Material_Farbe__1_}
78
+ />
79
+ <mesh
80
+ name="visuals006_2"
81
+ castShadow
82
+ receiveShadow
83
+ geometry={nodes.visuals006_2.geometry}
84
+ material={materials.material_Material_Metall}
85
+ />
86
+ </group>
87
+ </group>
88
+ </animated.group>
89
+ <group
90
+ name="link_5"
91
+ position={[0, 0.044, 0]}
92
+ rotation={[Math.PI / 2, 0, -Math.PI / 2]}
93
+ >
94
+ <mesh
95
+ name="visuals005"
96
+ castShadow
97
+ receiveShadow
98
+ geometry={nodes.visuals005.geometry}
99
+ material={materials.material_Material_Farbe}
100
+ />
101
+ </group>
102
+ </animated.group>
103
+ <group
104
+ name="link_4"
105
+ position={[0, -0.954, 0]}
106
+ rotation={[0, 0, -Math.PI / 2]}
107
+ >
108
+ <mesh
109
+ name="visuals004"
110
+ castShadow
111
+ receiveShadow
112
+ geometry={nodes.visuals004.geometry}
113
+ material={materials.material_Material_Farbe}
114
+ />
115
+ </group>
116
+ </animated.group>
117
+ <group
118
+ name="link_3"
119
+ position={[0, -0.178, 0]}
120
+ rotation={[Math.PI / 2, 0, -Math.PI / 2]}
121
+ >
122
+ <group name="visuals003">
123
+ <mesh
124
+ name="visuals003_1"
125
+ castShadow
126
+ receiveShadow
127
+ geometry={nodes.visuals003_1.geometry}
128
+ material={materials.material_Material_Farbe__1_}
129
+ />
130
+ <mesh
131
+ name="visuals003_2"
132
+ castShadow
133
+ receiveShadow
134
+ geometry={nodes.visuals003_2.geometry}
135
+ material={materials.material_Material_Farbe__2_}
136
+ />
137
+ <mesh
138
+ name="visuals003_3"
139
+ castShadow
140
+ receiveShadow
141
+ geometry={nodes.visuals003_3.geometry}
142
+ material={materials.material_Material_Metall}
143
+ />
144
+ <mesh
145
+ name="visuals003_4"
146
+ castShadow
147
+ receiveShadow
148
+ geometry={nodes.visuals003_4.geometry}
149
+ material={materials.material_Material_Farbe}
150
+ />
151
+ </group>
152
+ </group>
153
+ </animated.group>
154
+ <group name="link_2" rotation={[Math.PI / 2, 0, 0]}>
155
+ <group name="visuals002">
156
+ <mesh
157
+ name="visuals002_1"
158
+ castShadow
159
+ receiveShadow
160
+ geometry={nodes.visuals002_1.geometry}
161
+ material={materials.material_Material_Farbe}
162
+ />
163
+ <mesh
164
+ name="visuals002_2"
165
+ castShadow
166
+ receiveShadow
167
+ geometry={nodes.visuals002_2.geometry}
168
+ material={materials.material_Material_Farbe__1_}
169
+ />
170
+ <mesh
171
+ name="visuals002_3"
172
+ castShadow
173
+ receiveShadow
174
+ geometry={nodes.visuals002_3.geometry}
175
+ material={materials.material_Material_Metall}
176
+ />
177
+ <mesh
178
+ name="visuals002_4"
179
+ castShadow
180
+ receiveShadow
181
+ geometry={nodes.visuals002_4.geometry}
182
+ material={materials.material_Material_Farbe__2_}
183
+ />
184
+ </group>
185
+ </group>
186
+ </animated.group>
187
+ <group name="link_1" position={[0, 0.226, 0]}>
188
+ <group name="visuals001">
189
+ <mesh
190
+ name="visuals001_1"
191
+ castShadow
192
+ receiveShadow
193
+ geometry={nodes.visuals001_1.geometry}
194
+ material={materials.material_Material_Metall}
195
+ />
196
+ <mesh
197
+ name="visuals001_2"
198
+ castShadow
199
+ receiveShadow
200
+ geometry={nodes.visuals001_2.geometry}
201
+ material={materials.material_Material_Farbe__1_}
202
+ />
203
+ <mesh
204
+ name="visuals001_3"
205
+ castShadow
206
+ receiveShadow
207
+ geometry={nodes.visuals001_3.geometry}
208
+ material={materials.material_Material_Farbe__2_}
209
+ />
210
+ <mesh
211
+ name="visuals001_4"
212
+ castShadow
213
+ receiveShadow
214
+ geometry={nodes.visuals001_4.geometry}
215
+ material={materials.material_Material_Farbe}
216
+ />
217
+ </group>
218
+ </group>
219
+ </animated.group>
220
+ <group name="link_0-base">
221
+ <group name="joint_1" />
222
+ <group name="visuals">
223
+ <mesh
224
+ name="visuals_1"
225
+ castShadow
226
+ receiveShadow
227
+ geometry={nodes.visuals_1.geometry}
228
+ material={materials.material_Material_Metall}
229
+ />
230
+ <mesh
231
+ name="visuals_2"
232
+ castShadow
233
+ receiveShadow
234
+ geometry={nodes.visuals_2.geometry}
235
+ material={materials.material_Material_Farbe__1_}
236
+ />
237
+ </group>
238
+ </group>
239
+ </group>
240
+ </group>
241
+ </group>
242
+ </>
243
+ )
244
+ }
@@ -0,0 +1,83 @@
1
+ import { useEffect, useRef } from "react"
2
+ import { Globals, useSpring } from "@react-spring/three"
3
+ import { useThree } from "@react-three/fiber"
4
+ import type * as THREE from "three"
5
+ import {
6
+ getAllJointsByName,
7
+ type RobotSceneJoint,
8
+ } from "../utils/robotTreeQuery"
9
+ import type { MotionStreamConnection } from "@wandelbots/wandelbots-js"
10
+ import { useAutorun } from "../utils/hooks"
11
+
12
+ type RobotAnimatorProps = {
13
+ connectedMotionGroup: MotionStreamConnection
14
+ robotRootObjectName: string
15
+ onRotationChanged: (joints: THREE.Object3D[], jointValues: number[]) => void
16
+ jointCollector?: (rootObject: THREE.Object3D) => RobotSceneJoint[]
17
+ }
18
+
19
+ export default function RobotAnimator({
20
+ connectedMotionGroup,
21
+ robotRootObjectName,
22
+ onRotationChanged,
23
+ jointCollector,
24
+ }: RobotAnimatorProps) {
25
+ Globals.assign({ frameLoop: "always" })
26
+ const jointValues = useRef<number[]>([])
27
+ const jointObjects = useRef<THREE.Object3D[]>([])
28
+ const { scene, invalidate } = useThree()
29
+
30
+ useEffect(() => {
31
+ // All robots have a "Scene" object as root
32
+ // From this object the tree is traversed and all joints are extracted (ordered ASC)
33
+ const sceneObject = scene.getObjectByName(robotRootObjectName)
34
+ if (!sceneObject) {
35
+ return
36
+ }
37
+
38
+ jointObjects.current = jointCollector
39
+ ? jointCollector(sceneObject)
40
+ : getAllJointsByName(sceneObject)
41
+
42
+ // Set initial position
43
+ setRotation()
44
+ invalidate()
45
+ }, [])
46
+
47
+ function updateJoints(newJointValues: number[]) {
48
+ jointValues.current = newJointValues
49
+ setSpring.start(Object.assign({}, jointValues.current) as any)
50
+ }
51
+
52
+ function setRotation() {
53
+ const updatedJointValues = jointObjects.current.map((object, objectIndex) =>
54
+ (axisValues as any)[objectIndex].get(),
55
+ )
56
+ onRotationChanged(jointObjects.current, updatedJointValues)
57
+ }
58
+
59
+ useAutorun(() => {
60
+ const newJointValues =
61
+ connectedMotionGroup.rapidlyChangingMotionState.state.joint_position.joints.filter(
62
+ (item) => item !== undefined,
63
+ )
64
+
65
+ requestAnimationFrame(() => updateJoints(newJointValues))
66
+ })
67
+
68
+ const [axisValues, setSpring] = useSpring(() => ({
69
+ ...Object.assign(
70
+ {},
71
+ connectedMotionGroup.rapidlyChangingMotionState.state.joint_position
72
+ .joints,
73
+ ),
74
+ onChange: () => {
75
+ setRotation()
76
+ invalidate()
77
+ },
78
+ onResolve: () => {
79
+ setRotation()
80
+ },
81
+ }))
82
+ return null
83
+ }