修改动画开始时机

master
夜笙歌 6 months ago
parent 97aeade5a2
commit 733bd264f9

2
hw-ui/.gitignore vendored

@ -22,4 +22,4 @@ selenium-debug.log
package-lock.json
yarn.lock
vue.config.js

@ -1,7 +1,7 @@
import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader'
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader'
import * as THREE from 'three'
import { camera, labelRenderer, renderer, scene } from '@/views/board/model/setThree'
import { camera, labelRenderer, renderer, scene,isLoading } from '@/views/board/model/setThree'
import * as TWEEN from '@tweenjs/tween.js'
let timeOrSpeed = true
@ -276,7 +276,7 @@ const AGVAnimationF = (item, type, newLocation = 0, time = 2000) => {
}
let distance = location - agvData[AGVLocationData].x
let tween = new TWEEN.Tween(agvData[group].position)
.to({ x: location }, Math.abs(distance) / s * 16) // 移动到(1, 1, 1)持续1000毫秒
.to({ x: location }, Math.abs(distance) / s * 16) // 移动到(1, 1, 1)持续1000毫秒
.onComplete(() => {
agvData[group].position.x = location
agvData[AGVLocationData].x = location
@ -335,7 +335,7 @@ const AGVAnimationF = (item, type, newLocation = 0, time = 2000) => {
let distance = location - agvData[AGVLocationData].z
let tween = new TWEEN.Tween(agvData[group].position)
.to({ z: location }, Math.abs(distance) / s * 16) // 移动到(1, 1, 1)持续1000毫秒
.to({ z: location }, Math.abs(distance) / s * 16) // 移动到(1, 1, 1)持续1000毫秒
.onComplete(() => {
agvData[group].position.z = location
agvData[AGVLocationData].z = location
@ -393,7 +393,7 @@ const AGVAnimationF = (item, type, newLocation = 0, time = 2000) => {
let bool = (nowRotateNum - endRotateNum) > 0
let tween = new TWEEN.Tween(agvData[group].rotation)
.to({ y: newLocation * (Math.PI / 180) }, 500) // 移动到(1, 1, 1)持续1000毫秒
.to({ y: newLocation * (Math.PI / 180) }, 500) // 移动到(1, 1, 1)持续1000毫秒
.onComplete(() => {
agvData[group].rotation.y = (newLocation * (Math.PI / 180))
resolve()
@ -436,50 +436,53 @@ const AGVAnimation = (e, item, type, newLocation = 0, time = 2000) => {
}
setInterval(() => {
let num1_1 = Math.random()
let num1_2 = Math.random()
let num1_3 = Math.random()
let num1_4 = Math.random()
let num1_5 = Math.random()
if (num1_1 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('2AGV', '2AGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('2AGV', '2AGV', 'z', num2)
}
if (isLoading) {
let num1_1 = Math.random()
let num1_2 = Math.random()
let num1_3 = Math.random()
let num1_4 = Math.random()
let num1_5 = Math.random()
if (num1_2 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('3AGV', '3AGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('3AGV', '3AGV', 'z', num2)
}
if (num1_1 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('2AGV', '2AGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('2AGV', '2AGV', 'z', num2)
}
if (num1_3 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('5CCAGV', '5CCAGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('5CCAGV', '5CCAGV', 'z', num2)
}
if (num1_2 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('3AGV', '3AGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('3AGV', '3AGV', 'z', num2)
}
if (num1_4 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('5BFAGV', '5BFAGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('5BFAGV', '5BFAGV', 'z', num2)
}
if (num1_3 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('5CCAGV', '5CCAGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('5CCAGV', '5CCAGV', 'z', num2)
}
if (num1_5 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('5CTU', '5CTU', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('5CTU', '5CTU', 'z', num2)
if (num1_4 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('5BFAGV', '5BFAGV', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('5BFAGV', '5BFAGV', 'z', num2)
}
if (num1_5 > 0.5) {
let num2 = Math.random() * 100
AGVAnimation('5CTU', '5CTU', 'x', num2)
} else {
let num2 = Math.random() * 100
AGVAnimation('5CTU', '5CTU', 'z', num2)
}
}
}, 1000)

@ -1,6 +1,7 @@
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader'
import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader'
import {
isLoading,
tuopanLocation,
tishengjiLocation, keyidongModel, storeyHeight, tuopanModel, animationLine, storeyWidth
} from './setThree'
@ -136,25 +137,6 @@ const tuopanYAnimation = (model, floor, newLocation = 0, time = 2000) => {
})
}
setInterval(() => {
if (animationLine.length < 5) {
let floor = Math.ceil(Math.random() * 5)
animationLine.push(() => {
if (tuopanInishengji) {
return Promise.all([tishengjiAnimation(keyidongModel, floor, storeyHeight[floor]), tuopanYAnimation(tuopanModel, floor, storeyHeight[floor])])
} else {
animationLine.push(() => tishengjiAnimation(keyidongModel, floor, storeyHeight[floor]))
}
})
if (Math.random() > 0.5) {
animationLine.push(() => tuopanXAnimation(tuopanModel, storeyWidth[floor]))
animationLine.push(() => tuopanXAnimation(tuopanModel, 0))
}
}
}, 1800)
const addtuopan = (params) => {
return new Promise((resolve, reject) => {
try {
@ -188,6 +170,28 @@ const addtuopan = (params) => {
}
setInterval(() => {
if (isLoading) {
if (animationLine.length < 5) {
let floor = Math.ceil(Math.random() * 5)
animationLine.push(() => {
if (tuopanInishengji) {
return Promise.all([tishengjiAnimation(keyidongModel, floor, storeyHeight[floor]), tuopanYAnimation(tuopanModel, floor, storeyHeight[floor])])
} else {
animationLine.push(() => tishengjiAnimation(keyidongModel, floor, storeyHeight[floor]))
}
})
if (Math.random() > 0.5) {
animationLine.push(() => tuopanXAnimation(tuopanModel, storeyWidth[floor]))
animationLine.push(() => tuopanXAnimation(tuopanModel, 0))
}
}
}
}, 1800)
export {
tuopanInishengji,
tishengjiAnimation,

@ -142,6 +142,7 @@ export default {
loadF(['tishengji', 'AGVchongdianzhuang002', 'AGVchongdianzhuang003', 'changfang002', 'changfang003', 'quanzidongchaibaojizhaungpeixian003', 'tishengji_keyidongbufen', 'tishengji_tuopan', 'AGVchongdianzhuang005', 'changfang005', 'liku005'])
// loadF(['changfang002', 'changfang003', 'changfang005'])
// CSS2DObject
// const label = this.$refs.demo
// const labelObject = new CSS2DObject(label)

@ -5,6 +5,7 @@ import * as TWEEN from '@tweenjs/tween.js'
import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader'
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader'
let isLoading = false
let isAnimation = false
let animationLine = []
let keyidongModel
@ -118,13 +119,17 @@ animate()
let a = 0
const loadingManager = new THREE.LoadingManager();
loadingManager.onLoad = function() {
isLoading = true
};
const loadF = (e) => {
e.forEach(v => {
let mtlLoader = new MTLLoader()
mtlLoader.load(`/model/${v}/${v}.mtl`,
materials => {
materials.preload()
let loader = new OBJLoader()
let loader = new OBJLoader(loadingManager)
loader.setMaterials(materials)
loader.load(
`/model/${v}/${v}.obj`,
@ -179,6 +184,7 @@ let tuopanLocation = {
}
export {
isLoading,
keyidongModel,
tuopanModel,
scene,

Loading…
Cancel
Save