@wandelbots/wandelbots-js-react-components 2.41.0-pr.feature-seperate-timer.383.cd7e408 → 2.41.0-pr.feature-seperate-timer.383.38eb55e

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": "2.41.0-pr.feature-seperate-timer.383.cd7e408",
3
+ "version": "2.41.0-pr.feature-seperate-timer.383.38eb55e",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -9,7 +9,7 @@ import { observer } from "mobx-react-lite"
9
9
  import { useRef, useState } from "react"
10
10
  import { externalizeComponent } from "../../externalizeComponent"
11
11
  import { CopyableText } from "../CopyableText"
12
- import { useAnimationFrame } from "../utils/hooks"
12
+ import { useAutorun } from "../utils/hooks"
13
13
 
14
14
  /** Minimal interface for what PoseCartesianValues needs from motion stream */
15
15
  type MotionStateProvider = {
@@ -79,16 +79,24 @@ export const PoseCartesianValues = externalizeComponent(
79
79
  }
80
80
  }
81
81
 
82
- useAnimationFrame(() => {
83
- if (!poseHolderRef.current) {
84
- return
85
- }
86
- const newPoseContent = getCurrentPoseString()
87
- if (poseHolderRef.current.textContent === newPoseContent) {
82
+ useAutorun(() => {
83
+ if (!poseHolderRef.current || !activeMotionStream) {
88
84
  return
89
85
  }
90
86
 
91
- poseHolderRef.current.textContent = newPoseContent
87
+ const tcpPose = activeMotionStream.rapidlyChangingMotionState.tcp_pose
88
+ if (!tcpPose) return
89
+
90
+ const newPoseContent = poseToWandelscriptString(tcpPose)
91
+
92
+ requestAnimationFrame(() => {
93
+ if (
94
+ poseHolderRef.current &&
95
+ poseHolderRef.current.textContent !== newPoseContent
96
+ ) {
97
+ poseHolderRef.current.textContent = newPoseContent
98
+ }
99
+ })
92
100
  })
93
101
 
94
102
  return (
@@ -8,7 +8,7 @@ import { observer } from "mobx-react-lite"
8
8
  import { useRef, useState } from "react"
9
9
  import { externalizeComponent } from "../../externalizeComponent"
10
10
  import { CopyableText } from "../CopyableText"
11
- import { useAnimationFrame } from "../utils/hooks"
11
+ import { useAutorun } from "../utils/hooks"
12
12
 
13
13
  /** Minimal interface for what PoseJointValues needs from motion stream */
14
14
  type MotionStateProvider = {
@@ -78,16 +78,23 @@ export const PoseJointValues = externalizeComponent(
78
78
  }
79
79
  }
80
80
 
81
- useAnimationFrame(() => {
82
- if (!poseHolderRef.current) {
81
+ useAutorun(() => {
82
+ if (!poseHolderRef.current || !activeMotionStream) {
83
83
  return
84
84
  }
85
85
 
86
- const newPoseContent = getCurrentPoseString()
87
- if (poseHolderRef.current.textContent === newPoseContent) {
88
- return
89
- }
90
- poseHolderRef.current.textContent = newPoseContent
86
+ const { joints } =
87
+ activeMotionStream.rapidlyChangingMotionState.state.joint_position
88
+ const newPoseContent = `[${joints.map((j: number) => parseFloat(j.toFixed(4))).join(", ")}]`
89
+
90
+ requestAnimationFrame(() => {
91
+ if (
92
+ poseHolderRef.current &&
93
+ poseHolderRef.current.textContent !== newPoseContent
94
+ ) {
95
+ poseHolderRef.current.textContent = newPoseContent
96
+ }
97
+ })
91
98
  })
92
99
 
93
100
  return (