test pc vor 3 Jahren
Ursprung
Commit
7b1719c900
1 geänderte Dateien mit 39 neuen und 53 gelöschten Zeilen
  1. 39 53
      src/move/move.service.ts

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

@@ -1009,22 +1009,7 @@ export class MoveService implements OnModuleInit {
 
         if (cameraInfo.mediaSrc) {
           this.reply.mediaSrc = cameraInfo.mediaSrc;
-        } else if (cameraInfo.file_name) {
-          this.reply.mediaSrc =
-            '/' +
-            appId +
-            '/' +
-            breakPointId +
-            '/' +
-            cameraInfo.file_name.substring(
-              0,
-              cameraInfo.file_name.indexOf('.'),
-            ) +
-            '/' +
-            cameraInfo.file_name +
-            '?m=' +
-            new Date().getTime();
-        }
+        } 
         if (this.cameraInfos.length == 0) {
           this.reply.moveOver = true;
         }
@@ -1090,23 +1075,7 @@ export class MoveService implements OnModuleInit {
 
         if (cameraInfo.mediaSrc) {
           this.reply.mediaSrc = cameraInfo.mediaSrc;
-        } else if (cameraInfo.file_name) {
-          this.reply.mediaSrc =
-            '/' +
-            appId +
-            '/' +
-            breakPointId +
-            '/' +
-            cameraInfo.file_name.substring(
-              0,
-              cameraInfo.file_name.indexOf('.'),
-            ) +
-            '/' +
-            cameraInfo.file_name +
-            '?m=' +
-            new Date().getTime();
-        }
-
+        } 
         if (this.cameraInfos.length == 0) {
           this.reply.moveOver = true;
         }
@@ -1173,7 +1142,7 @@ export class MoveService implements OnModuleInit {
         Math.floor(user.camera.angle.yaw / 45);
       const moveFramesRes = await this.cacheService.get(key);
       const moveFrames = JSON.parse(moveFramesRes);
-      this.setCameraInfo(moveFrames,chooseBreakPointId);
+      this.setCameraInfo(appId,moveFrames,breakPointId,chooseBreakPointId);
       //user.breakPointId = chooseBreakPointId;
       const cameraInfo = this.getCameraInfo();
       if (cameraInfo != null) {
@@ -1189,24 +1158,7 @@ export class MoveService implements OnModuleInit {
 
         if (cameraInfo.mediaSrc) {
           this.reply.mediaSrc = cameraInfo.mediaSrc;
-        } else if (cameraInfo.file_name) {
-          this.reply.mediaSrc =
-            '/' +
-            appId +
-            '/' +
-            breakPointId +
-            '/' +
-            cameraInfo.file_name.substring(
-              0,
-              cameraInfo.file_name.indexOf('.'),
-            ) +
-            '/' +
-            cameraInfo.file_name +
-            '?m=' +
-            new Date().getTime();
-        } else {
-          debugger;
-        }
+        } 
         this.reply.moveStart = true;
         this.sendingFrameForJoystick = true;
       }
@@ -1214,9 +1166,10 @@ export class MoveService implements OnModuleInit {
     }
   }
 
-  setCameraInfo(moveFrames,endBreakPointId) {
+  setCameraInfo(appId,moveFrames,startBreakPointId,endBreakPointId) {
     for (let i = 0; i < moveFrames.length; i += 5) {
       moveFrames[i].endBreakPointId = endBreakPointId;
+      moveFrames[i].mediaSrc =  '/' + appId +'/' + startBreakPointId +'/' + moveFrames[i].file_name.substring( 0, moveFrames[i].file_name.indexOf('.'), ) + '/' +moveFrames[i].file_name + '?m=' +new Date().getTime();
       this.cameraInfos.push(moveFrames[i]);
     }
   }
@@ -1238,6 +1191,39 @@ export class MoveService implements OnModuleInit {
     }
   }
 
+  complementFrame(userId){
+    if (this.cameraInfos.length > 0) {
+      const user = this.users[userId];
+      const cameraInfo = this.cameraInfos.shift();
+      this.reply.traceIds = [];
+      this.reply['newUserStates'][0].userId = userId;
+      this.reply['actionResponses'][0].traceId = null;
+      this.reply['newUserStates'][0].playerState.player.angle.yaw = user.player.angle.yaw;
+      this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+        JSON.stringify(user.player.position),
+      );
+      this.reply['newUserStates'][0].playerState.camera.angle = JSON.parse(
+        JSON.stringify(cameraInfo.camera_angle),
+      );
+      this.reply['newUserStates'][0].playerState.camera.position = JSON.parse(
+        JSON.stringify(cameraInfo.camera_position),
+      );
+
+      this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
+        JSON.stringify(user.player.position),
+      );
+      this.reply['newUserStates'][0].renderInfo.isMoving = 0;
+      this.reply['actionResponses'][0].traceId = null;
+      
+      if (cameraInfo.mediaSrc) {
+        this.reply.mediaSrc = cameraInfo.mediaSrc;
+      } 
+    } 
+    else {
+      return null;
+    }
+  }
+
   async modeifyCameraAngle(angle, userId, traceId, actionType) {
     const checkReplys = [];
     if (angle > 22) {