|
@@ -79,7 +79,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
private isHoldingStream = false;
|
|
|
private lastMovingPointArray: MovingLastUpdateType[] = [];
|
|
|
private latestWalkingRequest: any; // 最新waking的接收值
|
|
|
- private latestJoystickRequest: any; // 最新joystick的接收值
|
|
|
+ private hasJoystickMoveRequest = false; // 最新joystick的接收值
|
|
|
|
|
|
private moveSliceLastFrame = new BehaviorSubject<MovingLastUpdateType>(null);
|
|
|
private moveSliceLastFrameSub: any;
|
|
@@ -502,10 +502,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
* joystick main core
|
|
|
*/
|
|
|
async joystick(request: JoystickRequest) {
|
|
|
- this.latestJoystickRequest = request;
|
|
|
- // if (!this.onMoving.getValue()) {
|
|
|
this.handlejoystick(request);
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
/***
|
|
@@ -562,56 +559,17 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
}
|
|
|
const seqs = Array.from(joystickRes).flat() as any as StreamReplyType[];
|
|
|
|
|
|
- if (seqs?.length) {
|
|
|
+ if (seqs?.length > 1) {
|
|
|
+ //TODO joystick中断逻辑
|
|
|
console.log('joystickRes-seqs', seqs.length);
|
|
|
- this.handleSeqMoving(seqs);
|
|
|
+ // hasJoystickMoveRequest是待数组move完成后接收新的数组
|
|
|
+ if (!this.hasJoystickMoveRequest) {
|
|
|
+ this.hasJoystickMoveRequest = true;
|
|
|
+ this.handleSeqMoving(seqs);
|
|
|
+ }
|
|
|
} else {
|
|
|
console.warn('joystick-move无数据');
|
|
|
}
|
|
|
-
|
|
|
- //TODO joystick中断逻辑
|
|
|
- // if (!this.moveSliceLastFrameSub) {
|
|
|
- // this.moveSliceLastFrameSub = this.moveSliceLastFrame.subscribe(
|
|
|
- // async (frame: MovingLastUpdateType) => {
|
|
|
- // if (this.latestJoystickRequest && this.onMoving.value) {
|
|
|
- // console.log('中断的小段', frame);
|
|
|
- // // this.moveQueue.complete();
|
|
|
- // // this.moveQueue.of('');
|
|
|
- // // TODO 中断move队列 ?优化如何清空
|
|
|
- // this.moveQueueSubscription.unsubscribe();
|
|
|
- // this.moveQueueSubscription = null;
|
|
|
- // //step1 执行stop方法
|
|
|
- // const metaData: StreamReplyType = frame.metaData;
|
|
|
- // const newUserStates: NewUserStatesType =
|
|
|
- // metaData.newUserStates.find(
|
|
|
- // (item) => item.userId === this.user_id,
|
|
|
- // );
|
|
|
- // const trace_id = metaData.traceIds[0];
|
|
|
- // const userId = newUserStates.userId;
|
|
|
- // const breakPointId = metaData.endBreakPointId;
|
|
|
- // const cameraAngle = newUserStates.playerState.camera.angle;
|
|
|
- // const playerAngle = newUserStates.playerState.player.angle;
|
|
|
- // console.log(
|
|
|
- // 'stop-data',
|
|
|
- // trace_id,
|
|
|
- // userId,
|
|
|
- // cameraAngle,
|
|
|
- // cameraAngle,
|
|
|
- // );
|
|
|
- // const redisMeta = await this.moveService.stop(
|
|
|
- // trace_id,
|
|
|
- // userId,
|
|
|
- // breakPointId,
|
|
|
- // cameraAngle,
|
|
|
- // playerAngle,
|
|
|
- // );
|
|
|
- // console.log('stop-redisMeta', redisMeta);
|
|
|
- // // 2. 中断重新joystick
|
|
|
- // this.handlejoystick(this.latestWalkingRequest);
|
|
|
- // }
|
|
|
- // },
|
|
|
- // );
|
|
|
- // }
|
|
|
} else {
|
|
|
console.log(
|
|
|
'joystick:' +
|
|
@@ -740,6 +698,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
|
|
|
this.onMoving.next(false);
|
|
|
this.cleanMoveSteam();
|
|
|
this.lastMovingPointArray = [];
|
|
|
+ this.hasJoystickMoveRequest = false;
|
|
|
console.log('move end');
|
|
|
}, 300);
|
|
|
}
|