gemercheung 3 سال پیش
والد
کامیت
92b9de1ef6
2فایلهای تغییر یافته به همراه432 افزوده شده و 125 حذف شده
  1. 431 124
      src/move/move.service.ts
  2. 1 1
      src/scene/scene.service.ts

+ 431 - 124
src/move/move.service.ts

@@ -3,9 +3,11 @@ import { ConfigService } from '@nestjs/config';
 import { readFileSync } from 'fs';
 import { join } from 'path';
 import { CacheService } from 'src/cache/cache.service';
-import configuration from 'src/config/configuration';
 import { RotateService } from 'src/rotate/rotate.service';
 
+// import * as  BreakPointIds from '../../ws/points-BreakPointId.json';
+// import { SceneService } from 'src/scene/scene.service';
+
 const seqExeAsyncFn = (asyncFn) => {
   let runPromise = null;
   return function seq(...args) {
@@ -126,15 +128,12 @@ export class MoveService implements OnModuleInit {
   };
   private breakPointInfo: any;
 
+  private cameraInfos = [];
+
   // eslint-disable-next-line @typescript-eslint/no-empty-function
   async onModuleInit() {
-    const app_id = configuration().app.appId;
-    const prefix = configuration().app.prefix;
-
-    // const app_id = '0000000005';
-    // const prefix = '/mnt/metaverse/scene';
-    console.log('app_id', app_id, configuration().app.appId);
-    console.log('prefix', prefix, configuration().app.appId);
+    const app_id = '0000000003';
+    const prefix = '/mnt/metaverse/scene';
     let path;
     // let path: string;
     if (process.env.NODE_ENV === 'development') {
@@ -436,13 +435,14 @@ export class MoveService implements OnModuleInit {
     const user = this.users[userId];
     user.breakPointId = breakPointId;
 
-    user.player.position =
-      lastReply['newUserStates'][0].playerState.player.position;
+    if (lastReply.actionResponses[0].actionType != 15) {
+      user.player.position =
+        lastReply['newUserStates'][0].playerState.player.position;
+    }
     user.player.angle = lastReply['newUserStates'][0].playerState.player.angle;
     user.camera.position =
       lastReply['newUserStates'][0].playerState.camera.position;
     user.camera.angle = lastReply['newUserStates'][0].playerState.camera.angle;
-    console.log('rotateForAngle-1:' + user.breakPointId);
   }
 
   getBreakPoints(actionRequest) {
@@ -510,7 +510,6 @@ export class MoveService implements OnModuleInit {
 
   async stop(traceId, userId, breakPointId, cameraAngle, playerAngle) {
     //const breakPointId = movePointIds.substring(movePointIds.indexOf('-') + 1);
-
     const user = this.users[userId];
     const startBreakPointId = user.breakPointId;
     user.breakPointId = breakPointId;
@@ -557,12 +556,225 @@ export class MoveService implements OnModuleInit {
     reply.startBreakPointId = startBreakPointId;
     reply.endBreakPointId = breakPointId;
     reply['newUserStates'][0].renderInfo.isMoving = 0;
-    console.log('rotateForAngle-2:' + user.breakPointId);
     return reply;
   }
   // 顺序旋转请求
   seqExeJoystick = seqExeAsyncFn(this.joystick);
 
+  // async joystick(actionRequest) {
+  //   try {
+  //     const userId = actionRequest['user_id'];
+  //     const traceId = actionRequest['trace_id'];
+  //     const dir_action = actionRequest['dir_action'];
+  //     const actionType = actionRequest['action_type'];
+  //     const user = this.users[userId];
+  //     const breakPointId = user.breakPointId;
+  //     const appId = user.appId;
+
+  //     const replys = [];
+  //     const step = 0.3;
+  //     const closestDis = 85; //小于这个距离就跳到邻居呼吸点
+  //     const distance = step * dir_action.speed_level;
+  //     let angle = null;
+  //     let move_angle = dir_action.move_angle + user.camera.angle.yaw;
+  //     move_angle = move_angle % 360;
+
+  //     //TODO 临时增加断言
+  //     const playerPosition: Point = { x: 0, y: 0, z: 0 };
+  //     playerPosition.x =
+  //       user.player.position.x +
+  //       distance * Math.cos((move_angle / 360) * 2 * Math.PI);
+  //     playerPosition.y =
+  //       user.player.position.y +
+  //       distance * Math.sin((move_angle / 360) * 2 * Math.PI);
+
+  //     //找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
+  //     let chooseBreakPointId = null;
+  //     const breakPoint = this.breakPointInfo[breakPointId];
+  //     const surroundPointIds = breakPoint.contact;
+  //     //const neighAngles = [];
+  //     const traceIds = [];
+
+  //     user.player.angle.yaw = move_angle;
+  //     traceIds.push(traceId);
+  //     this.reply.traceIds = traceIds;
+  //     this.reply['newUserStates'][0].userId = userId;
+  //     this.reply['actionResponses'][0].traceId = traceId;
+  //     this.reply['newUserStates'][0].playerState.player.angle.yaw = move_angle;
+
+  //     this.reply['newUserStates'][0].playerState.camera.angle = JSON.parse(
+  //       JSON.stringify(user.camera.angle),
+  //     );
+  //     this.reply['newUserStates'][0].playerState.camera.position = JSON.parse(
+  //       JSON.stringify(user.camera.position),
+  //     );
+  //     this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
+  //       JSON.stringify(breakPoint.position),
+  //     );
+  //     this.reply['newUserStates'][0].renderInfo.isMoving = 1;
+  //     this.reply['actionResponses'][0].traceId = traceId;
+  //     this.reply.mediaSrc = null;
+
+  //     if (surroundPointIds.length == 1) {
+  //       return await this.moveDirect(
+  //         playerPosition,
+  //         closestDis,
+  //         breakPointId,
+  //         surroundPointIds[0],
+  //         appId,
+  //         userId,
+  //         traceId,
+  //         actionType,
+  //       );
+  //     }
+
+  //     let count = 0;
+  //     const neighPoints = [];
+  //     //人在哪个角度
+  //     let _angle = this.getAngle(
+  //       breakPoint.position,
+  //       { 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) {
+  //       const neighPoint = this.breakPointInfo[surroundPointIds[i]];
+  //       neighPoint.breakPointId = surroundPointIds[i];
+  //       angle = this.getAngle(
+  //         breakPoint.position,
+  //         { x: breakPoint.position.x + 1, y: breakPoint.position.y },
+  //         neighPoint.position,
+  //       );
+  //       if (angle < 0) {
+  //         angle += 360;
+  //       }
+
+  //       //if(angle<45&&angle!=0){
+  //       if (
+  //         // Math.abs(angle - move_angle) < 45 &&
+  //         // Math.abs(angle - move_angle) != 0
+  //         Math.abs(angle - _angle) < 45 &&
+  //         Math.abs(angle - _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) {
+  //       if (angle == 0 && Math.abs(360 - _angle) < 45) {
+  //         neighPoint.angle = angle;
+  //         neighPoints.push(neighPoint);
+  //         ++count;
+  //       }
+
+  //       if(Math.abs(angle - move_angle)<45||Math.abs(angle+360 - move_angle)<45){
+  //         if(singleInfo == null){
+  //           singleInfo = {
+  //             angle:angle,
+  //             breakPointId:surroundPointIds[i]
+  //           }
+  //         }
+  //       }
+  //     }
+
+  //     if (count == 2) {
+  //       //人物移动
+  //       user.player.position = JSON.parse(JSON.stringify(playerPosition));
+  //       this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+  //         JSON.stringify(playerPosition),
+  //       );
+  //     }
+  //     else{
+  //       if(singleInfo != null){
+  //         return await this.moveDirect(
+  //           playerPosition,
+  //           closestDis,
+  //           breakPointId,
+  //           singleInfo.breakPointId,
+  //           appId,
+  //           userId,
+  //           traceId,
+  //           actionType,
+  //         );
+  //       }
+  //       else if (count == 1) {
+  //         return await this.moveDirect(
+  //           playerPosition,
+  //           closestDis,
+  //           breakPointId,
+  //           neighPoints[0].breakPointId,
+  //           appId,
+  //           userId,
+  //           traceId,
+  //           actionType,
+  //         );
+  //       }
+  //       else if (count == 0) {
+  //         this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+  //           JSON.stringify(user.player.position),
+  //         );
+  //         this.reply.actionResponses[0].actionType = actionType;
+  //         return this.reply;
+  //       }
+  //     }
+
+  //     //count == 2
+  //     //超出范围了
+  //     if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
+  //       let offsetAngle1 = Math.abs(_angle - neighPoints[0].angle);
+  //       if (neighPoints[0].angle == 0) {
+  //         offsetAngle1 = Math.min(offsetAngle1, Math.abs(_angle - 360));
+  //       }
+
+  //       let offsetAngle2 = Math.abs(_angle - neighPoints[1].angle);
+  //       if (neighPoints[1].angle == 0) {
+  //         offsetAngle2 = Math.min(offsetAngle2, Math.abs(_angle - 360));
+  //       }
+
+  //       if (offsetAngle1 > offsetAngle2) {
+  //         chooseBreakPointId = neighPoints[1].breakPointId;
+  //       } else {
+  //         chooseBreakPointId = neighPoints[0].breakPointId;
+  //       }
+  //       return await this.moveCamera(
+  //         breakPointId,
+  //         chooseBreakPointId,
+  //         appId,
+  //         userId,
+  //         traceId,
+  //         actionType,
+  //       );
+  //     } else {
+  //       user.player.position = JSON.parse(JSON.stringify(playerPosition));
+  //       this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+  //         JSON.stringify(user.player.position),
+  //       );
+  //       this.reply.actionResponses[0].actionType = actionType;
+  //       return this.reply;
+  //     }
+  //   } catch (error) {
+  //     console.log('MoveService', error);
+  //     debugger;
+  //     return null;
+  //   }
+  // }
+
   async joystick(actionRequest) {
     try {
       const userId = actionRequest['user_id'];
@@ -573,13 +785,13 @@ export class MoveService implements OnModuleInit {
       const breakPointId = user.breakPointId;
       const appId = user.appId;
 
-      const replys = [];
       const step = 0.3;
-      const closestDis = 90; //小于这个距离就跳到邻居呼吸点
+      const closestDis = 85; //小于这个距离就跳到邻居呼吸点
       const distance = step * dir_action.speed_level;
       let angle = null;
       let move_angle = dir_action.move_angle + user.camera.angle.yaw;
       move_angle = move_angle % 360;
+
       //TODO 临时增加断言
       const playerPosition: Point = { x: 0, y: 0, z: 0 };
       playerPosition.x =
@@ -593,7 +805,6 @@ export class MoveService implements OnModuleInit {
       let chooseBreakPointId = null;
       const breakPoint = this.breakPointInfo[breakPointId];
       const surroundPointIds = breakPoint.contact;
-      //const neighAngles = [];
       const traceIds = [];
 
       user.player.angle.yaw = move_angle;
@@ -616,18 +827,10 @@ export class MoveService implements OnModuleInit {
       this.reply['actionResponses'][0].traceId = traceId;
       this.reply.mediaSrc = null;
 
-      //方向不对的话,人物不能走动,只是修改朝向
-      // 找到和角度最贴近的邻居点
-      let _angle = this.getAngle(
-        breakPoint.position,
-        {
-          x: this.breakPointInfo[surroundPointIds[0]].position.x,
-          y: this.breakPointInfo[surroundPointIds[0]].position.y,
-        },
-        playerPosition,
-      );
-
       if (surroundPointIds.length == 1) {
+        console.log(
+          'joystick校验--->' + breakPointId + '-' + surroundPointIds[0],
+        );
         return await this.moveDirect(
           playerPosition,
           closestDis,
@@ -639,40 +842,43 @@ export class MoveService implements OnModuleInit {
           actionType,
         );
       }
-      //判断_angle与angle的差在45以内的个数,两个的话表示可以走
+
       let count = 0;
       const neighPoints = [];
-      // _angle = this.getAngle(
-      //   user.player.position,
-      //   { x: user.player.position.x + 1, y: user.player.position.y },
-      //   playerPosition,
-      // );
-      // if (_angle < 0) {
-      //   _angle += 360;
-      // }
+      //人在哪个角度
+      let _angle = this.getAngle(
+        breakPoint.position,
+        { 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) {
         const neighPoint = this.breakPointInfo[surroundPointIds[i]];
         neighPoint.breakPointId = surroundPointIds[i];
         angle = this.getAngle(
           breakPoint.position,
           { x: breakPoint.position.x + 1, y: breakPoint.position.y },
-          //playerPosition,
           neighPoint.position,
         );
-        if (angle < 0) {
-          angle += 360;
-        }
 
         //if(angle<45&&angle!=0){
         if (
-          Math.abs(angle - move_angle) < 45 &&
-          Math.abs(angle - move_angle) != 0
+          // Math.abs(angle - move_angle) < 45 &&
+          // Math.abs(angle - move_angle) != 0
+          Math.abs(angle - _angle) < 45 &&
+          Math.abs(angle - _angle) != 0
         ) {
           neighPoint.angle = angle;
           neighPoints.push(neighPoint);
           ++count;
         } else if (Math.abs(angle - move_angle) == 0) {
+          console.log(
+            'joystick直走--->' + breakPointId + '-' + surroundPointIds[i],
+          );
           return await this.moveDirect(
             playerPosition,
             closestDis,
@@ -685,27 +891,24 @@ export class MoveService implements OnModuleInit {
           );
         }
 
-        if (angle == 0 && Math.abs(360 - move_angle) < 45) {
+        //if (angle == 0 && Math.abs(360 - move_angle) < 45) {
+        if (angle == 0 && Math.abs(360 - _angle) < 45) {
           neighPoint.angle = angle;
           neighPoints.push(neighPoint);
           ++count;
         }
-        /*
-        //neighAngles.push(angle);
-        if (Math.abs(angle - _angle) < 45) {
-          neighPoint.angle = angle;
-          neighPoints.push(neighPoint);
-          ++count;
-        } else if (angle == 0 && _angle > 315) {
-          neighPoint.angle = angle;
-          neighPoints.push(neighPoint);
-          ++count;
-        } else if (Math.abs(angle - _angle) == 0) {
-          neighPoint.angle = angle;
-          neighPoints.push(neighPoint);
-          ++count;
+
+        if (
+          Math.abs(angle - move_angle) < 45 ||
+          Math.abs(angle + 360 - move_angle) < 45
+        ) {
+          if (singleInfo == null) {
+            singleInfo = {
+              angle: angle,
+              breakPointId: surroundPointIds[i],
+            };
+          }
         }
-        */
       }
 
       if (count == 2) {
@@ -714,52 +917,49 @@ export class MoveService implements OnModuleInit {
         this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
           JSON.stringify(playerPosition),
         );
-      } else if (count == 1) {
-        return await this.moveDirect(
-          playerPosition,
-          closestDis,
-          breakPointId,
-          neighPoints[0].breakPointId,
-          appId,
-          userId,
-          traceId,
-          actionType,
-        );
-      } else if (count == 0) {
-        this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
-          JSON.stringify(user.player.position),
-        );
-        this.reply.actionResponses[0].actionType = actionType;
-        return this.reply;
+      } else {
+        if (singleInfo != null) {
+          console.log(
+            'joystick校验--->' + breakPointId + '-' + singleInfo.breakPointId,
+          );
+          return await this.moveDirect(
+            playerPosition,
+            closestDis,
+            breakPointId,
+            singleInfo.breakPointId,
+            appId,
+            userId,
+            traceId,
+            actionType,
+          );
+        } else if (count == 1) {
+          console.log(
+            'joystick校验--->' +
+              breakPointId +
+              '-' +
+              neighPoints[0].breakPointId,
+          );
+          return await this.moveDirect(
+            playerPosition,
+            closestDis,
+            breakPointId,
+            neighPoints[0].breakPointId,
+            appId,
+            userId,
+            traceId,
+            actionType,
+          );
+        } else if (count == 0) {
+          this.reply['newUserStates'][0].playerState.player.position =
+            JSON.parse(JSON.stringify(user.player.position));
+          this.reply.actionResponses[0].actionType = actionType;
+          return this.reply;
+        }
       }
 
       //count == 2
       //超出范围了
       if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
-        _angle = this.getAngle(
-          breakPoint.position,
-          {
-            x: breakPoint.position.x + 1,
-            y: breakPoint.position.y,
-          },
-          playerPosition,
-        );
-        //角度是45的倍数
-        // if (_angle % 45 == 0) {
-        //   chooseBreakPointId = neighPoints[0].breakPointId;
-        // } else if (
-        console.log(
-          'joystick-breakPointId:' +
-            _angle +
-            ',' +
-            neighPoints[0].angle +
-            ',' +
-            neighPoints[0].breakPointId +
-            ',' +
-            neighPoints[1].angle +
-            ',' +
-            neighPoints[1].breakPointId,
-        );
         let offsetAngle1 = Math.abs(_angle - neighPoints[0].angle);
         if (neighPoints[0].angle == 0) {
           offsetAngle1 = Math.min(offsetAngle1, Math.abs(_angle - 360));
@@ -775,6 +975,9 @@ export class MoveService implements OnModuleInit {
         } else {
           chooseBreakPointId = neighPoints[0].breakPointId;
         }
+        console.log(
+          'joystick镜头过渡--->' + breakPointId + '-' + chooseBreakPointId,
+        );
         return await this.moveCamera(
           breakPointId,
           chooseBreakPointId,
@@ -784,12 +987,21 @@ export class MoveService implements OnModuleInit {
           actionType,
         );
       } 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),
         );
         this.reply.actionResponses[0].actionType = actionType;
+        const cameraInfo = this.getCameraInfo();
+        if (cameraInfo != null) {
+          console.log('joystick自由--->合并');
+          this.reply['newUserStates'][0].playerState.camera.position =
+            cameraInfo.cameraPosition;
+          this.reply['newUserStates'][0].playerState.camera.angle =
+            cameraInfo.cameraAngle;
+        } else {
+          console.log('joystick自由--->不合并');
+        }
         return this.reply;
       }
     } catch (error) {
@@ -799,6 +1011,7 @@ export class MoveService implements OnModuleInit {
     }
   }
 
+  //沿着最合适的neighBreakPointId走
   async moveDirect(
     playerPosition,
     closestDis,
@@ -814,9 +1027,9 @@ export class MoveService implements OnModuleInit {
     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;
@@ -837,6 +1050,13 @@ export class MoveService implements OnModuleInit {
         JSON.stringify(user.player.position),
       );
       this.reply.actionResponses[0].actionType = actionType;
+      const cameraInfo = this.getCameraInfo();
+      if (cameraInfo != null) {
+        this.reply['newUserStates'][0].playerState.camera.position =
+          cameraInfo.camera_position;
+        this.reply['newUserStates'][0].playerState.camera.angle =
+          cameraInfo.camera_angle;
+      }
       return this.reply;
     }
   }
@@ -861,13 +1081,12 @@ export class MoveService implements OnModuleInit {
     //相机纠正加过渡
     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(
@@ -876,11 +1095,17 @@ export class MoveService implements OnModuleInit {
         traceId,
         actionType,
       );
+
       for (let i = 0; i < checkReplys.length; ++i) {
-        checkReplys[i].actionResponses[0].actionType = actionType;
+        //checkReplys[i].actionResponses[0].actionType = actionType;
+        this.addCameraInfo(
+          checkReplys[i]['newUserStates'][0].playerState.camera.position,
+          checkReplys[i]['newUserStates'][0].playerState.camera.angle,
+          checkReplys[i].mediaSrc,
+        );
       }
-      replys.push(checkReplys);
 
+      //replys.push(checkReplys);
       //读redis里的数据,按照frame_index的大小排序
       const key =
         'moveframe:app_id:' +
@@ -893,26 +1118,81 @@ export class MoveService implements OnModuleInit {
         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,
-      );
-      for (let i = 0; i < pathReplys.length; ++i) {
-        pathReplys[i].actionResponses[0].actionType = actionType;
-      }
-      replys.push(pathReplys);
+      this.setCameraInfo(moveFrames);
+      // const pathReplys = this.createCacheReplys(
+      //   appId,
+      //   moveFrames,
+      //   traceId,
+      //   userId,
+      //   breakPointId,
+      //   chooseBreakPointId,
+      //   true,
+      // );
+      // for (let i = 0; i < pathReplys.length; ++i) {
+      //   pathReplys[i].actionResponses[0].actionType = actionType;
+      // }
+      // 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;
-      return replys;
+      const cameraInfo = this.getCameraInfo();
+      if (cameraInfo != null) {
+        this.reply['newUserStates'][0].playerState.camera.position =
+          cameraInfo.camera_position;
+        this.reply['newUserStates'][0].playerState.camera.angle =
+          cameraInfo.camera_angle;
+
+        user.camera.position = JSON.parse(
+          JSON.stringify(cameraInfo.camera_position),
+        );
+        user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
+
+        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;
+        }
+      }
+      return this.reply;
+      // user.camera.position = JSON.parse(
+      //   JSON.stringify(lastFrame.camera_position),
+      // );
+      // user.camera.angle.yaw = lastFrame.camera_angle.yaw;
+      // return replys;
+    }
+  }
+
+  setCameraInfo(moveFrames) {
+    this.cameraInfos = moveFrames;
+  }
+
+  addCameraInfo(cameraPosition, cameraAngle, mediaSrc) {
+    this.cameraInfos.push({
+      camera_position: cameraPosition,
+      camera_angle: cameraAngle,
+      mediaSrc: mediaSrc,
+    });
+  }
+
+  getCameraInfo() {
+    if (this.cameraInfos.length > 0) {
+      const item = this.cameraInfos.shift();
+      return item;
+    } else {
+      return null;
     }
   }
 
@@ -1145,4 +1425,31 @@ export class MoveService implements OnModuleInit {
     const decimal = 2;
     return parseFloat(num.toFixed(decimal));
   }
+
+  isPointInPoly(position, breakPointIds) {
+    const x = position.x;
+    const y = position.y;
+
+    let inside = false;
+
+    for (
+      let i = 0, j = breakPointIds.length - 1;
+      i < breakPointIds.length;
+      j = i++
+    ) {
+      const pt1 = this.breakPointInfo[breakPointIds[i]];
+      const pt2 = this.breakPointInfo[breakPointIds[j]];
+
+      const xi = pt1.x;
+      const yi = pt1.y;
+      const xj = pt2.x;
+      const yj = pt2.y;
+
+      const intersect =
+        yi > y != yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
+      if (intersect) inside = !inside;
+    }
+
+    return inside;
+  }
 }

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

@@ -433,7 +433,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
             // 中断清除上一次最后小段队列
             this.moveSliceLastFrameSub.unsubscribe();
             this.moveSliceLastFrameSub = null;
-
+            this.logger.debug('重新行走---handleReWalking');
             this.handleReWalking(this.latestWalkingRequest);
           }
         },