model-action 2.0.12 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/Action.d.ts +29 -3
- package/dist/modules/Action.d.ts.map +1 -1
- package/dist/modules/Action.js +138 -11
- package/dist/modules/Action.js.map +1 -1
- package/dist/modules/Animation.d.ts +6 -6
- package/dist/modules/Animation.js +6 -6
- package/dist/modules/Animation.js.map +1 -1
- package/dist/modules/Building.d.ts +4 -4
- package/dist/modules/Building.js +4 -4
- package/dist/modules/Building.js.map +1 -1
- package/dist/modules/CameraView.d.ts +5 -5
- package/dist/modules/CameraView.js +5 -5
- package/dist/modules/CameraView.js.map +1 -1
- package/dist/modules/Effect.d.ts +3 -3
- package/dist/modules/Effect.js +3 -3
- package/dist/modules/Effect.js.map +1 -1
- package/dist/modules/Environment.d.ts +3 -3
- package/dist/modules/Environment.js +3 -3
- package/dist/modules/Environment.js.map +1 -1
- package/dist/modules/Focus.d.ts +1 -1
- package/dist/modules/Focus.js +1 -1
- package/dist/modules/Focus.js.map +1 -1
- package/dist/modules/GameMode.d.ts +2 -2
- package/dist/modules/GameMode.js +2 -2
- package/dist/modules/GameMode.js.map +1 -1
- package/dist/modules/Init.d.ts.map +1 -1
- package/dist/modules/Init.js +9 -17
- package/dist/modules/Init.js.map +1 -1
- package/dist/modules/Path.d.ts +5 -5
- package/dist/modules/Path.js +6 -6
- package/dist/modules/Path.js.map +1 -1
- package/dist/modules/Poi.d.ts +8 -8
- package/dist/modules/Poi.js +8 -8
- package/dist/modules/Poi.js.map +1 -1
- package/dist/modules/Routing.d.ts +4 -4
- package/dist/modules/Routing.js +4 -4
- package/dist/modules/Routing.js.map +1 -1
- package/dist/modules/Scene.d.ts +2 -2
- package/dist/modules/Scene.js +2 -2
- package/dist/modules/Scene.js.map +1 -1
- package/dist/modules/SceneAsset.d.ts +115 -0
- package/dist/modules/SceneAsset.d.ts.map +1 -0
- package/dist/modules/SceneAsset.js +97 -0
- package/dist/modules/SceneAsset.js.map +1 -0
- package/dist/modules/SingleMesh.d.ts +54 -0
- package/dist/modules/SingleMesh.d.ts.map +1 -0
- package/dist/modules/SingleMesh.js +33 -0
- package/dist/modules/SingleMesh.js.map +1 -0
- package/dist/modules/Status.d.ts +1 -1
- package/dist/modules/Status.js +1 -1
- package/dist/modules/Status.js.map +1 -1
- package/dist/modules/VideoFusion.d.ts +9 -9
- package/dist/modules/VideoFusion.js +9 -9
- package/dist/modules/VideoFusion.js.map +1 -1
- package/dist/modules/Window.d.ts +63 -10
- package/dist/modules/Window.d.ts.map +1 -1
- package/dist/modules/Window.js +30 -27
- package/dist/modules/Window.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +33 -0
- package/src/modules/Action.ts +173 -10
- package/src/modules/Animation.ts +6 -6
- package/src/modules/Building.ts +4 -4
- package/src/modules/CameraView.ts +5 -5
- package/src/modules/Effect.ts +3 -3
- package/src/modules/Environment.ts +3 -3
- package/src/modules/Focus.ts +1 -1
- package/src/modules/GameMode.ts +2 -2
- package/src/modules/Init.ts +8 -19
- package/src/modules/Path.ts +6 -6
- package/src/modules/Poi.ts +8 -8
- package/src/modules/Routing.ts +4 -4
- package/src/modules/Scene.ts +2 -2
- package/src/modules/SceneAsset.ts +242 -0
- package/src/modules/SingleMesh.ts +89 -0
- package/src/modules/Status.ts +1 -1
- package/src/modules/VideoFusion.ts +9 -9
- package/src/modules/Window.ts +128 -0
package/src/modules/Action.ts
CHANGED
|
@@ -8,19 +8,182 @@ export interface SendParam {
|
|
|
8
8
|
},
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
// 请求响应处理器接口
|
|
12
|
+
interface PendingRequest {
|
|
13
|
+
resolve: (value: any) => void;
|
|
14
|
+
reject: (reason?: any) => void;
|
|
15
|
+
timeout: ReturnType<typeof setTimeout>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 三维大包分包:首包 -S、中间 -I、末包 -E,拼接后为完整 JSON 字符串(与未分包时一致) */
|
|
19
|
+
interface ChunkAssembly {
|
|
20
|
+
buffer: string;
|
|
21
|
+
requestId: string | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
export class Action {
|
|
25
|
+
// 存储待处理的请求,key 为 requestId
|
|
26
|
+
private static pendingRequests = new Map<string, PendingRequest>();
|
|
27
|
+
|
|
28
|
+
/** 正在组装的分包(同一时间仅处理一条分包流;并行多条需三维在每段携带 requestId,见 tryExtractRequestId) */
|
|
29
|
+
private static chunkAssembly: ChunkAssembly | null = null;
|
|
30
|
+
|
|
31
|
+
// 默认超时时间(毫秒)
|
|
32
|
+
private static defaultTimeout = 10000;
|
|
33
|
+
|
|
12
34
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {SendParam} param 发送的参数
|
|
15
|
-
* @param {string} msg 打印的信息
|
|
35
|
+
* 生成唯一请求ID
|
|
16
36
|
*/
|
|
17
|
-
static
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
private static generateRequestId(): string {
|
|
38
|
+
return `req_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 处理来自三维系统的响应消息
|
|
43
|
+
* 注意:三维系统保证在响应中返回 requestId,因此通过 requestId 精确匹配请求
|
|
44
|
+
* @param responseData 响应数据,必须包含 requestId 字段
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* 从 JSON 片段中尽早解析 requestId(用于日志;分包并行时需首段或中段出现该字段)
|
|
48
|
+
*/
|
|
49
|
+
private static tryExtractRequestId(jsonPrefix: string): string | null {
|
|
50
|
+
const m = jsonPrefix.match(/"requestId"\s*:\s*"([^"]+)"/);
|
|
51
|
+
return m ? m[1] : null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 处理 peer-stream 收到的一条原始消息(支持未分包 JSON 与 -S/-I/-E 分包)
|
|
56
|
+
* @param raw 字符串:整段 JSON,或以 -S / -I / -E 开头的分包片段
|
|
57
|
+
* @param onMessage 与 Init 中一致的业务回调(收到完整一条 JSON 后调用一次)
|
|
58
|
+
*/
|
|
59
|
+
static handleIncomingRawMessage(raw: string | object, onMessage?: (data: any) => void) {
|
|
60
|
+
if (typeof raw !== 'string') {
|
|
61
|
+
const data = raw as any;
|
|
62
|
+
this.handleResponse(data);
|
|
63
|
+
onMessage?.(data);
|
|
64
|
+
return;
|
|
24
65
|
}
|
|
66
|
+
|
|
67
|
+
const isChunk = raw.startsWith('-S') || raw.startsWith('-I') || raw.startsWith('-E');
|
|
68
|
+
if (!isChunk) {
|
|
69
|
+
let data: any;
|
|
70
|
+
try {
|
|
71
|
+
data = JSON.parse(raw);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error('解析消息失败:', e);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.handleResponse(data);
|
|
77
|
+
onMessage?.(data);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const tag = raw.slice(0, 2);
|
|
82
|
+
const body = raw.slice(2);
|
|
83
|
+
|
|
84
|
+
if (tag === '-S') {
|
|
85
|
+
if (this.chunkAssembly) {
|
|
86
|
+
console.warn('分包消息: 收到新的 -S,丢弃未拼完的上一包');
|
|
87
|
+
}
|
|
88
|
+
this.chunkAssembly = { buffer: body, requestId: this.tryExtractRequestId(body) };
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (tag === '-I') {
|
|
93
|
+
if (!this.chunkAssembly) {
|
|
94
|
+
console.error('分包消息: 收到 -I 但缺少前置 -S');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.chunkAssembly.buffer += body;
|
|
98
|
+
if (!this.chunkAssembly.requestId) {
|
|
99
|
+
this.chunkAssembly.requestId = this.tryExtractRequestId(this.chunkAssembly.buffer);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (tag === '-E') {
|
|
105
|
+
if (!this.chunkAssembly) {
|
|
106
|
+
console.error('分包消息: 收到 -E 但缺少前置 -S');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.chunkAssembly.buffer += body;
|
|
110
|
+
const fullJson = this.chunkAssembly.buffer;
|
|
111
|
+
this.chunkAssembly = null;
|
|
112
|
+
|
|
113
|
+
let data: any;
|
|
114
|
+
try {
|
|
115
|
+
data = JSON.parse(fullJson);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.error('分包消息 JSON 解析失败:', e);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.handleResponse(data);
|
|
121
|
+
onMessage?.(data);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static handleResponse(responseData: any) {
|
|
126
|
+
// 通过 requestId 精确匹配请求(三维系统保证返回 requestId)
|
|
127
|
+
if (responseData.requestId && this.pendingRequests.has(responseData.requestId)) {
|
|
128
|
+
const request = this.pendingRequests.get(responseData.requestId)!;
|
|
129
|
+
clearTimeout(request.timeout);
|
|
130
|
+
this.pendingRequests.delete(responseData.requestId);
|
|
131
|
+
|
|
132
|
+
// 根据响应状态决定 resolve 或 reject
|
|
133
|
+
if (responseData.code === '0' || responseData.code === 0) {
|
|
134
|
+
request.resolve(responseData);
|
|
135
|
+
} else {
|
|
136
|
+
request.reject(new Error(responseData.message || '请求失败'));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 发送到model
|
|
143
|
+
* @param param 发送的参数
|
|
144
|
+
* @param msg 打印的信息
|
|
145
|
+
* @param timeout 超时时间(毫秒),默认 10 秒
|
|
146
|
+
* @returns 收到响应时 resolve 为三维数据;超时时 resolve `{ timedOut: true, requestId }`(不 reject)
|
|
147
|
+
*/
|
|
148
|
+
static sendParam<T extends SendParam>(
|
|
149
|
+
param: T,
|
|
150
|
+
msg: string = '',
|
|
151
|
+
timeout: number = this.defaultTimeout
|
|
152
|
+
): Promise<any> {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
// 生成唯一请求ID
|
|
155
|
+
const requestId = this.generateRequestId();
|
|
156
|
+
|
|
157
|
+
// 在请求参数中添加 requestId
|
|
158
|
+
const paramWithId = {
|
|
159
|
+
...param,
|
|
160
|
+
requestId
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
console.log(`发送给三维|${msg}`, JSON.stringify(paramWithId));
|
|
164
|
+
|
|
165
|
+
const timeoutHandle = setTimeout(() => {
|
|
166
|
+
this.pendingRequests.delete(requestId);
|
|
167
|
+
console.warn(`请求等待超时(三维可能不返回): ${msg}`);
|
|
168
|
+
resolve({ timedOut: true, requestId });
|
|
169
|
+
}, timeout);
|
|
170
|
+
|
|
171
|
+
// 存储待处理的请求(通过 requestId 匹配)
|
|
172
|
+
this.pendingRequests.set(requestId, {
|
|
173
|
+
resolve,
|
|
174
|
+
reject,
|
|
175
|
+
timeout: timeoutHandle
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
//peer-stream 中已经把ps挂到window上了,为了不改peer-stream的代码,这里直接使用window.ps
|
|
179
|
+
try {
|
|
180
|
+
(window as any).ps?.emitMessage(JSON.stringify(paramWithId));
|
|
181
|
+
} catch (error) {
|
|
182
|
+
clearTimeout(timeoutHandle);
|
|
183
|
+
this.pendingRequests.delete(requestId);
|
|
184
|
+
console.error("发送给三维失败", error);
|
|
185
|
+
reject(error);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
25
188
|
}
|
|
26
189
|
}
|
package/src/modules/Animation.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class AnimationAction extends Action {
|
|
|
60
60
|
data
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
this.sendParam(param, `开始动画 - type: ${type}, id: ${id}`);
|
|
63
|
+
return this.sendParam(param, `开始动画 - type: ${type}, id: ${id}`);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -78,7 +78,7 @@ export class AnimationAction extends Action {
|
|
|
78
78
|
data
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
this.sendParam(param, `停止动画 - type: ${type}`);
|
|
81
|
+
return this.sendParam(param, `停止动画 - type: ${type}`);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -96,7 +96,7 @@ export class AnimationAction extends Action {
|
|
|
96
96
|
data
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
this.sendParam(param, `暂停动画 - type: ${type}`);
|
|
99
|
+
return this.sendParam(param, `暂停动画 - type: ${type}`);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -114,7 +114,7 @@ export class AnimationAction extends Action {
|
|
|
114
114
|
data
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
this.sendParam(param, `重新开始动画 - type: ${type}`);
|
|
117
|
+
return this.sendParam(param, `重新开始动画 - type: ${type}`);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -134,7 +134,7 @@ export class AnimationAction extends Action {
|
|
|
134
134
|
data
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
-
this.sendParam(param, `调整动画速度 - type: ${type}, speedRate: ${speedRate}`);
|
|
137
|
+
return this.sendParam(param, `调整动画速度 - type: ${type}, speedRate: ${speedRate}`);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
/**
|
|
@@ -166,6 +166,6 @@ export class AnimationAction extends Action {
|
|
|
166
166
|
data
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
this.sendParam(param, `恢复初始状态 - type: ${type}, id: ${id}`);
|
|
169
|
+
return this.sendParam(param, `恢复初始状态 - type: ${type}, id: ${id}`);
|
|
170
170
|
}
|
|
171
171
|
}
|
package/src/modules/Building.ts
CHANGED
|
@@ -38,7 +38,7 @@ export class BuildingAction extends Action {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const floorDesc = floor === '0' ? '退出分层' : floor === '-1' ? '负一楼' : `第${floor}层`;
|
|
41
|
-
this.sendParam(param, `建筑分层 - ${floorDesc}`)
|
|
41
|
+
return this.sendParam(param, `建筑分层 - ${floorDesc}`);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -58,7 +58,7 @@ export class BuildingAction extends Action {
|
|
|
58
58
|
cmd: "building",
|
|
59
59
|
data
|
|
60
60
|
};
|
|
61
|
-
this.sendParam(param, '掀顶')
|
|
61
|
+
return this.sendParam(param, '掀顶');
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -78,7 +78,7 @@ export class BuildingAction extends Action {
|
|
|
78
78
|
cmd: "building",
|
|
79
79
|
data
|
|
80
80
|
};
|
|
81
|
-
this.sendParam(param, '高亮楼层')
|
|
81
|
+
return this.sendParam(param, '高亮楼层');
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -98,6 +98,6 @@ export class BuildingAction extends Action {
|
|
|
98
98
|
cmd: "building",
|
|
99
99
|
data
|
|
100
100
|
};
|
|
101
|
-
this.sendParam(param, '虚化楼')
|
|
101
|
+
return this.sendParam(param, '虚化楼');
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -42,7 +42,7 @@ export class CameraViewAction extends Action {
|
|
|
42
42
|
data
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
this.sendParam(param, '获取当前视角信息');
|
|
45
|
+
return this.sendParam(param, '获取当前视角信息');
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -85,7 +85,7 @@ export class CameraViewAction extends Action {
|
|
|
85
85
|
data
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
this.sendParam(param, '设置视角并飞过去');
|
|
88
|
+
return this.sendParam(param, '设置视角并飞过去');
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -103,7 +103,7 @@ export class CameraViewAction extends Action {
|
|
|
103
103
|
data
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
this.sendParam(param, '切换到默认视角');
|
|
106
|
+
return this.sendParam(param, '切换到默认视角');
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -149,7 +149,7 @@ export class CameraViewAction extends Action {
|
|
|
149
149
|
data
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
this.sendParam(param, `保存视角 - tag: ${tag}`);
|
|
152
|
+
return this.sendParam(param, `保存视角 - tag: ${tag}`);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -170,6 +170,6 @@ export class CameraViewAction extends Action {
|
|
|
170
170
|
data
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
this.sendParam(param, `飞向视角 - tag: ${tag}`);
|
|
173
|
+
return this.sendParam(param, `飞向视角 - tag: ${tag}`);
|
|
174
174
|
}
|
|
175
175
|
}
|
package/src/modules/Effect.ts
CHANGED
|
@@ -61,7 +61,7 @@ export class EffectAction extends Action {
|
|
|
61
61
|
data
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
this.sendParam(param, `显示效果 - type: ${type}, place: ${place}`);
|
|
64
|
+
return this.sendParam(param, `显示效果 - type: ${type}, place: ${place}`);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
@@ -90,7 +90,7 @@ export class EffectAction extends Action {
|
|
|
90
90
|
data
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
this.sendParam(param, `隐藏效果 - type: ${type}, place: ${place}`);
|
|
93
|
+
return this.sendParam(param, `隐藏效果 - type: ${type}, place: ${place}`);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -122,6 +122,6 @@ export class EffectAction extends Action {
|
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
const actionText = action === '1' ? '显示' : '隐藏';
|
|
125
|
-
this.sendParam(param, `${actionText}效果 - type: ${type}, place: ${place}`);
|
|
125
|
+
return this.sendParam(param, `${actionText}效果 - type: ${type}, place: ${place}`);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -34,7 +34,7 @@ export class EnvironmentAction extends Action {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const dayNightDesc = type === '0' ? '白天' : '夜晚';
|
|
37
|
-
this.sendParam(param, `昼夜切换 - ${dayNightDesc}`)
|
|
37
|
+
return this.sendParam(param, `昼夜切换 - ${dayNightDesc}`);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -55,7 +55,7 @@ export class EnvironmentAction extends Action {
|
|
|
55
55
|
data
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
this.sendParam(param, `天气切换 - ${type}`)
|
|
58
|
+
return this.sendParam(param, `天气切换 - ${type}`);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -76,6 +76,6 @@ export class EnvironmentAction extends Action {
|
|
|
76
76
|
data
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
this.sendParam(param, `时间切换 - ${type}`)
|
|
79
|
+
return this.sendParam(param, `时间切换 - ${type}`);
|
|
80
80
|
}
|
|
81
81
|
}
|
package/src/modules/Focus.ts
CHANGED
package/src/modules/GameMode.ts
CHANGED
|
@@ -37,7 +37,7 @@ export class GameModeAction extends Action {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const modeDesc = mode === 'Normal' ? '普通模式' : mode === 'Edit' ? '编辑模式' : '绘制模式';
|
|
40
|
-
this.sendParam(param, `切换游戏模式 - ${modeDesc}`);
|
|
40
|
+
return this.sendParam(param, `切换游戏模式 - ${modeDesc}`);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -55,6 +55,6 @@ export class GameModeAction extends Action {
|
|
|
55
55
|
data
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
this.sendParam(param, '获取当前游戏模式');
|
|
58
|
+
return this.sendParam(param, '获取当前游戏模式');
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/modules/Init.ts
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
import { Action } from "./Action";
|
|
5
5
|
// 导入 peer-stream.js 以确保自定义元素在使用前被注册
|
|
6
6
|
import "../peer-stream.js";
|
|
7
|
-
import { VideoFusionAction } from "./VideoFusion";
|
|
8
|
-
|
|
9
7
|
// 初始化配置选项
|
|
10
8
|
export interface InitVideoOptions {
|
|
11
9
|
/** 视频容器元素(DOM元素或ref) */
|
|
@@ -56,23 +54,14 @@ export class InitAction extends Action {
|
|
|
56
54
|
ps.registerMouseHoverEvents();
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// //获取当前所有融合点位ID
|
|
68
|
-
|
|
69
|
-
// VideoFusionAction.get();
|
|
70
|
-
// }
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error("解析消息失败:", error);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
57
|
+
// 监听消息事件(含三维大包 -S/-I/-E 分包拼包后,再 handleResponse + onMessage)
|
|
58
|
+
ps.addEventListener("message", (e: any) => {
|
|
59
|
+
try {
|
|
60
|
+
Action.handleIncomingRawMessage(e.detail, options.onMessage);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error("解析消息失败:", error);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
76
65
|
|
|
77
66
|
// 监听元数据加载完成
|
|
78
67
|
ps.addEventListener("loadedmetadata", () => {
|
package/src/modules/Path.ts
CHANGED
|
@@ -118,7 +118,7 @@ export class PathAction extends Action {
|
|
|
118
118
|
cmd: "path",
|
|
119
119
|
data
|
|
120
120
|
};
|
|
121
|
-
this.sendParam(param, '请求三维绘制路径')
|
|
121
|
+
return this.sendParam(param, '请求三维绘制路径');
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
@@ -156,7 +156,7 @@ export class PathAction extends Action {
|
|
|
156
156
|
hide: '隐藏路径',
|
|
157
157
|
remove: '删除路径'
|
|
158
158
|
};
|
|
159
|
-
this.sendParam(param, actionMap[action])
|
|
159
|
+
return this.sendParam(param, actionMap[action]);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/**
|
|
@@ -182,7 +182,7 @@ export class PathAction extends Action {
|
|
|
182
182
|
cmd: "path",
|
|
183
183
|
data
|
|
184
184
|
};
|
|
185
|
-
this.sendParam(param, '更新移动参数')
|
|
185
|
+
return this.sendParam(param, '更新移动参数');
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -236,7 +236,7 @@ export class PathAction extends Action {
|
|
|
236
236
|
stop: '停止移动',
|
|
237
237
|
restart: '重启移动'
|
|
238
238
|
};
|
|
239
|
-
this.sendParam(param, actionMap[action])
|
|
239
|
+
return this.sendParam(param, actionMap[action]);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
@@ -278,7 +278,7 @@ export class PathAction extends Action {
|
|
|
278
278
|
cmd: "path",
|
|
279
279
|
data
|
|
280
280
|
};
|
|
281
|
-
this.sendParam(param, '开启路径编辑')
|
|
281
|
+
return this.sendParam(param, '开启路径编辑');
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
@@ -295,6 +295,6 @@ export class PathAction extends Action {
|
|
|
295
295
|
cmd: "path",
|
|
296
296
|
data
|
|
297
297
|
};
|
|
298
|
-
this.sendParam(param, '停止路径编辑')
|
|
298
|
+
return this.sendParam(param, '停止路径编辑');
|
|
299
299
|
}
|
|
300
300
|
}
|
package/src/modules/Poi.ts
CHANGED
|
@@ -58,7 +58,7 @@ export class PoiAction extends Action {
|
|
|
58
58
|
show: '显示指定POI',
|
|
59
59
|
hide: '隐藏指定POI'
|
|
60
60
|
};
|
|
61
|
-
this.sendParam(param, actionMap[action])
|
|
61
|
+
return this.sendParam(param, actionMap[action]);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -95,7 +95,7 @@ export class PoiAction extends Action {
|
|
|
95
95
|
show: '显示指定类型POI',
|
|
96
96
|
hide: '隐藏指定类型POI'
|
|
97
97
|
};
|
|
98
|
-
this.sendParam(param, actionMap[action])
|
|
98
|
+
return this.sendParam(param, actionMap[action]);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
@@ -112,7 +112,7 @@ export class PoiAction extends Action {
|
|
|
112
112
|
cmd: "POI",
|
|
113
113
|
data
|
|
114
114
|
};
|
|
115
|
-
this.sendParam(param, '显示所有POI')
|
|
115
|
+
return this.sendParam(param, '显示所有POI');
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
@@ -129,7 +129,7 @@ export class PoiAction extends Action {
|
|
|
129
129
|
cmd: "POI",
|
|
130
130
|
data
|
|
131
131
|
};
|
|
132
|
-
this.sendParam(param, '隐藏所有POI')
|
|
132
|
+
return this.sendParam(param, '隐藏所有POI');
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -149,7 +149,7 @@ export class PoiAction extends Action {
|
|
|
149
149
|
cmd: "POI",
|
|
150
150
|
data
|
|
151
151
|
};
|
|
152
|
-
this.sendParam(param, '添加POI点')
|
|
152
|
+
return this.sendParam(param, '添加POI点');
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -169,7 +169,7 @@ export class PoiAction extends Action {
|
|
|
169
169
|
cmd: "POI",
|
|
170
170
|
data
|
|
171
171
|
};
|
|
172
|
-
this.sendParam(param, '删除POI点')
|
|
172
|
+
return this.sendParam(param, '删除POI点');
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/**
|
|
@@ -189,7 +189,7 @@ export class PoiAction extends Action {
|
|
|
189
189
|
cmd: "POI",
|
|
190
190
|
data
|
|
191
191
|
};
|
|
192
|
-
this.sendParam(param, '更新POI点')
|
|
192
|
+
return this.sendParam(param, '更新POI点');
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
@@ -240,6 +240,6 @@ export class PoiAction extends Action {
|
|
|
240
240
|
msg = '获取所有POI信息';
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
this.sendParam(param, msg)
|
|
243
|
+
return this.sendParam(param, msg);
|
|
244
244
|
}
|
|
245
245
|
}
|
package/src/modules/Routing.ts
CHANGED
|
@@ -76,7 +76,7 @@ export class RoutingAction extends Action {
|
|
|
76
76
|
cmd: "routing",
|
|
77
77
|
data
|
|
78
78
|
};
|
|
79
|
-
this.sendParam(sendParam, '开始路由巡视')
|
|
79
|
+
return this.sendParam(sendParam, '开始路由巡视');
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
@@ -94,7 +94,7 @@ export class RoutingAction extends Action {
|
|
|
94
94
|
cmd: "routing",
|
|
95
95
|
data
|
|
96
96
|
};
|
|
97
|
-
this.sendParam(sendParam, '停止路由巡视')
|
|
97
|
+
return this.sendParam(sendParam, '停止路由巡视');
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -111,7 +111,7 @@ export class RoutingAction extends Action {
|
|
|
111
111
|
cmd: "routing",
|
|
112
112
|
data
|
|
113
113
|
};
|
|
114
|
-
this.sendParam(sendParam, '暂停路由巡视')
|
|
114
|
+
return this.sendParam(sendParam, '暂停路由巡视');
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -129,6 +129,6 @@ export class RoutingAction extends Action {
|
|
|
129
129
|
cmd: "routing",
|
|
130
130
|
data
|
|
131
131
|
};
|
|
132
|
-
this.sendParam(sendParam, '重新开始路由巡视')
|
|
132
|
+
return this.sendParam(sendParam, '重新开始路由巡视');
|
|
133
133
|
}
|
|
134
134
|
}
|
package/src/modules/Scene.ts
CHANGED
|
@@ -35,7 +35,7 @@ export class SceneAction extends Action {
|
|
|
35
35
|
cmd: "sence",
|
|
36
36
|
data
|
|
37
37
|
};
|
|
38
|
-
this.sendParam(sendParam, `切换场景 - code: ${code}`);
|
|
38
|
+
return this.sendParam(sendParam, `切换场景 - code: ${code}`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -52,6 +52,6 @@ export class SceneAction extends Action {
|
|
|
52
52
|
cmd: "sence",
|
|
53
53
|
data
|
|
54
54
|
};
|
|
55
|
-
this.sendParam(sendParam, '重置场景到初始状态');
|
|
55
|
+
return this.sendParam(sendParam, '重置场景到初始状态');
|
|
56
56
|
}
|
|
57
57
|
}
|