|
@@ -9,7 +9,7 @@ export class MoveService {
|
|
Rotation: 1014,
|
|
Rotation: 1014,
|
|
Joystick: 15,
|
|
Joystick: 15,
|
|
};
|
|
};
|
|
- private users = {};
|
|
|
|
|
|
+ public users = {};
|
|
|
|
|
|
private reply = {
|
|
private reply = {
|
|
traceIds: [],
|
|
traceIds: [],
|
|
@@ -135,7 +135,7 @@ export class MoveService {
|
|
this.users[userId] = user;
|
|
this.users[userId] = user;
|
|
}
|
|
}
|
|
|
|
|
|
- async move(actionRequest) {
|
|
|
|
|
|
+ async move(pathArray, actionRequest) {
|
|
try {
|
|
try {
|
|
const userId = actionRequest['user_id'];
|
|
const userId = actionRequest['user_id'];
|
|
const traceId = actionRequest['trace_id'];
|
|
const traceId = actionRequest['trace_id'];
|
|
@@ -143,7 +143,7 @@ export class MoveService {
|
|
const user = this.users[userId];
|
|
const user = this.users[userId];
|
|
|
|
|
|
const appId = user.appId;
|
|
const appId = user.appId;
|
|
- const path = [100, 101, 102]; //需要计算路径
|
|
|
|
|
|
+ const path = pathArray || [100, 101, 102]; //需要计算路径
|
|
const angle = user.camera.angle.yaw % 45; //纠正需要
|
|
const angle = user.camera.angle.yaw % 45; //纠正需要
|
|
const index = Math.round(user.camera.angle.yaw / 45); //过渡需要
|
|
const index = Math.round(user.camera.angle.yaw / 45); //过渡需要
|
|
|
|
|
|
@@ -214,6 +214,13 @@ export class MoveService {
|
|
startBreakPoint.position,
|
|
startBreakPoint.position,
|
|
endBreakPoint.position,
|
|
endBreakPoint.position,
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ if (i == path.length - 2) {
|
|
|
|
+ pathReplys[pathReplys.length - 1][
|
|
|
|
+ 'newUserStates'
|
|
|
|
+ ][0].renderInfo.isMoving = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
//replys.push(pathReplys);
|
|
//replys.push(pathReplys);
|
|
replys['P' + start_break_point_id + 'T' + end_break_point_id] =
|
|
replys['P' + start_break_point_id + 'T' + end_break_point_id] =
|
|
pathReplys;
|
|
pathReplys;
|
|
@@ -297,6 +304,7 @@ export class MoveService {
|
|
const user = this.users[userId];
|
|
const user = this.users[userId];
|
|
user.breakPointId = breakPointId;
|
|
user.breakPointId = breakPointId;
|
|
|
|
|
|
|
|
+ // debugger;
|
|
user.player.position =
|
|
user.player.position =
|
|
lastReply['newUserStates'][0].playerState.player.position;
|
|
lastReply['newUserStates'][0].playerState.player.position;
|
|
user.player.angle = lastReply['newUserStates'][0].playerState.player.angle;
|
|
user.player.angle = lastReply['newUserStates'][0].playerState.player.angle;
|
|
@@ -334,10 +342,16 @@ export class MoveService {
|
|
|
|
|
|
//const breakPoints = await this.cacheService.get('breakpoints:app_id:'+appId+':break_point_id:'+breakPointId);
|
|
//const breakPoints = await this.cacheService.get('breakpoints:app_id:'+appId+':break_point_id:'+breakPointId);
|
|
//获取redis表全部元素,'breakpoints:app_id:'+appId+':break_point_id:'开头的
|
|
//获取redis表全部元素,'breakpoints:app_id:'+appId+':break_point_id:'开头的
|
|
- const breakPoints = [];
|
|
|
|
- for (let i = 0; i < breakPoints.length; ++i) {
|
|
|
|
- const position = breakPoints[i].position;
|
|
|
|
- reply['nps'].push(position);
|
|
|
|
|
|
+ const keys = await this.cacheService.keys(`breakpoints:app_id:${appId}*`);
|
|
|
|
+
|
|
|
|
+ for (let i = 0; i < keys.length; ++i) {
|
|
|
|
+ const breakPointRes = await this.cacheService.get(keys[i]);
|
|
|
|
+ const breakPoint = JSON.parse(breakPointRes);
|
|
|
|
+ const position = breakPoint.position;
|
|
|
|
+ reply['nps'].push({
|
|
|
|
+ position: position,
|
|
|
|
+ breakPointId: breakPoint.breakPointId,
|
|
|
|
+ });
|
|
}
|
|
}
|
|
return reply;
|
|
return reply;
|
|
}
|
|
}
|
|
@@ -355,20 +369,31 @@ export class MoveService {
|
|
return (angle + 360) % 360;
|
|
return (angle + 360) % 360;
|
|
}
|
|
}
|
|
|
|
|
|
- async stop(traceId,userId,breakPointId,cameraAngle,playerAngle){
|
|
|
|
|
|
+ async stop(traceId, userId, movePointIds, cameraAngle, playerAngle) {
|
|
|
|
+ const breakPointId = movePointIds.substring(movePointIds.indexOf('-') + 1);
|
|
const user = this.users[userId];
|
|
const user = this.users[userId];
|
|
user.breakPointId = breakPointId;
|
|
user.breakPointId = breakPointId;
|
|
const appId = user.appId;
|
|
const appId = user.appId;
|
|
|
|
|
|
- const breakPointRes = await this.cacheService.get('breakpoints:app_id:' +appId +':break_point_id:' +breakPointId);
|
|
|
|
|
|
+ const breakPointRes = await this.cacheService.get(
|
|
|
|
+ 'breakpoints:app_id:' + appId + ':break_point_id:' + breakPointId,
|
|
|
|
+ );
|
|
|
|
+
|
|
const breakPoint = JSON.parse(breakPointRes);
|
|
const breakPoint = JSON.parse(breakPointRes);
|
|
|
|
|
|
user.player.position = breakPoint.position;
|
|
user.player.position = breakPoint.position;
|
|
user.player.angle = playerAngle;
|
|
user.player.angle = playerAngle;
|
|
|
|
|
|
- const rotateDataRes ='rotateframe:app_id:' +appId +':frame_index:' + cameraAngle.yaw +':break_point_id:' +breakPointId;
|
|
|
|
- const rotateData = await this.cacheService.get(rotateDataRes);
|
|
|
|
|
|
+ const rotateKey =
|
|
|
|
+ 'rotateframe:app_id:' +
|
|
|
|
+ appId +
|
|
|
|
+ ':frame_index:' +
|
|
|
|
+ cameraAngle.yaw +
|
|
|
|
+ ':break_point_id:' +
|
|
|
|
+ breakPointId;
|
|
|
|
|
|
|
|
+ const rotateDataRes = await this.cacheService.get(rotateKey);
|
|
|
|
+ const rotateData = JSON.parse(rotateDataRes);
|
|
user.camera.position = rotateData.cameraPosition;
|
|
user.camera.position = rotateData.cameraPosition;
|
|
user.camera.angle = rotateData.cameraAngle;
|
|
user.camera.angle = rotateData.cameraAngle;
|
|
|
|
|
|
@@ -377,11 +402,23 @@ export class MoveService {
|
|
reply['newUserStates'][0].userId = userId;
|
|
reply['newUserStates'][0].userId = userId;
|
|
reply['newUserStates'][0].playerState.player.position = breakPoint.position;
|
|
reply['newUserStates'][0].playerState.player.position = breakPoint.position;
|
|
reply['newUserStates'][0].playerState.player.angle = playerAngle;
|
|
reply['newUserStates'][0].playerState.player.angle = playerAngle;
|
|
- reply['newUserStates'][0].playerState.camera.position = rotateData.cameraPosition;
|
|
|
|
|
|
+ reply['newUserStates'][0].playerState.camera.position =
|
|
|
|
+ rotateData.cameraPosition;
|
|
reply['newUserStates'][0].playerState.camera.angle = rotateData.cameraAngle;
|
|
reply['newUserStates'][0].playerState.camera.angle = rotateData.cameraAngle;
|
|
reply['newUserStates'][0].playerState.cameraCenter = breakPoint.position;
|
|
reply['newUserStates'][0].playerState.cameraCenter = breakPoint.position;
|
|
reply['actionResponses'][0].traceId = traceId;
|
|
reply['actionResponses'][0].traceId = traceId;
|
|
- reply.mediaSrc ='/' +'0000000001' +'/' +breakPointId +'/' +rotateData.directory +'/' +rotateData.fileName +'?m=' +new Date().getTime();
|
|
|
|
|
|
+ reply.mediaSrc =
|
|
|
|
+ '/' +
|
|
|
|
+ '0000000001' +
|
|
|
|
+ '/' +
|
|
|
|
+ breakPointId +
|
|
|
|
+ '/' +
|
|
|
|
+ rotateData.directory +
|
|
|
|
+ '/' +
|
|
|
|
+ rotateData.fileName +
|
|
|
|
+ '?m=' +
|
|
|
|
+ new Date().getTime();
|
|
|
|
+ reply['newUserStates'][0].renderInfo.isMoving = 0;
|
|
return reply;
|
|
return reply;
|
|
}
|
|
}
|
|
}
|
|
}
|