From 4873e7b5eb2f75e38768b8886c11a1e1c2708b7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com>
Date: Fri, 12 Jul 2024 13:40:37 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E5=8D=87=E6=9C=BA?=
=?UTF-8?q?=E5=8A=A8=E7=94=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hw-ui/src/views/board/model/animation.js | 124 +++++++++--------------
hw-ui/src/views/board/model/index.vue | 96 +++++++-----------
2 files changed, 83 insertions(+), 137 deletions(-)
diff --git a/hw-ui/src/views/board/model/animation.js b/hw-ui/src/views/board/model/animation.js
index 4ffa103..59ba57b 100644
--- a/hw-ui/src/views/board/model/animation.js
+++ b/hw-ui/src/views/board/model/animation.js
@@ -1,3 +1,4 @@
+let tuopanInishengji = true
let storeyHeight = {
1: 0,
2: 261.9,
@@ -27,70 +28,70 @@ let tuopanLocation = {
z: 0
}
-const tishengjiAnimation = (model, oddLocation = 0, newLocation = 0, time = 2000) => {
+const tishengjiAnimation = (model, floor, newLocation = 0, time = 2000) => {
return new Promise((resolve, reject) => {
- try {
- if (!model) {
- reject()
+ tishengjiLocation.floor = floor
+ if (!model || tishengjiLocation.y === newLocation) {
+ resolve()
+ }
+ let distance = newLocation - tishengjiLocation.y
+ let time1 = setInterval(() => {
+ if ((distance > 0 && model.position.y >= newLocation) || (distance < 0 && model.position.y <= newLocation)) {
+ model.position.y = newLocation
+ tishengjiLocation.y = newLocation
+ resolve()
+ clearInterval(time1)
+ clearTimeout(time3)
+ } else {
+ model.position.y += distance / (time / 16)
+ tishengjiLocation.y = model.position.y
}
- let distance = newLocation - oddLocation
+ }, 16)
+ let time3 = setTimeout(() => {
+ resolve()
+ clearInterval(time1)
+ clearTimeout(time3)
+ }, time + 1000)
+
+ })
+}
+
+const tuopanXAnimation = (model, newLocation = 0, time = 2000) => {
+ return new Promise((resolve, reject) => {
+ if (!model || newLocation === tuopanLocation.x || tishengjiLocation.floor !== tuopanLocation.floor) {
+ resolve()
+ }else{
+ tuopanInishengji = newLocation === 0;
+ let distance = newLocation - tuopanLocation.x
let time1 = setInterval(() => {
- if ((distance > 0 && model.position.y >= newLocation) || (distance < 0 && model.position.y <= newLocation)) {
- model.position.y = newLocation
- tishengjiLocation.y = newLocation
+ if ((distance > 0 && model.position.x >= newLocation) || (distance < 0 && model.position.x <= newLocation)) {
+ model.position.x = newLocation
+ tuopanLocation.x = newLocation
resolve()
clearInterval(time1)
clearTimeout(time3)
} else {
- model.position.y += distance / (time / 16)
- tishengjiLocation.y = model.position.y
+ model.position.x += distance / (time / 16)
+ tuopanLocation.x = model.position.x
}
}, 16)
let time3 = setTimeout(() => {
- reject()
+ resolve(0)
clearInterval(time1)
clearTimeout(time3)
}, time + 1000)
-
- }catch (e) {
- console.log(e)
}
})
}
-const tuopanXAnimation = (model, oddLocation = 0, newLocation = 0, time = 2000) => {
+const tuopanYAnimation = (model, floor, newLocation = 0, time = 2000) => {
return new Promise((resolve, reject) => {
- if (!model) {
- reject()
- }
- let distance = newLocation - oddLocation
- let time1 = setInterval(() => {
- if ((distance > 0 && model.position.x >= newLocation) || (distance < 0 && model.position.x <= newLocation)) {
- model.position.x = newLocation
- tuopanLocation.x = newLocation
- resolve()
- clearInterval(time1)
- clearTimeout(time3)
- } else {
- model.position.x += distance / (time / 16)
- tuopanLocation.x = model.position.x
- }
- }, 16)
- let time3 = setTimeout(() => {
- reject()
- clearInterval(time1)
- clearTimeout(time3)
- }, time + 1000)
- })
-}
-
-const tuopanYAnimation = (model, oddLocation = 0, newLocation = 0, time = 2000) => {
- return new Promise((resolve, reject) => {
- if (!model) {
- reject()
+ tuopanLocation.floor = floor
+ if (!model || tuopanLocation.y === newLocation) {
+ resolve()
}
- let distance = newLocation - oddLocation
+ let distance = newLocation - tuopanLocation.y
let time1 = setInterval(() => {
if ((distance > 0 && model.position.y >= newLocation) || (distance < 0 && model.position.y <= newLocation)) {
model.position.y = newLocation
@@ -104,50 +105,19 @@ const tuopanYAnimation = (model, oddLocation = 0, newLocation = 0, time = 2000)
}
}, 16)
let time3 = setTimeout(() => {
- reject()
- clearInterval(time1)
- clearTimeout(time3)
- }, time + 1000)
- })
-}
-
-const tuopanAnimation = (model, oddLocation = {}, newLocation = {}, time = 2000) => {
- return new Promise((resolve, reject) => {
- if (!model) {
- reject()
- }
- let X = ((newLocation.x === null || newLocation.x === undefined) ? oddLocation.x : newLocation.x) - oddLocation.x
- let Y = ((newLocation.y === null || newLocation.y === undefined) ? oddLocation.y : newLocation.y) - oddLocation.y
- let time1 = setInterval(() => {
- model.position.x += X / (time / 16)
- model.position.y += Y / (time / 16)
- tuopanLocation.x = model.position.x
- tuopanLocation.y = model.position.y
- }, 16)
- let time2 = setTimeout(() => {
- model.position.x = ((newLocation.x === null || newLocation.x === undefined) ? oddLocation.x : newLocation.x)
- model.position.y = ((newLocation.y === null || newLocation.y === undefined) ? oddLocation.y : newLocation.y)
resolve()
clearInterval(time1)
- clearTimeout(time2)
- clearTimeout(time3)
- }, time)
- let time3 = setTimeout(() => {
- reject()
- clearInterval(time1)
- clearTimeout(time2)
clearTimeout(time3)
}, time + 1000)
})
}
export {
+ tuopanInishengji,
storeyHeight,
storeyWidth,
- tishengjiLocation,
- tuopanLocation,
tishengjiAnimation,
tuopanXAnimation,
tuopanYAnimation,
- tuopanAnimation
+ tuopanLocation
}
diff --git a/hw-ui/src/views/board/model/index.vue b/hw-ui/src/views/board/model/index.vue
index be7e0e3..829103e 100644
--- a/hw-ui/src/views/board/model/index.vue
+++ b/hw-ui/src/views/board/model/index.vue
@@ -6,7 +6,7 @@