|
@@ -17,14 +17,14 @@ export class RotateService {
|
|
|
public users = {};
|
|
|
private replies = {};
|
|
|
|
|
|
- init(app_id, userId) {
|
|
|
+ init(app_id: string, userId: string) {
|
|
|
const user = {
|
|
|
appId: null,
|
|
|
userId: null,
|
|
|
breakPointId: null,
|
|
|
roomId: null,
|
|
|
player: {
|
|
|
- position: { x: -700, y: 0, z: 0 },
|
|
|
+ position: { x: 800.0, y: 300.0, z: 0.0 },
|
|
|
angle: {
|
|
|
pitch: 0,
|
|
|
yaw: 0,
|
|
@@ -32,7 +32,7 @@ export class RotateService {
|
|
|
},
|
|
|
},
|
|
|
camera: {
|
|
|
- position: { x: -1145, y: 0, z: 160 },
|
|
|
+ position: { x: 368.6542053222656, y: 323.94207763671875, z: 120.0 },
|
|
|
angle: {
|
|
|
pitch: 0,
|
|
|
yaw: 0,
|
|
@@ -50,7 +50,7 @@ export class RotateService {
|
|
|
|
|
|
user.appId = app_id;
|
|
|
user.userId = userId;
|
|
|
- user.breakPointId = 100;
|
|
|
+ user.breakPointId = 10;
|
|
|
this.users[userId] = user;
|
|
|
|
|
|
const reply = {
|
|
@@ -419,7 +419,7 @@ export class RotateService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async echo(userId) {
|
|
|
+ async echo(userId: string, isFirst: boolean) {
|
|
|
const user = this.users[userId];
|
|
|
const reply = JSON.parse(JSON.stringify(this.replies[userId]));
|
|
|
reply['newUserStates'][0]['userId'] = userId;
|
|
@@ -433,31 +433,47 @@ export class RotateService {
|
|
|
reply['newUserStates'][0]['playerState'].cameraCenter =
|
|
|
user.player.position;
|
|
|
|
|
|
- const key =
|
|
|
- 'rotateframe:app_id:' +
|
|
|
- user.appId +
|
|
|
- ':frame_index:' +
|
|
|
- user.camera.angle.yaw +
|
|
|
- ':break_point_id:' +
|
|
|
- user.breakPointId;
|
|
|
- const redisData = await this.cacheService.get(key);
|
|
|
- if (redisData && redisData.length > 0) {
|
|
|
- const value = redisData ? JSON.parse(redisData) : null;
|
|
|
+ if (isFirst) {
|
|
|
reply.mediaSrc =
|
|
|
'/' +
|
|
|
user.appId +
|
|
|
'/' +
|
|
|
user.breakPointId +
|
|
|
'/' +
|
|
|
- value.directory +
|
|
|
+ user.breakPointId +
|
|
|
'/' +
|
|
|
- value.fileName +
|
|
|
+ `${user.breakPointId}.0000.h264` +
|
|
|
'?m=' +
|
|
|
new Date().getTime();
|
|
|
reply.breakPointId = user.breakPointId;
|
|
|
- return reply;
|
|
|
} else {
|
|
|
- return null;
|
|
|
+ const key =
|
|
|
+ 'rotateframe:app_id:' +
|
|
|
+ user.appId +
|
|
|
+ ':frame_index:' +
|
|
|
+ user.camera.angle.yaw +
|
|
|
+ ':break_point_id:' +
|
|
|
+ user.breakPointId;
|
|
|
+ const redisData = await this.cacheService.get(key);
|
|
|
+ if (redisData && redisData.length > 0) {
|
|
|
+ const value = redisData ? JSON.parse(redisData) : null;
|
|
|
+ reply.mediaSrc =
|
|
|
+ '/' +
|
|
|
+ user.appId +
|
|
|
+ '/' +
|
|
|
+ user.breakPointId +
|
|
|
+ '/' +
|
|
|
+ value.directory +
|
|
|
+ '/' +
|
|
|
+ value.fileName +
|
|
|
+ '?m=' +
|
|
|
+ new Date().getTime();
|
|
|
+ reply.breakPointId = user.breakPointId;
|
|
|
+ return reply;
|
|
|
+ } else {
|
|
|
+ this.logger.error('echo返回null');
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|