test pc 3 anni fa
parent
commit
c8c4e708d9
2 ha cambiato i file con 23 aggiunte e 12 eliminazioni
  1. 17 11
      src/move/move.service.ts
  2. 6 1
      src/scene/scene.service.ts

+ 17 - 11
src/move/move.service.ts

@@ -129,6 +129,7 @@ export class MoveService implements OnModuleInit {
   private breakPointInfo: any;
 
   private cameraInfos = [];
+  public sendingFrameForJoystick = false;
 
   // eslint-disable-next-line @typescript-eslint/no-empty-function
   async onModuleInit() {
@@ -777,7 +778,13 @@ export class MoveService implements OnModuleInit {
   // }
 
   async joystick(actionRequest) {
-    try {
+    //try {
+
+
+      if(this.sendingFrameForJoystick){
+        return null;
+      }
+
       const userId = actionRequest['user_id'];
       const traceId = actionRequest['trace_id'];
       const dir_action = actionRequest['dir_action'];
@@ -1023,16 +1030,18 @@ export class MoveService implements OnModuleInit {
           if(this.cameraInfos.length == 0){
             this.reply.moveOver = true;
           }
+          this.sendingFrameForJoystick = true;
         } else {
           console.log('joystick自由--->不合并');
         }
         return this.reply;
       }
-    } catch (error) {
-      console.log('MoveService', error);
-      debugger;
-      return null;
-    }
+    // } 
+    // catch (error) {
+    //   console.log('MoveService', error);
+    //   debugger;
+    //   return null;
+    // }
   }
 
   //沿着最合适的neighBreakPointId走
@@ -1102,6 +1111,7 @@ export class MoveService implements OnModuleInit {
         if(this.cameraInfos.length == 0){
           this.reply.moveOver = true;
         }
+        this.sendingFrameForJoystick = true;
       }
       return this.reply;
     }
@@ -1212,13 +1222,9 @@ export class MoveService implements OnModuleInit {
           debugger;
         }
         this.reply.moveStart = true;
+        this.sendingFrameForJoystick = true;
       }
       return this.reply;
-      // user.camera.position = JSON.parse(
-      //   JSON.stringify(lastFrame.camera_position),
-      // );
-      // user.camera.angle.yaw = lastFrame.camera_angle.yaw;
-      // return replys;
     }
   }
 

+ 6 - 1
src/scene/scene.service.ts

@@ -612,7 +612,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       // 有数据 [0]是rotate数据,[1-infinity]是walking数据
       this.logger.log('joystickRes-1', joystickRes);
       this.onJoysticking.next(true);
-      console.log('handlejoystick:'+joystickRes.mediaSrc+',坐标:'+JSON.stringify(joystickRes.newUserStates[0].playerState.camera.position))
+      if(joystickRes != null){
+        console.log('handlejoystick:'+joystickRes.mediaSrc+',相机坐标:'+JSON.stringify(joystickRes.newUserStates[0].playerState.camera.position))
+      }
+      else{
+        console.log('handlejoystick:null');
+      }
       if (Array.isArray(joystickRes)) {
         // 处理第一个镜头数据
         const rotateCamData = joystickRes[0];