From 9efa735d68a8385a73290156b73850f7233e05fe Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 08 五月 2024 10:27:24 +0800
Subject: [PATCH] #
---
src/utils/common.js | 8 ++++++++
src/components/agv.jsx | 10 ++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/components/agv.jsx b/src/components/agv.jsx
index c96cf8c..4588a9d 100644
--- a/src/components/agv.jsx
+++ b/src/components/agv.jsx
@@ -14,7 +14,8 @@
} from '../config/setting'
const Agv = (props) => {
- const { agvNo, position, theta, trayList, hasBox } = props;
+ const { agvNo, position, trayList, hasBox } = props;
+ const theta = -props.theta;
const height = props.height * 0.04;
const forkLength = props.forkLength * 0.1;
const loaderTheta = Number(props.loaderTheta?.toFixed(1));
@@ -50,8 +51,8 @@
}
// group theta
- if (groupTheta !== -theta && props.theta !== null) {
- const minTheta = Common.minDiffTheta(groupTheta, -theta);
+ if (groupTheta !== theta && props.theta !== null) {
+ const minTheta = Common.normalizeAngle(theta);
new TWEEN.Tween({ value: groupTheta })
.to({ value: minTheta }, INTERVAL_TIME)
.easing(TWEEN.Easing.Linear.None)
@@ -83,9 +84,10 @@
// console.log("loaderTheta", loaderTheta);
// console.log("loaderAbsoluteAngle", loaderAbsoluteAngle);
if (integrateTheta !== loaderAbsoluteAngle && props.loaderTheta !== null) {
+ const minTheta = Common.normalizeAngle(loaderAbsoluteAngle);
// const minTheta = Common.minDiffTheta(integrateTheta, loaderAbsoluteAngle);
new TWEEN.Tween({ value: integrateTheta })
- .to({ value: loaderAbsoluteAngle }, INTERVAL_TIME)
+ .to({ value: minTheta }, INTERVAL_TIME)
.easing(TWEEN.Easing.Linear.None)
.onUpdate((e) => {
setIntegrateTheta(e.value)
diff --git a/src/utils/common.js b/src/utils/common.js
index 149c847..b3ba740 100644
--- a/src/utils/common.js
+++ b/src/utils/common.js
@@ -28,6 +28,14 @@
return (targetTheta - originTheta > 180) ? targetTheta - 360 : targetTheta;
}
+export const normalizeAngle = (angle) => {
+ let newAngle = angle % 360;
+ if (newAngle < 0) {
+ newAngle += 360;
+ }
+ return newAngle;
+}
+
export const calculateMappedPosition = (realPos) => {
return [
realPos[0] * REAL_COMPARE_MAP_SCALE + REAL_COMPARE_MAP_OFFSET_X,
--
Gitblit v1.9.1