|
@@ -5,6 +5,7 @@ import { join } from 'path';
|
|
import { CacheService } from 'src/cache/cache.service';
|
|
import { CacheService } from 'src/cache/cache.service';
|
|
import { RotateService } from 'src/rotate/rotate.service';
|
|
import { RotateService } from 'src/rotate/rotate.service';
|
|
import configuration from 'src/config/configuration';
|
|
import configuration from 'src/config/configuration';
|
|
|
|
+// import ShareData from 'src/ShareData';
|
|
|
|
|
|
// import * as BreakPointIds from '../../ws/points-BreakPointId.json';
|
|
// import * as BreakPointIds from '../../ws/points-BreakPointId.json';
|
|
// import { SceneService } from 'src/scene/scene.service';
|
|
// import { SceneService } from 'src/scene/scene.service';
|
|
@@ -12,6 +13,7 @@ import configuration from 'src/config/configuration';
|
|
const MaxDelayTime = 80; //超过这个值就需要干预(操作杆)
|
|
const MaxDelayTime = 80; //超过这个值就需要干预(操作杆)
|
|
const MaxBufferCameraInfo = 3; //超过这个值就需要干预(操作杆)
|
|
const MaxBufferCameraInfo = 3; //超过这个值就需要干预(操作杆)
|
|
const MaxNet = 3;
|
|
const MaxNet = 3;
|
|
|
|
+const MaxWalkCount = 20;
|
|
|
|
|
|
const seqExeAsyncFn = (asyncFn) => {
|
|
const seqExeAsyncFn = (asyncFn) => {
|
|
let runPromise = null;
|
|
let runPromise = null;
|
|
@@ -45,6 +47,7 @@ export class MoveService implements OnModuleInit {
|
|
Joystick: 15,
|
|
Joystick: 15,
|
|
};
|
|
};
|
|
public users = this.rotateService.users;
|
|
public users = this.rotateService.users;
|
|
|
|
+ //public users = ShareData.users;
|
|
|
|
|
|
private reply = {
|
|
private reply = {
|
|
traceIds: [],
|
|
traceIds: [],
|
|
@@ -95,7 +98,7 @@ export class MoveService implements OnModuleInit {
|
|
renderType: 0,
|
|
renderType: 0,
|
|
videoFrame: null,
|
|
videoFrame: null,
|
|
cameraStateType: 3,
|
|
cameraStateType: 3,
|
|
- isMoving: 1,
|
|
|
|
|
|
+ isMoving: 0,
|
|
needIfr: 0,
|
|
needIfr: 0,
|
|
isVideo: 0,
|
|
isVideo: 0,
|
|
stillFrame: 0,
|
|
stillFrame: 0,
|
|
@@ -197,7 +200,10 @@ export class MoveService implements OnModuleInit {
|
|
frameIndex: 0,
|
|
frameIndex: 0,
|
|
horizontal_move: 0,
|
|
horizontal_move: 0,
|
|
},
|
|
},
|
|
- moveInfo: {},
|
|
|
|
|
|
+ netQua:0,
|
|
|
|
+ walkState:0,
|
|
|
|
+ isMoving:0,
|
|
|
|
+ IDRCount:0,
|
|
// traceIds: [],
|
|
// traceIds: [],
|
|
// actionResponses:[]
|
|
// actionResponses:[]
|
|
};
|
|
};
|
|
@@ -271,7 +277,8 @@ export class MoveService implements OnModuleInit {
|
|
);
|
|
);
|
|
for (let i = 0; i < checkReplys.length; ++i) {
|
|
for (let i = 0; i < checkReplys.length; ++i) {
|
|
checkReplys[i].actionResponses[0].actionType = actionType;
|
|
checkReplys[i].actionResponses[0].actionType = actionType;
|
|
- if (i == 0 || i == checkReplys.length - 1) {
|
|
|
|
|
|
+ //if (i == 0 || i == checkReplys.length - 1) {
|
|
|
|
+ if (i == 0) {
|
|
checkReplys[i].isIDR = true;
|
|
checkReplys[i].isIDR = true;
|
|
} else {
|
|
} else {
|
|
checkReplys[i].isIDR = false;
|
|
checkReplys[i].isIDR = false;
|
|
@@ -408,7 +415,13 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
reply['newUserStates'][0].playerState.camera.angle =
|
|
reply['newUserStates'][0].playerState.camera.angle =
|
|
moveFrame.camera_angle;
|
|
moveFrame.camera_angle;
|
|
- reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
|
|
+ if(user.walkState>MaxWalkCount){
|
|
|
|
+ reply['newUserStates'][0].renderInfo.isMoving = 2;
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
reply['actionResponses'][0].traceId = traceId;
|
|
reply['actionResponses'][0].traceId = traceId;
|
|
|
|
|
|
reply.mediaSrc =
|
|
reply.mediaSrc =
|
|
@@ -423,6 +436,7 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
if (startBreakPointId > endBreakPointId) {
|
|
if (startBreakPointId > endBreakPointId) {
|
|
|
|
+ //console.log('change move437:'+startBreakPointId+','+endBreakPointId)
|
|
reply.mediaSrc =
|
|
reply.mediaSrc =
|
|
'/' +
|
|
'/' +
|
|
appId +
|
|
appId +
|
|
@@ -435,14 +449,10 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
}
|
|
}
|
|
|
|
+ console.log('mediaSrc_1:'+reply.mediaSrc)
|
|
|
|
|
|
reply.startBreakPointId = startBreakPointId;
|
|
reply.startBreakPointId = startBreakPointId;
|
|
reply.endBreakPointId = endBreakPointId;
|
|
reply.endBreakPointId = endBreakPointId;
|
|
- // if (i == moveFrames.length - 1) {
|
|
|
|
- // reply.isIDR = true;
|
|
|
|
- // } else {
|
|
|
|
- // reply.isIDR = false;
|
|
|
|
- // }
|
|
|
|
reply.isIDR = false;
|
|
reply.isIDR = false;
|
|
replys.push(reply);
|
|
replys.push(reply);
|
|
}
|
|
}
|
|
@@ -452,7 +462,12 @@ export class MoveService implements OnModuleInit {
|
|
const reply = JSON.parse(JSON.stringify(this.reply));
|
|
const reply = JSON.parse(JSON.stringify(this.reply));
|
|
reply.traceIds.push(traceId);
|
|
reply.traceIds.push(traceId);
|
|
reply['newUserStates'][0].userId = userId;
|
|
reply['newUserStates'][0].userId = userId;
|
|
- reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
|
|
+ if(user.walkState>MaxWalkCount){
|
|
|
|
+ reply['newUserStates'][0].renderInfo.isMoving = 2;
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
+ }
|
|
if (!isFromUser) {
|
|
if (!isFromUser) {
|
|
reply['newUserStates'][0].playerState.player.position = {
|
|
reply['newUserStates'][0].playerState.player.position = {
|
|
x:
|
|
x:
|
|
@@ -506,6 +521,7 @@ export class MoveService implements OnModuleInit {
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
|
|
|
|
if (startBreakPointId > endBreakPointId) {
|
|
if (startBreakPointId > endBreakPointId) {
|
|
|
|
+ console.log('change move526:'+startBreakPointId+','+endBreakPointId)
|
|
reply.mediaSrc =
|
|
reply.mediaSrc =
|
|
'/' +
|
|
'/' +
|
|
appId +
|
|
appId +
|
|
@@ -518,11 +534,12 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
}
|
|
}
|
|
|
|
+ console.log('mediaSrc_2:'+reply.mediaSrc)
|
|
reply.startBreakPointId = startBreakPointId;
|
|
reply.startBreakPointId = startBreakPointId;
|
|
reply.endBreakPointId = endBreakPointId;
|
|
reply.endBreakPointId = endBreakPointId;
|
|
replys.push(reply);
|
|
replys.push(reply);
|
|
}
|
|
}
|
|
- replys[replys.length - 1].isIDR = true;
|
|
|
|
|
|
+ //replys[replys.length - 1].isIDR = true;
|
|
return replys;
|
|
return replys;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -637,6 +654,7 @@ export class MoveService implements OnModuleInit {
|
|
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;
|
|
|
|
+ console.log('stop658:'+breakPointId+','+rotateData.directory)
|
|
reply.mediaSrc =
|
|
reply.mediaSrc =
|
|
'/' +
|
|
'/' +
|
|
appId +
|
|
appId +
|
|
@@ -667,7 +685,10 @@ export class MoveService implements OnModuleInit {
|
|
const breakPointId = user.breakPointId;
|
|
const breakPointId = user.breakPointId;
|
|
const appId = user.appId;
|
|
const appId = user.appId;
|
|
const replys = [];
|
|
const replys = [];
|
|
- const step = 0.4;
|
|
|
|
|
|
+ let step = 0.4;
|
|
|
|
+ if(user.walkState>MaxWalkCount){
|
|
|
|
+ step = 1.2;
|
|
|
|
+ }
|
|
//const step = 1;
|
|
//const step = 1;
|
|
const closestDis = 50; //小于这个距离就跳到邻居呼吸点
|
|
const closestDis = 50; //小于这个距离就跳到邻居呼吸点
|
|
const distance = step * dir_action.speed_level;
|
|
const distance = step * dir_action.speed_level;
|
|
@@ -692,6 +713,8 @@ export class MoveService implements OnModuleInit {
|
|
{ x: 550, y: -300 },
|
|
{ x: 550, y: -300 },
|
|
];
|
|
];
|
|
|
|
|
|
|
|
+ //更新行走状态
|
|
|
|
+ ++user.walkState;
|
|
//找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
//找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
const breakPoint = this.breakPointInfo[breakPointId];
|
|
const breakPoint = this.breakPointInfo[breakPointId];
|
|
const surroundPointIds = breakPoint.contact;
|
|
const surroundPointIds = breakPoint.contact;
|
|
@@ -714,7 +737,13 @@ export class MoveService implements OnModuleInit {
|
|
this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
|
|
this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
|
|
JSON.stringify(user.player.position),
|
|
JSON.stringify(user.player.position),
|
|
);
|
|
);
|
|
- this.reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
|
|
+
|
|
|
|
+ if(user.walkState>MaxWalkCount){
|
|
|
|
+ this.reply['newUserStates'][0].renderInfo.isMoving = 2;
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ this.reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
+ }
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
this.reply.mediaSrc = null;
|
|
this.reply.mediaSrc = null;
|
|
|
|
|
|
@@ -758,10 +787,9 @@ export class MoveService implements OnModuleInit {
|
|
closestAngleNeighor = angle;
|
|
closestAngleNeighor = angle;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ console.log('joystickjoystick:' + this.cameraInfos.length);
|
|
//超出范围了
|
|
//超出范围了
|
|
if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
|
|
if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
|
|
- console.log('20220627test-joystick-moveCamera');
|
|
|
|
return await this.moveCamera(
|
|
return await this.moveCamera(
|
|
breakPointId,
|
|
breakPointId,
|
|
closestNeighorId,
|
|
closestNeighorId,
|
|
@@ -775,7 +803,6 @@ export class MoveService implements OnModuleInit {
|
|
//超出区域
|
|
//超出区域
|
|
if (!inside) {
|
|
if (!inside) {
|
|
if (minAngleNeighorId != null) {
|
|
if (minAngleNeighorId != null) {
|
|
- console.log('20220627test-joystick-moveDirect');
|
|
|
|
return await this.moveDirect(
|
|
return await this.moveDirect(
|
|
playerPosition,
|
|
playerPosition,
|
|
closestDis,
|
|
closestDis,
|
|
@@ -797,17 +824,18 @@ export class MoveService implements OnModuleInit {
|
|
);
|
|
);
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
|
|
|
|
- console.log('20220708_延时->' + time_delay);
|
|
|
|
|
|
+ console.log('20220719_延时->' + time_delay);
|
|
// //网络延迟的情况下,就暂时不推流
|
|
// //网络延迟的情况下,就暂时不推流
|
|
- if (time_delay && time_delay > MaxDelayTime) {
|
|
|
|
- user.netQua = 0;
|
|
|
|
- } else if (
|
|
|
|
|
|
+ if (
|
|
time_delay &&
|
|
time_delay &&
|
|
time_delay < MaxDelayTime &&
|
|
time_delay < MaxDelayTime &&
|
|
user.netQua < MaxNet
|
|
user.netQua < MaxNet
|
|
) {
|
|
) {
|
|
++user.netQua;
|
|
++user.netQua;
|
|
}
|
|
}
|
|
|
|
+ else if (time_delay && time_delay > MaxDelayTime) {
|
|
|
|
+ user.netQua = 0;
|
|
|
|
+ }
|
|
|
|
|
|
if (user.netQua < MaxNet) {
|
|
if (user.netQua < MaxNet) {
|
|
if (user.lastJoyStickMediaSrc) {
|
|
if (user.lastJoyStickMediaSrc) {
|
|
@@ -817,9 +845,6 @@ export class MoveService implements OnModuleInit {
|
|
}
|
|
}
|
|
const cameraInfo = this.getCameraInfo();
|
|
const cameraInfo = this.getCameraInfo();
|
|
if (cameraInfo != null) {
|
|
if (cameraInfo != null) {
|
|
- console.log(
|
|
|
|
- '20220627test-joystick-自由-合并,' + this.cameraInfos.length,
|
|
|
|
- );
|
|
|
|
this.reply['newUserStates'][0].playerState.camera.position =
|
|
this.reply['newUserStates'][0].playerState.camera.position =
|
|
cameraInfo.camera_position;
|
|
cameraInfo.camera_position;
|
|
this.reply['newUserStates'][0].playerState.camera.angle =
|
|
this.reply['newUserStates'][0].playerState.camera.angle =
|
|
@@ -829,21 +854,17 @@ export class MoveService implements OnModuleInit {
|
|
this.reply.mediaSrc = cameraInfo.mediaSrc;
|
|
this.reply.mediaSrc = cameraInfo.mediaSrc;
|
|
this.reply.isIDR = cameraInfo.isIDR;
|
|
this.reply.isIDR = cameraInfo.isIDR;
|
|
user.lastJoyStickMediaSrc = true;
|
|
user.lastJoyStickMediaSrc = true;
|
|
- console.log('20220708_mediaSrc1:' + cameraInfo.mediaSrc);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
user.camera.position = JSON.parse(
|
|
user.camera.position = JSON.parse(
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
);
|
|
);
|
|
- // console.log(
|
|
|
|
- // 'handlejoystick-angle->:自由并过渡更新user.angle' +
|
|
|
|
- // cameraInfo.camera_angle.yaw,
|
|
|
|
- // );
|
|
|
|
|
|
+
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
|
|
|
this.sendingFrameForJoystick = true;
|
|
this.sendingFrameForJoystick = true;
|
|
} else {
|
|
} else {
|
|
- console.log('20220627test-joystick-自由-不合并');
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
return this.reply;
|
|
return this.reply;
|
|
}
|
|
}
|
|
@@ -872,17 +893,13 @@ export class MoveService implements OnModuleInit {
|
|
const closestDis = 80; //小于这个距离就跳到邻居呼吸点
|
|
const closestDis = 80; //小于这个距离就跳到邻居呼吸点
|
|
const distance = step * dir_action.speed_level;
|
|
const distance = step * dir_action.speed_level;
|
|
let angle = null;
|
|
let angle = null;
|
|
- // console.log(
|
|
|
|
- // 'handlejoystick-angle->:dir_action.move_angle' + dir_action.move_angle,
|
|
|
|
- // );
|
|
|
|
|
|
+
|
|
if (user.camera.angle.yaw < 0) {
|
|
if (user.camera.angle.yaw < 0) {
|
|
user.camera.angle.yaw = 360 + user.camera.angle.yaw;
|
|
user.camera.angle.yaw = 360 + user.camera.angle.yaw;
|
|
}
|
|
}
|
|
let move_angle = dir_action.move_angle + user.camera.angle.yaw;
|
|
let move_angle = dir_action.move_angle + user.camera.angle.yaw;
|
|
move_angle = move_angle % 360;
|
|
move_angle = move_angle % 360;
|
|
- // console.log(
|
|
|
|
- // 'handlejoystick-angle->:叠加后move_angle(也是user.angle)' + move_angle,
|
|
|
|
- // );
|
|
|
|
|
|
+
|
|
//TODO 临时增加断言
|
|
//TODO 临时增加断言
|
|
const playerPosition: Point = { x: 0, y: 0, z: 0 };
|
|
const playerPosition: Point = { x: 0, y: 0, z: 0 };
|
|
playerPosition.x =
|
|
playerPosition.x =
|
|
@@ -894,10 +911,7 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
// const offsetX = playerPosition.x - user.player.position.x;
|
|
// const offsetX = playerPosition.x - user.player.position.x;
|
|
// const offsetY = playerPosition.y - user.player.position.y;
|
|
// const offsetY = playerPosition.y - user.player.position.y;
|
|
- console.log(
|
|
|
|
- 'handlejoysticktesttest:actionRequest-playerPosition' +
|
|
|
|
- JSON.stringify(playerPosition),
|
|
|
|
- );
|
|
|
|
|
|
+
|
|
//找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
//找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
let chooseBreakPointId = null;
|
|
let chooseBreakPointId = null;
|
|
const breakPoint = this.breakPointInfo[breakPointId];
|
|
const breakPoint = this.breakPointInfo[breakPointId];
|
|
@@ -920,7 +934,13 @@ export class MoveService implements OnModuleInit {
|
|
this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
|
|
this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
|
|
JSON.stringify(breakPoint.position),
|
|
JSON.stringify(breakPoint.position),
|
|
);
|
|
);
|
|
- this.reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
|
|
+
|
|
|
|
+ if(user.walkState>MaxWalkCount){
|
|
|
|
+ this.reply['newUserStates'][0].renderInfo.isMoving = 2;
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ this.reply['newUserStates'][0].renderInfo.isMoving = 1;
|
|
|
|
+ }
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
this.reply['actionResponses'][0].traceId = traceId;
|
|
this.reply.mediaSrc = null;
|
|
this.reply.mediaSrc = null;
|
|
|
|
|
|
@@ -1021,11 +1041,6 @@ export class MoveService implements OnModuleInit {
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
if (singleInfo != null) {
|
|
if (singleInfo != null) {
|
|
- // console.log(
|
|
|
|
- // 'joystick校验--->' + breakPointId + '-' + singleInfo.breakPointId,
|
|
|
|
- // );
|
|
|
|
- //console.log('handlejoysticktesttest校验0角度:'+_angle+','+move_angle) //这个没办法,得换方案
|
|
|
|
- //console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
|
return await this.moveDirect(
|
|
return await this.moveDirect(
|
|
playerPosition,
|
|
playerPosition,
|
|
closestDis,
|
|
closestDis,
|
|
@@ -1037,7 +1052,6 @@ export class MoveService implements OnModuleInit {
|
|
actionType,
|
|
actionType,
|
|
);
|
|
);
|
|
} else if (count == 1) {
|
|
} else if (count == 1) {
|
|
- //console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
|
return await this.moveDirect(
|
|
return await this.moveDirect(
|
|
playerPosition,
|
|
playerPosition,
|
|
closestDis,
|
|
closestDis,
|
|
@@ -1052,7 +1066,6 @@ export class MoveService implements OnModuleInit {
|
|
this.reply['newUserStates'][0].playerState.player.position =
|
|
this.reply['newUserStates'][0].playerState.player.position =
|
|
JSON.parse(JSON.stringify(user.player.position));
|
|
JSON.parse(JSON.stringify(user.player.position));
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
- //console.log('handlejoysticktesttest:actionRequest-停止'+new Date().getTime());
|
|
|
|
return this.reply;
|
|
return this.reply;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1068,24 +1081,6 @@ export class MoveService implements OnModuleInit {
|
|
this.getDistance(playerPosition, breakPoint.position),
|
|
this.getDistance(playerPosition, breakPoint.position),
|
|
);
|
|
);
|
|
if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
|
|
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;
|
|
|
|
- // }
|
|
|
|
- // if (closestNeighorId == null) {
|
|
|
|
- // debugger;
|
|
|
|
- // }
|
|
|
|
chooseBreakPointId = closestNeighorId;
|
|
chooseBreakPointId = closestNeighorId;
|
|
return await this.moveCamera(
|
|
return await this.moveCamera(
|
|
breakPointId,
|
|
breakPointId,
|
|
@@ -1116,17 +1111,13 @@ export class MoveService implements OnModuleInit {
|
|
user.camera.position = JSON.parse(
|
|
user.camera.position = JSON.parse(
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
);
|
|
);
|
|
- // console.log(
|
|
|
|
- // 'handlejoystick-angle->:自由并过渡更新user.angle' +
|
|
|
|
- // cameraInfo.camera_angle.yaw,
|
|
|
|
- // );
|
|
|
|
|
|
+
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
|
|
|
this.sendingFrameForJoystick = true;
|
|
this.sendingFrameForJoystick = true;
|
|
} else {
|
|
} else {
|
|
- //console.log('joystick自由--->不合并');
|
|
|
|
}
|
|
}
|
|
- //console.log('handlejoysticktesttest:actionRequest-自由'+new Date().getTime());
|
|
|
|
|
|
+
|
|
console.log(
|
|
console.log(
|
|
'handlejoysticktesttest:自由:' +
|
|
'handlejoysticktesttest:自由:' +
|
|
this.reply.mediaSrc +
|
|
this.reply.mediaSrc +
|
|
@@ -1159,10 +1150,7 @@ export class MoveService implements OnModuleInit {
|
|
breakPoint.position,
|
|
breakPoint.position,
|
|
this.breakPointInfo[neighBreakPointId].position,
|
|
this.breakPointInfo[neighBreakPointId].position,
|
|
);
|
|
);
|
|
- // console.log('handlejoysticktesttest校验1线段:'+breakPointId+','+neighBreakPointId)
|
|
|
|
- // console.log('handlejoysticktesttest校验2计算后的:'+JSON.stringify(player_Position))
|
|
|
|
- // console.log('handlejoysticktesttest校验3人物变化前:'+JSON.stringify(user.player.position))
|
|
|
|
- // console.log('handlejoysticktesttest校验4人物本应该的坐标:'+JSON.stringify(playerPosition))
|
|
|
|
|
|
+
|
|
if (player_Position != null) {
|
|
if (player_Position != null) {
|
|
playerPosition.x = player_Position.x;
|
|
playerPosition.x = player_Position.x;
|
|
playerPosition.y = player_Position.y;
|
|
playerPosition.y = player_Position.y;
|
|
@@ -1245,7 +1233,8 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
for (let i = 0; i < checkReplys.length; ++i) {
|
|
for (let i = 0; i < checkReplys.length; ++i) {
|
|
let isIDR = false;
|
|
let isIDR = false;
|
|
- if (i == 0 || i == checkReplys.length - 1) {
|
|
|
|
|
|
+ //if (i == 0 || i == checkReplys.length - 1) {
|
|
|
|
+ if (i == 0) {
|
|
isIDR = true;
|
|
isIDR = true;
|
|
}
|
|
}
|
|
this.addCameraInfo(
|
|
this.addCameraInfo(
|
|
@@ -1256,21 +1245,6 @@ export class MoveService implements OnModuleInit {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- //replys.push(checkReplys);
|
|
|
|
- //读redis里的数据,按照frame_index的大小排序
|
|
|
|
- /*
|
|
|
|
- const key =
|
|
|
|
- 'moveframe:app_id:' +
|
|
|
|
- appId +
|
|
|
|
- ':start_break_point_id:' +
|
|
|
|
- breakPointId +
|
|
|
|
- ':end_break_point_id:' +
|
|
|
|
- chooseBreakPointId +
|
|
|
|
- ':angle:' +
|
|
|
|
- Math.floor(user.camera.angle.yaw / 45);
|
|
|
|
- const moveFramesRes = await this.cacheService.get(key);
|
|
|
|
- const moveFrames = JSON.parse(moveFramesRes);
|
|
|
|
- */
|
|
|
|
const index = this.getMoveIndex(user.camera.angle.yaw);
|
|
const index = this.getMoveIndex(user.camera.angle.yaw);
|
|
const moveFrames = await this.getMoveFrames(
|
|
const moveFrames = await this.getMoveFrames(
|
|
appId,
|
|
appId,
|
|
@@ -1298,10 +1272,7 @@ export class MoveService implements OnModuleInit {
|
|
user.camera.position = JSON.parse(
|
|
user.camera.position = JSON.parse(
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
);
|
|
);
|
|
- // console.log(
|
|
|
|
- // 'handlejoystick-angle->:刚刚过渡更新user.angle' +
|
|
|
|
- // cameraInfo.camera_angle.yaw,
|
|
|
|
- // );
|
|
|
|
|
|
+
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
|
|
|
if (cameraInfo.mediaSrc) {
|
|
if (cameraInfo.mediaSrc) {
|
|
@@ -1310,7 +1281,7 @@ export class MoveService implements OnModuleInit {
|
|
}
|
|
}
|
|
this.sendingFrameForJoystick = true;
|
|
this.sendingFrameForJoystick = true;
|
|
}
|
|
}
|
|
- //console.log('handlejoysticktesttest:actionRequest-镜头过渡'+new Date().getTime());
|
|
|
|
|
|
+
|
|
console.log(
|
|
console.log(
|
|
'handlejoysticktesttest:actionRequest-镜头过渡:从' +
|
|
'handlejoysticktesttest:actionRequest-镜头过渡:从' +
|
|
breakPointId +
|
|
breakPointId +
|
|
@@ -1324,17 +1295,28 @@ export class MoveService implements OnModuleInit {
|
|
}
|
|
}
|
|
|
|
|
|
setCameraInfo(appId, userId, moveFrames, startBreakPointId, endBreakPointId) {
|
|
setCameraInfo(appId, userId, moveFrames, startBreakPointId, endBreakPointId) {
|
|
- // let moveInterval = 1;
|
|
|
|
- // console.log('20220708_cameraInfos设置->'+this.cameraInfos.length);
|
|
|
|
- // if(this.cameraInfos.length>MaxBufferCameraInfo){
|
|
|
|
- // moveInterval = 1;
|
|
|
|
- // }
|
|
|
|
|
|
+ console.log('setCameraInfo前:'+this.cameraInfos.length);
|
|
const user = this.users[userId];
|
|
const user = this.users[userId];
|
|
- let moveInterval = 2;
|
|
|
|
|
|
+ //let moveInterval = 2;
|
|
let flag = false;
|
|
let flag = false;
|
|
for (let i = 0; i < moveFrames.length; ++i) {
|
|
for (let i = 0; i < moveFrames.length; ++i) {
|
|
- if (user.netQua < MaxNet) {
|
|
|
|
- if (i != 0 && i != moveFrames.length - 1 && i % moveInterval == 0) {
|
|
|
|
|
|
+ if(user.walkState > MaxWalkCount){
|
|
|
|
+ //网络差
|
|
|
|
+ if (user.netQua < MaxNet) {
|
|
|
|
+ if (i != 0 && i != moveFrames.length - 1 && i % 5 != 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //网络正常
|
|
|
|
+ else{
|
|
|
|
+ if (i != 0 && i != moveFrames.length - 1 && i % 4 != 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //网络差
|
|
|
|
+ else if (user.netQua < MaxNet) {
|
|
|
|
+ if (i != 0 && i != moveFrames.length - 1 && i % 2 == 0) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1357,6 +1339,7 @@ export class MoveService implements OnModuleInit {
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
|
|
|
|
if (startBreakPointId > endBreakPointId) {
|
|
if (startBreakPointId > endBreakPointId) {
|
|
|
|
+ console.log('change move1341:'+startBreakPointId+','+endBreakPointId)
|
|
moveFrames[i].mediaSrc =
|
|
moveFrames[i].mediaSrc =
|
|
'/' +
|
|
'/' +
|
|
appId +
|
|
appId +
|
|
@@ -1372,17 +1355,30 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
}
|
|
}
|
|
- console.log('20220708_mediaSrc3:' + moveFrames[i].mediaSrc);
|
|
|
|
- if (i == 0 || i == moveFrames.length - 1) {
|
|
|
|
|
|
+ // if (i == 0 || i == moveFrames.length - 1) {
|
|
|
|
+ // moveFrames[i].isIDR = true;
|
|
|
|
+ // if (i == moveFrames.length - 1) {
|
|
|
|
+ // flag = true;
|
|
|
|
+ // }
|
|
|
|
+ // } else {
|
|
|
|
+ // moveFrames[i].isIDR = false; }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(user.IDRCount % 10 == 0){
|
|
moveFrames[i].isIDR = true;
|
|
moveFrames[i].isIDR = true;
|
|
- if (i == moveFrames.length - 1) {
|
|
|
|
- flag = true;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
|
|
+ user.IDRCount = 0;
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
moveFrames[i].isIDR = false;
|
|
moveFrames[i].isIDR = false;
|
|
}
|
|
}
|
|
|
|
+ if (i == moveFrames.length - 1) {
|
|
|
|
+ flag = true;
|
|
|
|
+ }
|
|
|
|
+ ++user.IDRCount;
|
|
this.cameraInfos.push(moveFrames[i]);
|
|
this.cameraInfos.push(moveFrames[i]);
|
|
|
|
+ console.log('mediaSrc_3:'+moveFrames[i].mediaSrc+',isIDR:'+moveFrames[i].isIDR)
|
|
}
|
|
}
|
|
|
|
+ //最后一个元素跳过了,要补上
|
|
if (!flag) {
|
|
if (!flag) {
|
|
const cameraInfo = moveFrames[moveFrames.length - 1];
|
|
const cameraInfo = moveFrames[moveFrames.length - 1];
|
|
cameraInfo.endBreakPointId = endBreakPointId;
|
|
cameraInfo.endBreakPointId = endBreakPointId;
|
|
@@ -1399,6 +1395,7 @@ export class MoveService implements OnModuleInit {
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
|
|
|
|
if (startBreakPointId > endBreakPointId) {
|
|
if (startBreakPointId > endBreakPointId) {
|
|
|
|
+ console.log('change move1384:'+startBreakPointId+','+endBreakPointId)
|
|
cameraInfo.mediaSrc =
|
|
cameraInfo.mediaSrc =
|
|
'/' +
|
|
'/' +
|
|
appId +
|
|
appId +
|
|
@@ -1411,10 +1408,16 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
}
|
|
}
|
|
- cameraInfo.isIDR = true;
|
|
|
|
|
|
+ //cameraInfo.isIDR = true;
|
|
|
|
+ if(user.IDRCount % 10 == 0){
|
|
|
|
+ cameraInfo.isIDR = true;
|
|
|
|
+ user.IDRCount = 0;
|
|
|
|
+ }
|
|
|
|
+ ++user.IDRCount;
|
|
this.cameraInfos.push(cameraInfo);
|
|
this.cameraInfos.push(cameraInfo);
|
|
- console.log('20220708_mediaSrc4:' + cameraInfo.mediaSrc);
|
|
|
|
|
|
+ console.log('mediaSrc_4:'+cameraInfo.mediaSrc+',isIDR:'+cameraInfo.isIDR)
|
|
}
|
|
}
|
|
|
|
+ console.log('setCameraInfo后:'+this.cameraInfos.length);
|
|
}
|
|
}
|
|
|
|
|
|
addCameraInfo(cameraPosition, cameraAngle, mediaSrc, isIDR) {
|
|
addCameraInfo(cameraPosition, cameraAngle, mediaSrc, isIDR) {
|
|
@@ -1429,7 +1432,6 @@ export class MoveService implements OnModuleInit {
|
|
getCameraInfo() {
|
|
getCameraInfo() {
|
|
if (this.cameraInfos.length > 0) {
|
|
if (this.cameraInfos.length > 0) {
|
|
const item = this.cameraInfos.shift();
|
|
const item = this.cameraInfos.shift();
|
|
- console.log('20220708_cameraInfos取值->' + this.cameraInfos.length);
|
|
|
|
return item;
|
|
return item;
|
|
} else {
|
|
} else {
|
|
return null;
|
|
return null;
|
|
@@ -1437,9 +1439,10 @@ export class MoveService implements OnModuleInit {
|
|
}
|
|
}
|
|
|
|
|
|
complementFrame(userId) {
|
|
complementFrame(userId) {
|
|
|
|
+ const user = this.users[userId];
|
|
|
|
+ user.walkState = 0;
|
|
|
|
+ user.IDRCount = 0;
|
|
if (this.cameraInfos.length > 0) {
|
|
if (this.cameraInfos.length > 0) {
|
|
- console.log('20220627test-执行complementFrame,' + new Date().getTime());
|
|
|
|
- const user = this.users[userId];
|
|
|
|
const cameraInfo = this.cameraInfos.shift();
|
|
const cameraInfo = this.cameraInfos.shift();
|
|
this.reply.traceIds = [];
|
|
this.reply.traceIds = [];
|
|
this.reply['newUserStates'][0].userId = userId;
|
|
this.reply['newUserStates'][0].userId = userId;
|
|
@@ -1475,11 +1478,9 @@ export class MoveService implements OnModuleInit {
|
|
this.sendingFrameForJoystick = true;
|
|
this.sendingFrameForJoystick = true;
|
|
return this.reply;
|
|
return this.reply;
|
|
} else if (this.cameraInfos.length == 0) {
|
|
} else if (this.cameraInfos.length == 0) {
|
|
- if (this.reply['newUserStates'][0].renderInfo.isMoving == 1) {
|
|
|
|
- //console.log('handlejoysticktesttest:complementFrame-2 停止1'+new Date().getTime())
|
|
|
|
|
|
+ if (this.reply['newUserStates'][0].renderInfo.isMoving != 0) {
|
|
return this.stopJoystick(userId);
|
|
return this.stopJoystick(userId);
|
|
} else {
|
|
} else {
|
|
- //console.log('handlejoysticktesttest:complementFrame-2 停止2'+new Date().getTime())
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1570,6 +1571,7 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
if (startBreakPointId > endBreakPointId) {
|
|
if (startBreakPointId > endBreakPointId) {
|
|
|
|
+ console.log('change move1552:'+startBreakPointId+','+endBreakPointId)
|
|
mediaSrc =
|
|
mediaSrc =
|
|
'/' +
|
|
'/' +
|
|
appId +
|
|
appId +
|
|
@@ -1582,7 +1584,7 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
}
|
|
}
|
|
- console.log('20220708_mediaSrc2:' + mediaSrc);
|
|
|
|
|
|
+ console.log('mediaSrc_5:'+mediaSrc)
|
|
this.cameraInfos.push({
|
|
this.cameraInfos.push({
|
|
startBreakPointId: startBreakPointId,
|
|
startBreakPointId: startBreakPointId,
|
|
endBreakPointId: endBreakPointId,
|
|
endBreakPointId: endBreakPointId,
|
|
@@ -1608,7 +1610,8 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
if (startBreakPointId > endBreakPointId) {
|
|
if (startBreakPointId > endBreakPointId) {
|
|
- frame.mediaSrc =
|
|
|
|
|
|
+ console.log('change move1591:'+startBreakPointId+','+endBreakPointId)
|
|
|
|
+ mediaSrc =
|
|
'/' +
|
|
'/' +
|
|
appId +
|
|
appId +
|
|
'/' +
|
|
'/' +
|
|
@@ -1620,6 +1623,7 @@ export class MoveService implements OnModuleInit {
|
|
'?m=' +
|
|
'?m=' +
|
|
new Date().getTime();
|
|
new Date().getTime();
|
|
}
|
|
}
|
|
|
|
+ console.log('mediaSrc_6:'+mediaSrc)
|
|
this.cameraInfos.push({
|
|
this.cameraInfos.push({
|
|
startBreakPointId: startBreakPointId,
|
|
startBreakPointId: startBreakPointId,
|
|
endBreakPointId: endBreakPointId,
|
|
endBreakPointId: endBreakPointId,
|
|
@@ -1631,7 +1635,7 @@ export class MoveService implements OnModuleInit {
|
|
}
|
|
}
|
|
|
|
|
|
stopJoystick(userId) {
|
|
stopJoystick(userId) {
|
|
- console.log('20220627test:stopJoystick');
|
|
|
|
|
|
+
|
|
this.reply.traceIds = [];
|
|
this.reply.traceIds = [];
|
|
const user = this.users[userId];
|
|
const user = this.users[userId];
|
|
this.reply['newUserStates'][0].userId = userId;
|
|
this.reply['newUserStates'][0].userId = userId;
|