test pc 3 yıl önce
ebeveyn
işleme
7cb4833b50
2 değiştirilmiş dosya ile 64 ekleme ve 36 silme
  1. 53 33
      src/move/move.service.ts
  2. 11 3
      src/scene/scene.service.ts

+ 53 - 33
src/move/move.service.ts

@@ -361,9 +361,7 @@ export class MoveService implements OnModuleInit {
         moveFrame.file_name +
         '?m=' +
         new Date().getTime();
-      if (moveFrame.file_name == '6_7_0.0031.h264') {
-        debugger;
-      }
+
       reply.startBreakPointId = startBreakPointId;
       reply.endBreakPointId = endBreakPointId;
       replys.push(reply);
@@ -860,9 +858,6 @@ export class MoveService implements OnModuleInit {
       { x: breakPoint.position.x + 1, y: breakPoint.position.y },
       playerPosition,
     );
-    if (_angle < 0) {
-      _angle += 360;
-    }
 
     let singleInfo = null;
     for (let i = 0; i < surroundPointIds.length; ++i) {
@@ -885,19 +880,24 @@ export class MoveService implements OnModuleInit {
         neighPoints.push(neighPoint);
         ++count;
       } else if (Math.abs(angle - move_angle) == 0) {
-        console.log(
-          'joystick直走--->' + breakPointId + '-' + surroundPointIds[i],
-        );
-        return await this.moveDirect(
-          playerPosition,
-          closestDis,
-          breakPointId,
-          surroundPointIds[i],
-          appId,
-          userId,
-          traceId,
-          actionType,
-        );
+        count = 2
+        console.log('handlejoysticktesttest:刚好45°的倍数')
+        //debugger;
+        break;
+
+        // console.log(
+        //   'joystick直走--->' + breakPointId + '-' + surroundPointIds[i],
+        // );
+        // return await this.moveDirect(
+        //   playerPosition,
+        //   closestDis,
+        //   breakPointId,
+        //   surroundPointIds[i],
+        //   appId,
+        //   userId,
+        //   traceId,
+        //   actionType,
+        // );
       }
 
       //if (angle == 0 && Math.abs(360 - move_angle) < 45) {
@@ -928,9 +928,10 @@ export class MoveService implements OnModuleInit {
       );
     } else {
       if (singleInfo != null) {
-        console.log(
-          'joystick校验--->' + breakPointId + '-' + singleInfo.breakPointId,
-        );
+        // console.log(
+        //   'joystick校验--->' + breakPointId + '-' + singleInfo.breakPointId,
+        // );
+        //console.log('handlejoysticktesttest校验0角度:'+_angle+','+move_angle)
         return await this.moveDirect(
           playerPosition,
           closestDis,
@@ -985,6 +986,7 @@ export class MoveService implements OnModuleInit {
       console.log(
         'joystick镜头过渡--->' + breakPointId + '-' + chooseBreakPointId,
       );
+      //this.reply.moveOver = true;
       return await this.moveCamera(
         breakPointId,
         chooseBreakPointId,
@@ -1010,9 +1012,15 @@ export class MoveService implements OnModuleInit {
         if (cameraInfo.mediaSrc) {
           this.reply.mediaSrc = cameraInfo.mediaSrc;
         } 
-        if (this.cameraInfos.length == 0) {
-          this.reply.moveOver = true;
-        }
+        // if (this.cameraInfos.length == 0) {
+        //   this.reply.moveOver = true;
+        // }
+
+        user.camera.position = JSON.parse(
+          JSON.stringify(cameraInfo.camera_position),
+        );
+        user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
+
         this.sendingFrameForJoystick = true;
       } else {
         console.log('joystick自由--->不合并');
@@ -1045,7 +1053,10 @@ export class MoveService implements OnModuleInit {
       breakPoint.position,
       this.breakPointInfo[neighBreakPointId].position,
     );
-
+    // console.log('handlejoysticktesttest校验1线段:'+breakPointId+','+neighBreakPointId)
+    // console.log('handlejoysticktesttest校验2计算后的:'+JSON.stringify(player_Position))
+    // console.log('handlejoysticktesttest校验3人物变化前:'+JSON.stringify(user.player.position))
+    // console.log('handlejoysticktesttest校验4人物本应该的坐标:'+JSON.stringify(playerPosition))
     if (player_Position != null) {
       playerPosition.x = player_Position.x;
       playerPosition.y = player_Position.y;
@@ -1053,6 +1064,7 @@ export class MoveService implements OnModuleInit {
     }
 
     if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
+      //this.reply.moveOver = true;
       return await this.moveCamera(
         breakPointId,
         neighBreakPointId,
@@ -1076,9 +1088,15 @@ export class MoveService implements OnModuleInit {
         if (cameraInfo.mediaSrc) {
           this.reply.mediaSrc = cameraInfo.mediaSrc;
         } 
-        if (this.cameraInfos.length == 0) {
-          this.reply.moveOver = true;
-        }
+        // if (this.cameraInfos.length == 0) {
+        //   this.reply.moveOver = true;
+        // }
+
+        user.camera.position = JSON.parse(
+          JSON.stringify(cameraInfo.camera_position),
+        );
+        user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
+        
         this.sendingFrameForJoystick = true;
       }
       return this.reply;
@@ -1143,7 +1161,9 @@ export class MoveService implements OnModuleInit {
       const moveFramesRes = await this.cacheService.get(key);
       const moveFrames = JSON.parse(moveFramesRes);
       this.setCameraInfo(appId,moveFrames,breakPointId,chooseBreakPointId);
-      //user.breakPointId = chooseBreakPointId;
+      
+      user.breakPointId = chooseBreakPointId;
+      
       const cameraInfo = this.getCameraInfo();
       if (cameraInfo != null) {
         this.reply['newUserStates'][0].playerState.camera.position =
@@ -1219,9 +1239,9 @@ export class MoveService implements OnModuleInit {
         this.reply.mediaSrc = cameraInfo.mediaSrc;
       } 
 
-      if(this.cameraInfos.length == 0){
-        this.reply.moveOver = true;
-      }
+      // if(this.cameraInfos.length == 0){
+      //   this.reply.moveOver = true;
+      // }
       this.sendingFrameForJoystick = true;
       return this.reply;
     } 

+ 11 - 3
src/scene/scene.service.ts

@@ -579,12 +579,19 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
       if (joystickRes) {
         this.onJoysticking.next(true);
+        // console.log(
+        //   'handlejoystick:' +
+        //     joystickRes.mediaSrc +
+        //     ',相机坐标:' +
+        //     JSON.stringify(
+        //       joystickRes.newUserStates[0].playerState.camera.position,
+        //     ),
         console.log(
-          'handlejoystick:' +
+          'handlejoysticktesttest:' +
             joystickRes.mediaSrc +
             ',相机坐标:' +
             JSON.stringify(
-              joystickRes.newUserStates[0].playerState.camera.position,
+              joystickRes.newUserStates[0].playerState.player.position,
             ),
         );
         if (joystickRes.mediaSrc) {
@@ -613,6 +620,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             console.log('joystick-hasPush', hasPush);
             this.moveService.sendingFrameForJoystick = false;
             const data = joystickRes as StreamReplyType;
+            console.log('handlejoystick-moveOver:'+data.moveOver)
             if (data?.moveOver && data.moveOver) {
               // moveOver
               console.log('回传updateUser', data);
@@ -620,7 +628,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
               // 回传点暂时有问题,待修复
               const breakPointId = data.endBreakPointId || data.breakPointId;
               const lastReply = JSON.stringify(joystickRes);
-              this.moveService.updateUser(userId, breakPointId, lastReply);
+              //this.moveService.updateUser(userId, breakPointId, lastReply);
               this.resumeStream();
             }
           } else {