@wandelbots/wandelbots-js-react-components 1.42.0 → 1.43.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 +2 -2
- package/dist/components/robots/Robot.d.ts +2 -2
- package/dist/components/robots/Robot.d.ts.map +1 -1
- package/dist/components/robots/SupportedRobot.d.ts +2 -2
- package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
- package/dist/components/robots/ghostStyle.d.ts +3 -3
- package/dist/components/robots/ghostStyle.d.ts.map +1 -1
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1855 -1853
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/robots/Robot.tsx +3 -3
- package/src/components/robots/SupportedRobot.tsx +5 -5
- package/src/components/robots/ghostStyle.ts +17 -16
package/package.json
CHANGED
|
@@ -8,8 +8,8 @@ import { defaultGetModel } from "./robotModelLogic"
|
|
|
8
8
|
export type RobotProps = {
|
|
9
9
|
connectedMotionGroup: ConnectedMotionGroup
|
|
10
10
|
getModel?: (modelFromController: string) => string
|
|
11
|
-
isGhost?: boolean
|
|
12
11
|
flangeRef?: React.Ref<Group>
|
|
12
|
+
transparentColor?: string
|
|
13
13
|
} & GroupProps
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -26,8 +26,8 @@ export type RobotProps = {
|
|
|
26
26
|
export function Robot({
|
|
27
27
|
connectedMotionGroup,
|
|
28
28
|
getModel = defaultGetModel,
|
|
29
|
-
isGhost = false,
|
|
30
29
|
flangeRef,
|
|
30
|
+
transparentColor,
|
|
31
31
|
...props
|
|
32
32
|
}: RobotProps) {
|
|
33
33
|
if (!connectedMotionGroup.dhParameters) {
|
|
@@ -42,8 +42,8 @@ export function Robot({
|
|
|
42
42
|
modelFromController={connectedMotionGroup.modelFromController || ""}
|
|
43
43
|
dhParameters={connectedMotionGroup.dhParameters}
|
|
44
44
|
getModel={getModel}
|
|
45
|
-
isGhost={isGhost}
|
|
46
45
|
flangeRef={flangeRef}
|
|
46
|
+
transparentColor={transparentColor}
|
|
47
47
|
{...props}
|
|
48
48
|
/>
|
|
49
49
|
)
|
|
@@ -24,10 +24,10 @@ export type SupportedRobotProps = {
|
|
|
24
24
|
rapidlyChangingMotionState: MotionGroupStateResponse
|
|
25
25
|
modelFromController: string
|
|
26
26
|
dhParameters: DHParameter[]
|
|
27
|
-
isGhost?: boolean
|
|
28
27
|
flangeRef?: React.Ref<THREE.Group>
|
|
29
28
|
getModel?: (modelFromController: string) => string
|
|
30
29
|
postModelRender?: () => void
|
|
30
|
+
transparentColor?: string
|
|
31
31
|
} & GroupProps
|
|
32
32
|
|
|
33
33
|
export const SupportedRobot = externalizeComponent(
|
|
@@ -36,9 +36,9 @@ export const SupportedRobot = externalizeComponent(
|
|
|
36
36
|
modelFromController,
|
|
37
37
|
dhParameters,
|
|
38
38
|
getModel = defaultGetModel,
|
|
39
|
-
isGhost = false,
|
|
40
39
|
flangeRef,
|
|
41
40
|
postModelRender,
|
|
41
|
+
transparentColor,
|
|
42
42
|
...props
|
|
43
43
|
}: SupportedRobotProps) => {
|
|
44
44
|
const [robotGroup, setRobotGroup] = useState<THREE.Group | null>(null)
|
|
@@ -50,12 +50,12 @@ export const SupportedRobot = externalizeComponent(
|
|
|
50
50
|
useEffect(() => {
|
|
51
51
|
if (!robotGroup) return
|
|
52
52
|
|
|
53
|
-
if (
|
|
54
|
-
applyGhostStyle(robotGroup)
|
|
53
|
+
if (transparentColor) {
|
|
54
|
+
applyGhostStyle(robotGroup, transparentColor)
|
|
55
55
|
} else {
|
|
56
56
|
removeGhostStyle(robotGroup)
|
|
57
57
|
}
|
|
58
|
-
}, [robotGroup,
|
|
58
|
+
}, [robotGroup, transparentColor])
|
|
59
59
|
|
|
60
60
|
const dhrobot = (
|
|
61
61
|
<DHRobot
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Material, Mesh, MeshStandardMaterial } from "three"
|
|
1
|
+
import * as THREE from "three"
|
|
3
2
|
|
|
4
|
-
export const applyGhostStyle = (robot: Group) => {
|
|
3
|
+
export const applyGhostStyle = (robot: THREE.Group, color: string) => {
|
|
5
4
|
if (robot.userData.isGhost) return
|
|
6
5
|
|
|
7
6
|
robot.traverse((obj) => {
|
|
8
|
-
if (obj instanceof Mesh) {
|
|
9
|
-
if (obj.material instanceof Material) {
|
|
10
|
-
obj.material.colorWrite =
|
|
7
|
+
if (obj instanceof THREE.Mesh) {
|
|
8
|
+
if (obj.material instanceof THREE.Material) {
|
|
9
|
+
obj.material.colorWrite = false
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
// Create a clone of the mesh
|
|
14
13
|
const depth = obj.clone()
|
|
15
14
|
const ghost = obj.clone()
|
|
16
15
|
|
|
17
|
-
depth.material = new MeshStandardMaterial({
|
|
16
|
+
depth.material = new THREE.MeshStandardMaterial({
|
|
18
17
|
depthTest: true,
|
|
19
18
|
depthWrite: true,
|
|
20
19
|
colorWrite: false,
|
|
21
20
|
polygonOffset: true,
|
|
22
|
-
polygonOffsetFactor: 1,
|
|
21
|
+
polygonOffsetFactor: -1,
|
|
22
|
+
side: THREE.DoubleSide,
|
|
23
23
|
})
|
|
24
24
|
depth.userData.isGhost = true
|
|
25
25
|
|
|
26
26
|
// Set the material for the ghost mesh
|
|
27
|
-
ghost.material = new MeshStandardMaterial({
|
|
28
|
-
color:
|
|
27
|
+
ghost.material = new THREE.MeshStandardMaterial({
|
|
28
|
+
color: color,
|
|
29
29
|
opacity: 0.3,
|
|
30
30
|
depthTest: true,
|
|
31
31
|
depthWrite: false,
|
|
32
32
|
transparent: true,
|
|
33
33
|
polygonOffset: true,
|
|
34
|
-
polygonOffsetFactor: -
|
|
34
|
+
polygonOffsetFactor: -2,
|
|
35
|
+
side: THREE.DoubleSide,
|
|
35
36
|
})
|
|
36
37
|
ghost.userData.isGhost = true
|
|
37
38
|
|
|
@@ -45,16 +46,16 @@ export const applyGhostStyle = (robot: Group) => {
|
|
|
45
46
|
robot.userData.isGhost = true
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
export const removeGhostStyle = (robot: Group) => {
|
|
49
|
+
export const removeGhostStyle = (robot: THREE.Group) => {
|
|
49
50
|
if (!robot.userData.isGhost) return
|
|
50
51
|
|
|
51
|
-
const objectsToRemove: Object3D[] = []
|
|
52
|
+
const objectsToRemove: THREE.Object3D[] = []
|
|
52
53
|
|
|
53
54
|
robot.traverse((obj) => {
|
|
54
|
-
if (obj instanceof Mesh) {
|
|
55
|
+
if (obj instanceof THREE.Mesh) {
|
|
55
56
|
if (obj.userData?.isGhost) {
|
|
56
57
|
objectsToRemove.push(obj)
|
|
57
|
-
} else if (obj.material instanceof Material) {
|
|
58
|
+
} else if (obj.material instanceof THREE.Material) {
|
|
58
59
|
obj.material.colorWrite = true
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -66,5 +67,5 @@ export const removeGhostStyle = (robot: Group) => {
|
|
|
66
67
|
}
|
|
67
68
|
})
|
|
68
69
|
|
|
69
|
-
robot.userData.isGhost =
|
|
70
|
+
robot.userData.isGhost = false
|
|
70
71
|
}
|