model-action 1.0.23 → 2.0.0

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.
Files changed (66) hide show
  1. package/dist/index.d.ts +8 -4
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +8 -4
  4. package/dist/index.js.map +1 -0
  5. package/dist/modules/Action.d.ts +5 -14
  6. package/dist/modules/Action.d.ts.map +1 -0
  7. package/dist/modules/Action.js +1 -10
  8. package/dist/modules/Action.js.map +1 -0
  9. package/dist/modules/Building.d.ts +28 -0
  10. package/dist/modules/Building.d.ts.map +1 -0
  11. package/dist/modules/Building.js +70 -0
  12. package/dist/modules/Building.js.map +1 -0
  13. package/dist/modules/Camera.d.ts +37 -0
  14. package/dist/modules/Camera.d.ts.map +1 -0
  15. package/dist/modules/Camera.js +110 -0
  16. package/dist/modules/Camera.js.map +1 -0
  17. package/dist/modules/Environment.d.ts +22 -0
  18. package/dist/modules/Environment.d.ts.map +1 -0
  19. package/dist/modules/Environment.js +53 -0
  20. package/dist/modules/Environment.js.map +1 -0
  21. package/dist/modules/Focus.d.ts +12 -0
  22. package/dist/modules/Focus.d.ts.map +1 -0
  23. package/dist/modules/Focus.js +22 -0
  24. package/dist/modules/Focus.js.map +1 -0
  25. package/dist/modules/Poi.d.ts +45 -62
  26. package/dist/modules/Poi.d.ts.map +1 -0
  27. package/dist/modules/Poi.js +117 -88
  28. package/dist/modules/Poi.js.map +1 -0
  29. package/dist/modules/Routing.d.ts +23 -31
  30. package/dist/modules/Routing.d.ts.map +1 -0
  31. package/dist/modules/Routing.js +62 -63
  32. package/dist/modules/Routing.js.map +1 -0
  33. package/dist/modules/Scene.d.ts +12 -15
  34. package/dist/modules/Scene.d.ts.map +1 -0
  35. package/dist/modules/Scene.js +26 -15
  36. package/dist/modules/Scene.js.map +1 -0
  37. package/dist/modules/Status.d.ts +59 -0
  38. package/dist/modules/Status.d.ts.map +1 -0
  39. package/dist/modules/Status.js +91 -0
  40. package/dist/modules/Status.js.map +1 -0
  41. package/dist/modules/Track.d.ts +65 -22
  42. package/dist/modules/Track.d.ts.map +1 -0
  43. package/dist/modules/Track.js +128 -20
  44. package/dist/modules/Track.js.map +1 -0
  45. package/dist/modules/VideoFusion.d.ts +1 -0
  46. package/dist/modules/VideoFusion.d.ts.map +1 -0
  47. package/dist/modules/VideoFusion.js +1 -0
  48. package/dist/modules/VideoFusion.js.map +1 -0
  49. package/dist/modules/Window.d.ts +1 -0
  50. package/dist/modules/Window.d.ts.map +1 -0
  51. package/dist/modules/Window.js +1 -0
  52. package/dist/modules/Window.js.map +1 -0
  53. package/package.json +1 -1
  54. package/src/index.ts +7 -4
  55. package/src/modules/Action.ts +4 -25
  56. package/src/modules/Building.ts +103 -0
  57. package/src/modules/Camera.ts +175 -0
  58. package/src/modules/Environment.ts +81 -0
  59. package/src/modules/Focus.ts +33 -0
  60. package/src/modules/Poi.ts +194 -117
  61. package/src/modules/Routing.ts +96 -85
  62. package/src/modules/Scene.ts +43 -21
  63. package/src/modules/Status.ts +150 -0
  64. package/src/modules/Track.ts +259 -30
  65. package/src/modules/VideoFusion.ts +0 -122
  66. package/src/modules/Window.ts +0 -40
@@ -0,0 +1,175 @@
1
+ /**
2
+ * 相机操作方法
3
+ */
4
+ import { Action, SendParam } from "./Action";
5
+
6
+ // 相机视角信息
7
+ export interface CameraViewInfo {
8
+ location?: string; // 相机坐标,格式 "X=-2133.518,Y=-7095.674,Z=-1550.000"
9
+ rotation?: string; // 相机旋转,格式 "P=-35.004208,Y=113.576096,R=0.000000"
10
+ armLength?: number; // 相机臂长(用于调整视角的远近)
11
+ fov?: number; // 相机视场角(选填)
12
+ }
13
+
14
+ // 相机视角操作类型
15
+ type CameraViewActionType = 'get' | 'set' | 'default' | 'save' | 'flyTo';
16
+
17
+ type CameraViewType = SendParam & {
18
+ cmd: "cameraView";
19
+ data: {
20
+ action: CameraViewActionType;
21
+ tag?: string; // 保存视角的唯一标识
22
+ location?: string; // 相机坐标
23
+ rotation?: string; // 相机旋转
24
+ armLength?: number; // 相机臂长
25
+ fov?: number; // 相机视场角
26
+ };
27
+ }
28
+
29
+ export class CameraAction extends Action {
30
+ /**
31
+ * 获取当前视角的信息,位置,旋转和臂长还有相机的视域角
32
+ */
33
+ static get() {
34
+ const data: {
35
+ action: 'get';
36
+ } = {
37
+ action: 'get'
38
+ };
39
+
40
+ const param: CameraViewType = {
41
+ cmd: "cameraView",
42
+ data
43
+ };
44
+
45
+ this.sendParam(param, '获取当前视角信息');
46
+ }
47
+
48
+ /**
49
+ * 设置视角,并飞过去
50
+ * @param viewInfo 视角信息
51
+ */
52
+ static set(viewInfo: CameraViewInfo) {
53
+ const data: {
54
+ action: 'set';
55
+ location?: string;
56
+ rotation?: string;
57
+ armLength?: number;
58
+ fov?: number;
59
+ } = {
60
+ action: 'set'
61
+ };
62
+
63
+ // 如果提供了 location,则添加
64
+ if (viewInfo.location) {
65
+ data.location = viewInfo.location;
66
+ }
67
+
68
+ // 如果提供了 rotation,则添加
69
+ if (viewInfo.rotation) {
70
+ data.rotation = viewInfo.rotation;
71
+ }
72
+
73
+ // 如果提供了 armLength,则添加
74
+ if (viewInfo.armLength !== undefined) {
75
+ data.armLength = viewInfo.armLength;
76
+ }
77
+
78
+ // 如果提供了 fov,则添加
79
+ if (viewInfo.fov !== undefined) {
80
+ data.fov = viewInfo.fov;
81
+ }
82
+
83
+ const param: CameraViewType = {
84
+ cmd: "cameraView",
85
+ data
86
+ };
87
+
88
+ this.sendParam(param, '设置视角并飞过去');
89
+ }
90
+
91
+ /**
92
+ * 切换到默认视角
93
+ */
94
+ static default() {
95
+ const data: {
96
+ action: 'default';
97
+ } = {
98
+ action: 'default'
99
+ };
100
+
101
+ const param: CameraViewType = {
102
+ cmd: "cameraView",
103
+ data
104
+ };
105
+
106
+ this.sendParam(param, '切换到默认视角');
107
+ }
108
+
109
+ /**
110
+ * 保存视角
111
+ * @param tag 保存视角的唯一标识
112
+ * @param viewInfo 视角信息
113
+ */
114
+ static save(tag: string, viewInfo: CameraViewInfo) {
115
+ const data: {
116
+ action: 'save';
117
+ tag: string;
118
+ location?: string;
119
+ rotation?: string;
120
+ armLength?: number;
121
+ fov?: number;
122
+ } = {
123
+ action: 'save',
124
+ tag
125
+ };
126
+
127
+ // 如果提供了 location,则添加
128
+ if (viewInfo.location) {
129
+ data.location = viewInfo.location;
130
+ }
131
+
132
+ // 如果提供了 rotation,则添加
133
+ if (viewInfo.rotation) {
134
+ data.rotation = viewInfo.rotation;
135
+ }
136
+
137
+ // 如果提供了 armLength,则添加
138
+ if (viewInfo.armLength !== undefined) {
139
+ data.armLength = viewInfo.armLength;
140
+ }
141
+
142
+ // 如果提供了 fov,则添加
143
+ if (viewInfo.fov !== undefined) {
144
+ data.fov = viewInfo.fov;
145
+ }
146
+
147
+ const param: CameraViewType = {
148
+ cmd: "cameraView",
149
+ data
150
+ };
151
+
152
+ this.sendParam(param, `保存视角 - tag: ${tag}`);
153
+ }
154
+
155
+ /**
156
+ * 飞向tag标识的视角
157
+ * @param tag 视角的唯一标识(需要提前使用save保存)
158
+ */
159
+ static flyTo(tag: string) {
160
+ const data: {
161
+ action: 'flyTo';
162
+ tag: string;
163
+ } = {
164
+ action: 'flyTo',
165
+ tag
166
+ };
167
+
168
+ const param: CameraViewType = {
169
+ cmd: "cameraView",
170
+ data
171
+ };
172
+
173
+ this.sendParam(param, `飞向视角 - tag: ${tag}`);
174
+ }
175
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 场景环境操作方法
3
+ */
4
+ import { Action, SendParam } from "./Action";
5
+
6
+ type EnvironmentActionType = 'DayNight' | 'Weather' | 'Time'
7
+
8
+ type EnvironmentType = SendParam & {
9
+ cmd: "environment";
10
+ data: {
11
+ action: EnvironmentActionType;
12
+ type: string;
13
+ [key: string]: any;
14
+ };
15
+ }
16
+
17
+ export class EnvironmentAction extends Action {
18
+ /**
19
+ * 昼夜切换
20
+ * @param type 0 = 白天,1 = 夜晚
21
+ */
22
+ static dayNight(type: "0" | "1") {
23
+ const data: {
24
+ action: 'DayNight';
25
+ type: string;
26
+ } = {
27
+ action: 'DayNight',
28
+ type
29
+ };
30
+
31
+ const param: EnvironmentType = {
32
+ cmd: "environment",
33
+ data
34
+ };
35
+
36
+ const dayNightDesc = type === '0' ? '白天' : '夜晚';
37
+ this.sendParam(param, `昼夜切换 - ${dayNightDesc}`)
38
+ }
39
+
40
+ /**
41
+ * 天气切换
42
+ * @param type 天气类型:晴、阴、小雨、大雨、小雪、大雪、雾
43
+ */
44
+ static weather(type: string) {
45
+ const data: {
46
+ action: 'Weather';
47
+ type: string;
48
+ } = {
49
+ action: 'Weather',
50
+ type
51
+ };
52
+
53
+ const param: EnvironmentType = {
54
+ cmd: "environment",
55
+ data
56
+ };
57
+
58
+ this.sendParam(param, `天气切换 - ${type}`)
59
+ }
60
+
61
+ /**
62
+ * 时间切换
63
+ * @param type 时间格式,如 "12:00"
64
+ */
65
+ static time(type: string) {
66
+ const data: {
67
+ action: 'Time';
68
+ type: string;
69
+ } = {
70
+ action: 'Time',
71
+ type
72
+ };
73
+
74
+ const param: EnvironmentType = {
75
+ cmd: "environment",
76
+ data
77
+ };
78
+
79
+ this.sendParam(param, `时间切换 - ${type}`)
80
+ }
81
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 聚焦操作方法
3
+ */
4
+ import { Action } from "./Action";
5
+
6
+ type FocusType = {
7
+ cmd: "focus";
8
+ data: {
9
+ id: string;
10
+ };
11
+ }
12
+
13
+ export class FocusAction extends Action {
14
+ /**
15
+ * 飞到指定ID的物体附近
16
+ * @param id 物体的ID(如POI、模型等)
17
+ */
18
+ static focus(id: string) {
19
+ const data: {
20
+ id: string;
21
+ } = {
22
+ id
23
+ };
24
+
25
+ const param: FocusType = {
26
+ cmd: "focus",
27
+ data
28
+ };
29
+
30
+ // 注意:focus 命令不需要 action 字段,直接发送参数
31
+ this.sendParam(param as any, `飞到指定物体附近 - id: ${id}`);
32
+ }
33
+ }
@@ -1,168 +1,245 @@
1
-
2
1
  /**
3
2
  * POI点方法
4
3
  */
5
- import { Action, LocationItem, RequiredSome, SendParam } from "./Action";
6
-
7
- type PoiActionType = 'show' | 'hide' | 'add' | 'delete' | 'update' | 'getInfo' | 'status'
8
- type PoiType = {
9
- action: PoiActionType, //方法
10
- id?: string, //POI点UE中的ID
11
- type?: string, //POI类型
12
- typeChild?: string, //POI子类型
13
- text?: string, //POI标题
14
- location?: LocationItem, //POI在场景中的坐标格式
15
- place?: string, //POI所在位置
16
- description?: string, //POI描述
17
- linkId?: string, //POI关联设备ID
18
- floorNum?: string, //总楼层
19
- lowestFloor?: string, //最低楼层
20
- state?: 'normal' | 'alarm'
21
- } & SendParam
22
-
23
- type IdList = Array<{
24
- id: string;
25
- state: 'normal' | 'alarm'
26
- }>
4
+ import { Action, SendParam } from "./Action";
5
+
6
+ type PoiActionType = 'show' | 'hide' | 'showAll' | 'hideAll' | 'add' | 'remove' | 'update' | 'find'
7
+
8
+ // POI基础信息
9
+ export interface PoiBaseInfo {
10
+ id: string; // POI的ID
11
+ type: string; // POI类型,如 "Camera"
12
+ label: string; // 标签
13
+ location: string; // 位置,格式 "X=0.0,Y=0.0,Z=0.0"
14
+ rotation: string; // 旋转,格式 "P=-35.004208,Y=113.576096,R=0.000000"
15
+ scale: number; // 缩放
16
+ place: string; // 地方
17
+ linkId: string; // 链接ID
18
+ category: string; // 分类,如 "Camera"
19
+ description: string; // 描述
20
+ hasMesh: boolean; // 是否有网格
21
+ }
22
+
23
+ // POI更新信息(不包含type字段)
24
+ export type PoiUpdateInfo = Omit<PoiBaseInfo, 'type'>
25
+
26
+ type PoiType = SendParam & {
27
+ cmd: "POI";
28
+ data: {
29
+ action: PoiActionType;
30
+ [key: string]: any;
31
+ };
32
+ }
27
33
 
28
34
  export class PoiAction extends Action {
29
35
  /**
30
- * 添加poi
31
- * @param {*} type 相机type
32
- * @param {*} location poi点位置
33
- * @param {*} text POI标题
34
- * @param {*} place POI所在位置
35
- * @param {*} description POI描述
36
- * @param {*} linkId POI关联的设备ID
37
- */
38
- static poiAdd(type: PoiType['type'] = 'Camera', location: LocationItem, text: PoiType['text'] = '', place: PoiType['place'] = '', description: PoiType['description'] = '', linkId: PoiType['linkId'] = '') {
39
- const param: RequiredSome<PoiType, 'action' | 'type' | 'location'> = {
36
+ * 显隐指定id的POI
37
+ * @param action 操作类型:show 显示 | hide 隐藏
38
+ * @param id POI的ID
39
+ */
40
+ static poiShowHide(
41
+ action: 'show' | 'hide',
42
+ id: string
43
+ ) {
44
+ const data: {
45
+ action: 'show' | 'hide';
46
+ id: string;
47
+ } = {
48
+ action,
49
+ id
50
+ };
51
+
52
+ const param: PoiType = {
40
53
  cmd: "POI",
41
- action: "add",
42
- type,
43
- text,
44
- location,
45
- place,
46
- description,
47
- linkId
48
- };
49
- this.sendParam(param, '新增POI')
54
+ data
55
+ };
56
+
57
+ const actionMap = {
58
+ show: '显示指定POI',
59
+ hide: '隐藏指定POI'
60
+ };
61
+ this.sendParam(param, actionMap[action])
50
62
  }
51
63
 
52
64
  /**
53
- * 更新poi
54
- * @param {*} type 相机type
55
- * @param {*} location poi点位置
56
- * @param {*} text POI标题
57
- * @param {*} place POI所在位置
58
- * @param {*} description POI描述
59
- * @param {*} linkId POI关联的设备ID
65
+ * 显隐指定类型和地方的POI
66
+ * @param action 操作类型:show 显示 | hide 隐藏
67
+ * @param type POI类型,如 "Camera"、"JK" 等
68
+ * @param place 地方,如 "A_1F",如果不传place字段,三维自动判断是显示楼里的还是楼外的
60
69
  */
61
- static poiUpdate(type: PoiType['type'] = 'Camera', location: LocationItem, text: PoiType['text'] = '', place: PoiType['place'] = '', description: PoiType['description'] = '', linkId: PoiType['linkId'] = '') {
62
- const param: RequiredSome<PoiType, 'action' | 'type' | 'location'> = {
70
+ static poiShowHideByType(
71
+ action: 'show' | 'hide',
72
+ type: string,
73
+ place?: string
74
+ ) {
75
+ const data: {
76
+ action: 'show' | 'hide';
77
+ type: string;
78
+ place?: string;
79
+ } = {
80
+ action,
81
+ type
82
+ };
83
+
84
+ // 如果提供了 place,则添加
85
+ if (place) {
86
+ data.place = place;
87
+ }
88
+
89
+ const param: PoiType = {
63
90
  cmd: "POI",
64
- action: "update",
65
- type,
66
- text,
67
- location,
68
- place,
69
- description,
70
- linkId
71
- };
72
- this.sendParam(param, '更新POI')
91
+ data
92
+ };
93
+
94
+ const actionMap = {
95
+ show: '显示指定类型POI',
96
+ hide: '隐藏指定类型POI'
97
+ };
98
+ this.sendParam(param, actionMap[action])
73
99
  }
74
100
 
75
101
  /**
76
- * 删除poi
77
- * @param {*} id 点ID
78
- */
79
- static poiDel(id: string) {
102
+ * 显示所有POI
103
+ */
104
+ static poiShowAll() {
105
+ const data: {
106
+ action: 'showAll';
107
+ } = {
108
+ action: 'showAll'
109
+ };
110
+
80
111
  const param: PoiType = {
81
112
  cmd: "POI",
82
- action: "delete",
83
- id,
113
+ data
84
114
  };
85
- this.sendParam(param, '删除POI')
115
+ this.sendParam(param, '显示所有POI')
86
116
  }
87
117
 
88
118
  /**
89
- * 显示poi
90
- * @param {*} id POI的ID
91
- * @param {*} type 相机type
92
- * @param {*} place POI所在位置
119
+ * 隐藏所有POI
93
120
  */
94
- static poiShow(id: PoiType['id'], type: PoiType['type'], place: PoiType['place']) {
121
+ static poiHideAll() {
122
+ const data: {
123
+ action: 'hideAll';
124
+ } = {
125
+ action: 'hideAll'
126
+ };
127
+
95
128
  const param: PoiType = {
96
129
  cmd: "POI",
97
- action: "show",
98
- type,
99
- place
130
+ data
100
131
  };
101
- if (id) {
102
- param['id'] = id
103
- }
104
-
105
- this.sendParam(param, '显示POI')
132
+ this.sendParam(param, '隐藏所有POI')
106
133
  }
107
134
 
108
135
  /**
109
- * 隐藏poi
110
- * @param {*} id POI的ID
111
- * @param {*} type 相机type
112
- * @param {*} place POI所在位置
113
- */
114
- static poiHide(id: PoiType['id'], type: PoiType['type'], place: PoiType['place']) {
136
+ * 添加POI点
137
+ * @param baseInfos POI基础信息数组
138
+ */
139
+ static poiAdd(baseInfos: PoiBaseInfo[]) {
140
+ const data: {
141
+ action: 'add';
142
+ baseInfos: PoiBaseInfo[];
143
+ } = {
144
+ action: 'add',
145
+ baseInfos
146
+ };
147
+
115
148
  const param: PoiType = {
116
149
  cmd: "POI",
117
- action: "hide",
118
- type,
119
- place
150
+ data
120
151
  };
121
- if (id) {
122
- param['id'] = id
123
- }
124
-
125
- this.sendParam(param, '隐藏POI')
152
+ this.sendParam(param, '添加POI点')
126
153
  }
127
154
 
128
155
  /**
129
- * 把所有的POI恢复到Normal状态
130
- * @param {*} state normal一般状态 alarm 告警状态
156
+ * 删除POI
157
+ * @param id POI的ID、linkId或type,根据传入的值删除对应的POI
131
158
  */
132
- static poiNormal(state: 'normal' | 'alarm') {
159
+ static poiRemove(id: string) {
160
+ const data: {
161
+ action: 'remove';
162
+ id: string;
163
+ } = {
164
+ action: 'remove',
165
+ id
166
+ };
167
+
133
168
  const param: PoiType = {
134
169
  cmd: "POI",
135
- action: "status",
136
- state
170
+ data
137
171
  };
138
- this.sendParam(param, `恢复poi至${state}状态`)
172
+ this.sendParam(param, '删除POI点')
139
173
  }
140
174
 
141
175
  /**
142
- * 切换指定ID设备的poi状态
143
- * @param {*} ids 设备ID列表
144
- * @param {*} isLocation 是否定位到第一个ID对应的设备
176
+ * 更新POI点
177
+ * @param baseInfos POI更新信息数组(不包含type字段)
145
178
  */
146
- static poiSwitchStatus(ids: IdList, isLocation: boolean = false) {
147
- const param = {
148
- cmd: "status",
149
- isLocation,
150
- type: 'POI',
151
- ids
152
- }
153
- this.sendParam(param, `切换poi至指定状态`)
179
+ static poiUpdate(baseInfos: PoiUpdateInfo[]) {
180
+ const data: {
181
+ action: 'update';
182
+ baseInfos: PoiUpdateInfo[];
183
+ } = {
184
+ action: 'update',
185
+ baseInfos
186
+ };
187
+
188
+ const param: PoiType = {
189
+ cmd: "POI",
190
+ data
191
+ };
192
+ this.sendParam(param, '更新POI点')
154
193
  }
155
194
 
156
195
  /**
157
- * 获取指定POI
158
- * @param {*} type 相机type
196
+ * 获取POI点信息
197
+ * @param id 可选,POI的ID,如果提供则获取指定ID的POI信息
198
+ * @param type 可选,POI类型,如 "Camera",如果提供则获取指定类型的POI信息
199
+ * @param place 可选,地方,如 "A_1F",如果提供则获取指定地方指定类型的POI信息
159
200
  */
160
- static poiGetInfo(type: PoiType['type'] = 'Camera') {
201
+ static poiFind(id?: string, type?: string, place?: string) {
202
+ const data: {
203
+ action: 'find';
204
+ id?: string;
205
+ type?: string;
206
+ place?: string;
207
+ } = {
208
+ action: 'find'
209
+ };
210
+
211
+ // 如果提供了 id,则添加
212
+ if (id) {
213
+ data.id = id;
214
+ }
215
+
216
+ // 如果提供了 type,则添加
217
+ if (type) {
218
+ data.type = type;
219
+ }
220
+
221
+ // 如果提供了 place,则添加
222
+ if (place) {
223
+ data.place = place;
224
+ }
225
+
161
226
  const param: PoiType = {
162
227
  cmd: "POI",
163
- action: "getInfo",
164
- type,
228
+ data
165
229
  };
166
- this.sendParam(param, '获取POI信息')
230
+
231
+ // 根据参数组合生成不同的描述
232
+ let msg = '获取POI点信息';
233
+ if (id) {
234
+ msg = '获取指定ID的POI信息';
235
+ } else if (type && place) {
236
+ msg = '获取指定地方指定类型的POI信息';
237
+ } else if (type) {
238
+ msg = '获取指定类型的POI信息';
239
+ } else {
240
+ msg = '获取所有POI信息';
241
+ }
242
+
243
+ this.sendParam(param, msg)
167
244
  }
168
245
  }