@aibee/crc-bmap 0.8.45 → 0.8.46

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 (88) hide show
  1. package/lib/bmap.cjs.min.js +408 -401
  2. package/lib/bmap.esm.js +7310 -1296
  3. package/lib/bmap.esm.min.js +408 -401
  4. package/lib/bmap.min.js +408 -401
  5. package/lib/src/bmap.js +60 -54
  6. package/lib/src/context/OrbitControls.js +4 -1
  7. package/lib/src/context/context.js +54 -37
  8. package/lib/src/context/control.js +85 -85
  9. package/lib/src/elements/base-svg.js +5 -4
  10. package/lib/src/elements/floor.js +8 -0
  11. package/lib/src/elements/glb-model.js +14 -18
  12. package/lib/src/elements/graphic.js +18 -8
  13. package/lib/src/elements/ground-texture.js +41 -44
  14. package/lib/src/elements/heatmap.js +2 -1
  15. package/lib/src/elements/lane.js +5 -1
  16. package/lib/src/elements/merge-graphic.js +3 -28
  17. package/lib/src/elements/model.js +5 -9
  18. package/lib/src/elements/overlay.js +9 -7
  19. package/lib/src/elements/poi.js +55 -49
  20. package/lib/src/elements/poi2.js +52 -53
  21. package/lib/src/elements/shadow.js +3 -1
  22. package/lib/src/elements/svg-line.js +2 -0
  23. package/lib/src/elements/svg-polygon.js +1 -0
  24. package/lib/src/elements/text-texture.js +32 -36
  25. package/lib/src/elements/wall.js +3 -41
  26. package/lib/src/external/meshLine.js +17 -0
  27. package/lib/src/factory/img-texture.js +1 -0
  28. package/lib/src/factory/material.js +21 -51
  29. package/lib/src/factory/model.js +31 -33
  30. package/lib/src/factory/text-texture.js +17 -0
  31. package/lib/src/factory/unique-key.js +8 -0
  32. package/lib/src/layer/graphic-layer.js +1 -0
  33. package/lib/src/layer/parking-layer.d.ts +6 -0
  34. package/lib/src/layer/parking-layer.js +8 -0
  35. package/lib/src/layer/poi-layer.js +4 -1
  36. package/lib/src/layer/poi-layer2.js +2 -0
  37. package/lib/src/loader/AibeeLoader/index.js +230 -276
  38. package/lib/src/loader/AibeeLoader/layer.js +8 -6
  39. package/lib/src/loader/CrLoader/api/floor.js +45 -73
  40. package/lib/src/loader/CrLoader/index.js +88 -106
  41. package/lib/src/operations/hover/hover-helper.js +12 -2
  42. package/lib/src/operations/selection/selection.js +11 -1
  43. package/lib/src/plugins/car-inertial-position/car-inertial-position.js +9 -3
  44. package/lib/src/plugins/car-inertial-position/compass.js +20 -25
  45. package/lib/src/plugins/car-inertial-position/utils.js +3 -0
  46. package/lib/src/plugins/cr-nav-path/cr-nav-path.js +47 -55
  47. package/lib/src/plugins/cr-nav-path/cr-path.worker.js +4 -2
  48. package/lib/src/plugins/equipment/equipment.js +20 -22
  49. package/lib/src/plugins/mul-floor-navigation/mul-floor-navigation.js +63 -61
  50. package/lib/src/plugins/mul-floor-navigation/path.js +34 -30
  51. package/lib/src/plugins/mul-floor-navigation/start-model.js +2 -1
  52. package/lib/src/plugins/mul-floor-select/mul-floor-select.js +2 -1
  53. package/lib/src/plugins/mul-floors/mul-floors.js +1 -0
  54. package/lib/src/plugins/nav-path/nav-path.js +51 -59
  55. package/lib/src/plugins/nav-path/path.worker.js +4 -2
  56. package/lib/src/plugins/navigation/navigation.js +206 -214
  57. package/lib/src/plugins/navigation/path.js +34 -30
  58. package/lib/src/plugins/navigation/position-navigation.js +53 -53
  59. package/lib/src/plugins/navigation/start-rotate-helper-poi.js +18 -6
  60. package/lib/src/plugins/pdr-position/imu-position.js +13 -9
  61. package/lib/src/plugins/pdr-position/particle.js +4 -2
  62. package/lib/src/plugins/pdr-position/pdr.js +5 -4
  63. package/lib/src/plugins/pdr-position/position.js +5 -2
  64. package/lib/src/plugins/pdr-position/sensor.js +20 -25
  65. package/lib/src/plugins/select/select.js +11 -1
  66. package/lib/src/utils/camera-bound.js +3 -1
  67. package/lib/src/utils/color.js +8 -4
  68. package/lib/src/utils/coordinate.js +1 -0
  69. package/lib/src/utils/create.js +4 -2
  70. package/lib/src/utils/events.js +15 -4
  71. package/lib/src/utils/index-db.js +18 -11
  72. package/lib/src/utils/init-helper.js +7 -2
  73. package/lib/src/utils/obj-utils.js +3 -2
  74. package/lib/src/utils/os.js +1 -0
  75. package/lib/src/utils/path.js +15 -4
  76. package/lib/src/utils/promise.js +3 -1
  77. package/lib/src/utils/proxy.js +2 -1
  78. package/lib/src/utils/road.js +20 -14
  79. package/lib/src/utils/road2.js +60 -39
  80. package/lib/src/utils/rules.js +1 -0
  81. package/lib/src/utils/string.js +3 -1
  82. package/lib/src/utils/svg.js +12 -11
  83. package/lib/src/utils/taskQueue.js +29 -29
  84. package/lib/src/utils/timer.js +8 -0
  85. package/lib/src/utils/translate.js +3 -1
  86. package/lib/src/utils/tween.js +8 -0
  87. package/lib/src/utils/webworker.js +10 -9
  88. package/package.json +2 -1
@@ -1,5 +1,5 @@
1
1
  // 加载Aibee地图/路网数据
2
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import "core-js/modules/web.dom-collections.iterator.js";
3
3
  import { createStore, createDb, closeDb, set, get } from "../../utils/index-db";
4
4
  import { Floor, Graphic } from "../../elements";
5
5
  import { transformGraphicData, HooksName, sleepOneRf, TaskQueue } from "../../utils";
@@ -15,196 +15,161 @@ const MapDataStoreName = "map_data"; // 地图数据
15
15
  const RoadNetworkDataStoreName = "road_network_data"; // 路网
16
16
  const FacilityDataStoreName = "facility_data"; // 设施
17
17
  export class AibeeLoader extends EventDispatcher {
18
- initDb() {
19
- var _this = this;
20
- return _async_to_generator(function*() {
21
- try {
22
- const { db, type } = yield createDb("aibee_map", 2);
23
- if (type === "onupgradeneeded") {
24
- createStore(MapVersionStoreName);
25
- createStore(RouteVersionStoreName);
26
- createStore(FacilityVersionStoreName);
27
- createStore(MapDataStoreName);
28
- createStore(RoadNetworkDataStoreName);
29
- createStore(FacilityDataStoreName);
30
- }
31
- _this.db = db;
32
- } catch (e) {
33
- console.log("[打开indexDb错误]", e);
18
+ async initDb() {
19
+ try {
20
+ const { db, type } = await createDb("aibee_map", 2);
21
+ if (type === "onupgradeneeded") {
22
+ createStore(MapVersionStoreName);
23
+ createStore(RouteVersionStoreName);
24
+ createStore(FacilityVersionStoreName);
25
+ createStore(MapDataStoreName);
26
+ createStore(RoadNetworkDataStoreName);
27
+ createStore(FacilityDataStoreName);
34
28
  }
35
- })();
29
+ this.db = db;
30
+ } catch (e) {
31
+ console.log("[打开indexDb错误]", e);
32
+ }
36
33
  }
37
- load(data) {
38
- var _this = this;
39
- return _async_to_generator(function*() {
40
- if (Array.isArray(data)) {
41
- _this.floors = data;
42
- } else {
43
- const res = yield fetch(data).then((res)=>res.json());
44
- if (res.code === "0") {
45
- _this.floors = res.data.list;
46
- }
34
+ async load(data) {
35
+ if (Array.isArray(data)) {
36
+ this.floors = data;
37
+ } else {
38
+ const res = await fetch(data).then((res)=>res.json());
39
+ if (res.code === "0") {
40
+ this.floors = res.data.list;
47
41
  }
48
- })();
42
+ }
49
43
  }
50
44
  setCacheData(storeName, key, data) {
51
- return this.initDbPromise.then(()=>set(storeName, `${key}`, data, this.db));
45
+ return this.initDbPromise.then(()=>set(storeName, "" + key, data, this.db));
52
46
  }
53
47
  getCacheData(storeName, key) {
54
- return this.initDbPromise.then(()=>get(storeName, `${key}`, this.db));
48
+ return this.initDbPromise.then(()=>get(storeName, "" + key, this.db));
55
49
  }
56
50
  getFloorCacheKey(floorInfo) {
57
- return `${floorInfo.floor_id}`;
51
+ return "" + floorInfo.floor_id;
58
52
  }
59
- getFloorData(floor) {
60
- var _this = this;
61
- return _async_to_generator(function*() {
62
- const data = yield _this.getFloorJsonData(floor);
63
- if (!data) {
64
- return null;
65
- }
66
- return _this.getDataByJson(data);
67
- })();
53
+ async getFloorData(floor) {
54
+ const data = await this.getFloorJsonData(floor);
55
+ if (!data) {
56
+ return null;
57
+ }
58
+ return this.getDataByJson(data);
68
59
  }
69
- getFloorDataByFloorInfo(floorInfo) {
70
- var _this = this;
71
- return _async_to_generator(function*() {
72
- const data = yield _this.getFloorJsonDataByFloorInfo(floorInfo);
73
- return _this.getDataByJson(data);
74
- })();
60
+ async getFloorDataByFloorInfo(floorInfo) {
61
+ const data = await this.getFloorJsonDataByFloorInfo(floorInfo);
62
+ return this.getDataByJson(data);
75
63
  }
76
- getFloorJsonDataByFloorInfo(floorInfo) {
77
- var _this = this;
78
- return _async_to_generator(function*() {
79
- const cacheKey = _this.getFloorCacheKey(floorInfo);
80
- // 直接请求json数据
81
- console.time(`zstd_json`);
82
- const res1 = yield fetch(floorInfo.map_url).then((res)=>res.json());
83
- res1.floor = floorInfo.floor;
84
- console.timeEnd(`zstd_json`);
85
- _this.setCacheData(MapDataStoreName, cacheKey, res1);
86
- _this.setCacheData(MapVersionStoreName, cacheKey, floorInfo.version_id);
87
- return res1;
88
- })();
64
+ async getFloorJsonDataByFloorInfo(floorInfo) {
65
+ const cacheKey = this.getFloorCacheKey(floorInfo);
66
+ // 直接请求json数据
67
+ console.time("zstd_json");
68
+ const res1 = await fetch(floorInfo.map_url).then((res)=>res.json());
69
+ res1.floor = floorInfo.floor;
70
+ console.timeEnd("zstd_json");
71
+ this.setCacheData(MapDataStoreName, cacheKey, res1);
72
+ this.setCacheData(MapVersionStoreName, cacheKey, floorInfo.version_id);
73
+ return res1;
89
74
  }
90
- getFloorJsonData(floor) {
91
- var _this = this;
92
- return _async_to_generator(function*() {
93
- const floorInfo = _this.floors.find((item)=>item.floor === floor);
94
- if (!floorInfo) {
95
- return null;
75
+ async getFloorJsonData(floor) {
76
+ const floorInfo = this.floors.find((item)=>item.floor === floor);
77
+ if (!floorInfo) {
78
+ return null;
79
+ }
80
+ const cacheKey = this.getFloorCacheKey(floorInfo);
81
+ try {
82
+ const cacheVersion = await this.getCacheData(MapVersionStoreName, cacheKey);
83
+ if (cacheVersion === floorInfo.version_id) {
84
+ const res = await this.getCacheData(MapDataStoreName, cacheKey);
85
+ if (res) {
86
+ return res;
87
+ }
96
88
  }
97
- const cacheKey = _this.getFloorCacheKey(floorInfo);
89
+ return this.getFloorJsonDataByFloorInfo(floorInfo);
90
+ } catch (e) {
91
+ console.log("[get floor data error]", e);
92
+ return this.getFloorJsonDataByFloorInfo(floorInfo);
93
+ }
94
+ }
95
+ // 获取路网数据
96
+ async getRoadNetworkData() {
97
+ const res = await Promise.all(this.floors.map(async (item)=>{
98
+ const cacheKey = this.getFloorCacheKey(item);
98
99
  try {
99
- const cacheVersion = yield _this.getCacheData(MapVersionStoreName, cacheKey);
100
- if (cacheVersion === floorInfo.version_id) {
101
- const res = yield _this.getCacheData(MapDataStoreName, cacheKey);
100
+ const cacheVersion = await this.getCacheData(RouteVersionStoreName, cacheKey);
101
+ if (cacheVersion === item.version_id) {
102
+ const res = await this.getCacheData(RoadNetworkDataStoreName, cacheKey);
102
103
  if (res) {
103
104
  return res;
104
105
  }
105
106
  }
106
- return _this.getFloorJsonDataByFloorInfo(floorInfo);
107
+ const route = await fetch(item.route_url).then((res)=>res.json());
108
+ this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
109
+ this.setCacheData(RouteVersionStoreName, cacheKey, item.version_id);
110
+ return route;
107
111
  } catch (e) {
108
- console.log("[get floor data error]", e);
109
- return _this.getFloorJsonDataByFloorInfo(floorInfo);
112
+ const route = await fetch(item.route_url).then((res)=>res.json());
113
+ this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
114
+ return route;
110
115
  }
111
- })();
112
- }
113
- // 获取路网数据
114
- getRoadNetworkData() {
115
- var _this = this;
116
- return _async_to_generator(function*() {
117
- const res = yield Promise.all(_this.floors.map(/*#__PURE__*/ _async_to_generator(function*(item) {
118
- const cacheKey = _this.getFloorCacheKey(item);
119
- try {
120
- const cacheVersion = yield _this.getCacheData(RouteVersionStoreName, cacheKey);
121
- if (cacheVersion === item.version_id) {
122
- const res = yield _this.getCacheData(RoadNetworkDataStoreName, cacheKey);
123
- if (res) {
124
- return res;
125
- }
126
- }
127
- const route = yield fetch(item.route_url).then((res)=>res.json());
128
- _this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
129
- _this.setCacheData(RouteVersionStoreName, cacheKey, item.version_id);
130
- return route;
131
- } catch (e) {
132
- const route = yield fetch(item.route_url).then((res)=>res.json());
133
- _this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
134
- return route;
135
- }
136
- })));
137
- return res.filter((item)=>item.points);
138
- })();
116
+ }));
117
+ return res.filter((item)=>item.points);
139
118
  }
140
- getFacilitiesData() {
141
- var _this = this;
142
- return _async_to_generator(function*() {
143
- const floorInfo = _this.floors.reduce((floor, cur)=>floor.updated_at > cur.updated_at ? floor : cur, _this.floors[0]);
144
- if (!floorInfo) {
145
- return null;
119
+ async getFacilitiesData() {
120
+ const floorInfo = this.floors.reduce((floor, cur)=>floor.updated_at > cur.updated_at ? floor : cur, this.floors[0]);
121
+ if (!floorInfo) {
122
+ return null;
123
+ }
124
+ const cacheKey = this.getFloorCacheKey(floorInfo);
125
+ const getFacilityUrl = async ()=>{
126
+ const res = await fetch(floorInfo.entry_infra_url).then((res)=>res.json());
127
+ if (res) {
128
+ this.setCacheData(FacilityDataStoreName, cacheKey, res);
129
+ this.setCacheData(FacilityVersionStoreName, cacheKey, floorInfo.version_id);
146
130
  }
147
- const cacheKey = _this.getFloorCacheKey(floorInfo);
148
- const getFacilityUrl = /*#__PURE__*/ _async_to_generator(function*() {
149
- const res = yield fetch(floorInfo.entry_infra_url).then((res)=>res.json());
131
+ return res;
132
+ };
133
+ try {
134
+ const cacheVersion = await this.getCacheData(FacilityVersionStoreName, cacheKey);
135
+ if (cacheVersion === floorInfo.version_id) {
136
+ const res = await this.getCacheData(FacilityDataStoreName, cacheKey);
150
137
  if (res) {
151
- _this.setCacheData(FacilityDataStoreName, cacheKey, res);
152
- _this.setCacheData(FacilityVersionStoreName, cacheKey, floorInfo.version_id);
153
- }
154
- return res;
155
- });
156
- try {
157
- const cacheVersion = yield _this.getCacheData(FacilityVersionStoreName, cacheKey);
158
- if (cacheVersion === floorInfo.version_id) {
159
- const res = yield _this.getCacheData(FacilityDataStoreName, cacheKey);
160
- if (res) {
161
- return res;
162
- }
138
+ return res;
163
139
  }
164
- return getFacilityUrl();
165
- } catch (e) {
166
- console.log("[get facility error]", e);
167
- return getFacilityUrl();
168
140
  }
169
- })();
141
+ return getFacilityUrl();
142
+ } catch (e) {
143
+ console.log("[get facility error]", e);
144
+ return getFacilityUrl();
145
+ }
170
146
  }
171
147
  // 空闲时间请求其他数据
172
- getOtherDataByFreeTime() {
173
- return _async_to_generator(function*() {
174
- // requestIdleCallback((deadline: IdleDeadline) => {
175
- // while (deadline.timeRemaining() > 0) {
176
- // // TODO 获取其他数据
177
- // // 在空闲时间执行的任务
178
- // console.log('执行任务...', deadline.timeRemaining());
179
- // // TODO 看一下还有哪些楼层没有获取最新的数据
180
- // // 模拟一些工作
181
- // // fetchData(); // 在空闲时间请求数据
182
- // }
183
- // })
184
- })();
148
+ async getOtherDataByFreeTime() {
149
+ // requestIdleCallback((deadline: IdleDeadline) => {
150
+ // while (deadline.timeRemaining() > 0) {
151
+ // // TODO 获取其他数据
152
+ // // 在空闲时间执行的任务
153
+ // console.log('执行任务...', deadline.timeRemaining());
154
+ // // TODO 看一下还有哪些楼层没有获取最新的数据
155
+ // // 模拟一些工作
156
+ // // fetchData(); // 在空闲时间请求数据
157
+ // }
158
+ // })
185
159
  }
186
160
  // 获取多楼层数据
187
- getMulFloorsData(floors) {
188
- var _this = this;
189
- return _async_to_generator(function*() {
190
- return Promise.all(floors.map((floor)=>_this.getFloorData(floor))).then((data)=>data.filter((item)=>item));
191
- })();
161
+ async getMulFloorsData(floors) {
162
+ return Promise.all(floors.map((floor)=>this.getFloorData(floor))).then((data)=>data.filter((item)=>item));
192
163
  }
193
- getDataByUrl(url) {
194
- var _this = this;
195
- return _async_to_generator(function*() {
196
- const data = yield fetch(url).then((res)=>res.json());
197
- return _this.getDataByJson(data);
198
- })();
164
+ async getDataByUrl(url) {
165
+ const data = await fetch(url).then((res)=>res.json());
166
+ return this.getDataByJson(data);
199
167
  }
200
- getDataByJson(data, floor) {
201
- var _this = this;
202
- return _async_to_generator(function*() {
203
- floor = _this.getFloorBaseLayer(data, floor);
204
- yield _this.getFloorContentLayer(data, floor);
205
- _this.changeFloorBox(data, floor);
206
- return floor;
207
- })();
168
+ async getDataByJson(data, floor) {
169
+ floor = this.getFloorBaseLayer(data, floor);
170
+ await this.getFloorContentLayer(data, floor);
171
+ this.changeFloorBox(data, floor);
172
+ return floor;
208
173
  }
209
174
  changeFloorBox(data, floor) {
210
175
  floor.updateBox();
@@ -212,95 +177,90 @@ export class AibeeLoader extends EventDispatcher {
212
177
  const max = Math.max(size.x, size.y, size.z);
213
178
  floor.userData.height = max / 4 + data.floorHeight;
214
179
  }
215
- switchFloor(data) {
216
- var _this = this;
217
- return _async_to_generator(function*() {
218
- return new Promise((resolve)=>{
219
- const task = {
220
- run: ()=>_this._switchFloor(data),
221
- meta: {
222
- type: "switchFloor"
223
- }
224
- };
225
- const tid = _this.taskQueue.replaceByMetaType(task);
226
- const handleTaskEnd = ({ task, res })=>{
227
- if (task.tid === tid) {
228
- _this.taskQueue.removeEventListener("active-task-end", handleTaskEnd);
229
- resolve(res);
230
- }
231
- };
232
- _this.taskQueue.addEventListener("active-task-end", handleTaskEnd);
233
- });
234
- })();
235
- }
236
- _switchFloor(data) {
237
- var _this = this;
238
- return _async_to_generator(function*() {
239
- var _floor_userData_data_layers_find;
240
- let floorData = data;
241
- if (typeof data === 'string') {
242
- const jsonData = yield _this.getFloorJsonData(data);
243
- if (jsonData) {
244
- floorData = jsonData;
245
- } else {
246
- return null;
247
- }
248
- }
249
- const floor = new Floor(_this.bmap.context);
250
- const floorInfo = _this.floors.find((item)=>item.floor === floorData.floor);
251
- var _floorInfo_map_angle;
252
- const angle = (_floorInfo_map_angle = floorInfo == null ? void 0 : floorInfo.map_angle) != null ? _floorInfo_map_angle : 0;
253
- _this.bmap.dispatchEvent({
254
- type: HooksName.SWITCH_FLOOR_BEFORE,
255
- data: {
256
- curFloor: floor,
257
- graphics: []
180
+ async switchFloor(data) {
181
+ return new Promise((resolve)=>{
182
+ const task = {
183
+ run: ()=>this._switchFloor(data),
184
+ meta: {
185
+ type: "switchFloor"
258
186
  }
259
- });
260
- _this.dispatchEvent({
261
- type: "switch-floor-before",
262
- data: {
263
- curFloor: floor,
264
- graphics: []
187
+ };
188
+ const tid = this.taskQueue.replaceByMetaType(task);
189
+ const handleTaskEnd = (param)=>{
190
+ let { task, res } = param;
191
+ if (task.tid === tid) {
192
+ this.taskQueue.removeEventListener("active-task-end", handleTaskEnd);
193
+ resolve(res);
265
194
  }
266
- });
267
- _this.bmap.context.control.setAzimuthalAngle(angle / 180 * Math.PI, true);
268
- _this.getFloorBaseLayer(floorData, floor);
269
- _this.changeFloorBox(floorData, floor);
270
- _this.bmap.buildingCenter = floor.userData.center;
271
- _this.bmap.currentBuildGround = (_floor_userData_data_layers_find = floor.userData.data.layers.find((item)=>item.l_type === "range")) == null ? void 0 : _floor_userData_data_layers_find.elements[0];
272
- _this.bmap.context.switchFloor(floor);
273
- _this.bmap.initialFloorCamera();
274
- yield sleepOneRf();
275
- _this.dispatchEvent({
276
- type: "switch-floor-ground",
277
- data: {
278
- curFloor: floor,
279
- graphics: []
280
- }
281
- });
282
- yield _this.getFloorContentLayer(floorData, floor);
283
- // TODO 兼容数据
284
- _this.changeFloorBox(floorData, floor);
285
- _this.bmap.initialFloorCamera();
286
- _this.bmap.context.cameraBound.updateBox();
287
- // TODO 兼容结束
288
- _this.dispatchEvent({
289
- type: "switch-floor-after",
290
- data: {
291
- curFloor: floor,
292
- graphics: floor.graphicLayer.children
293
- }
294
- });
295
- _this.bmap.dispatchEvent({
296
- type: HooksName.SWITCH_FLOOR_AFTER,
297
- data: {
298
- curFloor: floor,
299
- graphics: floor.graphicLayer.children
300
- }
301
- });
302
- return floor;
303
- })();
195
+ };
196
+ this.taskQueue.addEventListener("active-task-end", handleTaskEnd);
197
+ });
198
+ }
199
+ async _switchFloor(data) {
200
+ var _floor_userData_data_layers_find;
201
+ let floorData = data;
202
+ if (typeof data === 'string') {
203
+ const jsonData = await this.getFloorJsonData(data);
204
+ if (jsonData) {
205
+ floorData = jsonData;
206
+ } else {
207
+ return null;
208
+ }
209
+ }
210
+ const floor = new Floor(this.bmap.context);
211
+ const floorInfo = this.floors.find((item)=>item.floor === floorData.floor);
212
+ var _floorInfo_map_angle;
213
+ const angle = (_floorInfo_map_angle = floorInfo == null ? void 0 : floorInfo.map_angle) != null ? _floorInfo_map_angle : 0;
214
+ this.bmap.dispatchEvent({
215
+ type: HooksName.SWITCH_FLOOR_BEFORE,
216
+ data: {
217
+ curFloor: floor,
218
+ graphics: []
219
+ }
220
+ });
221
+ this.dispatchEvent({
222
+ type: "switch-floor-before",
223
+ data: {
224
+ curFloor: floor,
225
+ graphics: []
226
+ }
227
+ });
228
+ this.bmap.context.control.setAzimuthalAngle(angle / 180 * Math.PI, true);
229
+ this.getFloorBaseLayer(floorData, floor);
230
+ this.changeFloorBox(floorData, floor);
231
+ this.bmap.buildingCenter = floor.userData.center;
232
+ this.bmap.currentBuildGround = (_floor_userData_data_layers_find = floor.userData.data.layers.find((item)=>item.l_type === "range")) == null ? void 0 : _floor_userData_data_layers_find.elements[0];
233
+ this.bmap.context.switchFloor(floor);
234
+ this.bmap.initialFloorCamera();
235
+ await sleepOneRf();
236
+ this.dispatchEvent({
237
+ type: "switch-floor-ground",
238
+ data: {
239
+ curFloor: floor,
240
+ graphics: []
241
+ }
242
+ });
243
+ await this.getFloorContentLayer(floorData, floor);
244
+ // TODO 兼容数据
245
+ this.changeFloorBox(floorData, floor);
246
+ this.bmap.initialFloorCamera();
247
+ this.bmap.context.cameraBound.updateBox();
248
+ // TODO 兼容结束
249
+ this.dispatchEvent({
250
+ type: "switch-floor-after",
251
+ data: {
252
+ curFloor: floor,
253
+ graphics: floor.graphicLayer.children
254
+ }
255
+ });
256
+ this.bmap.dispatchEvent({
257
+ type: HooksName.SWITCH_FLOOR_AFTER,
258
+ data: {
259
+ curFloor: floor,
260
+ graphics: floor.graphicLayer.children
261
+ }
262
+ });
263
+ return floor;
304
264
  }
305
265
  getFloorBaseLayer(data, floor) {
306
266
  if (!floor) {
@@ -334,39 +294,33 @@ export class AibeeLoader extends EventDispatcher {
334
294
  floor.userData.data = data;
335
295
  return floor;
336
296
  }
337
- getFloorContentLayer(data, floor) {
338
- var _this = this;
339
- return _async_to_generator(function*() {
340
- if (!floor) {
341
- floor = new Floor(_this.bmap.context);
297
+ async getFloorContentLayer(data, floor) {
298
+ if (!floor) {
299
+ floor = new Floor(this.bmap.context);
300
+ }
301
+ floor.userData.graphics = [];
302
+ floor.userData.graphicMap = new Map();
303
+ let startTime = Date.now();
304
+ for(let i = 0; i < data.layers.length; i++){
305
+ const layer = data.layers[i];
306
+ if ([
307
+ 'range',
308
+ 'ground'
309
+ ].includes(layer.l_type)) {
310
+ continue;
342
311
  }
343
- floor.userData.graphics = [];
344
- floor.userData.graphicMap = new Map();
345
- let startTime = Date.now();
346
- for(let i = 0; i < data.layers.length; i++){
347
- const layer = data.layers[i];
348
- if ([
349
- 'range',
350
- 'ground'
351
- ].includes(layer.l_type)) {
352
- continue;
353
- }
354
- transformLayers(layer, floor);
355
- console.log('time', Date.now() - startTime, layer.l_type);
356
- if (Date.now() - startTime > 16) {
357
- yield sleepOneRf();
358
- startTime = Date.now();
359
- }
312
+ transformLayers(layer, floor);
313
+ console.log('time', Date.now() - startTime, layer.l_type);
314
+ if (Date.now() - startTime > 16) {
315
+ await sleepOneRf();
316
+ startTime = Date.now();
360
317
  }
361
- return floor;
362
- })();
318
+ }
319
+ return floor;
363
320
  }
364
- clear() {
365
- var _this = this;
366
- return _async_to_generator(function*() {
367
- var _this_db;
368
- closeDb((_this_db = _this.db) != null ? _this_db : undefined);
369
- })();
321
+ async clear() {
322
+ var _this_db;
323
+ closeDb((_this_db = this.db) != null ? _this_db : undefined);
370
324
  }
371
325
  dispose() {
372
326
  this.clear();
@@ -1,4 +1,6 @@
1
1
  import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import "core-js/modules/es.array.push.js";
3
+ import "core-js/modules/web.dom-collections.iterator.js";
2
4
  import { getMinEdgeSquare, transformGraphicData, translatePosToCenter } from "../../utils";
3
5
  import { GlbModel, GroundTexture, Lane, MergeGraphic, Poi2, TextTexture, Wall } from "../../elements";
4
6
  import { ParkingTypeIconMap } from '../../assets';
@@ -41,9 +43,9 @@ export function transformLayers(layer, floor) {
41
43
  // 对可以合并的图形做合并处理
42
44
  const group = canMergeGraphics.reduce((obj, options)=>{
43
45
  const { fillColor, fillOpacity, strokeColor, strokeOpacity, height, airHeight } = options;
44
- let key = `${fillColor.toLowerCase()}-${fillOpacity}-${strokeColor.toLowerCase()}-${strokeOpacity}-${height}-${airHeight}`;
46
+ let key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + strokeColor.toLowerCase() + "-" + strokeOpacity + "-" + height + "-" + airHeight;
45
47
  if (strokeOpacity === 0) {
46
- key = `${fillColor.toLowerCase()}-${fillOpacity}-${height}-${airHeight}`;
48
+ key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + height + "-" + airHeight;
47
49
  }
48
50
  if (obj[key]) {
49
51
  obj[key].push(options);
@@ -69,9 +71,9 @@ export function transformLayers(layer, floor) {
69
71
  // 分组
70
72
  const wallGroup = layer.elements.reduce((obj, options)=>{
71
73
  const { fillColor, fillOpacity, strokeColor, strokeOpacity, height } = options;
72
- let key = `${fillColor.toLowerCase()}-${fillOpacity}-${strokeColor.toLowerCase()}-${strokeOpacity}-${height}`;
74
+ let key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + strokeColor.toLowerCase() + "-" + strokeOpacity + "-" + height;
73
75
  if (strokeOpacity === 0) {
74
- key = `${fillColor.toLowerCase()}-${fillOpacity}-${height}`;
76
+ key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + height;
75
77
  }
76
78
  if (obj[key]) {
77
79
  obj[key].push(options);
@@ -95,9 +97,9 @@ export function transformLayers(layer, floor) {
95
97
  // 分组
96
98
  const laneGroup = layer.elements.reduce((obj, options)=>{
97
99
  const { fillColor, fillOpacity, strokeColor, strokeOpacity } = options;
98
- let key = `${fillColor.toLowerCase()}-${fillOpacity}-${strokeColor.toLowerCase()}-${strokeOpacity}`;
100
+ let key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + strokeColor.toLowerCase() + "-" + strokeOpacity;
99
101
  if (strokeOpacity === 0) {
100
- key = `${fillColor.toLowerCase()}-${fillOpacity}`;
102
+ key = fillColor.toLowerCase() + "-" + fillOpacity;
101
103
  }
102
104
  if (obj[key]) {
103
105
  obj[key].push(options);