@wandelbots/wandelbots-js-react-components 2.26.0-pr.feature-update-to-react-19.361.4e55758 → 2.26.0-pr.feature-update-to-react-19.361.edd4b6b
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/components/robots/RobotAnimator.d.ts.map +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/robots/RobotAnimator.tsx +43 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "2.26.0-pr.feature-update-to-react-19.361.
|
|
3
|
+
"version": "2.26.0-pr.feature-update-to-react-19.361.edd4b6b",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -50,19 +50,23 @@ export default function RobotAnimator({
|
|
|
50
50
|
setSpring.start(Object.assign({}, jointValues.current) as any)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const [axisValues, setSpring] = useSpring(() =>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
const [axisValues, setSpring] = useSpring(() => {
|
|
54
|
+
const currentJointValues =
|
|
55
|
+
rapidlyChangingMotionState.state.joint_position.joints.filter(
|
|
56
|
+
(item) => item !== undefined,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
...Object.assign({}, currentJointValues),
|
|
61
|
+
onChange: () => {
|
|
62
|
+
setRotation()
|
|
63
|
+
invalidate()
|
|
64
|
+
},
|
|
65
|
+
onResolve: () => {
|
|
66
|
+
setRotation()
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
})
|
|
66
70
|
|
|
67
71
|
function setRotation() {
|
|
68
72
|
// Safety check to prevent race condition
|
|
@@ -97,7 +101,32 @@ export default function RobotAnimator({
|
|
|
97
101
|
(item) => item !== undefined,
|
|
98
102
|
)
|
|
99
103
|
|
|
100
|
-
requestAnimationFrame(() =>
|
|
104
|
+
requestAnimationFrame(() => {
|
|
105
|
+
// Check if spring values are significantly different from target values
|
|
106
|
+
const currentSpringValues = jointObjects.current.map(
|
|
107
|
+
(_, index) => (axisValues as any)[index]?.get() || 0,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
const maxDifference = Math.max(
|
|
111
|
+
...newJointValues.map((newValue, index) =>
|
|
112
|
+
Math.abs(newValue - (currentSpringValues[index] || 0)),
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
// Be more aggressive about detecting "snap back" situations
|
|
117
|
+
// If difference is large (> 0.05 radians ~= 2.9 degrees), reset immediately
|
|
118
|
+
// This handles focus restoration and other cases where animation would be jarring
|
|
119
|
+
if (maxDifference > 0.05) {
|
|
120
|
+
jointValues.current = newJointValues
|
|
121
|
+
setSpring.set(Object.assign({}, jointValues.current) as any)
|
|
122
|
+
// Force immediate rotation update
|
|
123
|
+
setRotation()
|
|
124
|
+
invalidate()
|
|
125
|
+
} else {
|
|
126
|
+
// Normal smooth animation for small changes
|
|
127
|
+
updateJoints(newJointValues)
|
|
128
|
+
}
|
|
129
|
+
})
|
|
101
130
|
})
|
|
102
131
|
|
|
103
132
|
return <group ref={setGroupRef}>{children}</group>
|