diff --git a/src/views/cs/index2.vue b/src/views/cs/index2.vue index 104b5dd..3190b23 100644 --- a/src/views/cs/index2.vue +++ b/src/views/cs/index2.vue @@ -101,7 +101,7 @@
+ :style="`${getLocation(i.x,i.y)}transform: rotate(${parseFloat(i.rotate )- 180}deg);`"> @@ -276,9 +276,9 @@ export default { hfData: [], equipmentData: [], agvData: [], - siteData:{ - x:250000, - y:200000 + siteData: { + x: 121000, + y: 82000 } } }, @@ -293,11 +293,12 @@ export default { getAgvLocation() { let agvArr = [] getAgvData().then(e => { + console.log(Math.max(...e.Data.map(v => v.X)), Math.max(...e.Data.map(v => v.Y))) e.Data.forEach(v => { agvArr.push({ id: v.AgvId, - x: Math.random() || v.X/this.siteData.x, - y: Math.random() || v.Y/this.siteData.y, + x: (v.X - 126000) / this.siteData.x, + y: (72000 - (v.Y - 116000)) / this.siteData.y, rotate: v.Angle, isGoods: false, }) @@ -305,16 +306,22 @@ export default { this.agvData = agvArr }) }, - updateAGVLocation(time){ + updateAGVLocation(time) { getAgvData().then(e => { e.Data.forEach(v => { - if(this.agvData.filter(r=>r.id===v.AgvId).length>=1){ - new TWEEN.Tween(this.agvData.find(r=>r.id===v.AgvId)).to({x:v.X/this.siteData.x, y: v.Y/this.siteData.y}, time).start() - }else{ + if (this.agvData.filter(r => r.id === v.AgvId).length >= 1) { + new TWEEN.Tween(this.agvData.find(r => r.id === v.AgvId)).to({ + rotate: v.Angle, + }, 100).start() + new TWEEN.Tween(this.agvData.find(r => r.id === v.AgvId)).to({ + x: (v.X - 126000) / this.siteData.x, + y: (72000 - (v.Y - 116000)) / this.siteData.y, + }, time - 100).start() + } else { this.agvData.push({ id: v.AgvId, - x: Math.random() || v.X/this.siteData.x, - y: Math.random() || v.Y/this.siteData.y, + x: (v.X - 126000) / this.siteData.x, + y: (72000 - (v.Y - 116000)) / this.siteData.y, rotate: v.Angle, isGoods: false, }) @@ -340,13 +347,15 @@ export default { mounted() { this.getData() this.getAgvLocation() - setInterval(()=>{ - this.updateAGVLocation(5*1000) - },5*1000) + let time = 2 * 1000 + setInterval(() => { + this.updateAGVLocation(time) + }, time) setInterval(() => { this.loopIndex = (this.loopIndex + 1) % 26 }, 1000 * 5) + function animate() { requestAnimationFrame(animate) TWEEN.update()