Ver código fonte

飞机角度bug

Rmengdi 2 meses atrás
pai
commit
022c2d17c2
1 arquivos alterados com 10 adições e 9 exclusões
  1. 10 9
      uavps-web/src/views/uavps/parameter/index.vue

+ 10 - 9
uavps-web/src/views/uavps/parameter/index.vue

@@ -688,8 +688,6 @@ export default {
       // 集群无人机总数
       // this.targetTotal = 2;
       this.targetTotal = data.targetAircraft[0].aircrafts.length;
-      // console.log("data.targetAircraft[0]", data.targetAircraft[0]);
-      // debugger;
       // 创建无人机,红色圆圈编号
       if (this.targetUavAry.length === 0) {
         this.targetTexture = new PIXI.Texture.from(
@@ -703,14 +701,13 @@ export default {
           group.interactive = true;
           // 创建无人机
           const dude = new PIXI.Sprite(this.targetTexture);
-          dude.anchor.set(0.5);
+          dude.anchor.set(0.5, 0.5);
           dude.scale.set(0.04);
           dude.x = data.targetAircraft[0].aircrafts[i].coordinateX;
           dude.y = data.targetAircraft[0].aircrafts[i].coordinateY;
-          dude.rotation = Math.atan2(dude.y, dude.x) + Math.PI / 2;
-
-          // const rotation = Math.atan2(eastSpeed, northSpeed);
-          // dude.rotation = (-rotation + 2 * Math.PI) % (2 * Math.PI);
+          const eastSpeed = data.targetAircraft[0].aircrafts[i].eastSpeed;
+          const northSpeed = data.targetAircraft[0].aircrafts[i].northSpeed;
+          dude.rotation = Math.atan2(northSpeed, eastSpeed);
 
           dude.id = data.targetAircraft[0].aircrafts[i].aircraftNumber; // 分配唯一编号
 
@@ -769,8 +766,12 @@ export default {
 
           targetUav.x = data.targetAircraft[0].aircrafts[i].coordinateX;
           targetUav.y = data.targetAircraft[0].aircrafts[i].coordinateY;
-          targetUav.rotation =
-            Math.atan2(targetUav.y, targetUav.x) + Math.PI / 2;
+          const eastSpeed = data.targetAircraft[0].aircrafts[i].eastSpeed;
+          const northSpeed = data.targetAircraft[0].aircrafts[i].northSpeed;
+          // targetUav.rotation = Math.atan2(northSpeed, eastSpeed) + Math.PI / 2;
+          targetUav.rotation = Math.atan2(northSpeed, eastSpeed);
+          // const rotation = Math.atan2(eastSpeed, northSpeed);
+          // targetUav.rotation = (-rotation + 2 * Math.PI) % (2 * Math.PI);
 
           const cx = targetUav.x - 25;
           const cy = targetUav.y - 17;