@wandelbots/wandelbots-js-react-components 5.4.1 → 5.4.2-pr.ci-pr-preview.586.f684aae
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/dist/3d.cjs.js +1 -1
- package/dist/3d.d.ts +1 -1
- package/dist/3d.d.ts.map +1 -1
- package/dist/3d.es.js +1 -1
- package/dist/MotionGroupVisualizer-B-e22qXF.cjs +2 -0
- package/dist/MotionGroupVisualizer-B-e22qXF.cjs.map +1 -0
- package/dist/MotionGroupVisualizer-CIASsBC6.js +1433 -0
- package/dist/MotionGroupVisualizer-CIASsBC6.js.map +1 -0
- package/dist/Setup.d.ts +1 -1
- package/dist/Setup.d.ts.map +1 -1
- package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts +1 -1
- package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
- package/dist/components/3d-viewport/collider/ColliderCollection.d.ts.map +1 -1
- package/dist/components/AppHeader.d.ts +1 -1
- package/dist/components/AppHeader.d.ts.map +1 -1
- package/dist/components/ConsoleFilter.d.ts +1 -1
- package/dist/components/ConsoleFilter.d.ts.map +1 -1
- package/dist/components/CopyableText.d.ts.map +1 -1
- package/dist/components/CycleTimer/DefaultVariant.d.ts.map +1 -1
- package/dist/components/CycleTimer/SmallVariant.d.ts.map +1 -1
- package/dist/components/DataGrid.d.ts +1 -1
- package/dist/components/DataGrid.d.ts.map +1 -1
- package/dist/components/LoadingCover.d.ts.map +1 -1
- package/dist/components/LogPanel.d.ts +1 -1
- package/dist/components/LogPanel.d.ts.map +1 -1
- package/dist/components/LogViewer.d.ts +1 -1
- package/dist/components/LogViewer.d.ts.map +1 -1
- package/dist/components/ProgramControl.d.ts.map +1 -1
- package/dist/components/ProgramStateIndicator.d.ts.map +1 -1
- package/dist/components/RobotCard.d.ts.map +1 -1
- package/dist/components/RobotListItem.d.ts.map +1 -1
- package/dist/components/RobotSetupReadinessIndicator.d.ts.map +1 -1
- package/dist/components/SelectableFab.d.ts +1 -1
- package/dist/components/SelectableFab.d.ts.map +1 -1
- package/dist/components/TabBar.d.ts +1 -1
- package/dist/components/TabBar.d.ts.map +1 -1
- package/dist/components/ThemeSelect.d.ts +1 -1
- package/dist/components/ThemeSelect.d.ts.map +1 -1
- package/dist/components/Timer/TimerDefaultVariant.d.ts.map +1 -1
- package/dist/components/Timer/TimerSmallVariant.d.ts.map +1 -1
- package/dist/components/TransparentOverlay.d.ts +2 -2
- package/dist/components/TransparentOverlay.d.ts.map +1 -1
- package/dist/components/VelocitySlider.d.ts +1 -1
- package/dist/components/VelocitySlider.d.ts.map +1 -1
- package/dist/components/experimental/utils/AdornedSelect.d.ts +1 -1
- package/dist/components/experimental/utils/AdornedSelect.d.ts.map +1 -1
- package/dist/components/jogging/JoggingBlocked.d.ts +1 -1
- package/dist/components/jogging/JoggingBlocked.d.ts.map +1 -1
- package/dist/components/jogging/JoggingCartesianAxisControl.d.ts.map +1 -1
- package/dist/components/jogging/JoggingCartesianTab.d.ts.map +1 -1
- package/dist/components/jogging/JoggingFreedriveTab.d.ts.map +1 -1
- package/dist/components/jogging/JoggingJointLimitDetector.d.ts +1 -1
- package/dist/components/jogging/JoggingJointLimitDetector.d.ts.map +1 -1
- package/dist/components/jogging/JoggingJointTab.d.ts +2 -2
- package/dist/components/jogging/JoggingJointTab.d.ts.map +1 -1
- package/dist/components/jogging/JoggingJointValueControl.d.ts.map +1 -1
- package/dist/components/jogging/JoggingOptions.d.ts.map +1 -1
- package/dist/components/jogging/JoggingPanel.d.ts +1 -1
- package/dist/components/jogging/JoggingPanel.d.ts.map +1 -1
- package/dist/components/jogging/JoggingStore.d.ts +1 -1
- package/dist/components/jogging/JoggingStore.d.ts.map +1 -1
- package/dist/components/jogging/JoggingToggleButtonGroup.d.ts +1 -1
- package/dist/components/jogging/JoggingToggleButtonGroup.d.ts.map +1 -1
- package/dist/components/jogging/JoggingVelocitySlider.d.ts +1 -1
- package/dist/components/jogging/JoggingVelocitySlider.d.ts.map +1 -1
- package/dist/components/jogging/PoseCartesianValues.d.ts.map +1 -1
- package/dist/components/jogging/PoseJointValues.d.ts.map +1 -1
- package/dist/components/modal/NoMotionGroupModal.d.ts.map +1 -1
- package/dist/components/robots/DHLinearAxis.d.ts.map +1 -1
- package/dist/components/robots/DHRobot.d.ts.map +1 -1
- package/dist/components/robots/GenericRobot.d.ts +1 -1
- package/dist/components/robots/GenericRobot.d.ts.map +1 -1
- package/dist/components/robots/LinearAxisAnimator.d.ts +1 -1
- package/dist/components/robots/LinearAxisAnimator.d.ts.map +1 -1
- package/dist/components/robots/MotionGroupVisualizer.d.ts +2 -2
- package/dist/components/robots/MotionGroupVisualizer.d.ts.map +1 -1
- package/dist/components/robots/RobotAnimator.d.ts +1 -1
- package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
- package/dist/components/robots/SupportedLinearAxis.d.ts.map +1 -1
- package/dist/components/robots/SupportedRobot.d.ts.map +1 -1
- package/dist/components/robots/robotModelLogic.d.ts.map +1 -1
- package/dist/components/safetyBar/ControllerTypeIndicator.d.ts +1 -1
- package/dist/components/safetyBar/ControllerTypeIndicator.d.ts.map +1 -1
- package/dist/components/safetyBar/IndicatorWithExplanation.d.ts +2 -1
- package/dist/components/safetyBar/IndicatorWithExplanation.d.ts.map +1 -1
- package/dist/components/safetyBar/OperationModeIndicator.d.ts +1 -1
- package/dist/components/safetyBar/OperationModeIndicator.d.ts.map +1 -1
- package/dist/components/safetyBar/SafetyBar.d.ts +1 -1
- package/dist/components/safetyBar/SafetyBar.d.ts.map +1 -1
- package/dist/components/safetyBar/SafetyStateIndicator.d.ts +1 -1
- package/dist/components/safetyBar/SafetyStateIndicator.d.ts.map +1 -1
- package/dist/components/utils/converters.d.ts +2 -2
- package/dist/components/utils/converters.d.ts.map +1 -1
- package/dist/components/utils/hooks.d.ts.map +1 -1
- package/dist/components/utils/interpolation.d.ts.map +1 -1
- package/dist/core.cjs.js +1 -1
- package/dist/core.es.js +2 -2
- package/dist/externalizeComponent.d.ts.map +1 -1
- package/dist/icons/DropdownArrowIcon.d.ts +1 -1
- package/dist/icons/DropdownArrowIcon.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +3 -3
- package/dist/interpolation-BIB6FC35.cjs +198 -0
- package/dist/interpolation-BIB6FC35.cjs.map +1 -0
- package/dist/interpolation-lSTX6ZXZ.js +14559 -0
- package/dist/interpolation-lSTX6ZXZ.js.map +1 -0
- package/dist/lib/JoggerConnection.d.ts +1 -1
- package/dist/lib/JoggerConnection.d.ts.map +1 -1
- package/dist/themes/createDarkTheme.d.ts +1 -1
- package/dist/themes/createDarkTheme.d.ts.map +1 -1
- package/dist/themes/createLightTheme.d.ts +1 -1
- package/dist/themes/createLightTheme.d.ts.map +1 -1
- package/dist/theming-D_pShDEg.js +32236 -0
- package/dist/theming-D_pShDEg.js.map +1 -0
- package/dist/theming-L5E8VSae.cjs +84 -0
- package/dist/theming-L5E8VSae.cjs.map +1 -0
- package/package.json +4 -3
- package/src/3d.ts +2 -2
- package/src/Setup.tsx +2 -6
- package/src/components/3d-viewport/PresetEnvironment.tsx +1 -0
- package/src/components/3d-viewport/SafetyZonesRenderer.tsx +43 -23
- package/src/components/3d-viewport/TrajectoryRenderer.tsx +1 -1
- package/src/components/3d-viewport/collider/ColliderCollection.tsx +3 -2
- package/src/components/AppHeader.tsx +9 -12
- package/src/components/ConsoleFilter.tsx +1 -1
- package/src/components/CopyableText.tsx +4 -1
- package/src/components/CycleTimer/DefaultVariant.tsx +8 -5
- package/src/components/CycleTimer/SmallVariant.tsx +3 -1
- package/src/components/DataGrid.tsx +4 -1
- package/src/components/LoadingCover.tsx +4 -1
- package/src/components/LogPanel.tsx +1 -1
- package/src/components/LogViewer.tsx +13 -17
- package/src/components/ProgramControl.tsx +7 -2
- package/src/components/ProgramStateIndicator.tsx +3 -2
- package/src/components/RobotCard.tsx +6 -1
- package/src/components/RobotListItem.tsx +4 -1
- package/src/components/RobotSetupReadinessIndicator.tsx +4 -2
- package/src/components/SelectableFab.tsx +2 -2
- package/src/components/TabBar.tsx +7 -3
- package/src/components/ThemeSelect.tsx +2 -1
- package/src/components/Timer/TimerDefaultVariant.tsx +9 -6
- package/src/components/Timer/TimerSmallVariant.tsx +2 -1
- package/src/components/Timer/useTimerLogic.ts +9 -9
- package/src/components/TransparentOverlay.tsx +2 -2
- package/src/components/VelocitySlider.tsx +3 -1
- package/src/components/experimental/utils/AdornedSelect.tsx +4 -8
- package/src/components/jogging/JoggingBlocked.tsx +6 -2
- package/src/components/jogging/JoggingCartesianAxisControl.tsx +5 -7
- package/src/components/jogging/JoggingCartesianTab.tsx +6 -8
- package/src/components/jogging/JoggingFreedriveTab.tsx +1 -2
- package/src/components/jogging/JoggingJointLimitDetector.tsx +41 -43
- package/src/components/jogging/JoggingJointTab.tsx +12 -20
- package/src/components/jogging/JoggingJointValueControl.tsx +44 -30
- package/src/components/jogging/JoggingOptions.tsx +143 -139
- package/src/components/jogging/JoggingPanel.test.tsx +77 -85
- package/src/components/jogging/JoggingPanel.tsx +10 -13
- package/src/components/jogging/JoggingStore.ts +18 -13
- package/src/components/jogging/JoggingToggleButtonGroup.tsx +3 -3
- package/src/components/jogging/JoggingVelocitySlider.tsx +2 -10
- package/src/components/jogging/PoseCartesianValues.tsx +2 -1
- package/src/components/jogging/PoseJointValues.tsx +2 -1
- package/src/components/jogging/__fixtures__/motionStreamMockData.ts +0 -1
- package/src/components/modal/NoMotionGroupModal.tsx +7 -10
- package/src/components/robots/DHLinearAxis.tsx +62 -45
- package/src/components/robots/DHRobot.tsx +47 -45
- package/src/components/robots/GenericRobot.tsx +24 -24
- package/src/components/robots/LinearAxis.tsx +0 -1
- package/src/components/robots/LinearAxisAnimator.tsx +4 -1
- package/src/components/robots/MotionGroupVisualizer.tsx +53 -53
- package/src/components/robots/RobotAnimator.test.tsx +2 -2
- package/src/components/robots/RobotAnimator.tsx +4 -1
- package/src/components/robots/SupportedLinearAxis.tsx +10 -3
- package/src/components/robots/SupportedRobot.tsx +10 -3
- package/src/components/robots/robotModelLogic.ts +22 -11
- package/src/components/safetyBar/ControllerTypeIndicator.tsx +2 -1
- package/src/components/safetyBar/IndicatorWithExplanation.tsx +13 -11
- package/src/components/safetyBar/OperationModeIndicator.tsx +2 -1
- package/src/components/safetyBar/SafetyBar.tsx +3 -1
- package/src/components/safetyBar/SafetyStateIndicator.tsx +2 -1
- package/src/components/utils/converters.ts +10 -7
- package/src/components/utils/errorHandling.ts +1 -1
- package/src/components/utils/hooks.tsx +1 -0
- package/src/components/utils/interpolation.test.ts +53 -38
- package/src/components/utils/interpolation.ts +1 -0
- package/src/externalizeComponent.tsx +3 -1
- package/src/icons/DropdownArrowIcon.tsx +1 -2
- package/src/lib/JoggerConnection.ts +24 -24
- package/src/themes/createDarkTheme.ts +2 -3
- package/dist/MotionGroupVisualizer-1twp8wG6.js +0 -1328
- package/dist/MotionGroupVisualizer-1twp8wG6.js.map +0 -1
- package/dist/MotionGroupVisualizer-Dq_KWGsa.cjs +0 -2
- package/dist/MotionGroupVisualizer-Dq_KWGsa.cjs.map +0 -1
- package/dist/interpolation-B3pbgXYX.cjs +0 -42
- package/dist/interpolation-B3pbgXYX.cjs.map +0 -1
- package/dist/interpolation-D4ATdkEg.js +0 -7912
- package/dist/interpolation-D4ATdkEg.js.map +0 -1
- package/dist/theming-BJ6pB6jG.cjs +0 -115
- package/dist/theming-BJ6pB6jG.cjs.map +0 -1
- package/dist/theming-LwkvEF-K.js +0 -22417
- package/dist/theming-LwkvEF-K.js.map +0 -1
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from "react"
|
|
2
1
|
import { JointTypeEnum } from "@wandelbots/nova-js/v2"
|
|
2
|
+
import type React from "react"
|
|
3
|
+
import { useEffect, useMemo, useState } from "react"
|
|
3
4
|
|
|
4
5
|
import { externalizeComponent } from "../../externalizeComponent"
|
|
6
|
+
import {
|
|
7
|
+
SupportedLinearAxis,
|
|
8
|
+
type SupportedLinearAxisProps,
|
|
9
|
+
} from "./SupportedLinearAxis"
|
|
5
10
|
import { SupportedRobot, type SupportedRobotProps } from "./SupportedRobot"
|
|
6
|
-
import { SupportedLinearAxis, type SupportedLinearAxisProps } from "./SupportedLinearAxis"
|
|
7
11
|
|
|
8
12
|
export type MotionGroupVisualizerProps = {
|
|
9
13
|
instanceUrl: string
|
|
10
14
|
inverseSolver?: string | null
|
|
11
15
|
} & (SupportedRobotProps | SupportedLinearAxisProps)
|
|
12
16
|
|
|
13
|
-
export const MotionGroupVisualizer: React.FC<MotionGroupVisualizerProps> =
|
|
14
|
-
|
|
15
|
-
inverseSolver,
|
|
16
|
-
dhParameters,
|
|
17
|
-
...rest
|
|
18
|
-
} = props
|
|
17
|
+
export const MotionGroupVisualizer: React.FC<MotionGroupVisualizerProps> =
|
|
18
|
+
externalizeComponent((props: MotionGroupVisualizerProps) => {
|
|
19
|
+
const { inverseSolver, dhParameters, ...rest } = props
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* Sets the joint type according to delivered dh parameter type
|
|
28
|
-
*/
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (dhParameters.length) {
|
|
31
|
-
setJointType(dhParameters[0].type ?? JointTypeEnum.RevoluteJoint)
|
|
32
|
-
}
|
|
33
|
-
}, [dhParameters])
|
|
21
|
+
/**
|
|
22
|
+
* Joint type to find out - in combination with inverseSolver - whether the
|
|
23
|
+
* active robot is a turn table
|
|
24
|
+
*/
|
|
25
|
+
const [jointType, setJointType] = useState<JointTypeEnum>(
|
|
26
|
+
JointTypeEnum.RevoluteJoint,
|
|
27
|
+
)
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Sets the joint type according to delivered dh parameter type
|
|
31
|
+
*/
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (dhParameters.length) {
|
|
34
|
+
setJointType(dhParameters[0].type ?? JointTypeEnum.RevoluteJoint)
|
|
35
|
+
}
|
|
36
|
+
}, [dhParameters])
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The turntable models return inverseSolver = null - however these models
|
|
40
|
+
* should be rendered with SupportedRobot instead of SupportedLinearAxis
|
|
41
|
+
*/
|
|
42
|
+
const isTurnTable = useMemo(() => {
|
|
43
|
+
return inverseSolver === null && jointType === JointTypeEnum.RevoluteJoint
|
|
44
|
+
}, [inverseSolver, jointType])
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Linear axis check
|
|
48
|
+
*/
|
|
49
|
+
const isLinearAxis = useMemo(() => {
|
|
50
|
+
return (
|
|
51
|
+
inverseSolver === null && jointType === JointTypeEnum.PrismaticJoint
|
|
52
|
+
)
|
|
53
|
+
}, [inverseSolver, jointType])
|
|
56
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Robot differentiation for readability reasons
|
|
57
|
+
*/
|
|
58
|
+
const isRobot = useMemo(() => {
|
|
59
|
+
return !!inverseSolver
|
|
60
|
+
}, [inverseSolver])
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
}
|
|
62
|
+
if (isRobot || isTurnTable) {
|
|
63
|
+
return <SupportedRobot dhParameters={dhParameters} {...rest} />
|
|
64
|
+
}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
)
|
|
68
|
-
}
|
|
66
|
+
if (isLinearAxis) {
|
|
67
|
+
return <SupportedLinearAxis dhParameters={dhParameters} {...rest} />
|
|
68
|
+
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
})
|
|
70
|
+
return null
|
|
71
|
+
})
|
|
@@ -25,7 +25,7 @@ describe("RobotAnimator", () => {
|
|
|
25
25
|
// Test that the component accepts different numbers of DH parameters
|
|
26
26
|
const mockMotionState4Joints: MotionGroupState = {
|
|
27
27
|
joint_position: [0.1, 0.2, 0.3, 0.4],
|
|
28
|
-
} as
|
|
28
|
+
} as unknown as MotionGroupState
|
|
29
29
|
|
|
30
30
|
const mockDHParameters4Joints: DHParameter[] = [
|
|
31
31
|
{ theta: 0, reverse_rotation_direction: false },
|
|
@@ -36,7 +36,7 @@ describe("RobotAnimator", () => {
|
|
|
36
36
|
|
|
37
37
|
const mockMotionState7Joints: MotionGroupState = {
|
|
38
38
|
joint_position: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7],
|
|
39
|
-
} as
|
|
39
|
+
} as unknown as MotionGroupState
|
|
40
40
|
|
|
41
41
|
const mockDHParameters7Joints: DHParameter[] = Array(7).fill({
|
|
42
42
|
theta: 0,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useFrame, useThree } from "@react-three/fiber"
|
|
2
2
|
import type { DHParameter, MotionGroupState } from "@wandelbots/nova-js/v2"
|
|
3
|
-
import React
|
|
3
|
+
import type React from "react"
|
|
4
|
+
import { useCallback, useEffect, useRef } from "react"
|
|
4
5
|
import type { Group, Object3D } from "three"
|
|
5
6
|
import { useAutorun } from "../utils/hooks"
|
|
6
7
|
import { ValueInterpolator } from "../utils/interpolation"
|
|
@@ -25,6 +26,7 @@ export default function RobotAnimator({
|
|
|
25
26
|
const { invalidate } = useThree()
|
|
26
27
|
|
|
27
28
|
// Initialize interpolator
|
|
29
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: pre-biome code
|
|
28
30
|
useEffect(() => {
|
|
29
31
|
const initialJointValues = rapidlyChangingMotionState.joint_position.filter(
|
|
30
32
|
(item) => item !== undefined,
|
|
@@ -96,6 +98,7 @@ export default function RobotAnimator({
|
|
|
96
98
|
* Fire an update joints call on every motion state change.
|
|
97
99
|
* requestAnimationFrame used to avoid blocking main thread
|
|
98
100
|
*/
|
|
101
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: pre-biome code
|
|
99
102
|
useEffect(() => {
|
|
100
103
|
updateJoints()
|
|
101
104
|
}, [rapidlyChangingMotionState, updateJoints])
|
|
@@ -22,7 +22,10 @@ export type SupportedLinearAxisProps = {
|
|
|
22
22
|
dhParameters: DHParameter[]
|
|
23
23
|
flangeRef?: React.Ref<THREE.Group>
|
|
24
24
|
instanceUrl?: string
|
|
25
|
-
getModel?: (
|
|
25
|
+
getModel?: (
|
|
26
|
+
modelFromController: string,
|
|
27
|
+
instanceUrl?: string,
|
|
28
|
+
) => Promise<string> | undefined
|
|
26
29
|
postModelRender?: () => void
|
|
27
30
|
transparentColor?: string
|
|
28
31
|
} & ThreeElements["group"]
|
|
@@ -81,8 +84,12 @@ export const SupportedLinearAxis = externalizeComponent(
|
|
|
81
84
|
modelURL={(() => {
|
|
82
85
|
const result = getModel(modelFromController, instanceUrl)
|
|
83
86
|
if (!result) {
|
|
84
|
-
const mockBlob = new Blob([], { type:
|
|
85
|
-
const mockFile = new File(
|
|
87
|
+
const mockBlob = new Blob([], { type: "model/gltf-binary" })
|
|
88
|
+
const mockFile = new File(
|
|
89
|
+
[mockBlob],
|
|
90
|
+
`${modelFromController}.glb`,
|
|
91
|
+
{ type: "model/gltf-binary" },
|
|
92
|
+
)
|
|
86
93
|
return Promise.resolve(URL.createObjectURL(mockFile))
|
|
87
94
|
}
|
|
88
95
|
return result
|
|
@@ -23,7 +23,10 @@ export type SupportedRobotProps = {
|
|
|
23
23
|
dhParameters: DHParameter[]
|
|
24
24
|
flangeRef?: React.Ref<THREE.Group>
|
|
25
25
|
instanceUrl?: string
|
|
26
|
-
getModel?: (
|
|
26
|
+
getModel?: (
|
|
27
|
+
modelFromController: string,
|
|
28
|
+
instanceUrl?: string,
|
|
29
|
+
) => Promise<string> | undefined
|
|
27
30
|
postModelRender?: () => void
|
|
28
31
|
transparentColor?: string
|
|
29
32
|
} & ThreeElements["group"]
|
|
@@ -82,8 +85,12 @@ export const SupportedRobot = externalizeComponent(
|
|
|
82
85
|
modelURL={(() => {
|
|
83
86
|
const result = getModel(modelFromController, instanceUrl)
|
|
84
87
|
if (!result) {
|
|
85
|
-
const mockBlob = new Blob([], { type:
|
|
86
|
-
const mockFile = new File(
|
|
88
|
+
const mockBlob = new Blob([], { type: "model/gltf-binary" })
|
|
89
|
+
const mockFile = new File(
|
|
90
|
+
[mockBlob],
|
|
91
|
+
`${modelFromController}.glb`,
|
|
92
|
+
{ type: "model/gltf-binary" },
|
|
93
|
+
)
|
|
87
94
|
return Promise.resolve(URL.createObjectURL(mockFile))
|
|
88
95
|
}
|
|
89
96
|
return result
|
|
@@ -8,7 +8,9 @@ const modelCache = new Map<string, Promise<string>>()
|
|
|
8
8
|
* Revoke a cached model's object URL to prevent memory leaks.
|
|
9
9
|
* Call this when a component unmounts or no longer needs the model.
|
|
10
10
|
*/
|
|
11
|
-
export async function revokeModelUrl(
|
|
11
|
+
export async function revokeModelUrl(
|
|
12
|
+
modelFromController: string,
|
|
13
|
+
): Promise<void> {
|
|
12
14
|
const urlPromise = modelCache.get(modelFromController)
|
|
13
15
|
if (!urlPromise) return
|
|
14
16
|
|
|
@@ -35,36 +37,45 @@ export async function revokeAllModelUrls(): Promise<void> {
|
|
|
35
37
|
} catch (e) {
|
|
36
38
|
// Ignore errors
|
|
37
39
|
}
|
|
38
|
-
})
|
|
40
|
+
}),
|
|
39
41
|
)
|
|
40
42
|
modelCache.clear()
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
export async function defaultGetModel(
|
|
45
|
+
export async function defaultGetModel(
|
|
46
|
+
modelFromController: string,
|
|
47
|
+
instanceUrlProp?: string,
|
|
48
|
+
): Promise<string> {
|
|
44
49
|
// Check cache first
|
|
45
50
|
if (modelCache.has(modelFromController)) {
|
|
51
|
+
// biome-ignore lint/style/noNonNullAssertion: pre-biome code
|
|
46
52
|
return modelCache.get(modelFromController)!
|
|
47
53
|
}
|
|
48
|
-
|
|
54
|
+
|
|
49
55
|
// Create the promise and cache it immediately to prevent duplicate calls
|
|
50
56
|
const modelPromise = (async () => {
|
|
51
57
|
const instanceUrl = instanceUrlProp || import.meta.env.WANDELAPI_BASE_URL
|
|
52
58
|
const nova = new NovaClient({ instanceUrl })
|
|
53
|
-
|
|
59
|
+
|
|
54
60
|
// Configure axios to handle binary responses for GLB files
|
|
61
|
+
// biome-ignore lint/suspicious/noExplicitAny: pre-biome code
|
|
55
62
|
const apiInstance = nova.api.motionGroupModels as any
|
|
56
63
|
if (apiInstance.axios?.interceptors) {
|
|
64
|
+
// biome-ignore lint/suspicious/noExplicitAny: pre-biome code
|
|
57
65
|
apiInstance.axios.interceptors.request.use((config: any) => {
|
|
58
|
-
if (config.url?.includes(
|
|
59
|
-
config.responseType =
|
|
66
|
+
if (config.url?.includes("/glb")) {
|
|
67
|
+
config.responseType = "blob"
|
|
60
68
|
}
|
|
61
69
|
return config
|
|
62
70
|
})
|
|
63
71
|
}
|
|
64
|
-
|
|
72
|
+
|
|
65
73
|
try {
|
|
66
|
-
const file =
|
|
67
|
-
|
|
74
|
+
const file =
|
|
75
|
+
await nova.api.motionGroupModels.getMotionGroupGlbModel(
|
|
76
|
+
modelFromController,
|
|
77
|
+
)
|
|
78
|
+
|
|
68
79
|
// Create object URL from the file and return it
|
|
69
80
|
const url = URL.createObjectURL(file)
|
|
70
81
|
return url
|
|
@@ -73,7 +84,7 @@ export async function defaultGetModel(modelFromController: string, instanceUrlPr
|
|
|
73
84
|
throw error
|
|
74
85
|
}
|
|
75
86
|
})()
|
|
76
|
-
|
|
87
|
+
|
|
77
88
|
// Cache the promise
|
|
78
89
|
modelCache.set(modelFromController, modelPromise)
|
|
79
90
|
return modelPromise
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useTheme
|
|
1
|
+
import { useTheme } from "@mui/material/styles"
|
|
2
|
+
import type { PopoverOrigin } from "@mui/material/Popover"
|
|
2
3
|
import { observer } from "mobx-react-lite"
|
|
3
4
|
import { useId } from "react"
|
|
4
5
|
import { Trans, useTranslation } from "react-i18next"
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Typography,
|
|
6
|
-
type PopoverOrigin,
|
|
7
|
-
type TypographyProps,
|
|
8
|
-
} from "@mui/material"
|
|
1
|
+
import Popover, { type PopoverOrigin } from "@mui/material/Popover"
|
|
2
|
+
import Stack from "@mui/material/Stack"
|
|
3
|
+
import SvgIcon from "@mui/material/SvgIcon"
|
|
4
|
+
import Typography, { type TypographyProps } from "@mui/material/Typography"
|
|
9
5
|
import { observer, useLocalObservable } from "mobx-react-lite"
|
|
10
6
|
import type { ElementType, ReactNode } from "react"
|
|
11
7
|
|
|
@@ -70,9 +66,15 @@ export const IndicatorWithExplanation = observer(
|
|
|
70
66
|
color,
|
|
71
67
|
}}
|
|
72
68
|
/>
|
|
73
|
-
{label && (
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
{label && (
|
|
70
|
+
<div
|
|
71
|
+
style={{
|
|
72
|
+
color,
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{label}
|
|
76
|
+
</div>
|
|
77
|
+
)}
|
|
76
78
|
</Stack>
|
|
77
79
|
<Popover
|
|
78
80
|
id={id}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useTheme
|
|
1
|
+
import { useTheme } from "@mui/material/styles"
|
|
2
|
+
import type { PopoverOrigin } from "@mui/material/Popover"
|
|
2
3
|
import type { OperationMode } from "@wandelbots/nova-js/v2"
|
|
3
4
|
import { observer } from "mobx-react-lite"
|
|
4
5
|
import { useId } from "react"
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Divider from "@mui/material/Divider"
|
|
2
|
+
import type { PopoverOrigin } from "@mui/material/Popover"
|
|
3
|
+
import Stack from "@mui/material/Stack"
|
|
2
4
|
import type { OperationMode, SafetyStateType } from "@wandelbots/nova-js/v2"
|
|
3
5
|
import { observer } from "mobx-react-lite"
|
|
4
6
|
import { externalizeComponent } from "../../externalizeComponent"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useTheme
|
|
1
|
+
import { useTheme } from "@mui/material/styles"
|
|
2
|
+
import type { PopoverOrigin } from "@mui/material/Popover"
|
|
2
3
|
import type { SafetyStateType } from "@wandelbots/nova-js/v2"
|
|
3
4
|
import { observer } from "mobx-react-lite"
|
|
4
5
|
import { useId } from "react"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as THREE from "three"
|
|
2
1
|
import type { DHParameter } from "@wandelbots/nova-js/v2"
|
|
2
|
+
import * as THREE from "three"
|
|
3
3
|
|
|
4
4
|
export interface CoplanarityResult {
|
|
5
5
|
isCoplanar: boolean
|
|
@@ -14,7 +14,7 @@ export function degreesToRadians(degrees: number): number {
|
|
|
14
14
|
return degrees * (Math.PI / 180)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function tryParseJson(json: unknown):
|
|
17
|
+
export function tryParseJson(json: unknown): unknown {
|
|
18
18
|
try {
|
|
19
19
|
return JSON.parse(json as string)
|
|
20
20
|
} catch {
|
|
@@ -30,7 +30,9 @@ export function tryStringifyJson(json: unknown): string | undefined {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function orientationToQuaternion(
|
|
33
|
+
export function orientationToQuaternion(
|
|
34
|
+
orientation: THREE.Vector3,
|
|
35
|
+
): THREE.Quaternion {
|
|
34
36
|
const angle = orientation.length()
|
|
35
37
|
const quaternion = new THREE.Quaternion()
|
|
36
38
|
if (angle > 1e-6) {
|
|
@@ -46,7 +48,7 @@ export function dhParametersToPlaneSize(dhParameters: DHParameter[]) {
|
|
|
46
48
|
return defaultPlaneSize
|
|
47
49
|
}
|
|
48
50
|
const reachRadiusM = dhParameters.reduce((sum, p) => {
|
|
49
|
-
return sum +
|
|
51
|
+
return sum + Math.abs(p.a ?? 0) / 1000 + Math.abs(p.d ?? 0) / 1000
|
|
50
52
|
}, 0)
|
|
51
53
|
const size = reachRadiusM * 2
|
|
52
54
|
if (!Number.isFinite(size) || size <= 0) {
|
|
@@ -55,8 +57,9 @@ export function dhParametersToPlaneSize(dhParameters: DHParameter[]) {
|
|
|
55
57
|
return size
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
export function verticesToCoplanarity(
|
|
61
|
+
vertices: THREE.Vector3[],
|
|
62
|
+
): CoplanarityResult {
|
|
60
63
|
if (vertices.length < 3) {
|
|
61
64
|
console.log("Not enough vertices to define a plane")
|
|
62
65
|
return { isCoplanar: false }
|
|
@@ -84,4 +87,4 @@ export function verticesToCoplanarity(vertices: THREE.Vector3[]): CoplanarityRes
|
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
return { isCoplanar: true, normal }
|
|
87
|
-
}
|
|
90
|
+
}
|
|
@@ -22,7 +22,7 @@ export function makeShortErrorMessage(err: unknown) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function assertUnreachable(x: never, msg: string): never {
|
|
25
|
-
throw new Error(msg
|
|
25
|
+
throw new Error(`${msg} ${JSON.stringify(x)}`)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function makeErrorMessage(err: unknown) {
|
|
@@ -5,6 +5,7 @@ import { useEffect, type EffectCallback } from "react"
|
|
|
5
5
|
* Run code once on component mount. Shorthand for useEffect(effect, []).
|
|
6
6
|
*/
|
|
7
7
|
export function useMounted(effect: EffectCallback) {
|
|
8
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: pre-biome code
|
|
8
9
|
useEffect(effect, [])
|
|
9
10
|
}
|
|
10
11
|
|