@wandelbots/wandelbots-js-react-components 1.17.2 → 1.17.4

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 (99) hide show
  1. package/dist/components/jogging/JoggingCartesianTab.d.ts.map +1 -1
  2. package/dist/components/jogging/JoggingJointLimitDetector.d.ts +1 -1
  3. package/dist/components/jogging/JoggingJointLimitDetector.d.ts.map +1 -1
  4. package/dist/components/jogging/JoggingPanel.d.ts +1 -1
  5. package/dist/components/jogging/JoggingPanel.d.ts.map +1 -1
  6. package/dist/components/jogging/JoggingVelocitySlider.d.ts.map +1 -1
  7. package/dist/components/robots/ABB_1200_07_7.d.ts +7 -2
  8. package/dist/components/robots/ABB_1200_07_7.d.ts.map +1 -1
  9. package/dist/components/robots/DHRobot.d.ts.map +1 -1
  10. package/dist/components/robots/FANUC_ARC_Mate_100iD.d.ts +7 -2
  11. package/dist/components/robots/FANUC_ARC_Mate_100iD.d.ts.map +1 -1
  12. package/dist/components/robots/FANUC_ARC_Mate_120iD.d.ts +7 -2
  13. package/dist/components/robots/FANUC_ARC_Mate_120iD.d.ts.map +1 -1
  14. package/dist/components/robots/FANUC_CRX10iA.d.ts +7 -2
  15. package/dist/components/robots/FANUC_CRX10iA.d.ts.map +1 -1
  16. package/dist/components/robots/FANUC_CRX20iAL.d.ts +7 -2
  17. package/dist/components/robots/FANUC_CRX20iAL.d.ts.map +1 -1
  18. package/dist/components/robots/FANUC_CRX25iA.d.ts +7 -2
  19. package/dist/components/robots/FANUC_CRX25iA.d.ts.map +1 -1
  20. package/dist/components/robots/FANUC_CRX25iAL.d.ts +7 -2
  21. package/dist/components/robots/FANUC_CRX25iAL.d.ts.map +1 -1
  22. package/dist/components/robots/KUKA_KR16_R2010_2.d.ts +7 -2
  23. package/dist/components/robots/KUKA_KR16_R2010_2.d.ts.map +1 -1
  24. package/dist/components/robots/KUKA_KR210_R2700.d.ts +7 -2
  25. package/dist/components/robots/KUKA_KR210_R2700.d.ts.map +1 -1
  26. package/dist/components/robots/KUKA_KR270_R2700.d.ts +7 -2
  27. package/dist/components/robots/KUKA_KR270_R2700.d.ts.map +1 -1
  28. package/dist/components/robots/Robot.d.ts +3 -3
  29. package/dist/components/robots/Robot.d.ts.map +1 -1
  30. package/dist/components/robots/RobotAnimator.d.ts +7 -4
  31. package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
  32. package/dist/components/robots/SupportedRobot.d.ts +1 -5
  33. package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
  34. package/dist/components/robots/UniversalRobots_UR10.d.ts +2 -2
  35. package/dist/components/robots/UniversalRobots_UR10.d.ts.map +1 -1
  36. package/dist/components/robots/UniversalRobots_UR10e.d.ts +2 -2
  37. package/dist/components/robots/UniversalRobots_UR10e.d.ts.map +1 -1
  38. package/dist/components/robots/UniversalRobots_UR3.d.ts +2 -2
  39. package/dist/components/robots/UniversalRobots_UR3.d.ts.map +1 -1
  40. package/dist/components/robots/UniversalRobots_UR3e.d.ts +2 -2
  41. package/dist/components/robots/UniversalRobots_UR3e.d.ts.map +1 -1
  42. package/dist/components/robots/UniversalRobots_UR5.d.ts +2 -2
  43. package/dist/components/robots/UniversalRobots_UR5.d.ts.map +1 -1
  44. package/dist/components/robots/UniversalRobots_UR5e.d.ts +2 -2
  45. package/dist/components/robots/UniversalRobots_UR5e.d.ts.map +1 -1
  46. package/dist/components/robots/Yaskawa_AR1440.d.ts +8 -2
  47. package/dist/components/robots/Yaskawa_AR1440.d.ts.map +1 -1
  48. package/dist/components/robots/Yaskawa_AR1730.d.ts +8 -2
  49. package/dist/components/robots/Yaskawa_AR1730.d.ts.map +1 -1
  50. package/dist/components/robots/Yaskawa_AR2010.d.ts +8 -2
  51. package/dist/components/robots/Yaskawa_AR2010.d.ts.map +1 -1
  52. package/dist/components/robots/Yaskawa_AR3120.d.ts +8 -2
  53. package/dist/components/robots/Yaskawa_AR3120.d.ts.map +1 -1
  54. package/dist/components/robots/Yaskawa_AR900.d.ts +7 -2
  55. package/dist/components/robots/Yaskawa_AR900.d.ts.map +1 -1
  56. package/dist/components/robots/Yaskawa_GP50.d.ts +7 -2
  57. package/dist/components/robots/Yaskawa_GP50.d.ts.map +1 -1
  58. package/dist/components/robots/types.d.ts +17 -0
  59. package/dist/components/robots/types.d.ts.map +1 -0
  60. package/dist/i18n/config.d.ts.map +1 -1
  61. package/dist/index.cjs +32 -32
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.js +9706 -10063
  64. package/dist/index.js.map +1 -1
  65. package/package.json +1 -1
  66. package/src/components/jogging/JoggingCartesianTab.tsx +11 -11
  67. package/src/components/jogging/JoggingJointLimitDetector.tsx +9 -8
  68. package/src/components/jogging/JoggingPanel.tsx +8 -10
  69. package/src/components/jogging/JoggingVelocitySlider.tsx +4 -5
  70. package/src/components/robots/ABB_1200_07_7.tsx +7 -22
  71. package/src/components/robots/DHRobot.tsx +34 -33
  72. package/src/components/robots/FANUC_ARC_Mate_100iD.tsx +7 -22
  73. package/src/components/robots/FANUC_ARC_Mate_120iD.tsx +7 -22
  74. package/src/components/robots/FANUC_CRX10iA.tsx +7 -22
  75. package/src/components/robots/FANUC_CRX20iAL.tsx +7 -22
  76. package/src/components/robots/FANUC_CRX25iA.tsx +7 -22
  77. package/src/components/robots/FANUC_CRX25iAL.tsx +7 -22
  78. package/src/components/robots/KUKA_KR16_R2010_2.tsx +19 -34
  79. package/src/components/robots/KUKA_KR210_R2700.tsx +7 -23
  80. package/src/components/robots/KUKA_KR270_R2700.tsx +7 -23
  81. package/src/components/robots/Robot.tsx +3 -3
  82. package/src/components/robots/RobotAnimator.tsx +32 -21
  83. package/src/components/robots/SupportedRobot.tsx +93 -103
  84. package/src/components/robots/UniversalRobots_UR10.tsx +3 -20
  85. package/src/components/robots/UniversalRobots_UR10e.tsx +2 -19
  86. package/src/components/robots/UniversalRobots_UR3.tsx +2 -19
  87. package/src/components/robots/UniversalRobots_UR3e.tsx +3 -20
  88. package/src/components/robots/UniversalRobots_UR5.tsx +3 -20
  89. package/src/components/robots/UniversalRobots_UR5e.tsx +3 -20
  90. package/src/components/robots/Yaskawa_AR1440.tsx +8 -24
  91. package/src/components/robots/Yaskawa_AR1730.tsx +8 -24
  92. package/src/components/robots/Yaskawa_AR2010.tsx +8 -24
  93. package/src/components/robots/Yaskawa_AR3120.tsx +8 -24
  94. package/src/components/robots/Yaskawa_AR900.tsx +7 -22
  95. package/src/components/robots/Yaskawa_GP50.tsx +7 -24
  96. package/src/components/robots/types.ts +19 -0
  97. package/src/i18n/config.ts +15 -19
  98. package/src/i18n/locales/de/translations.json +2 -1
  99. package/src/i18n/locales/en/translations.json +2 -1
@@ -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
  }
@@ -1,50 +1,47 @@
1
1
  import { Suspense, useCallback, useEffect, useRef } from "react"
2
2
 
3
+ import { ABB_1200_07_7 } from "./ABB_1200_07_7"
4
+ import { FANUC_ARC_Mate_100iD } from "./FANUC_ARC_Mate_100iD"
5
+ import { FANUC_ARC_Mate_120iD } from "./FANUC_ARC_Mate_120iD"
6
+ import { FANUC_CRX10iA } from "./FANUC_CRX10iA"
7
+ import { FANUC_CRX20iAL } from "./FANUC_CRX20iAL"
8
+ import { FANUC_CRX25iA } from "./FANUC_CRX25iA"
9
+ import { FANUC_CRX25iAL } from "./FANUC_CRX25iAL"
10
+ import { KUKA_KR16_R2010_2 } from "./KUKA_KR16_R2010_2"
11
+ import { KUKA_KR210_R2700 } from "./KUKA_KR210_R2700"
12
+ import { KUKA_KR270_R2700 } from "./KUKA_KR270_R2700"
13
+ import { UniversalRobots_UR10 } from "./UniversalRobots_UR10"
14
+ import { UniversalRobots_UR10e } from "./UniversalRobots_UR10e"
3
15
  import { UniversalRobots_UR3 } from "./UniversalRobots_UR3"
4
16
  import { UniversalRobots_UR3e } from "./UniversalRobots_UR3e"
5
17
  import { UniversalRobots_UR5 } from "./UniversalRobots_UR5"
6
18
  import { UniversalRobots_UR5e } from "./UniversalRobots_UR5e"
7
- import { UniversalRobots_UR10 } from "./UniversalRobots_UR10"
8
- import { UniversalRobots_UR10e } from "./UniversalRobots_UR10e"
9
- import { Yaskawa_AR900 } from "./Yaskawa_AR900"
10
19
  import { Yaskawa_AR1440 } from "./Yaskawa_AR1440"
11
20
  import { Yaskawa_AR1730 } from "./Yaskawa_AR1730"
12
21
  import { Yaskawa_AR2010 } from "./Yaskawa_AR2010"
13
22
  import { Yaskawa_AR3120 } from "./Yaskawa_AR3120"
23
+ import { Yaskawa_AR900 } from "./Yaskawa_AR900"
14
24
  import { Yaskawa_GP50 } from "./Yaskawa_GP50"
15
- import { FANUC_CRX10iA } from "./FANUC_CRX10iA"
16
- import { FANUC_CRX20iAL } from "./FANUC_CRX20iAL"
17
- import { FANUC_CRX25iA } from "./FANUC_CRX25iA"
18
- import { FANUC_CRX25iAL } from "./FANUC_CRX25iAL"
19
- import { KUKA_KR210_R2700 } from "./KUKA_KR210_R2700"
20
- import { KUKA_KR270_R2700 } from "./KUKA_KR270_R2700"
21
- import { KUKA_KR16_R2010_2 } from "./KUKA_KR16_R2010_2"
22
- import { FANUC_ARC_Mate_100iD } from "./FANUC_ARC_Mate_100iD"
23
- import { FANUC_ARC_Mate_120iD } from "./FANUC_ARC_Mate_120iD"
24
- import { ABB_1200_07_7 } from "./ABB_1200_07_7"
25
25
 
26
26
  import type { GroupProps } from "@react-three/fiber"
27
27
  import type {
28
- MotionGroupStateResponse,
29
28
  DHParameter,
29
+ MotionGroupStateResponse,
30
30
  } from "@wandelbots/wandelbots-api-client"
31
31
  import { DHRobot } from "./DHRobot"
32
32
 
33
- import * as THREE from "three"
34
33
  import { ErrorBoundary } from "react-error-boundary"
35
- import ConsoleFilter from "../ConsoleFilter"
34
+ import * as THREE from "three"
36
35
  import { externalizeComponent } from "../../externalizeComponent"
36
+ import ConsoleFilter from "../ConsoleFilter"
37
+ import RobotAnimator from "./RobotAnimator"
38
+ import type { RobotModelComponent } from "./types"
37
39
 
38
40
  export type DHRobotProps = {
39
41
  rapidlyChangingMotionState: MotionGroupStateResponse
40
42
  dhParameters: Array<DHParameter>
41
43
  } & GroupProps
42
44
 
43
- export type RobotProps = {
44
- rapidlyChangingMotionState: MotionGroupStateResponse
45
- modelURL: string
46
- } & GroupProps
47
-
48
45
  export type SupportedRobotProps = {
49
46
  rapidlyChangingMotionState: MotionGroupStateResponse
50
47
  modelFromController: string
@@ -66,107 +63,93 @@ export const SupportedRobot = externalizeComponent(
66
63
  isGhost = false,
67
64
  ...props
68
65
  }: SupportedRobotProps) => {
69
- let Robot
66
+ let Robot: RobotModelComponent | null = null
70
67
 
71
- const robotRef = useRef<THREE.Group>(new THREE.Group())
68
+ const robotRef = useRef<THREE.Group>()
72
69
 
73
70
  const setRobotRef = useCallback(
74
71
  (instance: THREE.Group | null) => {
75
- if (instance !== null) {
76
- robotRef.current = instance
77
- console.log("robotRef.current", robotRef.current)
78
- if (
79
- isGhost &&
80
- robotRef.current &&
81
- robotRef.current.children.length > 0
82
- ) {
83
- addGhosts()
84
- }
85
- }
72
+ if (!instance) return
73
+ robotRef.current = instance
74
+
75
+ if (isGhost) applyGhostStyle()
86
76
  },
87
77
  [isGhost],
88
78
  )
89
79
 
90
- const addGhosts = () => {
91
- if (robotRef.current && !robotRef.current.userData.ghostsCreated) {
92
- robotRef.current.traverse((obj) => {
93
- if (obj instanceof THREE.Mesh && !obj.userData.isGhost) {
94
- if (obj.material instanceof THREE.Material) {
95
- obj.material.colorWrite = false
96
- }
80
+ const applyGhostStyle = () => {
81
+ if (!robotRef.current || robotRef.current.userData.isGhost) return
97
82
 
98
- // Create a clone of the mesh
99
- const depth = obj.clone()
100
- const ghost = obj.clone()
83
+ robotRef.current.traverse((obj) => {
84
+ if (obj instanceof THREE.Mesh) {
85
+ if (obj.material instanceof THREE.Material) {
86
+ obj.material.colorWrite = true
87
+ }
88
+
89
+ // Create a clone of the mesh
90
+ const depth = obj.clone()
91
+ const ghost = obj.clone()
101
92
 
102
- depth.material = new THREE.MeshStandardMaterial({
103
- depthTest: true,
104
- depthWrite: true,
105
- colorWrite: false,
106
- polygonOffset: true,
107
- polygonOffsetFactor: 1,
108
- })
109
- depth.userData.isGhost = true
93
+ depth.material = new THREE.MeshStandardMaterial({
94
+ depthTest: true,
95
+ depthWrite: true,
96
+ colorWrite: false,
97
+ polygonOffset: true,
98
+ polygonOffsetFactor: 1,
99
+ })
100
+ depth.userData.isGhost = true
110
101
 
111
- // Set the material for the ghost mesh
112
- ghost.material = new THREE.MeshStandardMaterial({
113
- color: "#D91433",
114
- opacity: 0.3,
115
- depthTest: true,
116
- depthWrite: false,
117
- transparent: true,
118
- polygonOffset: true,
119
- polygonOffsetFactor: -1,
120
- })
121
- ghost.userData.isGhost = true
102
+ // Set the material for the ghost mesh
103
+ ghost.material = new THREE.MeshStandardMaterial({
104
+ color: "#D91433",
105
+ opacity: 0.3,
106
+ depthTest: true,
107
+ depthWrite: false,
108
+ transparent: true,
109
+ polygonOffset: true,
110
+ polygonOffsetFactor: -1,
111
+ })
112
+ ghost.userData.isGhost = true
122
113
 
123
- if (obj.parent) {
124
- obj.parent.add(depth)
125
- obj.parent.add(ghost)
126
- }
114
+ if (obj.parent) {
115
+ obj.parent.add(depth)
116
+ obj.parent.add(ghost)
127
117
  }
128
- })
129
- robotRef.current.userData.ghostsCreated = true
130
- }
118
+ }
119
+ })
120
+
121
+ robotRef.current.userData.isGhost = true
131
122
  }
132
123
 
133
- const removeGhosts = () => {
134
- if (robotRef.current) {
135
- const objectsToRemove: THREE.Object3D[] = []
124
+ const removeGhostStyle = () => {
125
+ if (!robotRef.current || !robotRef.current.userData.isGhost) return
136
126
 
137
- robotRef.current.traverse((obj) => {
138
- if (obj instanceof THREE.Mesh) {
139
- if (obj.material instanceof THREE.Material) {
140
- obj.material.colorWrite = true
141
- }
142
- }
127
+ const objectsToRemove: THREE.Object3D[] = []
143
128
 
144
- if (
145
- obj instanceof THREE.Mesh &&
146
- obj.userData !== undefined &&
147
- obj.userData &&
148
- obj.userData.isGhost !== undefined &&
149
- obj.userData.isGhost
150
- ) {
129
+ robotRef.current.traverse((obj) => {
130
+ if (obj instanceof THREE.Mesh) {
131
+ if (obj.userData?.isGhost) {
151
132
  objectsToRemove.push(obj)
133
+ } else if (obj.material instanceof THREE.Material) {
134
+ obj.material.colorWrite = true
152
135
  }
153
- })
136
+ }
137
+ })
154
138
 
155
- objectsToRemove.forEach((obj) => {
156
- if (obj.parent) {
157
- obj.parent.remove(obj)
158
- }
159
- })
139
+ objectsToRemove.forEach((obj) => {
140
+ if (obj.parent) {
141
+ obj.parent.remove(obj)
142
+ }
143
+ })
160
144
 
161
- robotRef.current.userData.ghostsCreated = false
162
- }
145
+ robotRef.current.userData.isGhost = true
163
146
  }
164
147
 
165
148
  useEffect(() => {
166
149
  if (isGhost) {
167
- addGhosts()
150
+ applyGhostStyle()
168
151
  } else {
169
- removeGhosts()
152
+ removeGhostStyle()
170
153
  }
171
154
  }, [isGhost])
172
155
 
@@ -245,7 +228,7 @@ export const SupportedRobot = externalizeComponent(
245
228
  break
246
229
  default:
247
230
  console.warn(`Unknown robot type: ${modelFromController}`)
248
- Robot = DHRobot
231
+ Robot = null
249
232
  }
250
233
 
251
234
  return (
@@ -268,12 +251,19 @@ export const SupportedRobot = externalizeComponent(
268
251
  }
269
252
  >
270
253
  <group ref={setRobotRef}>
271
- <Robot
272
- rapidlyChangingMotionState={rapidlyChangingMotionState}
273
- modelURL={getModel(modelFromController)}
274
- dhParameters={dhParameters}
275
- {...props}
276
- />
254
+ {Robot ? (
255
+ <RobotAnimator
256
+ rapidlyChangingMotionState={rapidlyChangingMotionState}
257
+ robotConfig={Robot.config}
258
+ >
259
+ <Robot modelURL={getModel(modelFromController)} {...props} />
260
+ </RobotAnimator>
261
+ ) : (
262
+ <DHRobot
263
+ rapidlyChangingMotionState={rapidlyChangingMotionState}
264
+ dhParameters={dhParameters}
265
+ />
266
+ )}
277
267
  </group>
278
268
  </Suspense>
279
269
  <ConsoleFilter />
@@ -1,31 +1,14 @@
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 UniversalRobots_UR10({
8
- modelURL,
9
- rapidlyChangingMotionState,
10
- ...props
11
- }: RobotProps) {
5
+ export function UniversalRobots_UR10({ modelURL, ...props }: RobotModelProps) {
12
6
  const gltf = useGLTF(modelURL) as any
13
7
  const nodes = gltf.nodes
14
8
  const materials = gltf.materials
15
9
 
16
- function setRotation(jointObjects: THREE.Object3D[], jointValues: number[]) {
17
- jointObjects.forEach(
18
- (object, index) => (object.rotation.y = jointValues[index]!),
19
- )
20
- }
21
-
22
10
  return (
23
11
  <>
24
- <RobotAnimator
25
- rapidlyChangingMotionState={rapidlyChangingMotionState}
26
- robotRootObjectName="Scene"
27
- onRotationChanged={setRotation}
28
- />
29
12
  <group {...props} dispose={null}>
30
13
  <group name="Scene">
31
14
  <animated.group name="UNIVERSALROBOTS_UR10CB3_J00">