gemercheung 3 years ago
parent
commit
850153c341
3 changed files with 24 additions and 7 deletions
  1. 1 1
      src/queue/delay-queue/delay-queue.ts
  2. 22 6
      src/scene/scene.service.ts
  3. 1 0
      src/scene/stream/stream.d.ts

+ 1 - 1
src/queue/delay-queue/delay-queue.ts

@@ -78,7 +78,7 @@ export class DelayQueue<T = unknown> extends RxQueue<T> {
     // .subscribe((item: T) => super.next(item));
 
     this.initQueue();
-    console.log('clean-DelayQueue-1', this.subject);
+    console.log('clean-DelayQueue');
   }
 }
 

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

@@ -268,7 +268,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       const start = performance.now();
       // 当move时处理 _rotateCount是移动端同时触发的问题,rotateStopThrottle是减少重复抖动stop的处理。
       if (
-        this.onMoving.value &&
+        this.onMoving.getValue() &&
         this._rotateCount > 5 &&
         !this.rotateStopThrottle
       ) {
@@ -297,6 +297,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
         const trace_id = metaData.traceIds[0];
         const userId = newUserStates.userId;
+        //TODO 临时,可能数据会不对
         const breakPointId = metaData.endBreakPointId || metaData.breakPointId;
         const cameraAngle = newUserStates.playerState.camera.angle;
         const playerAngle = newUserStates.playerState.player.angle;
@@ -395,9 +396,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           //TODO 正在行走时,有新的reqest
           if (this.latestWalkingRequest && this.onMoving.value) {
             this.logger.log('stop-data-1', frame);
+            this.moveQueueSubscription.unsubscribe();
+            this.moveQueueSubscription = null;
             this.moveQueue.clean();
-            // this.moveQueueSubscription.unsubscribe();
-            // this.moveQueueSubscription = null;
             //step1 执行stop方法
             const metaData: StreamReplyType = frame.metaData;
             const newUserStates: NewUserStatesType =
@@ -429,6 +430,10 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
               'walking-step-reWalking-1',
               request.trace_id + ',' + this.latestWalkingRequest.trace_id,
             );
+            // 中断清除上一次最后小段队列
+            this.moveSliceLastFrameSub.unsubscribe();
+            this.moveSliceLastFrameSub = null;
+
             this.handleReWalking(this.latestWalkingRequest);
           }
         },
@@ -528,7 +533,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         const seqs = Array.from(walkingRes).flat() as any as StreamReplyType[];
 
         if (seqs?.length) {
-          this.logger.log('walking --总序列--seqs-2:' + seqs.length);
+          this.logger.log(
+            'walking --队列总览:' +
+              ' 总段数: ' +
+              walkingRes.length +
+              ' 镜头帧数:' +
+              walkingRes[0].length +
+              ' 行走段数:' +
+              (walkingRes.length - 1) +
+              ' 队列总帧数:' +
+              seqs.length,
+          );
           const stop = performance.now();
           const inMillSeconds = stop - start;
           const rounded = Number(inMillSeconds).toFixed(3);
@@ -686,11 +701,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     if (!this.moveQueueSubscription) {
       this.handleMoveSteam();
     }
-    this.logger.log('moving-seqs', seqs.length);
+    // this.logger.log('moving-seqs', seqs.length);
     this.onMoving.next(true);
     this.holdSteam();
     //TODO Remove
     // clearTimeout(this._JoyStickingTimeout);
+    this.moveQueue.clean();
 
     seqs.forEach((frame: StreamReplyType) => {
       const mediaSrc = frame.mediaSrc;
@@ -801,7 +817,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
               this.lastMovingPointArray = [];
               this.hasJoystickMoveRequest = false;
               this.logger.log('move end');
-            }, 300);
+            }, 200);
           } else {
             this.logger.error(
               `movesteam::当前帧:${res.frame}` + JSON.stringify(res),

+ 1 - 0
src/scene/stream/stream.d.ts

@@ -77,6 +77,7 @@ interface StreamReplyType {
   // breakPointId?: number;
   startBreakPointId?: number;
   endBreakPointId?: number;
+  breakPointId?: number; //临时记录存在的点()
   mType?: string; //类型
   DIR: ?number;
 }