@wandelbots/wandelbots-js-react-components 4.0.1 → 4.0.2
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.es.js +1 -1
- package/dist/components/robots/RobotAnimator.d.ts.map +1 -1
- package/dist/core.cjs.js +1 -1
- package/dist/core.es.js +28 -28
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +26 -26
- package/dist/{interpolation-DAXKfoDS.cjs → interpolation-BGC6adne.cjs} +4 -4
- package/dist/interpolation-BGC6adne.cjs.map +1 -0
- package/dist/{interpolation-DcPbemBD.js → interpolation-CZsbXLpo.js} +175 -200
- package/dist/interpolation-CZsbXLpo.js.map +1 -0
- package/dist/manufacturerHomePositions-B04wcsF8.cjs +2 -0
- package/dist/manufacturerHomePositions-B04wcsF8.cjs.map +1 -0
- package/dist/{manufacturerHomePositions-j75MUgMb.js → manufacturerHomePositions-h7G6BCs7.js} +101 -99
- package/dist/manufacturerHomePositions-h7G6BCs7.js.map +1 -0
- package/dist/{theming-CPShzNuV.cjs → theming-49GSfpiH.cjs} +37 -37
- package/dist/theming-49GSfpiH.cjs.map +1 -0
- package/dist/{theming-Hr605E6v.js → theming-Jezu_BIw.js} +2210 -2186
- package/dist/theming-Jezu_BIw.js.map +1 -0
- package/package.json +1 -1
- package/src/components/robots/RobotAnimator.tsx +15 -9
- package/dist/interpolation-DAXKfoDS.cjs.map +0 -1
- package/dist/interpolation-DcPbemBD.js.map +0 -1
- package/dist/manufacturerHomePositions-B3eJ_OqZ.cjs +0 -2
- package/dist/manufacturerHomePositions-B3eJ_OqZ.cjs.map +0 -1
- package/dist/manufacturerHomePositions-j75MUgMb.js.map +0 -1
- package/dist/theming-CPShzNuV.cjs.map +0 -1
- package/dist/theming-Hr605E6v.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useFrame, useThree } from "@react-three/fiber"
|
|
2
2
|
import type { DHParameter, MotionGroupState } from "@wandelbots/nova-js/v2"
|
|
3
|
-
import React, { useEffect, useRef } from "react"
|
|
3
|
+
import React, { useEffect, useRef, useCallback } from "react"
|
|
4
4
|
import type { Group, Object3D } from "three"
|
|
5
5
|
import { useAutorun } from "../utils/hooks"
|
|
6
6
|
import { ValueInterpolator } from "../utils/interpolation"
|
|
@@ -64,11 +64,6 @@ export default function RobotAnimator({
|
|
|
64
64
|
invalidate()
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function updateJoints(newJointValues: number[]) {
|
|
68
|
-
jointValues.current = newJointValues
|
|
69
|
-
interpolatorRef.current?.setTarget(newJointValues)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
67
|
function setRotation() {
|
|
73
68
|
const updatedJointValues = interpolatorRef.current?.getCurrentValues() || []
|
|
74
69
|
|
|
@@ -86,13 +81,24 @@ export default function RobotAnimator({
|
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
|
|
89
|
-
|
|
84
|
+
const updateJoints = useCallback(() => {
|
|
90
85
|
const newJointValues = rapidlyChangingMotionState.joint_position.filter(
|
|
91
86
|
(item) => item !== undefined,
|
|
92
87
|
)
|
|
93
88
|
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
jointValues.current = newJointValues
|
|
90
|
+
interpolatorRef.current?.setTarget(newJointValues)
|
|
91
|
+
}, [rapidlyChangingMotionState])
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Fire an update joints call on every motion state change.
|
|
95
|
+
* requestAnimationFrame used to avoid blocking main thread
|
|
96
|
+
*/
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
requestAnimationFrame(() => {
|
|
99
|
+
updateJoints()
|
|
100
|
+
})
|
|
101
|
+
}, [rapidlyChangingMotionState, updateJoints])
|
|
96
102
|
|
|
97
103
|
return <group ref={setGroupRef}>{children}</group>
|
|
98
104
|
}
|