@wandelbots/wandelbots-js-react-components 1.4.2 → 1.5.0
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 +43 -8
- package/dist/components/robots/Robot.d.ts +2 -1
- package/dist/components/robots/Robot.d.ts.map +1 -1
- package/dist/components/robots/SupportedRobot.d.ts +2 -1
- package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
- package/dist/icons/robot.d.ts.map +1 -1
- package/dist/index.cjs +29 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2083 -2051
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/robots/Robot.tsx +3 -0
- package/src/components/robots/SupportedRobot.tsx +67 -7
- package/src/icons/robot.tsx +8 -4
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import { defaultGetModel, SupportedRobot } from "./SupportedRobot"
|
|
|
6
6
|
export type ConnectecMotionGroupRobotProps = {
|
|
7
7
|
connectedMotionGroup: ConnectedMotionGroup
|
|
8
8
|
getModel?: (modelFromController: string) => string
|
|
9
|
+
isGhost?: boolean
|
|
9
10
|
} & GroupProps
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -22,6 +23,7 @@ export type ConnectecMotionGroupRobotProps = {
|
|
|
22
23
|
export function Robot({
|
|
23
24
|
connectedMotionGroup,
|
|
24
25
|
getModel = defaultGetModel,
|
|
26
|
+
isGhost = false,
|
|
25
27
|
...props
|
|
26
28
|
}: ConnectecMotionGroupRobotProps) {
|
|
27
29
|
if (!connectedMotionGroup.dhParameters) {
|
|
@@ -36,6 +38,7 @@ export function Robot({
|
|
|
36
38
|
modelFromController={connectedMotionGroup.modelFromController || ""}
|
|
37
39
|
dhParameters={connectedMotionGroup.dhParameters}
|
|
38
40
|
getModel={getModel}
|
|
41
|
+
isGhost={isGhost}
|
|
39
42
|
{...props}
|
|
40
43
|
/>
|
|
41
44
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Suspense } from "react"
|
|
1
|
+
import { Suspense, useCallback, useRef } from "react"
|
|
2
2
|
|
|
3
3
|
import { UniversalRobots_UR3 } from "./UniversalRobots_UR3"
|
|
4
4
|
import { UniversalRobots_UR3e } from "./UniversalRobots_UR3e"
|
|
@@ -27,6 +27,8 @@ import type {
|
|
|
27
27
|
} from "@wandelbots/wandelbots-api-client"
|
|
28
28
|
import { DHRobot } from "./DHRobot"
|
|
29
29
|
|
|
30
|
+
import * as THREE from "three"
|
|
31
|
+
|
|
30
32
|
export type DHRobotProps = {
|
|
31
33
|
rapidlyChangingMotionState: MotionGroupStateResponse
|
|
32
34
|
dhParameters: Array<DHParameter>
|
|
@@ -42,6 +44,7 @@ export type SupportedRobotProps = {
|
|
|
42
44
|
modelFromController: string
|
|
43
45
|
dhParameters: DHParameter[]
|
|
44
46
|
getModel?: (modelFromController: string) => string
|
|
47
|
+
isGhost?: boolean
|
|
45
48
|
} & GroupProps
|
|
46
49
|
|
|
47
50
|
export function defaultGetModel(modelFromController: string): string {
|
|
@@ -53,10 +56,62 @@ export function SupportedRobot({
|
|
|
53
56
|
modelFromController,
|
|
54
57
|
dhParameters,
|
|
55
58
|
getModel = defaultGetModel,
|
|
59
|
+
isGhost = false,
|
|
56
60
|
...props
|
|
57
61
|
}: SupportedRobotProps) {
|
|
58
62
|
let Robot
|
|
59
63
|
|
|
64
|
+
const robotRef = useRef<THREE.Group>(new THREE.Group())
|
|
65
|
+
|
|
66
|
+
const setRobotRef = useCallback(
|
|
67
|
+
(instance: THREE.Group | null) => {
|
|
68
|
+
if (instance !== null) {
|
|
69
|
+
robotRef.current = instance
|
|
70
|
+
if (
|
|
71
|
+
isGhost &&
|
|
72
|
+
robotRef.current &&
|
|
73
|
+
robotRef.current.children.length > 0
|
|
74
|
+
) {
|
|
75
|
+
if (!robotRef.current.userData.ghostsCreated) {
|
|
76
|
+
robotRef.current.traverse((obj) => {
|
|
77
|
+
if (obj instanceof THREE.Mesh && !obj.userData.isGhost) {
|
|
78
|
+
// Create a clone of the mesh
|
|
79
|
+
const ghost = obj.clone()
|
|
80
|
+
|
|
81
|
+
obj.material = new THREE.MeshStandardMaterial({
|
|
82
|
+
depthTest: true,
|
|
83
|
+
depthWrite: true,
|
|
84
|
+
colorWrite: false,
|
|
85
|
+
polygonOffset: true,
|
|
86
|
+
polygonOffsetFactor: 1,
|
|
87
|
+
color: "#ffffff",
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// Set the material for the ghost mesh
|
|
91
|
+
ghost.material = new THREE.MeshStandardMaterial({
|
|
92
|
+
color: "#D91433",
|
|
93
|
+
opacity: 0.3,
|
|
94
|
+
depthTest: true,
|
|
95
|
+
depthWrite: false,
|
|
96
|
+
transparent: true,
|
|
97
|
+
polygonOffset: true,
|
|
98
|
+
polygonOffsetFactor: -1,
|
|
99
|
+
})
|
|
100
|
+
ghost.userData.isGhost = true
|
|
101
|
+
|
|
102
|
+
if (obj.parent) {
|
|
103
|
+
obj.parent.add(ghost)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
robotRef.current.userData.ghostsCreated = true
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[isGhost],
|
|
113
|
+
)
|
|
114
|
+
|
|
60
115
|
switch (modelFromController) {
|
|
61
116
|
case "UniversalRobots_UR3":
|
|
62
117
|
Robot = UniversalRobots_UR3
|
|
@@ -106,6 +161,9 @@ export function SupportedRobot({
|
|
|
106
161
|
case "FANUC_ARC_Mate_120iD":
|
|
107
162
|
Robot = FANUC_ARC_Mate_120iD
|
|
108
163
|
break
|
|
164
|
+
case "FANUC_ARC_Mate_120iD35":
|
|
165
|
+
Robot = FANUC_ARC_Mate_120iD
|
|
166
|
+
break
|
|
109
167
|
case "FANUC_ARC_Mate_100iD":
|
|
110
168
|
Robot = FANUC_ARC_Mate_100iD
|
|
111
169
|
break
|
|
@@ -133,12 +191,14 @@ export function SupportedRobot({
|
|
|
133
191
|
/>
|
|
134
192
|
}
|
|
135
193
|
>
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
194
|
+
<group ref={setRobotRef}>
|
|
195
|
+
<Robot
|
|
196
|
+
rapidlyChangingMotionState={rapidlyChangingMotionState}
|
|
197
|
+
modelURL={getModel(modelFromController)}
|
|
198
|
+
dhParameters={dhParameters}
|
|
199
|
+
{...props}
|
|
200
|
+
/>
|
|
201
|
+
</group>
|
|
142
202
|
</Suspense>
|
|
143
203
|
)
|
|
144
204
|
}
|
package/src/icons/robot.tsx
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
1
|
export function RobotIcon() {
|
|
4
2
|
return (
|
|
5
|
-
<svg
|
|
3
|
+
<svg
|
|
4
|
+
width="24"
|
|
5
|
+
height="24"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
fill="none"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
>
|
|
6
10
|
<path
|
|
7
11
|
fill-rule="evenodd"
|
|
8
12
|
clip-rule="evenodd"
|
|
@@ -10,5 +14,5 @@ export function RobotIcon() {
|
|
|
10
14
|
fill="white"
|
|
11
15
|
/>
|
|
12
16
|
</svg>
|
|
13
|
-
)
|
|
17
|
+
)
|
|
14
18
|
}
|