|
@@ -27,7 +27,7 @@ const seqExeAsyncFn = (asyncFn) => {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-const moveInterval = 3;
|
|
|
+let moveInterval = 3;
|
|
|
|
|
|
@Injectable()
|
|
|
export class MoveService implements OnModuleInit {
|
|
@@ -132,7 +132,7 @@ export class MoveService implements OnModuleInit {
|
|
|
};
|
|
|
private breakPointInfo: any;
|
|
|
|
|
|
- private cameraInfos = [];
|
|
|
+ public cameraInfos = [];
|
|
|
public sendingFrameForJoystick = false;
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -261,7 +261,6 @@ export class MoveService implements OnModuleInit {
|
|
|
const replys = [];
|
|
|
const traceIds = [];
|
|
|
traceIds.push(traceId);
|
|
|
-
|
|
|
const checkReplys = await this.modeifyCameraAngle(
|
|
|
angle,
|
|
|
userId,
|
|
@@ -285,6 +284,7 @@ export class MoveService implements OnModuleInit {
|
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
|
//const index = Math.floor((user.camera.angle.yaw + 1) / 45) % 8; //过渡需要
|
|
|
const index = this.getMoveIndex(user.camera.angle.yaw);
|
|
|
+
|
|
|
for (let i = 0; i < path.length - 1; ++i) {
|
|
|
const start_break_point_id = path[i];
|
|
|
const end_break_point_id = path[i + 1];
|
|
@@ -315,18 +315,20 @@ export class MoveService implements OnModuleInit {
|
|
|
pathReplys[0].isIDR = true;
|
|
|
}
|
|
|
//最后一段
|
|
|
- else if (i == path.length - 2) {
|
|
|
+ if (i == path.length - 2) {
|
|
|
//最后一帧
|
|
|
pathReplys[pathReplys.length - 1][
|
|
|
'newUserStates'
|
|
|
][0].renderInfo.isMoving = 0;
|
|
|
}
|
|
|
+
|
|
|
for (let j = 0; j < pathReplys.length; ++j) {
|
|
|
pathReplys[j].actionResponses[0].actionType = actionType;
|
|
|
}
|
|
|
replys.push(pathReplys);
|
|
|
//replys['P' + start_break_point_id + 'T' + end_break_point_id] =pathReplys;
|
|
|
}
|
|
|
+
|
|
|
return replys;
|
|
|
} catch (error) {
|
|
|
console.log('MoveService', error);
|
|
@@ -434,11 +436,12 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
reply.startBreakPointId = startBreakPointId;
|
|
|
reply.endBreakPointId = endBreakPointId;
|
|
|
- if (i == moveFrames.length - 1) {
|
|
|
- reply.isIDR = true;
|
|
|
- } else {
|
|
|
- reply.isIDR = false;
|
|
|
- }
|
|
|
+ // if (i == moveFrames.length - 1) {
|
|
|
+ // reply.isIDR = true;
|
|
|
+ // } else {
|
|
|
+ // reply.isIDR = false;
|
|
|
+ // }
|
|
|
+ reply.isIDR = false;
|
|
|
replys.push(reply);
|
|
|
}
|
|
|
if (i != moveFrames.length - 1) {
|
|
@@ -515,9 +518,9 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
reply.startBreakPointId = startBreakPointId;
|
|
|
reply.endBreakPointId = endBreakPointId;
|
|
|
- reply.isIDR = true;
|
|
|
replys.push(reply);
|
|
|
}
|
|
|
+ replys[replys.length-1].isIDR = true;
|
|
|
return replys;
|
|
|
}
|
|
|
|
|
@@ -651,222 +654,181 @@ export class MoveService implements OnModuleInit {
|
|
|
// 顺序旋转请求
|
|
|
seqExeJoystick = seqExeAsyncFn(this.joystick);
|
|
|
|
|
|
- // async joystick(actionRequest) {
|
|
|
- // try {
|
|
|
- // const userId = actionRequest['user_id'];
|
|
|
- // const traceId = actionRequest['trace_id'];
|
|
|
- // const dir_action = actionRequest['dir_action'];
|
|
|
- // const actionType = actionRequest['action_type'];
|
|
|
- // const user = this.users[userId];
|
|
|
- // const breakPointId = user.breakPointId;
|
|
|
- // const appId = user.appId;
|
|
|
-
|
|
|
- // const replys = [];
|
|
|
- // const step = 0.3;
|
|
|
- // const closestDis = 85; //小于这个距离就跳到邻居呼吸点
|
|
|
- // const distance = step * dir_action.speed_level;
|
|
|
- // let angle = null;
|
|
|
- // let move_angle = dir_action.move_angle + user.camera.angle.yaw;
|
|
|
- // move_angle = move_angle % 360;
|
|
|
-
|
|
|
- // //TODO 临时增加断言
|
|
|
- // const playerPosition: Point = { x: 0, y: 0, z: 0 };
|
|
|
- // playerPosition.x =
|
|
|
- // user.player.position.x +
|
|
|
- // distance * Math.cos((move_angle / 360) * 2 * Math.PI);
|
|
|
- // playerPosition.y =
|
|
|
- // user.player.position.y +
|
|
|
- // distance * Math.sin((move_angle / 360) * 2 * Math.PI);
|
|
|
-
|
|
|
- // //找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
|
- // let chooseBreakPointId = null;
|
|
|
- // const breakPoint = this.breakPointInfo[breakPointId];
|
|
|
- // const surroundPointIds = breakPoint.contact;
|
|
|
- // //const neighAngles = [];
|
|
|
- // const traceIds = [];
|
|
|
-
|
|
|
- // user.player.angle.yaw = move_angle;
|
|
|
- // traceIds.push(traceId);
|
|
|
- // this.reply.traceIds = traceIds;
|
|
|
- // this.reply['newUserStates'][0].userId = userId;
|
|
|
- // this.reply['actionResponses'][0].traceId = traceId;
|
|
|
- // this.reply['newUserStates'][0].playerState.player.angle.yaw = move_angle;
|
|
|
-
|
|
|
- // this.reply['newUserStates'][0].playerState.camera.angle = JSON.parse(
|
|
|
- // JSON.stringify(user.camera.angle),
|
|
|
- // );
|
|
|
- // this.reply['newUserStates'][0].playerState.camera.position = JSON.parse(
|
|
|
- // JSON.stringify(user.camera.position),
|
|
|
- // );
|
|
|
- // this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
|
|
|
- // JSON.stringify(breakPoint.position),
|
|
|
- // );
|
|
|
- // this.reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
- // this.reply['actionResponses'][0].traceId = traceId;
|
|
|
- // this.reply.mediaSrc = null;
|
|
|
-
|
|
|
- // if (surroundPointIds.length == 1) {
|
|
|
- // return await this.moveDirect(
|
|
|
- // playerPosition,
|
|
|
- // closestDis,
|
|
|
- // breakPointId,
|
|
|
- // surroundPointIds[0],
|
|
|
- // appId,
|
|
|
- // userId,
|
|
|
- // traceId,
|
|
|
- // actionType,
|
|
|
- // );
|
|
|
- // }
|
|
|
-
|
|
|
- // let count = 0;
|
|
|
- // const neighPoints = [];
|
|
|
- // //人在哪个角度
|
|
|
- // let _angle = this.getAngle(
|
|
|
- // breakPoint.position,
|
|
|
- // { x: breakPoint.position.x + 1, y: breakPoint.position.y },
|
|
|
- // playerPosition,
|
|
|
- // );
|
|
|
- // if (_angle < 0) {
|
|
|
- // _angle += 360;
|
|
|
- // }
|
|
|
-
|
|
|
- // let singleInfo = null;
|
|
|
- // for (let i = 0; i < surroundPointIds.length; ++i) {
|
|
|
- // const neighPoint = this.breakPointInfo[surroundPointIds[i]];
|
|
|
- // neighPoint.breakPointId = surroundPointIds[i];
|
|
|
- // angle = this.getAngle(
|
|
|
- // breakPoint.position,
|
|
|
- // { x: breakPoint.position.x + 1, y: breakPoint.position.y },
|
|
|
- // neighPoint.position,
|
|
|
- // );
|
|
|
- // if (angle < 0) {
|
|
|
- // angle += 360;
|
|
|
- // }
|
|
|
-
|
|
|
- // //if(angle<45&&angle!=0){
|
|
|
- // if (
|
|
|
- // // Math.abs(angle - move_angle) < 45 &&
|
|
|
- // // Math.abs(angle - move_angle) != 0
|
|
|
- // Math.abs(angle - _angle) < 45 &&
|
|
|
- // Math.abs(angle - _angle) != 0
|
|
|
- // ) {
|
|
|
- // neighPoint.angle = angle;
|
|
|
- // neighPoints.push(neighPoint);
|
|
|
- // ++count;
|
|
|
- // } else if (Math.abs(angle - move_angle) == 0) {
|
|
|
- // return await this.moveDirect(
|
|
|
- // playerPosition,
|
|
|
- // closestDis,
|
|
|
- // breakPointId,
|
|
|
- // surroundPointIds[i],
|
|
|
- // appId,
|
|
|
- // userId,
|
|
|
- // traceId,
|
|
|
- // actionType,
|
|
|
- // );
|
|
|
- // }
|
|
|
-
|
|
|
- // //if (angle == 0 && Math.abs(360 - move_angle) < 45) {
|
|
|
- // if (angle == 0 && Math.abs(360 - _angle) < 45) {
|
|
|
- // neighPoint.angle = angle;
|
|
|
- // neighPoints.push(neighPoint);
|
|
|
- // ++count;
|
|
|
- // }
|
|
|
-
|
|
|
- // if(Math.abs(angle - move_angle)<45||Math.abs(angle+360 - move_angle)<45){
|
|
|
- // if(singleInfo == null){
|
|
|
- // singleInfo = {
|
|
|
- // angle:angle,
|
|
|
- // breakPointId:surroundPointIds[i]
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // if (count == 2) {
|
|
|
- // //人物移动
|
|
|
- // user.player.position = JSON.parse(JSON.stringify(playerPosition));
|
|
|
- // this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
- // JSON.stringify(playerPosition),
|
|
|
- // );
|
|
|
- // }
|
|
|
- // else{
|
|
|
- // if(singleInfo != null){
|
|
|
- // return await this.moveDirect(
|
|
|
- // playerPosition,
|
|
|
- // closestDis,
|
|
|
- // breakPointId,
|
|
|
- // singleInfo.breakPointId,
|
|
|
- // appId,
|
|
|
- // userId,
|
|
|
- // traceId,
|
|
|
- // actionType,
|
|
|
- // );
|
|
|
- // }
|
|
|
- // else if (count == 1) {
|
|
|
- // return await this.moveDirect(
|
|
|
- // playerPosition,
|
|
|
- // closestDis,
|
|
|
- // breakPointId,
|
|
|
- // neighPoints[0].breakPointId,
|
|
|
- // appId,
|
|
|
- // userId,
|
|
|
- // traceId,
|
|
|
- // actionType,
|
|
|
- // );
|
|
|
- // }
|
|
|
- // else if (count == 0) {
|
|
|
- // this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
- // JSON.stringify(user.player.position),
|
|
|
- // );
|
|
|
- // this.reply.actionResponses[0].actionType = actionType;
|
|
|
- // return this.reply;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // //count == 2
|
|
|
- // //超出范围了
|
|
|
- // if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
|
|
|
- // let offsetAngle1 = Math.abs(_angle - neighPoints[0].angle);
|
|
|
- // if (neighPoints[0].angle == 0) {
|
|
|
- // offsetAngle1 = Math.min(offsetAngle1, Math.abs(_angle - 360));
|
|
|
- // }
|
|
|
-
|
|
|
- // let offsetAngle2 = Math.abs(_angle - neighPoints[1].angle);
|
|
|
- // if (neighPoints[1].angle == 0) {
|
|
|
- // offsetAngle2 = Math.min(offsetAngle2, Math.abs(_angle - 360));
|
|
|
- // }
|
|
|
-
|
|
|
- // if (offsetAngle1 > offsetAngle2) {
|
|
|
- // chooseBreakPointId = neighPoints[1].breakPointId;
|
|
|
- // } else {
|
|
|
- // chooseBreakPointId = neighPoints[0].breakPointId;
|
|
|
- // }
|
|
|
- // return await this.moveCamera(
|
|
|
- // breakPointId,
|
|
|
- // chooseBreakPointId,
|
|
|
- // appId,
|
|
|
- // userId,
|
|
|
- // traceId,
|
|
|
- // actionType,
|
|
|
- // );
|
|
|
- // } else {
|
|
|
- // user.player.position = JSON.parse(JSON.stringify(playerPosition));
|
|
|
- // this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
- // JSON.stringify(user.player.position),
|
|
|
- // );
|
|
|
- // this.reply.actionResponses[0].actionType = actionType;
|
|
|
- // return this.reply;
|
|
|
- // }
|
|
|
- // } catch (error) {
|
|
|
- // console.log('MoveService', error);
|
|
|
- // debugger;
|
|
|
- // return null;
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
async joystick(actionRequest) {
|
|
|
try {
|
|
|
+ const userId = actionRequest['user_id'];
|
|
|
+ const traceId = actionRequest['trace_id'];
|
|
|
+ const dir_action = actionRequest['dir_action'];
|
|
|
+ const actionType = actionRequest['action_type'];
|
|
|
+ const user = this.users[userId];
|
|
|
+ const breakPointId = user.breakPointId;
|
|
|
+ const appId = user.appId;
|
|
|
+ moveInterval = 1;
|
|
|
+ const replys = [];
|
|
|
+ const step = 0.4;
|
|
|
+ const closestDis = 45; //小于这个距离就跳到邻居呼吸点
|
|
|
+ const distance = step * dir_action.speed_level;
|
|
|
+ let angle = null;
|
|
|
+ let move_angle = dir_action.move_angle + user.camera.angle.yaw;
|
|
|
+ move_angle = move_angle % 360;
|
|
|
+
|
|
|
+ //TODO 临时增加断言
|
|
|
+ const playerPosition: Point = { x: 0, y: 0, z: 0 };
|
|
|
+ playerPosition.x =
|
|
|
+ user.player.position.x +
|
|
|
+ distance * Math.cos((move_angle / 360) * 2 * Math.PI);
|
|
|
+ playerPosition.y =
|
|
|
+ user.player.position.y +
|
|
|
+ distance * Math.sin((move_angle / 360) * 2 * Math.PI);
|
|
|
+
|
|
|
+ //可行走的区域
|
|
|
+ const area = [
|
|
|
+ {x:-600,y:-300},
|
|
|
+ {x:-600,y:250},
|
|
|
+ {x:550,y:250},
|
|
|
+ {x:550,y:-300}
|
|
|
+ ];
|
|
|
+
|
|
|
+ //找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
|
+ const breakPoint = this.breakPointInfo[breakPointId];
|
|
|
+ const surroundPointIds = breakPoint.contact;
|
|
|
+ //const neighAngles = [];
|
|
|
+ const traceIds = [];
|
|
|
+
|
|
|
+ user.player.angle.yaw = move_angle;
|
|
|
+ traceIds.push(traceId);
|
|
|
+ this.reply.traceIds = traceIds;
|
|
|
+ this.reply['newUserStates'][0].userId = userId;
|
|
|
+ this.reply['actionResponses'][0].traceId = traceId;
|
|
|
+ this.reply['newUserStates'][0].playerState.player.angle.yaw = move_angle;
|
|
|
+
|
|
|
+ this.reply['newUserStates'][0].playerState.camera.angle = JSON.parse(
|
|
|
+ JSON.stringify(user.camera.angle),
|
|
|
+ );
|
|
|
+ this.reply['newUserStates'][0].playerState.camera.position = JSON.parse(
|
|
|
+ JSON.stringify(user.camera.position),
|
|
|
+ );
|
|
|
+ this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
|
|
|
+ JSON.stringify(user.player.position),
|
|
|
+ );
|
|
|
+ this.reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
+ this.reply['actionResponses'][0].traceId = traceId;
|
|
|
+ this.reply.mediaSrc = null;
|
|
|
+
|
|
|
+ //人在哪个角度
|
|
|
+ let _angle = this.getAngle(
|
|
|
+ breakPoint.position,
|
|
|
+ { x: breakPoint.position.x + 1, y: breakPoint.position.y },
|
|
|
+ playerPosition,
|
|
|
+ );
|
|
|
+
|
|
|
+ //需要找到最近的邻居点和最接近角度的邻居点
|
|
|
+ let closestNeighorId = null;
|
|
|
+ let closestDisNeighor = null;
|
|
|
+
|
|
|
+ //超出行走区域的时候用得上
|
|
|
+ let minAngleNeighorId = null;
|
|
|
+ let closestAngleNeighor = null;
|
|
|
+
|
|
|
+ for (let i = 0; i < surroundPointIds.length; ++i) {
|
|
|
+ const neighPoint = this.breakPointInfo[surroundPointIds[i]];
|
|
|
+ neighPoint.breakPointId = surroundPointIds[i];
|
|
|
+ angle = this.getAngle(
|
|
|
+ breakPoint.position,
|
|
|
+ { x: breakPoint.position.x + 1, y: breakPoint.position.y },
|
|
|
+ neighPoint.position,
|
|
|
+ );
|
|
|
+
|
|
|
+ let distance = this.getDistance(playerPosition,neighPoint.position);
|
|
|
+ if(closestNeighorId == null || closestDisNeighor>distance){
|
|
|
+ closestNeighorId = surroundPointIds[i]
|
|
|
+ closestDisNeighor = distance;
|
|
|
+ }
|
|
|
+
|
|
|
+ if((this.getOffsetAngle(angle , _angle)<90)&&(minAngleNeighorId == null || this.getOffsetAngle(closestAngleNeighor , _angle)>this.getOffsetAngle(angle , _angle))){
|
|
|
+ minAngleNeighorId = surroundPointIds[i]
|
|
|
+ closestAngleNeighor = angle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //超出范围了
|
|
|
+ if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
|
|
|
+ console.log('20220627test-joystick-moveCamera')
|
|
|
+ return await this.moveCamera(
|
|
|
+ breakPointId,
|
|
|
+ closestNeighorId,
|
|
|
+ appId,
|
|
|
+ userId,
|
|
|
+ traceId,
|
|
|
+ actionType,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ let inside = this.isPointInPoly(playerPosition, area);
|
|
|
+ //超出区域
|
|
|
+ if(!inside){
|
|
|
+ if(minAngleNeighorId != null){
|
|
|
+ console.log('20220627test-joystick-moveDirect')
|
|
|
+ return await this.moveDirect(
|
|
|
+ playerPosition,
|
|
|
+ closestDis,
|
|
|
+ breakPointId,
|
|
|
+ minAngleNeighorId,
|
|
|
+ appId,
|
|
|
+ userId,
|
|
|
+ traceId,
|
|
|
+ actionType,
|
|
|
+ );
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ user.player.position = JSON.parse(JSON.stringify(playerPosition));
|
|
|
+ this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
+ JSON.stringify(user.player.position),
|
|
|
+ );
|
|
|
+ this.reply.actionResponses[0].actionType = actionType;
|
|
|
+
|
|
|
+ const cameraInfo = this.getCameraInfo();
|
|
|
+ if (cameraInfo != null) {
|
|
|
+ console.log('20220627test-joystick-自由-合并,'+this.cameraInfos.length)
|
|
|
+ this.reply['newUserStates'][0].playerState.camera.position =
|
|
|
+ cameraInfo.camera_position;
|
|
|
+ this.reply['newUserStates'][0].playerState.camera.angle =
|
|
|
+ cameraInfo.camera_angle;
|
|
|
+
|
|
|
+ if (cameraInfo.mediaSrc) {
|
|
|
+ this.reply.mediaSrc = cameraInfo.mediaSrc;
|
|
|
+ this.reply.isIDR = cameraInfo.isIDR;
|
|
|
+ }
|
|
|
+
|
|
|
+ user.camera.position = JSON.parse(
|
|
|
+ JSON.stringify(cameraInfo.camera_position),
|
|
|
+ );
|
|
|
+ // console.log(
|
|
|
+ // 'handlejoystick-angle->:自由并过渡更新user.angle' +
|
|
|
+ // cameraInfo.camera_angle.yaw,
|
|
|
+ // );
|
|
|
+ user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
+
|
|
|
+ this.sendingFrameForJoystick = true;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ console.log('20220627test-joystick-自由-不合并')
|
|
|
+ }
|
|
|
+ return this.reply;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log('MoveService', error);
|
|
|
+ debugger;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async joystick2(actionRequest) {
|
|
|
+ try {
|
|
|
if (this.sendingFrameForJoystick) {
|
|
|
return null;
|
|
|
}
|
|
@@ -1391,7 +1353,7 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
complementFrame(userId) {
|
|
|
if (this.cameraInfos.length > 0) {
|
|
|
- //console.log('handlejoysticktesttest:complementFrame-1 继续'+userId+','+new Date().getTime())
|
|
|
+ console.log('20220627test-执行complementFrame,'+new Date().getTime())
|
|
|
const user = this.users[userId];
|
|
|
const cameraInfo = this.cameraInfos.shift();
|
|
|
this.reply.traceIds = [];
|
|
@@ -1440,7 +1402,7 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
|
|
|
stopJoystick(userId) {
|
|
|
- //console.log('handlejoysticktesttest:stopJoystick');
|
|
|
+ console.log('20220627test:stopJoystick');
|
|
|
this.reply.traceIds = [];
|
|
|
const user = this.users[userId];
|
|
|
this.reply['newUserStates'][0].userId = userId;
|
|
@@ -1698,19 +1660,19 @@ export class MoveService implements OnModuleInit {
|
|
|
return parseFloat(num.toFixed(decimal));
|
|
|
}
|
|
|
|
|
|
- isPointInPoly(position, breakPointIds) {
|
|
|
+ isPointInPoly(position, points) {
|
|
|
const x = position.x;
|
|
|
const y = position.y;
|
|
|
|
|
|
let inside = false;
|
|
|
|
|
|
for (
|
|
|
- let i = 0, j = breakPointIds.length - 1;
|
|
|
- i < breakPointIds.length;
|
|
|
+ let i = 0, j = points.length - 1;
|
|
|
+ i < points.length;
|
|
|
j = i++
|
|
|
) {
|
|
|
- const pt1 = this.breakPointInfo[breakPointIds[i]];
|
|
|
- const pt2 = this.breakPointInfo[breakPointIds[j]];
|
|
|
+ const pt1 = points[i];
|
|
|
+ const pt2 = points[j];
|
|
|
|
|
|
const xi = pt1.x;
|
|
|
const yi = pt1.y;
|
|
@@ -1739,4 +1701,17 @@ export class MoveService implements OnModuleInit {
|
|
|
//超过了337
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+ getOffsetAngle(angle1,angle2){
|
|
|
+ if(angle1<0){
|
|
|
+ angle1 = 360+angle1;
|
|
|
+ //return Math.min(Math.abs(angle1-angle2),Math.abs());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(angle2<0){
|
|
|
+ angle2 = 360+angle2;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Math.min(Math.abs(angle1 - angle2),360 - Math.abs(angle1 - angle2))
|
|
|
+ }
|
|
|
}
|