gemercheung 3 lat temu
rodzic
commit
2b59b3e5d2

+ 2 - 2
src/get-router/get-router.service.ts

@@ -7,7 +7,7 @@ import configuration from 'src/config/configuration';
 
 @Injectable()
 export class GetRouterService implements OnModuleInit {
-  constructor(private cacheService: CacheService) { }
+  constructor(private cacheService: CacheService) {}
   private breakPointInfo: any;
   private logger: Logger = new Logger('GetRouterService');
   // private configService: ConfigService;
@@ -240,7 +240,7 @@ export class GetRouterService implements OnModuleInit {
   getDistance(position1, position2) {
     return Math.sqrt(
       (position1.x - position2.x) * (position1.x - position2.x) +
-      (position1.y - position2.y) * (position1.y - position2.y),
+        (position1.y - position2.y) * (position1.y - position2.y),
     );
   }
 }

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

@@ -6,7 +6,6 @@ import { CacheService } from 'src/cache/cache.service';
 import configuration from 'src/config/configuration';
 import { RotateService } from 'src/rotate/rotate.service';
 
-
 const seqExeAsyncFn = (asyncFn) => {
   let runPromise = null;
   return function seq(...args) {
@@ -31,7 +30,7 @@ export class MoveService implements OnModuleInit {
     private cacheService: CacheService,
     private rotateService: RotateService,
     private configService: ConfigService,
-  ) { }
+  ) {}
   private logger: Logger = new Logger('MoveService');
   private Actions = {
     Clicking: 1,
@@ -751,15 +750,15 @@ export class MoveService implements OnModuleInit {
         // } else if (
         console.log(
           'joystick-breakPointId:' +
-          _angle +
-          ',' +
-          neighPoints[0].angle +
-          ',' +
-          neighPoints[0].breakPointId +
-          ',' +
-          neighPoints[1].angle +
-          ',' +
-          neighPoints[1].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) {
@@ -972,7 +971,7 @@ export class MoveService implements OnModuleInit {
   getDistance(position1, position2) {
     return Math.sqrt(
       (position1.x - position2.x) * (position1.x - position2.x) +
-      (position1.y - position2.y) * (position1.y - position2.y),
+        (position1.y - position2.y) * (position1.y - position2.y),
     );
   }
 

+ 2 - 2
src/rotate/rotate.service.ts

@@ -44,7 +44,7 @@ export class RotateService {
       breakPointId: null,
       roomId: null,
       player: {
-        position: { x: -800.0, y: 100.0, z: 0.0 },
+        position: { x: -3200, y: -100, z: 3.79 },
         angle: {
           pitch: 0,
           yaw: 0,
@@ -52,7 +52,7 @@ export class RotateService {
         },
       },
       camera: {
-        position: { x: -1141.6719970703125, y: 94.03607940673828, z: 120.0 },
+        position: { x: -1139.3031005859375, y: 99.99999237060548, z: 120 },
         angle: {
           pitch: 0,
           yaw: 0,

+ 48 - 34
src/scene/scene.service.ts

@@ -26,7 +26,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     private rotateService: RotateService,
     private moveService: MoveService,
     private getRouterService: GetRouterService, // @InjectQueue('rotate') private rotateQueue: Queue, // @InjectQueue('walking') private walkingQueue: Queue,
-  ) { }
+  ) {}
   @Client(grpcClientOptions) private readonly client: ClientGrpc;
 
   public _frameInteval: NodeJS.Timeout;
@@ -324,16 +324,16 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         const playerAngle = newUserStates.playerState.player.angle;
         this.logger.log(
           'stop-data-0' +
-          'trace_id: ' +
-          trace_id +
-          'userId:' +
-          userId +
-          'breakPointId :' +
-          breakPointId +
-          'cameraAngle :' +
-          JSON.stringify(cameraAngle) +
-          'playerAngle: ' +
-          JSON.stringify(playerAngle),
+            'trace_id: ' +
+            trace_id +
+            'userId:' +
+            userId +
+            'breakPointId :' +
+            breakPointId +
+            'cameraAngle :' +
+            JSON.stringify(cameraAngle) +
+            'playerAngle: ' +
+            JSON.stringify(playerAngle),
         );
         //debugger;
         redisMeta = await this.moveService.stop(
@@ -468,7 +468,20 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       this._rotateCount = 0;
       const user = this.moveService.users[this.user_id];
       console.log('进入1 - searchRoad');
+      this.logger.log(
+        'handleWalking-users' +
+          JSON.stringify(this.moveService.users) +
+          ' this.user_id: ' +
+          this.user_id,
+      );
+      this.logger.log(
+        'handleWalking-currentUser' +
+          JSON.stringify(user) +
+          ' this.user_id: ' +
+          this.user_id,
+      );
       console.log('path-start' + user.breakPointId);
+
       const path = await this.getRouterService.searchRoad(
         user.appId,
         user.breakPointId,
@@ -588,7 +601,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       const joystickRes = await this.moveService.seqExeJoystick(request);
       this.logger.log(
         'joystick-breakPointId:' +
-        this.moveService.users[this.user_id].breakPointId,
+          this.moveService.users[this.user_id].breakPointId,
       );
       // 有数据 [0]是rotate数据,[1-infinity]是walking数据
       this.logger.log('joystickRes-1', joystickRes);
@@ -754,14 +767,14 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           };
           this.logger.log(
             '[media-move]: ' +
-            ', moveframeCnt: ' +
-            this.moveframeCnt +
-            ', clipPath: ' +
-            stream.clipPath +
-            ', mType: ' +
-            stream.mType +
-            ', DIR: ' +
-            stream.DIR,
+              ', moveframeCnt: ' +
+              this.moveframeCnt +
+              ', clipPath: ' +
+              stream.clipPath +
+              ', mType: ' +
+              stream.mType +
+              ', DIR: ' +
+              stream.DIR,
             // stream.metaData,
           );
           this.logger.log(
@@ -951,7 +964,8 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
           const IDRflag = this._rotateCurrentFame % 5 === 0 ? 1 : 3;
           this.logger.log(
-            `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${this._rotateCurrentFame
+            `当前rotate ,mainframeCnt:${this.frameCnt.getValue()}, _rotateCurrentFame:${
+              this._rotateCurrentFame
             } IDRflag:${IDRflag}`,
           );
           stream.DIR = this.rotateFirstIDR ? 1 : IDRflag;
@@ -962,12 +976,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
           this.logger.log(
             '[media-rotate]: ' +
-            ', frame: ' +
-            stream.frame +
-            ', rotateframeCnt: ' +
-            this.rotateframeCnt +
-            ', clipPath: ' +
-            stream.clipPath,
+              ', frame: ' +
+              stream.frame +
+              ', rotateframeCnt: ' +
+              this.rotateframeCnt +
+              ', clipPath: ' +
+              stream.clipPath,
             // stream.metaData,
           );
           // this.logger.log(
@@ -1025,12 +1039,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           this.logger.log('frame', frame);
           console.log(
             'mock' +
-            ' maxMessageSize: ' +
-            this.channel.maxMessageSize() +
-            ' bytesReceived: ' +
-            this.peer.bytesReceived() +
-            ' bytesSent: ' +
-            this.peer.bytesSent(),
+              ' maxMessageSize: ' +
+              this.channel.maxMessageSize() +
+              ' bytesReceived: ' +
+              this.peer.bytesReceived() +
+              ' bytesSent: ' +
+              this.peer.bytesSent(),
           );
           if (frame === 1) {
             redisData = await this.rotateService.echo(this.user_id, true);
@@ -1045,7 +1059,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
                 delete redisData.mediaSrc;
                 this.logger.log(
                   `user:${this.user_id}:first render stream` +
-                  JSON.stringify({ path: clipPath, meta: redisData }),
+                    JSON.stringify({ path: clipPath, meta: redisData }),
                 );
                 const status = await this.pushFirstRender(
                   clipPath,