@wandelbots/wandelbots-js-react-components 1.17.3 → 1.17.5

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 (95) hide show
  1. package/dist/components/jogging/JoggingActivationRequired.d.ts +9 -0
  2. package/dist/components/jogging/JoggingActivationRequired.d.ts.map +1 -0
  3. package/dist/components/jogging/JoggingCartesianTab.d.ts.map +1 -1
  4. package/dist/components/jogging/JoggingJointTab.d.ts.map +1 -1
  5. package/dist/components/jogging/JoggingPanel.d.ts.map +1 -1
  6. package/dist/components/robots/ABB_1200_07_7.d.ts +7 -2
  7. package/dist/components/robots/ABB_1200_07_7.d.ts.map +1 -1
  8. package/dist/components/robots/DHRobot.d.ts.map +1 -1
  9. package/dist/components/robots/FANUC_ARC_Mate_100iD.d.ts +7 -2
  10. package/dist/components/robots/FANUC_ARC_Mate_100iD.d.ts.map +1 -1
  11. package/dist/components/robots/FANUC_ARC_Mate_120iD.d.ts +7 -2
  12. package/dist/components/robots/FANUC_ARC_Mate_120iD.d.ts.map +1 -1
  13. package/dist/components/robots/FANUC_CRX10iA.d.ts +7 -2
  14. package/dist/components/robots/FANUC_CRX10iA.d.ts.map +1 -1
  15. package/dist/components/robots/FANUC_CRX20iAL.d.ts +7 -2
  16. package/dist/components/robots/FANUC_CRX20iAL.d.ts.map +1 -1
  17. package/dist/components/robots/FANUC_CRX25iA.d.ts +7 -2
  18. package/dist/components/robots/FANUC_CRX25iA.d.ts.map +1 -1
  19. package/dist/components/robots/FANUC_CRX25iAL.d.ts +7 -2
  20. package/dist/components/robots/FANUC_CRX25iAL.d.ts.map +1 -1
  21. package/dist/components/robots/KUKA_KR16_R2010_2.d.ts +7 -2
  22. package/dist/components/robots/KUKA_KR16_R2010_2.d.ts.map +1 -1
  23. package/dist/components/robots/KUKA_KR210_R2700.d.ts +7 -2
  24. package/dist/components/robots/KUKA_KR210_R2700.d.ts.map +1 -1
  25. package/dist/components/robots/KUKA_KR270_R2700.d.ts +7 -2
  26. package/dist/components/robots/KUKA_KR270_R2700.d.ts.map +1 -1
  27. package/dist/components/robots/Robot.d.ts +3 -3
  28. package/dist/components/robots/Robot.d.ts.map +1 -1
  29. package/dist/components/robots/RobotAnimator.d.ts +7 -4
  30. package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
  31. package/dist/components/robots/SupportedRobot.d.ts +1 -5
  32. package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
  33. package/dist/components/robots/UniversalRobots_UR10.d.ts +2 -2
  34. package/dist/components/robots/UniversalRobots_UR10.d.ts.map +1 -1
  35. package/dist/components/robots/UniversalRobots_UR10e.d.ts +2 -2
  36. package/dist/components/robots/UniversalRobots_UR10e.d.ts.map +1 -1
  37. package/dist/components/robots/UniversalRobots_UR3.d.ts +2 -2
  38. package/dist/components/robots/UniversalRobots_UR3.d.ts.map +1 -1
  39. package/dist/components/robots/UniversalRobots_UR3e.d.ts +2 -2
  40. package/dist/components/robots/UniversalRobots_UR3e.d.ts.map +1 -1
  41. package/dist/components/robots/UniversalRobots_UR5.d.ts +2 -2
  42. package/dist/components/robots/UniversalRobots_UR5.d.ts.map +1 -1
  43. package/dist/components/robots/UniversalRobots_UR5e.d.ts +2 -2
  44. package/dist/components/robots/UniversalRobots_UR5e.d.ts.map +1 -1
  45. package/dist/components/robots/Yaskawa_AR1440.d.ts +8 -2
  46. package/dist/components/robots/Yaskawa_AR1440.d.ts.map +1 -1
  47. package/dist/components/robots/Yaskawa_AR1730.d.ts +8 -2
  48. package/dist/components/robots/Yaskawa_AR1730.d.ts.map +1 -1
  49. package/dist/components/robots/Yaskawa_AR2010.d.ts +8 -2
  50. package/dist/components/robots/Yaskawa_AR2010.d.ts.map +1 -1
  51. package/dist/components/robots/Yaskawa_AR3120.d.ts +8 -2
  52. package/dist/components/robots/Yaskawa_AR3120.d.ts.map +1 -1
  53. package/dist/components/robots/Yaskawa_AR900.d.ts +7 -2
  54. package/dist/components/robots/Yaskawa_AR900.d.ts.map +1 -1
  55. package/dist/components/robots/Yaskawa_GP50.d.ts +7 -2
  56. package/dist/components/robots/Yaskawa_GP50.d.ts.map +1 -1
  57. package/dist/components/robots/types.d.ts +17 -0
  58. package/dist/components/robots/types.d.ts.map +1 -0
  59. package/dist/index.cjs +32 -32
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.js +9370 -9717
  62. package/dist/index.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/components/TransparentOverlay.tsx +2 -2
  65. package/src/components/jogging/JoggingActivationRequired.tsx +46 -0
  66. package/src/components/jogging/JoggingCartesianTab.tsx +84 -79
  67. package/src/components/jogging/JoggingJointTab.tsx +66 -61
  68. package/src/components/jogging/JoggingPanel.tsx +1 -32
  69. package/src/components/robots/ABB_1200_07_7.tsx +7 -22
  70. package/src/components/robots/DHRobot.tsx +34 -33
  71. package/src/components/robots/FANUC_ARC_Mate_100iD.tsx +7 -22
  72. package/src/components/robots/FANUC_ARC_Mate_120iD.tsx +7 -22
  73. package/src/components/robots/FANUC_CRX10iA.tsx +7 -22
  74. package/src/components/robots/FANUC_CRX20iAL.tsx +7 -22
  75. package/src/components/robots/FANUC_CRX25iA.tsx +7 -22
  76. package/src/components/robots/FANUC_CRX25iAL.tsx +7 -22
  77. package/src/components/robots/KUKA_KR16_R2010_2.tsx +19 -34
  78. package/src/components/robots/KUKA_KR210_R2700.tsx +7 -23
  79. package/src/components/robots/KUKA_KR270_R2700.tsx +7 -23
  80. package/src/components/robots/Robot.tsx +3 -3
  81. package/src/components/robots/RobotAnimator.tsx +32 -21
  82. package/src/components/robots/SupportedRobot.tsx +93 -103
  83. package/src/components/robots/UniversalRobots_UR10.tsx +3 -20
  84. package/src/components/robots/UniversalRobots_UR10e.tsx +2 -19
  85. package/src/components/robots/UniversalRobots_UR3.tsx +2 -19
  86. package/src/components/robots/UniversalRobots_UR3e.tsx +3 -20
  87. package/src/components/robots/UniversalRobots_UR5.tsx +3 -20
  88. package/src/components/robots/UniversalRobots_UR5e.tsx +3 -20
  89. package/src/components/robots/Yaskawa_AR1440.tsx +8 -24
  90. package/src/components/robots/Yaskawa_AR1730.tsx +8 -24
  91. package/src/components/robots/Yaskawa_AR2010.tsx +8 -24
  92. package/src/components/robots/Yaskawa_AR3120.tsx +8 -24
  93. package/src/components/robots/Yaskawa_AR900.tsx +7 -22
  94. package/src/components/robots/Yaskawa_GP50.tsx +7 -24
  95. package/src/components/robots/types.ts +19 -0
@@ -1,33 +1,18 @@
1
- import { useGLTF } from "@react-three/drei"
2
- import type * as THREE from "three"
3
- import type { RobotProps } from "./SupportedRobot"
4
- import RobotAnimator from "./RobotAnimator"
5
1
  import { animated } from "@react-spring/three"
2
+ import { useGLTF } from "@react-three/drei"
3
+ import type { RobotModelProps } from "./types"
6
4
 
7
- export function FANUC_ARC_Mate_120iD({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
5
+ FANUC_ARC_Mate_120iD.config = {
6
+ rotationOffsets: [0, Math.PI / 2, 0, 0, 0, 0],
7
+ }
8
+
9
+ export function FANUC_ARC_Mate_120iD({ modelURL, ...props }: RobotModelProps) {
12
10
  const gltf = useGLTF(modelURL) as any
13
11
  const nodes = gltf.nodes
14
12
  const materials = gltf.materials
15
- const rotationOffsets = [0, Math.PI / 2, 0, 0, 0, 0]
16
-
17
- function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
18
- jointObjects.forEach(
19
- (object, index) =>
20
- (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
21
- )
22
- }
23
13
 
24
14
  return (
25
15
  <>
26
- <RobotAnimator
27
- rapidlyChangingMotionState={rapidlyChangingMotionState}
28
- robotRootObjectName="Scene"
29
- onRotationChanged={setRotation}
30
- />
31
16
  <group {...props} dispose={null}>
32
17
  <group name="Scene">
33
18
  <group name="M10iD" rotation={[0, 0, 0]}>
@@ -1,33 +1,18 @@
1
- import { useGLTF } from "@react-three/drei"
2
- import type * as THREE from "three"
3
- import type { RobotProps } from "./SupportedRobot"
4
- import RobotAnimator from "./RobotAnimator"
5
1
  import { animated } from "@react-spring/three"
2
+ import { useGLTF } from "@react-three/drei"
3
+ import type { RobotModelProps } from "./types"
6
4
 
7
- export function FANUC_CRX10iA({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
5
+ FANUC_CRX10iA.config = {
6
+ rotationOffsets: [0, Math.PI / 2, 0, 0, 0, 0],
7
+ }
8
+
9
+ export function FANUC_CRX10iA({ modelURL, ...props }: RobotModelProps) {
12
10
  const gltf = useGLTF(modelURL) as any
13
11
  const nodes = gltf.nodes
14
12
  const materials = gltf.materials
15
- const rotationOffsets = [0, Math.PI / 2, 0, 0, 0, 0]
16
-
17
- function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
18
- jointObjects.forEach(
19
- (object, index) =>
20
- (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
21
- )
22
- }
23
13
 
24
14
  return (
25
15
  <>
26
- <RobotAnimator
27
- rapidlyChangingMotionState={rapidlyChangingMotionState}
28
- robotRootObjectName="Scene"
29
- onRotationChanged={setRotation}
30
- />
31
16
  <group {...props} dispose={null}>
32
17
  <group name="Scene">
33
18
  <animated.group name="CRX10iA_J00">
@@ -1,33 +1,18 @@
1
- import { useGLTF } from "@react-three/drei"
2
- import type * as THREE from "three"
3
- import type { RobotProps } from "./SupportedRobot"
4
1
  import { animated } from "@react-spring/three"
5
- import RobotAnimator from "./RobotAnimator"
2
+ import { useGLTF } from "@react-three/drei"
3
+ import type { RobotModelProps } from "./types"
6
4
 
7
- export function FANUC_CRX20iAL({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
5
+ FANUC_CRX20iAL.config = {
6
+ rotationOffsets: [0, Math.PI / 2, 0, 0, 0, 0],
7
+ }
8
+
9
+ export function FANUC_CRX20iAL({ modelURL, ...props }: RobotModelProps) {
12
10
  const gltf = useGLTF(modelURL) as any
13
11
  const nodes = gltf.nodes
14
12
  const materials = gltf.materials
15
- const rotationOffsets = [0, Math.PI / 2, 0, 0, 0, 0]
16
-
17
- function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
18
- jointObjects.forEach(
19
- (object, index) =>
20
- (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
21
- )
22
- }
23
13
 
24
14
  return (
25
15
  <>
26
- <RobotAnimator
27
- rapidlyChangingMotionState={rapidlyChangingMotionState}
28
- robotRootObjectName="Scene"
29
- onRotationChanged={setRotation}
30
- />
31
16
  <group {...props} dispose={null}>
32
17
  <group name="Scene">
33
18
  <mesh
@@ -1,33 +1,18 @@
1
- import { useGLTF } from "@react-three/drei"
2
- import type * as THREE from "three"
3
- import type { RobotProps } from "./SupportedRobot"
4
1
  import { animated } from "@react-spring/three"
5
- import RobotAnimator from "./RobotAnimator"
2
+ import { useGLTF } from "@react-three/drei"
3
+ import type { RobotModelProps } from "./types"
6
4
 
7
- export function FANUC_CRX25iA({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
5
+ FANUC_CRX25iA.config = {
6
+ rotationOffsets: [0, Math.PI / 2, 0, 0, 0, 0],
7
+ }
8
+
9
+ export function FANUC_CRX25iA({ modelURL, ...props }: RobotModelProps) {
12
10
  const gltf = useGLTF(modelURL) as any
13
11
  const nodes = gltf.nodes
14
12
  const materials = gltf.materials
15
- const rotationOffsets = [0, Math.PI / 2, 0, 0, 0, 0]
16
-
17
- function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
18
- jointObjects.forEach(
19
- (object, index) =>
20
- (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
21
- )
22
- }
23
13
 
24
14
  return (
25
15
  <>
26
- <RobotAnimator
27
- rapidlyChangingMotionState={rapidlyChangingMotionState}
28
- robotRootObjectName="Scene"
29
- onRotationChanged={setRotation}
30
- />
31
16
  <group {...props} dispose={null}>
32
17
  <group name="Scene" position={[0, -0.37, 0]}>
33
18
  <group name="CRX25iA_L00">
@@ -1,33 +1,18 @@
1
- import { useGLTF } from "@react-three/drei"
2
- import type * as THREE from "three"
3
- import type { RobotProps } from "./SupportedRobot"
4
1
  import { animated } from "@react-spring/three"
5
- import RobotAnimator from "./RobotAnimator"
2
+ import { useGLTF } from "@react-three/drei"
3
+ import type { RobotModelProps } from "./types"
6
4
 
7
- export function FANUC_CRX25iAL({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
5
+ FANUC_CRX25iAL.config = {
6
+ rotationOffsets: [0, Math.PI / 2, 0, 0, 0, 0],
7
+ }
8
+
9
+ export function FANUC_CRX25iAL({ modelURL, ...props }: RobotModelProps) {
12
10
  const gltf = useGLTF(modelURL) as any
13
11
  const nodes = gltf.nodes
14
12
  const materials = gltf.materials
15
- const rotationOffsets = [0, Math.PI / 2, 0, 0, 0, 0]
16
-
17
- function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
18
- jointObjects.forEach(
19
- (object, index) =>
20
- (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
21
- )
22
- }
23
13
 
24
14
  return (
25
15
  <>
26
- <RobotAnimator
27
- rapidlyChangingMotionState={rapidlyChangingMotionState}
28
- robotRootObjectName="Scene"
29
- onRotationChanged={setRotation}
30
- />
31
16
  <group {...props} dispose={null}>
32
17
  <group name="Scene">
33
18
  <animated.group name="CRX10iA_J00">
@@ -1,9 +1,8 @@
1
+ import { animated } from "@react-spring/three"
1
2
  import { useGLTF } from "@react-three/drei"
2
3
  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
4
  import type { GLTF } from "three-stdlib"
5
+ import type { RobotModelProps } from "./types"
7
6
 
8
7
  type GLTFResult = GLTF & {
9
8
  nodes: {
@@ -29,29 +28,15 @@ type GLTFResult = GLTF & {
29
28
  }
30
29
  }
31
30
 
32
- export function KUKA_KR16_R2010_2({
33
- modelURL,
34
- rapidlyChangingMotionState,
35
- ...props
36
- }: RobotProps) {
37
- const { nodes, materials } = useGLTF(modelURL) as GLTFResult
38
-
39
- const rotationOffsets = [0, 0, -Math.PI / 2, 0, 0, 0]
31
+ KUKA_KR16_R2010_2.config = {
32
+ rotationOffsets: [0, 0, -Math.PI / 2, 0, 0, 0],
33
+ }
40
34
 
41
- function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
42
- jointObjects.forEach(
43
- (object, index) =>
44
- (object.rotation.y = jointValues[index]! + rotationOffsets[index]!),
45
- )
46
- }
35
+ export function KUKA_KR16_R2010_2({ modelURL, ...props }: RobotModelProps) {
36
+ const { nodes, materials } = useGLTF(modelURL) as GLTFResult
47
37
 
48
38
  return (
49
39
  <>
50
- <RobotAnimator
51
- rapidlyChangingMotionState={rapidlyChangingMotionState}
52
- robotRootObjectName="Scene"
53
- onRotationChanged={setRotation}
54
- />
55
40
  <group {...props} dispose={null}>
56
41
  <group name="Scene">
57
42
  <group name="link_0">
@@ -77,28 +62,28 @@ export function KUKA_KR16_R2010_2({
77
62
  material={materials.material_Material_Metall}
78
63
  />
79
64
  </group>
80
- <group name="KUKA_KR16R2010_2_J00">
81
- <group
65
+ <animated.group name="KUKA_KR16R2010_2_J00">
66
+ <animated.group
82
67
  name="KUKA_KR16R2010_2_J01"
83
68
  position={[0.16, 0.52, 0]}
84
69
  rotation={[-Math.PI / 2, 0, 0]}
85
70
  >
86
- <group
71
+ <animated.group
87
72
  name="KUKA_KR16R2010_2_J02"
88
73
  position={[0.98, 0, 0]}
89
74
  rotation={[0, -Math.PI / 2, 0]}
90
75
  >
91
- <group
76
+ <animated.group
92
77
  name="KUKA_KR16R2010_2_J03"
93
78
  position={[0.15, 0, 0]}
94
79
  rotation={[Math.PI / 2, 0, 0]}
95
80
  >
96
- <group
81
+ <animated.group
97
82
  name="KUKA_KR16R2010_2_J04"
98
83
  position={[0, -0.86, 0]}
99
84
  rotation={[-Math.PI / 2, 0, 0]}
100
85
  >
101
- <group
86
+ <animated.group
102
87
  name="KUKA_KR16R2010_2_J05"
103
88
  rotation={[-Math.PI / 2, 0, -Math.PI]}
104
89
  >
@@ -111,7 +96,7 @@ export function KUKA_KR16_R2010_2({
111
96
  position={[0.67, 2, 0]}
112
97
  rotation={[-Math.PI, 0, Math.PI / 2]}
113
98
  />
114
- </group>
99
+ </animated.group>
115
100
  <mesh
116
101
  name="link_5"
117
102
  castShadow
@@ -121,7 +106,7 @@ export function KUKA_KR16_R2010_2({
121
106
  position={[-0.67, 0, 2]}
122
107
  rotation={[Math.PI / 2, 0, -Math.PI / 2]}
123
108
  />
124
- </group>
109
+ </animated.group>
125
110
  <mesh
126
111
  name="link_4"
127
112
  castShadow
@@ -131,7 +116,7 @@ export function KUKA_KR16_R2010_2({
131
116
  position={[-0.67, 1.14, 0]}
132
117
  rotation={[0, 0, -Math.PI / 2]}
133
118
  />
134
- </group>
119
+ </animated.group>
135
120
  <group
136
121
  name="link_3"
137
122
  position={[-0.52, 0, 1.14]}
@@ -159,7 +144,7 @@ export function KUKA_KR16_R2010_2({
159
144
  material={materials.material_Material_Farbe__2_}
160
145
  />
161
146
  </group>
162
- </group>
147
+ </animated.group>
163
148
  <group
164
149
  name="link_2"
165
150
  position={[-0.16, 0, -0.52]}
@@ -180,7 +165,7 @@ export function KUKA_KR16_R2010_2({
180
165
  material={materials.material_Material_Metall}
181
166
  />
182
167
  </group>
183
- </group>
168
+ </animated.group>
184
169
  <group name="link_1">
185
170
  <mesh
186
171
  name="visuals_1"
@@ -204,7 +189,7 @@ export function KUKA_KR16_R2010_2({
204
189
  material={materials.material_Material_Metall}
205
190
  />
206
191
  </group>
207
- </group>
192
+ </animated.group>
208
193
  </group>
209
194
  </group>
210
195
  </>
@@ -1,35 +1,19 @@
1
- import { useGLTF } from "@react-three/drei"
2
- import type * as THREE from "three"
3
- import type { RobotProps } from "./SupportedRobot"
4
1
  import { animated } from "@react-spring/three"
5
- import RobotAnimator from "./RobotAnimator"
2
+ import { useGLTF } from "@react-three/drei"
3
+ import type { RobotModelProps } from "./types"
4
+
5
+ KUKA_KR210_R2700.config = {
6
+ rotationOffsets: [0, 0, -Math.PI / 2, 0, 0, 0],
7
+ }
6
8
 
7
- export function KUKA_KR210_R2700({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
9
+ export function KUKA_KR210_R2700({ modelURL, ...props }: RobotModelProps) {
12
10
  const gltf = useGLTF(modelURL) as any
13
11
 
14
12
  const nodes = gltf.nodes
15
13
  const materials = gltf.materials
16
14
 
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
15
  return (
27
16
  <>
28
- <RobotAnimator
29
- rapidlyChangingMotionState={rapidlyChangingMotionState}
30
- robotRootObjectName="Scene"
31
- onRotationChanged={setRotation}
32
- />
33
17
  <group {...props} dispose={null}>
34
18
  <group name="Scene">
35
19
  <group name="kuka_kr210_2700">
@@ -1,35 +1,19 @@
1
- import { useGLTF } from "@react-three/drei"
2
- import type * as THREE from "three"
3
- import type { RobotProps } from "./SupportedRobot"
4
1
  import { animated } from "@react-spring/three"
5
- import RobotAnimator from "./RobotAnimator"
2
+ import { useGLTF } from "@react-three/drei"
3
+ import type { RobotModelProps } from "./types"
4
+
5
+ KUKA_KR270_R2700.config = {
6
+ rotationOffsets: [0, 0, -Math.PI / 2, 0, 0, 0],
7
+ }
6
8
 
7
- export function KUKA_KR270_R2700({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
9
+ export function KUKA_KR270_R2700({ modelURL, ...props }: RobotModelProps) {
12
10
  const gltf = useGLTF(modelURL) as any
13
11
 
14
12
  const nodes = gltf.nodes
15
13
  const materials = gltf.materials
16
14
 
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
15
  return (
27
16
  <>
28
- <RobotAnimator
29
- rapidlyChangingMotionState={rapidlyChangingMotionState}
30
- robotRootObjectName="Scene"
31
- onRotationChanged={setRotation}
32
- />
33
17
  <group {...props} dispose={null}>
34
18
  <group name="Scene">
35
19
  <animated.group name="joint_01">
@@ -3,7 +3,7 @@ import { type GroupProps } from "@react-three/fiber"
3
3
  import type { ConnectedMotionGroup } from "@wandelbots/wandelbots-js"
4
4
  import { defaultGetModel, SupportedRobot } from "./SupportedRobot"
5
5
 
6
- export type ConnectecMotionGroupRobotProps = {
6
+ export type RobotProps = {
7
7
  connectedMotionGroup: ConnectedMotionGroup
8
8
  getModel?: (modelFromController: string) => string
9
9
  isGhost?: boolean
@@ -13,7 +13,7 @@ export type ConnectecMotionGroupRobotProps = {
13
13
  * The Robot component is a wrapper around the SupportedRobot component
14
14
  * for usage with @wandelbots/wandelbots-js ConnectedMotionGroup object.
15
15
  *
16
- * @param {ConnectecMotionGroupRobotProps} props - The properties for the Robot component.
16
+ * @param {RobotProps} props - The properties for the Robot component.
17
17
  * @param {ConnectedMotionGroup} props.connectedMotionGroup - The connected motion group containing motion state and parameters.
18
18
  * @param {Function} [props.getModel=defaultGetModel] - Optional function to get the model URL. Defaults to defaultGetModel.
19
19
  * @param {Object} props - Additional properties passed to the SupportedRobot component.
@@ -25,7 +25,7 @@ export function Robot({
25
25
  getModel = defaultGetModel,
26
26
  isGhost = false,
27
27
  ...props
28
- }: ConnectecMotionGroupRobotProps) {
28
+ }: RobotProps) {
29
29
  if (!connectedMotionGroup.dhParameters) {
30
30
  return null
31
31
  }
@@ -1,59 +1,69 @@
1
- import { useEffect, useRef } from "react"
2
1
  import { Globals, useSpring } from "@react-spring/three"
3
2
  import { useThree } from "@react-three/fiber"
3
+ import type { MotionGroupStateResponse } from "@wandelbots/wandelbots-api-client"
4
+ import React, { useRef } from "react"
4
5
  import type * as THREE from "three"
6
+ import { useAutorun } from "../utils/hooks"
5
7
  import {
6
8
  getAllJointsByName,
7
9
  type RobotSceneJoint,
8
10
  } from "../utils/robotTreeQuery"
9
- import type { MotionGroupStateResponse } from "@wandelbots/wandelbots-api-client"
10
- import { useAutorun } from "../utils/hooks"
11
+ import type { RobotModelConfig } from "./types"
11
12
 
12
13
  type RobotAnimatorProps = {
13
14
  rapidlyChangingMotionState: MotionGroupStateResponse
14
- robotRootObjectName: string
15
- onRotationChanged: (joints: THREE.Object3D[], jointValues: number[]) => void
15
+ onRotationChanged?: (joints: THREE.Object3D[], jointValues: number[]) => void
16
16
  jointCollector?: (rootObject: THREE.Object3D) => RobotSceneJoint[]
17
+ robotConfig?: RobotModelConfig
18
+ children: React.ReactNode
17
19
  }
18
20
 
19
21
  export default function RobotAnimator({
20
22
  rapidlyChangingMotionState,
21
- robotRootObjectName,
22
- onRotationChanged,
23
23
  jointCollector,
24
+ onRotationChanged,
25
+ robotConfig,
26
+ children,
24
27
  }: RobotAnimatorProps) {
25
28
  Globals.assign({ frameLoop: "always" })
26
29
  const jointValues = useRef<number[]>([])
27
30
  const jointObjects = useRef<THREE.Object3D[]>([])
28
- const { scene, invalidate } = useThree()
31
+ const { invalidate } = useThree()
29
32
 
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
- }
33
+ function setGroupRef(group: THREE.Group | null) {
34
+ if (!group) return
37
35
 
38
36
  jointObjects.current = jointCollector
39
- ? jointCollector(sceneObject)
40
- : getAllJointsByName(sceneObject)
37
+ ? jointCollector(group)
38
+ : getAllJointsByName(group)
41
39
 
42
40
  // Set initial position
43
41
  setRotation()
44
42
  invalidate()
45
- }, [])
43
+ }
46
44
 
47
45
  function updateJoints(newJointValues: number[]) {
48
46
  jointValues.current = newJointValues
49
47
  setSpring.start(Object.assign({}, jointValues.current) as any)
50
48
  }
51
49
 
50
+ const rotationSign = robotConfig?.rotationSign || [1, 1, 1, 1, 1, 1]
51
+ const rotationOffsets = robotConfig?.rotationOffsets || [0, 0, 0, 0, 0, 0]
52
+
52
53
  function setRotation() {
53
- const updatedJointValues = jointObjects.current.map((object, objectIndex) =>
54
+ const updatedJointValues = jointObjects.current.map((_, objectIndex) =>
54
55
  (axisValues as any)[objectIndex].get(),
55
56
  )
56
- onRotationChanged(jointObjects.current, updatedJointValues)
57
+
58
+ if (onRotationChanged) {
59
+ onRotationChanged(jointObjects.current, updatedJointValues)
60
+ } else {
61
+ for (const [index, object] of jointObjects.current.entries()) {
62
+ object.rotation.y =
63
+ rotationSign[index]! * updatedJointValues[index]! +
64
+ rotationOffsets[index]!
65
+ }
66
+ }
57
67
  }
58
68
 
59
69
  useAutorun(() => {
@@ -78,5 +88,6 @@ export default function RobotAnimator({
78
88
  setRotation()
79
89
  },
80
90
  }))
81
- return null
91
+
92
+ return <group ref={setGroupRef}>{children}</group>
82
93
  }