gemercheung 3 years ago
parent
commit
4b64f98792

+ 1 - 1
config.dev.yaml

@@ -5,7 +5,7 @@ app:
 
 
 queueConfig:
 queueConfig:
   move: 10
   move: 10
-  rotate: 10
+  rotate: 2
 
 
 http:
 http:
   host: '0.0.0.0'
   host: '0.0.0.0'

+ 1 - 1
config.production.yaml

@@ -5,7 +5,7 @@ app:
 
 
 queueConfig:
 queueConfig:
   move: 10
   move: 10
-  rotate: 10
+  rotate: 2
 
 
 http:
 http:
   host: '0.0.0.0'
   host: '0.0.0.0'

+ 1 - 1
config.production1.yaml

@@ -4,7 +4,7 @@ app:
 
 
 queueConfig:
 queueConfig:
   move: 10
   move: 10
-  rotate: 5
+  rotate: 2
 
 
 http:
 http:
   host: '0.0.0.0'
   host: '0.0.0.0'

+ 402 - 121
src/move/move.service.ts

@@ -181,6 +181,7 @@ export class MoveService implements OnModuleInit {
     user.appId = app_id;
     user.appId = app_id;
     user.userId = userId;
     user.userId = userId;
     user.breakPointId = Number(this.configService.get('app.startPoint')) || 0;
     user.breakPointId = Number(this.configService.get('app.startPoint')) || 0;
+    console.log('user-init', user);
     this.users[userId] = user;
     this.users[userId] = user;
   }
   }
 
 
@@ -384,6 +385,9 @@ export class MoveService implements OnModuleInit {
         moveFrame.file_name +
         moveFrame.file_name +
         '?m=' +
         '?m=' +
         new Date().getTime();
         new Date().getTime();
+      if (moveFrame.file_name == '6_7_0.0031.h264') {
+        debugger;
+      }
       reply.startBreakPointId = startBreakPointId;
       reply.startBreakPointId = startBreakPointId;
       reply.endBreakPointId = endBreakPointId;
       reply.endBreakPointId = endBreakPointId;
       replys.push(reply);
       replys.push(reply);
@@ -639,67 +643,79 @@ export class MoveService implements OnModuleInit {
 
 
       //方向不对的话,人物不能走动,只是修改朝向
       //方向不对的话,人物不能走动,只是修改朝向
       // 找到和角度最贴近的邻居点
       // 找到和角度最贴近的邻居点
+      let _angle = this.getAngle(
+        breakPoint.position,
+        {
+          x: this.breakPointInfo[surroundPointIds[0]].position.x,
+          y: this.breakPointInfo[surroundPointIds[0]].position.y,
+        },
+        playerPosition,
+      );
 
 
-      let _angle = null;
       if (surroundPointIds.length == 1) {
       if (surroundPointIds.length == 1) {
-        _angle = this.getAngle(
-          breakPoint.position,
-          {
-            x: this.breakPointInfo[surroundPointIds[0]].position.x,
-            y: this.breakPointInfo[surroundPointIds[0]].position.y,
-          },
+        return await this.moveDirect(
           playerPosition,
           playerPosition,
+          closestDis,
+          breakPointId,
+          surroundPointIds[0],
+          appId,
+          userId,
+          traceId,
+          actionType,
         );
         );
-        console.log(
-          'joystick:->' +
-            'playerPosition:' +
-            JSON.stringify(
-              this.reply['newUserStates'][0].playerState.player.position,
-            ) +
-            ',cameraPosition:' +
-            JSON.stringify(
-              this.reply['newUserStates'][0].playerState.camera.position,
-            ),
-        );
-        if (_angle > -90 && _angle < 90) {
-          return this.reply;
-        } else {
-          //投影
-          console.error('补充!');
-          return this.reply;
-        }
       }
       }
-
       //判断_angle与angle的差在45以内的个数,两个的话表示可以走
       //判断_angle与angle的差在45以内的个数,两个的话表示可以走
       let count = 0;
       let count = 0;
       const neighPoints = [];
       const neighPoints = [];
-      _angle = this.getAngle(
-        breakPoint.position,
-        { x: breakPoint.position.x + 1, y: breakPoint.position.y },
-        playerPosition,
-      );
-      if (_angle < 0) {
-        _angle += 360;
-      }
+      // _angle = this.getAngle(
+      //   user.player.position,
+      //   { x: user.player.position.x + 1, y: user.player.position.y },
+      //   playerPosition,
+      // );
+      // if (_angle < 0) {
+      //   _angle += 360;
+      // }
 
 
       for (let i = 0; i < surroundPointIds.length; ++i) {
       for (let i = 0; i < surroundPointIds.length; ++i) {
         const neighPoint = this.breakPointInfo[surroundPointIds[i]];
         const neighPoint = this.breakPointInfo[surroundPointIds[i]];
         neighPoint.breakPointId = surroundPointIds[i];
         neighPoint.breakPointId = surroundPointIds[i];
-        // const neighDistance = this.getDistance(
-        //   playerPosition,
-        //   neighPoint.position,
-        // );
-        // if (neighDistance < closestDis) {
-        //   chooseBreakPointId = surroundPointIds[i];
-        // }
         angle = this.getAngle(
         angle = this.getAngle(
           breakPoint.position,
           breakPoint.position,
           { x: breakPoint.position.x + 1, y: breakPoint.position.y },
           { x: breakPoint.position.x + 1, y: breakPoint.position.y },
+          //playerPosition,
           neighPoint.position,
           neighPoint.position,
         );
         );
         if (angle < 0) {
         if (angle < 0) {
           angle += 360;
           angle += 360;
         }
         }
+
+        //if(angle<45&&angle!=0){
+        if (
+          Math.abs(angle - move_angle) < 45 &&
+          Math.abs(angle - move_angle) != 0
+        ) {
+          neighPoint.angle = angle;
+          neighPoints.push(neighPoint);
+          ++count;
+        } else if (Math.abs(angle - move_angle) == 0) {
+          return await this.moveDirect(
+            playerPosition,
+            closestDis,
+            breakPointId,
+            surroundPointIds[i],
+            appId,
+            userId,
+            traceId,
+            actionType,
+          );
+        }
+
+        if (angle == 0 && Math.abs(360 - move_angle) < 45) {
+          neighPoint.angle = angle;
+          neighPoints.push(neighPoint);
+          ++count;
+        }
+        /*
         //neighAngles.push(angle);
         //neighAngles.push(angle);
         if (Math.abs(angle - _angle) < 45) {
         if (Math.abs(angle - _angle) < 45) {
           neighPoint.angle = angle;
           neighPoint.angle = angle;
@@ -712,32 +728,66 @@ export class MoveService implements OnModuleInit {
         } else if (Math.abs(angle - _angle) == 0) {
         } else if (Math.abs(angle - _angle) == 0) {
           neighPoint.angle = angle;
           neighPoint.angle = angle;
           neighPoints.push(neighPoint);
           neighPoints.push(neighPoint);
+          ++count;
         }
         }
+        */
       }
       }
 
 
-      if (count == 2 || _angle % 45 == 0) {
+      if (count == 2) {
         //人物移动
         //人物移动
         user.player.position = JSON.parse(JSON.stringify(playerPosition));
         user.player.position = JSON.parse(JSON.stringify(playerPosition));
         this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
         this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
           JSON.stringify(playerPosition),
           JSON.stringify(playerPosition),
         );
         );
-      } else {
-        console.log(
-          'joystick:->' +
-            'playerPosition:' +
-            JSON.stringify(
-              this.reply['newUserStates'][0].playerState.player.position,
-            ) +
-            ',cameraPosition:' +
-            JSON.stringify(
-              this.reply['newUserStates'][0].playerState.camera.position,
-            ),
+      } else if (count == 1) {
+        return await this.moveDirect(
+          playerPosition,
+          closestDis,
+          breakPointId,
+          neighPoints[0].breakPointId,
+          appId,
+          userId,
+          traceId,
+          actionType,
+        );
+        // //投影
+        // let player_Position = this.getTarget(
+        //   playerPosition,
+        //   breakPoint.position,
+        //   neighPoints[0].position,
+        // );
+        // if (player_Position != null) {
+        //   playerPosition.x = player_Position.x;
+        //   player_Position.y = player_Position.y;
+        //   user.player.position = JSON.parse(JSON.stringify(playerPosition));
+        // }
+
+        // if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
+        //   debugger;
+        //   return await this.moveCamera(breakPointId,neighPoints[0].breakPointId,appId,userId,traceId,actionType);
+        // }
+        // else{
+        //   this.reply['newUserStates'][0].playerState.player.position = JSON.parse(JSON.stringify(user.player.position));
+        //   return this.reply;
+        // }
+      } else if (count == 0) {
+        this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+          JSON.stringify(user.player.position),
         );
         );
         return this.reply;
         return this.reply;
       }
       }
 
 
+      //count == 2
       //超出范围了
       //超出范围了
       if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
       if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
+        _angle = this.getAngle(
+          breakPoint.position,
+          {
+            x: breakPoint.position.x + 1,
+            y: breakPoint.position.y,
+          },
+          playerPosition,
+        );
         //角度是45的倍数
         //角度是45的倍数
         if (_angle % 45 == 0) {
         if (_angle % 45 == 0) {
           chooseBreakPointId = neighPoints[0].breakPointId;
           chooseBreakPointId = neighPoints[0].breakPointId;
@@ -751,79 +801,21 @@ export class MoveService implements OnModuleInit {
         } else {
         } else {
           chooseBreakPointId = neighPoints[0].breakPointId;
           chooseBreakPointId = neighPoints[0].breakPointId;
         }
         }
-      }
-
-      if (chooseBreakPointId == null) {
-        console.log(
-          'joystick:->' +
-            'playerPosition:' +
-            JSON.stringify(
-              this.reply['newUserStates'][0].playerState.player.position,
-            ) +
-            ',cameraPosition:' +
-            JSON.stringify(
-              this.reply['newUserStates'][0].playerState.camera.position,
-            ),
-        );
-        return this.reply;
-      }
-      //判断人物离该邻接点的距离是否在最小路径内,如果是,跳到这个邻接点里
-      //相机纠正加过渡
-      else {
-        if (chooseBreakPointId == user.breakPointId) {
-          console.log(
-            'joystick:->' +
-              'playerPosition:' +
-              JSON.stringify(
-                this.reply['newUserStates'][0].playerState.player.position,
-              ) +
-              ',cameraPosition:' +
-              JSON.stringify(
-                this.reply['newUserStates'][0].playerState.camera.position,
-              ),
-          );
-          return this.reply;
-        }
-        angle = user.camera.angle.yaw % 45; //纠正需要
-        //通过user.camera.angle矫正相机的angle
-        const checkReplys = await this.modeifyCameraAngle(
-          angle,
+        return await this.moveCamera(
+          breakPointId,
+          chooseBreakPointId,
+          appId,
           userId,
           userId,
           traceId,
           traceId,
           actionType,
           actionType,
         );
         );
-        console.log('joystick:过渡');
-        replys.push(checkReplys);
-
-        //读redis里的数据,按照frame_index的大小排序
-        const key =
-          'moveframe:app_id:' +
-          appId +
-          ':start_break_point_id:' +
-          breakPointId +
-          ':end_break_point_id:' +
-          chooseBreakPointId +
-          ':angle:' +
-          Math.floor(user.camera.angle.yaw / 45);
-        const moveFramesRes = await this.cacheService.get(key);
-        const moveFrames = JSON.parse(moveFramesRes);
-        const pathReplys = this.createCacheReplys(
-          appId,
-          moveFrames,
-          traceId,
-          userId,
-          breakPointId,
-          chooseBreakPointId,
-          true,
-        );
-        replys.push(pathReplys);
-        user.breakPointId = chooseBreakPointId;
-        const lastFrame = moveFrames[moveFrames.length - 1];
-        user.camera.position = JSON.parse(
-          JSON.stringify(lastFrame.camera_position),
+      } else {
+        console.log('joystick-1:');
+        user.player.position = JSON.parse(JSON.stringify(playerPosition));
+        this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+          JSON.stringify(user.player.position),
         );
         );
-        user.camera.angle.yaw = lastFrame.camera_angle.yaw;
-        return replys;
+        return this.reply;
       }
       }
     } catch (error) {
     } catch (error) {
       console.log('MoveService', error);
       console.log('MoveService', error);
@@ -832,6 +824,118 @@ export class MoveService implements OnModuleInit {
     }
     }
   }
   }
 
 
+  async moveDirect(
+    playerPosition,
+    closestDis,
+    breakPointId,
+    neighBreakPointId,
+    appId,
+    userId,
+    traceId,
+    actionType,
+  ) {
+    const breakPoint = this.breakPointInfo[breakPointId];
+    const user = this.users[userId];
+    const player_Position = this.getTarget(
+      playerPosition,
+      breakPoint.position,
+      //this.breakPointInfo[surroundPointIds[0]].position,
+      this.breakPointInfo[neighBreakPointId].position,
+    );
+    if (player_Position != null) {
+      playerPosition.x = player_Position.x;
+      playerPosition.y = player_Position.y;
+      user.player.position = JSON.parse(JSON.stringify(playerPosition));
+    }
+
+    if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
+      //return await this.moveCamera(breakPointId,surroundPointIds[0],appId,userId,traceId,actionType);
+      return await this.moveCamera(
+        breakPointId,
+        neighBreakPointId,
+        appId,
+        userId,
+        traceId,
+        actionType,
+      );
+    } else {
+      this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+        JSON.stringify(user.player.position),
+      );
+      return this.reply;
+    }
+  }
+
+  async moveCamera(
+    breakPointId,
+    chooseBreakPointId,
+    appId,
+    userId,
+    traceId,
+    actionType,
+  ) {
+    const user = this.users[userId];
+    if (chooseBreakPointId == null) {
+      this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+        JSON.stringify(user.player.position),
+      );
+      console.log('joystick-2:');
+      return this.reply;
+    }
+    //判断人物离该邻接点的距离是否在最小路径内,如果是,跳到这个邻接点里
+    //相机纠正加过渡
+    else {
+      if (chooseBreakPointId == user.breakPointId) {
+        console.log('joystick-3:');
+        this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+          JSON.stringify(user.player.position),
+        );
+        return this.reply;
+      }
+      const replys = [];
+      const angle = user.camera.angle.yaw % 45; //纠正需要
+      //通过user.camera.angle矫正相机的angle
+      const checkReplys = await this.modeifyCameraAngle(
+        angle,
+        userId,
+        traceId,
+        actionType,
+      );
+      replys.push(checkReplys);
+
+      //读redis里的数据,按照frame_index的大小排序
+      const key =
+        'moveframe:app_id:' +
+        appId +
+        ':start_break_point_id:' +
+        breakPointId +
+        ':end_break_point_id:' +
+        chooseBreakPointId +
+        ':angle:' +
+        Math.floor(user.camera.angle.yaw / 45);
+      const moveFramesRes = await this.cacheService.get(key);
+      const moveFrames = JSON.parse(moveFramesRes);
+      const pathReplys = this.createCacheReplys(
+        appId,
+        moveFrames,
+        traceId,
+        userId,
+        breakPointId,
+        chooseBreakPointId,
+        true,
+      );
+      replys.push(pathReplys);
+      user.breakPointId = chooseBreakPointId;
+      const lastFrame = moveFrames[moveFrames.length - 1];
+      user.camera.position = JSON.parse(
+        JSON.stringify(lastFrame.camera_position),
+      );
+      user.camera.angle.yaw = lastFrame.camera_angle.yaw;
+      console.log('joystick-4:');
+      return replys;
+    }
+  }
+
   async modeifyCameraAngle(angle, userId, traceId, actionType) {
   async modeifyCameraAngle(angle, userId, traceId, actionType) {
     const checkReplys = [];
     const checkReplys = [];
     if (angle > 22) {
     if (angle > 22) {
@@ -873,10 +977,187 @@ export class MoveService implements OnModuleInit {
     return checkReplys;
     return checkReplys;
   }
   }
 
 
+  getTarget(position, position1, position2) {
+    const line = this.createLine1(position1, position2);
+    const join = this.getJoinLinePoint(position, line);
+    // if (this.isContainForSegment(join, position1, position2)) {
+    //   return join;
+    // } else {
+    //   return null;
+    // }
+    return join;
+  }
+
   getDistance(position1, position2) {
   getDistance(position1, position2) {
     return Math.sqrt(
     return Math.sqrt(
       (position1.x - position2.x) * (position1.x - position2.x) +
       (position1.x - position2.x) * (position1.x - position2.x) +
         (position1.y - position2.y) * (position1.y - position2.y),
         (position1.y - position2.y) * (position1.y - position2.y),
     );
     );
   }
   }
+
+  isContainForSegment(point, startPoint, endPoint) {
+    const minDis = 0.1;
+    const dis1 =
+      this.getDistance(startPoint, point) + this.getDistance(endPoint, point);
+    const dis2 = this.getDistance(startPoint, endPoint);
+    if (Math.abs(dis1 - dis2) < minDis) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  //两条线的交点
+  getIntersectionPoint(parameter1, parameter2) {
+    if (this.isParallel(parameter1, parameter2)) {
+      return null;
+    }
+    if (
+      typeof parameter1.a == 'undefined' &&
+      typeof parameter2.a != 'undefined'
+    ) {
+      if (parameter1.x) {
+        return {
+          x: parameter1.x,
+          y: parameter2.a * parameter1.x + parameter2.b,
+        };
+      } else if (parameter1.y) {
+        return {
+          x: (parameter1.y - parameter2.b) / parameter2.a,
+          y: parameter1.y,
+        };
+      }
+    } else if (
+      typeof parameter2.a == 'undefined' &&
+      typeof parameter1.a != 'undefined'
+    ) {
+      if (parameter2.x) {
+        return {
+          x: parameter2.x,
+          y: parameter1.a * parameter2.x + parameter1.b,
+        };
+      } else if (parameter2.y) {
+        return {
+          x: (parameter2.y - parameter1.b) / parameter1.a,
+          y: parameter2.y,
+        };
+      }
+    } else if (
+      typeof parameter2.a == 'undefined' &&
+      typeof parameter1.a == 'undefined'
+    ) {
+      if (parameter1.hasOwnProperty('x') && parameter2.hasOwnProperty('y')) {
+        return { x: parameter1.x, y: parameter2.y };
+      } else if (
+        parameter1.hasOwnProperty('y') &&
+        parameter2.hasOwnProperty('x')
+      ) {
+        return { x: parameter2.x, y: parameter1.y };
+      } else {
+        return null;
+      }
+    }
+
+    if (parameter1.a == parameter2.a) {
+      return null;
+    }
+
+    const joinpointx =
+      (parameter2.b - parameter1.b) / (parameter1.a - parameter2.a);
+    const joinpointy =
+      (parameter1.a * parameter2.b - parameter2.a * parameter1.b) /
+      (parameter1.a - parameter2.a);
+
+    const point = { x: joinpointx, y: joinpointy };
+    return point;
+  }
+
+  // 垂直线
+  getVerticalLine(line, point) {
+    if (typeof line.a === 'undefined') {
+      if (line.hasOwnProperty('x')) {
+        return { y: point.y };
+      } else if (line.hasOwnProperty('y')) {
+        return { x: point.x };
+      } else {
+        return null;
+      }
+    } else if (line.a == 0) {
+      return { x: point.x };
+    } else {
+      const tl = {};
+      tl.a = -1 / line.a;
+      const result = this.createLine2(tl, point);
+      return result;
+    }
+  }
+
+  // 经过point且与line垂直的直线,该直线与line的交点
+  getJoinLinePoint(point, line) {
+    const verticalLine = this.getVerticalLine(line, point);
+    const join = this.getIntersectionPoint(line, verticalLine);
+    return join;
+  }
+
+  // 与lineA平行并且point在线上
+  createLine2(lineA, point) {
+    const parameter = {};
+    if (typeof lineA.a === 'undefined') {
+      if (typeof lineA.x !== 'undefined') {
+        parameter.x = point.x;
+      } else if (typeof lineA.y !== 'undefined') {
+        parameter.y = point.y;
+      }
+    } else {
+      parameter.a = lineA.a;
+      parameter.b = point.y - point.x * lineA.a;
+    }
+    return parameter;
+  }
+
+  createLine1(point1, point2) {
+    if (point1.x == point2.x && point1.y == point2.y) {
+      return null;
+    } else if (this.getFixed(Math.abs(point1.x - point2.x)) == 0) {
+      return { x: point1.x };
+    } else if (this.getFixed(Math.abs(point1.y - point2.y)) == 0) {
+      return { y: point1.y };
+    }
+
+    const parametera = (point1.y - point2.y) / (point1.x - point2.x);
+    const parameterb =
+      (point1.x * point2.y - point2.x * point1.y) / (point1.x - point2.x);
+    if (this.getFixed(parametera) == 0) {
+      return { y: this.getFixed(parameterb) };
+    }
+    const parameter = {
+      a: this.getFixed(parametera),
+      b: this.getFixed(parameterb),
+    };
+    return parameter;
+  }
+
+  //返回true表示平行
+  isParallel(line1, line2) {
+    if (typeof line1.a == 'undefined' && typeof line2.a == 'undefined') {
+      if (line1.hasOwnProperty('x') && line2.hasOwnProperty('x')) {
+        return true;
+      } else if (line1.hasOwnProperty('y') && line2.hasOwnProperty('y')) {
+        return true;
+      } else {
+        return false;
+      }
+    } else if (typeof line1.a == 'undefined' || typeof line2.a == 'undefined') {
+      return false;
+    } else if (this.getFixed(line1.a) == this.getFixed(line2.a)) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  getFixed(num) {
+    const decimal = 2;
+    return parseFloat(num.toFixed(decimal));
+  }
 }
 }

+ 30 - 6
src/rotate/rotate.service.ts

@@ -26,7 +26,7 @@ export class RotateService {
   constructor(
   constructor(
     private cacheService: CacheService, // private sceneService: SceneService,
     private cacheService: CacheService, // private sceneService: SceneService,
     private configService: ConfigService,
     private configService: ConfigService,
-  ) { }
+  ) {}
   private actionRequestPool = {};
   private actionRequestPool = {};
   private logger: Logger = new Logger('rotateService');
   private logger: Logger = new Logger('rotateService');
   private Actions = {
   private Actions = {
@@ -70,7 +70,7 @@ export class RotateService {
 
 
     user.appId = app_id;
     user.appId = app_id;
     user.userId = userId;
     user.userId = userId;
-    user.breakPointId = 29;
+    user.breakPointId = Number(this.configService.get('app.startPoint')) || 0;
     console.log('user-init', user);
     console.log('user-init', user);
     this.users[userId] = user;
     this.users[userId] = user;
     const reply = {
     const reply = {
@@ -459,6 +459,7 @@ export class RotateService {
       reply.breakPointId = user.breakPointId;
       reply.breakPointId = user.breakPointId;
       return reply;
       return reply;
     } else {
     } else {
+      /*
       const key =
       const key =
         'rotateframe:app_id:' +
         'rotateframe:app_id:' +
         user.appId +
         user.appId +
@@ -492,11 +493,34 @@ export class RotateService {
         //       reply['newUserStates'][0].playerState.camera.position,
         //       reply['newUserStates'][0].playerState.camera.position,
         //     ),
         //     ),
         // );
         // );
-        return reply;
-      } else {
-        this.logger.error('echo返回null', key);
-        return {};
+        */
+      let fileName = user.camera.angle.yaw + '.h264';
+      if (fileName.length == 8) {
+        fileName = '0' + fileName;
+      } else if (fileName.length == 7) {
+        fileName = '00' + fileName;
+      } else if (fileName.length == 6) {
+        fileName = '000' + fileName;
       }
       }
+
+      reply.mediaSrc =
+        '/' +
+        user.appId +
+        '/' +
+        user.breakPointId +
+        '/' +
+        user.breakPointId +
+        '/' +
+        user.breakPointId +
+        '.' +
+        fileName +
+        '?m=' +
+        new Date().getTime();
+      reply.breakPointId = user.breakPointId;
+      return reply;
+      // } else {
+      //   this.logger.error('echo返回null', key);
+      //   return {};
     }
     }
   }
   }
 }
 }

+ 9 - 7
src/scene/scene.service.ts

@@ -515,6 +515,10 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     try {
     try {
       //const joystickRes = await this.moveService.joystick(request);
       //const joystickRes = await this.moveService.joystick(request);
       const joystickRes = await this.moveService.seqExeJoystick(request);
       const joystickRes = await this.moveService.seqExeJoystick(request);
+      console.log(
+        'joystick-breakPointId:' +
+          this.moveService.users[this.user_id].breakPointId,
+      );
       // 有数据 [0]是rotate数据,[1-infinity]是walking数据
       // 有数据 [0]是rotate数据,[1-infinity]是walking数据
       console.log('joystickRes-1', joystickRes);
       console.log('joystickRes-1', joystickRes);
       this.onJoysticking.next(true);
       this.onJoysticking.next(true);
@@ -820,13 +824,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     };
     };
     this.streamService.pushNormalDataToStream(reply);
     this.streamService.pushNormalDataToStream(reply);
   }
   }
-  async updateUserStatus(request) {
+  updateUserStatus(request) {
     try {
     try {
-      const redisMeta = await this.rotateService.getNewUserStateRequest(
-        request,
-      );
-      if (redisMeta) {
-        redisMeta.actionType = 1024;
+      const usersData = this.rotateService.getNewUserStateRequest(request);
+      if (usersData) {
+        usersData.actionType = 1024;
         // console.log(
         // console.log(
         //   'joystick:->updateUserStatus' +
         //   'joystick:->updateUserStatus' +
         //   'playerPosition:' +
         //   'playerPosition:' +
@@ -834,7 +836,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         //     redisMeta['newUserStates'][0].playerState.player.position,
         //     redisMeta['newUserStates'][0].playerState.player.position,
         //   ),
         //   ),
         // );
         // );
-        this.streamService.pushNormalDataToStream(redisMeta);
+        this.streamService.pushNormalDataToStream(usersData);
       } else {
       } else {
         this.logger.error('updateUserStatus::function-empty');
         this.logger.error('updateUserStatus::function-empty');
       }
       }