|
@@ -1,4 +1,9 @@
|
|
-import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
|
|
|
|
|
+import {
|
|
|
|
+ ConsoleLogger,
|
|
|
|
+ Injectable,
|
|
|
|
+ Logger,
|
|
|
|
+ OnModuleInit,
|
|
|
|
+} from '@nestjs/common';
|
|
import { readFileSync } from 'fs';
|
|
import { readFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
import { join } from 'path';
|
|
import { CacheService } from 'src/cache/cache.service';
|
|
import { CacheService } from 'src/cache/cache.service';
|
|
@@ -168,8 +173,7 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
const appId = user.appId;
|
|
const appId = user.appId;
|
|
const path = pathArray || [100, 101, 102]; //需要计算路径
|
|
const path = pathArray || [100, 101, 102]; //需要计算路径
|
|
- const angle = user.camera.angle.yaw % 44; //纠正需要
|
|
|
|
- console.log('矫正前-相机:' + user.camera.angle.yaw);
|
|
|
|
|
|
+ const angle = (user.camera.angle.yaw + 1) % 45; //纠正需要
|
|
const replys = [];
|
|
const replys = [];
|
|
const traceIds = [];
|
|
const traceIds = [];
|
|
traceIds.push(traceId);
|
|
traceIds.push(traceId);
|
|
@@ -219,8 +223,7 @@ export class MoveService implements OnModuleInit {
|
|
this.reply.traceIds = traceIds;
|
|
this.reply.traceIds = traceIds;
|
|
this.reply['newUserStates'][0].userId = userId;
|
|
this.reply['newUserStates'][0].userId = userId;
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
- console.log('矫正后-相机:' + user.camera.angle.yaw);
|
|
|
|
- const index = Math.floor(user.camera.angle.yaw / 44); //过渡需要
|
|
|
|
|
|
+ const index = Math.floor((user.camera.angle.yaw + 1) / 45); //过渡需要
|
|
for (let i = 0; i < path.length - 1; ++i) {
|
|
for (let i = 0; i < path.length - 1; ++i) {
|
|
let pathReplys = [];
|
|
let pathReplys = [];
|
|
const start_break_point_id = path[i];
|
|
const start_break_point_id = path[i];
|
|
@@ -240,6 +243,7 @@ export class MoveService implements OnModuleInit {
|
|
return replys;
|
|
return replys;
|
|
}
|
|
}
|
|
const moveFrames = JSON.parse(moveFramesRes);
|
|
const moveFrames = JSON.parse(moveFramesRes);
|
|
|
|
+ // debugger;
|
|
//读redis里的数据
|
|
//读redis里的数据
|
|
const startBreakPointRes = await this.cacheService.get(
|
|
const startBreakPointRes = await this.cacheService.get(
|
|
'breakpoints:app_id:' +
|
|
'breakpoints:app_id:' +
|
|
@@ -301,7 +305,7 @@ export class MoveService implements OnModuleInit {
|
|
endPosition,
|
|
endPosition,
|
|
);
|
|
);
|
|
|
|
|
|
- for (let i = 1; i < moveFrames.length; i += 5) {
|
|
|
|
|
|
+ for (let i = 1; i < moveFrames.length; i += 2) {
|
|
const moveFrame = moveFrames[i];
|
|
const moveFrame = moveFrames[i];
|
|
|
|
|
|
const reply = JSON.parse(JSON.stringify(this.reply));
|
|
const reply = JSON.parse(JSON.stringify(this.reply));
|
|
@@ -324,6 +328,12 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
reply['newUserStates'][0].playerState.camera.position =
|
|
reply['newUserStates'][0].playerState.camera.position =
|
|
moveFrame.camera_position;
|
|
moveFrame.camera_position;
|
|
|
|
+ if (moveFrame.camera_angle.yaw < 0) {
|
|
|
|
+ moveFrame.camera_angle.yaw += 360;
|
|
|
|
+ } else if (moveFrame.camera_angle.yaw > 359) {
|
|
|
|
+ moveFrame.camera_angle.yaw -= 360;
|
|
|
|
+ }
|
|
|
|
+
|
|
reply['newUserStates'][0].playerState.camera.angle =
|
|
reply['newUserStates'][0].playerState.camera.angle =
|
|
moveFrame.camera_angle;
|
|
moveFrame.camera_angle;
|
|
reply['newUserStates'][0].playerState.cameraCenter =
|
|
reply['newUserStates'][0].playerState.cameraCenter =
|
|
@@ -580,7 +590,7 @@ export class MoveService implements OnModuleInit {
|
|
traceIds.push(traceId);
|
|
traceIds.push(traceId);
|
|
// debugger;
|
|
// debugger;
|
|
const checkReplys = [];
|
|
const checkReplys = [];
|
|
- angle = user.camera.angle.yaw % 44; //纠正需要
|
|
|
|
|
|
+ angle = (user.camera.angle.yaw + 1) % 45; //纠正需要
|
|
for (let i = 0; i < angle; ++i) {
|
|
for (let i = 0; i < angle; ++i) {
|
|
const reply = await this.rotateService.rotateForAngle(userId, 1);
|
|
const reply = await this.rotateService.rotateForAngle(userId, 1);
|
|
reply.traceIds = [];
|
|
reply.traceIds = [];
|
|
@@ -604,7 +614,7 @@ export class MoveService implements OnModuleInit {
|
|
':end_break_point_id:' +
|
|
':end_break_point_id:' +
|
|
chooseBreakPointId +
|
|
chooseBreakPointId +
|
|
':angle:' +
|
|
':angle:' +
|
|
- (user.camera.angle.yaw % 44);
|
|
|
|
|
|
+ ((user.camera.angle.yaw + 1) % 45);
|
|
const moveFramesRes = await this.cacheService.get(key);
|
|
const moveFramesRes = await this.cacheService.get(key);
|
|
if (moveFramesRes == null) {
|
|
if (moveFramesRes == null) {
|
|
return replys;
|
|
return replys;
|
|
@@ -634,10 +644,6 @@ export class MoveService implements OnModuleInit {
|
|
endBreakPoint.position,
|
|
endBreakPoint.position,
|
|
);
|
|
);
|
|
replys.push(pathReplys);
|
|
replys.push(pathReplys);
|
|
- if (replys.length > 0) {
|
|
|
|
- console.log('最后一帧' + JSON.stringify(replys[replys.length - 1]));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return replys;
|
|
return replys;
|
|
}
|
|
}
|
|
}
|
|
}
|