From 1c0347c32b3f20c9eb4b482b1535ff8a1e9518c3 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 23 四月 2024 11:18:48 +0800
Subject: [PATCH] #

---
 src/utils/common.js    |    7 ++++++-
 src/assets/data/agv.js |    2 +-
 src/components/agv.jsx |    3 ++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/assets/data/agv.js b/src/assets/data/agv.js
index 6d3a899..affd012 100644
--- a/src/assets/data/agv.js
+++ b/src/assets/data/agv.js
@@ -27,7 +27,7 @@
         {
             no: 1,
             position: [100, 0, 0],
-            theta: 90,
+            theta: 270,
             height: 100,
             loaderTheta: 180,
             forkLength: 0,
diff --git a/src/components/agv.jsx b/src/components/agv.jsx
index cf713ed..89041bb 100644
--- a/src/components/agv.jsx
+++ b/src/components/agv.jsx
@@ -42,8 +42,9 @@
 
         // group theta
         if (groupTheta !== theta) {
+            const minTheta = Common.minDiffTheta(groupTheta, theta);
             new TWEEN.Tween({ value: groupTheta })
-                .to({ value: theta }, INTERVAL_TIME)
+                .to({ value: minTheta }, INTERVAL_TIME)
                 .easing(TWEEN.Easing.Linear.None)
                 .onUpdate((e) => {
                     setGroupTheta(e.value)
diff --git a/src/utils/common.js b/src/utils/common.js
index 4806db1..01b74cc 100644
--- a/src/utils/common.js
+++ b/src/utils/common.js
@@ -19,7 +19,12 @@
 }
 
 export const rotationParseNum = (num) => {
-    return num * Math.PI / 180;
+    const normalizedDegrees = num % 360;
+    return normalizedDegrees * Math.PI / 180;
+}
+
+export const minDiffTheta = (originTheta, targetTheta) => {
+    return (targetTheta - originTheta > 180) ? targetTheta - 360 : targetTheta;
 }
 
 export const setShadow = (obj) => {

--
Gitblit v1.9.1