@wandelbots/wandelbots-js-react-components 4.0.2 → 4.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -86,8 +86,10 @@ export default function RobotAnimator({
86
86
  (item) => item !== undefined,
87
87
  )
88
88
 
89
- jointValues.current = newJointValues
90
- interpolatorRef.current?.setTarget(newJointValues)
89
+ requestAnimationFrame(() => {
90
+ jointValues.current = newJointValues
91
+ interpolatorRef.current?.setTarget(newJointValues)
92
+ })
91
93
  }, [rapidlyChangingMotionState])
92
94
 
93
95
  /**
@@ -95,10 +97,17 @@ export default function RobotAnimator({
95
97
  * requestAnimationFrame used to avoid blocking main thread
96
98
  */
97
99
  useEffect(() => {
98
- requestAnimationFrame(() => {
99
- updateJoints()
100
- })
100
+ updateJoints()
101
101
  }, [rapidlyChangingMotionState, updateJoints])
102
102
 
103
+ /**
104
+ * As some consumer applications (eg. storybook) deliver
105
+ * mobx observable for rapidlyChangingMotionState, we need to
106
+ * register the watcher to get the newest value updates
107
+ */
108
+ useAutorun(() => {
109
+ updateJoints()
110
+ })
111
+
103
112
  return <group ref={setGroupRef}>{children}</group>
104
113
  }