|
@@ -173,16 +173,15 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
const appId = user.appId;
|
|
|
const path = pathArray || [100, 101, 102]; //需要计算路径
|
|
|
- const angle = user.camera.angle.yaw % 45; //纠正需要
|
|
|
+ let angle = user.camera.angle.yaw % 45; //纠正需要
|
|
|
const replys = [];
|
|
|
const traceIds = [];
|
|
|
traceIds.push(traceId);
|
|
|
-
|
|
|
- // debugger;
|
|
|
//纠正,旋转传到缓存里
|
|
|
const checkReplys = [];
|
|
|
// console.log('矫正: ' + angle + ' 度');
|
|
|
if (angle > 22) {
|
|
|
+ angle = 45 - angle;
|
|
|
for (let i = 0; i < angle; ++i) {
|
|
|
// console.warn('矫正一次:' + i);
|
|
|
const reply = await this.rotateService.rotateForAngle(userId, 1);
|
|
@@ -219,11 +218,18 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
//replys['P' + user.breakPointId + 'T' + user.breakPointId] = checkReplys;
|
|
|
replys.push(checkReplys);
|
|
|
+ if (checkReplys.length > 0) {
|
|
|
+ console.log(
|
|
|
+ 'move-1' +
|
|
|
+ checkReplys[checkReplys.length - 1].newUserStates[0].playerState
|
|
|
+ .camera.angle.yaw,
|
|
|
+ );
|
|
|
+ }
|
|
|
//过渡传到缓存里
|
|
|
this.reply.traceIds = traceIds;
|
|
|
this.reply['newUserStates'][0].userId = userId;
|
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
|
- const index = Math.floor(user.camera.angle.yaw / 45); //过渡需要
|
|
|
+ const index = Math.floor((user.camera.angle.yaw + 1) / 45); //过渡需要
|
|
|
for (let i = 0; i < path.length - 1; ++i) {
|
|
|
let pathReplys = [];
|
|
|
const start_break_point_id = path[i];
|
|
@@ -243,7 +249,6 @@ export class MoveService implements OnModuleInit {
|
|
|
return replys;
|
|
|
}
|
|
|
const moveFrames = JSON.parse(moveFramesRes);
|
|
|
- // debugger;
|
|
|
//读redis里的数据
|
|
|
const startBreakPointRes = await this.cacheService.get(
|
|
|
'breakpoints:app_id:' +
|
|
@@ -307,7 +312,8 @@ export class MoveService implements OnModuleInit {
|
|
|
endPosition,
|
|
|
);
|
|
|
|
|
|
- for (let i = 1; i < moveFrames.length; i += 2) {
|
|
|
+ let i;
|
|
|
+ for (i = 1; i < moveFrames.length; i += 3) {
|
|
|
const moveFrame = moveFrames[i];
|
|
|
|
|
|
const reply = JSON.parse(JSON.stringify(this.reply));
|
|
@@ -330,6 +336,60 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
reply['newUserStates'][0].playerState.camera.position =
|
|
|
moveFrame.camera_position;
|
|
|
+ if (i == 1) {
|
|
|
+ console.log('move-2' + moveFrame.camera_angle.yaw);
|
|
|
+ }
|
|
|
+ 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 =
|
|
|
+ moveFrame.camera_angle;
|
|
|
+ reply['newUserStates'][0].playerState.cameraCenter =
|
|
|
+ reply['newUserStates'][0].playerState.player.position;
|
|
|
+
|
|
|
+ reply['actionResponses'][0].traceId = traceId;
|
|
|
+
|
|
|
+ reply.mediaSrc =
|
|
|
+ '/' +
|
|
|
+ appId +
|
|
|
+ '/' +
|
|
|
+ startBreakPointId +
|
|
|
+ '/' +
|
|
|
+ moveFrame.file_name.substring(0, moveFrame.file_name.indexOf('.')) +
|
|
|
+ '/' +
|
|
|
+ moveFrame.file_name +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+ reply.startBreakPointId = startBreakPointId;
|
|
|
+ reply.endBreakPointId = endBreakPointId;
|
|
|
+ replys.push(reply);
|
|
|
+ }
|
|
|
+ if (i != moveFrames.length - 1) {
|
|
|
+ i = moveFrames.length - 1;
|
|
|
+ const moveFrame = moveFrames[i];
|
|
|
+ const reply = JSON.parse(JSON.stringify(this.reply));
|
|
|
+ reply.traceIds.push(traceId);
|
|
|
+ reply['newUserStates'][0].userId = userId;
|
|
|
+
|
|
|
+ reply['newUserStates'][0].playerState.player.position = {
|
|
|
+ x:
|
|
|
+ startPosition.x +
|
|
|
+ ((endPosition.x - startPosition.x) / moveFrames.length) * i,
|
|
|
+ y:
|
|
|
+ startPosition.y +
|
|
|
+ ((endPosition.y - startPosition.y) / moveFrames.length) * i,
|
|
|
+ z:
|
|
|
+ startPosition.z +
|
|
|
+ ((endPosition.z - startPosition.z) / moveFrames.length) * i,
|
|
|
+ };
|
|
|
+
|
|
|
+ reply['newUserStates'][0].playerState.player.angle.yaw = angle;
|
|
|
+
|
|
|
+ reply['newUserStates'][0].playerState.camera.position =
|
|
|
+ moveFrame.camera_position;
|
|
|
if (moveFrame.camera_angle.yaw < 0) {
|
|
|
moveFrame.camera_angle.yaw += 360;
|
|
|
} else if (moveFrame.camera_angle.yaw > 359) {
|
|
@@ -366,7 +426,6 @@ export class MoveService implements OnModuleInit {
|
|
|
const user = this.users[userId];
|
|
|
user.breakPointId = breakPointId;
|
|
|
|
|
|
- // debugger;
|
|
|
user.player.position =
|
|
|
lastReply['newUserStates'][0].playerState.player.position;
|
|
|
user.player.angle = lastReply['newUserStates'][0].playerState.player.angle;
|