@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.
- package/lib/bmap.cjs.min.js +408 -401
- package/lib/bmap.esm.js +7310 -1296
- package/lib/bmap.esm.min.js +408 -401
- package/lib/bmap.min.js +408 -401
- package/lib/src/bmap.js +60 -54
- package/lib/src/context/OrbitControls.js +4 -1
- package/lib/src/context/context.js +54 -37
- package/lib/src/context/control.js +85 -85
- package/lib/src/elements/base-svg.js +5 -4
- package/lib/src/elements/floor.js +8 -0
- package/lib/src/elements/glb-model.js +14 -18
- package/lib/src/elements/graphic.js +18 -8
- package/lib/src/elements/ground-texture.js +41 -44
- package/lib/src/elements/heatmap.js +2 -1
- package/lib/src/elements/lane.js +5 -1
- package/lib/src/elements/merge-graphic.js +3 -28
- package/lib/src/elements/model.js +5 -9
- package/lib/src/elements/overlay.js +9 -7
- package/lib/src/elements/poi.js +55 -49
- package/lib/src/elements/poi2.js +52 -53
- package/lib/src/elements/shadow.js +3 -1
- package/lib/src/elements/svg-line.js +2 -0
- package/lib/src/elements/svg-polygon.js +1 -0
- package/lib/src/elements/text-texture.js +32 -36
- package/lib/src/elements/wall.js +3 -41
- package/lib/src/external/meshLine.js +17 -0
- package/lib/src/factory/img-texture.js +1 -0
- package/lib/src/factory/material.js +21 -51
- package/lib/src/factory/model.js +31 -33
- package/lib/src/factory/text-texture.js +17 -0
- package/lib/src/factory/unique-key.js +8 -0
- package/lib/src/layer/graphic-layer.js +1 -0
- package/lib/src/layer/parking-layer.d.ts +6 -0
- package/lib/src/layer/parking-layer.js +8 -0
- package/lib/src/layer/poi-layer.js +4 -1
- package/lib/src/layer/poi-layer2.js +2 -0
- package/lib/src/loader/AibeeLoader/index.js +230 -276
- package/lib/src/loader/AibeeLoader/layer.js +8 -6
- package/lib/src/loader/CrLoader/api/floor.js +45 -73
- package/lib/src/loader/CrLoader/index.js +88 -106
- package/lib/src/operations/hover/hover-helper.js +12 -2
- package/lib/src/operations/selection/selection.js +11 -1
- package/lib/src/plugins/car-inertial-position/car-inertial-position.js +9 -3
- package/lib/src/plugins/car-inertial-position/compass.js +20 -25
- package/lib/src/plugins/car-inertial-position/utils.js +3 -0
- package/lib/src/plugins/cr-nav-path/cr-nav-path.js +47 -55
- package/lib/src/plugins/cr-nav-path/cr-path.worker.js +4 -2
- package/lib/src/plugins/equipment/equipment.js +20 -22
- package/lib/src/plugins/mul-floor-navigation/mul-floor-navigation.js +63 -61
- package/lib/src/plugins/mul-floor-navigation/path.js +34 -30
- package/lib/src/plugins/mul-floor-navigation/start-model.js +2 -1
- package/lib/src/plugins/mul-floor-select/mul-floor-select.js +2 -1
- package/lib/src/plugins/mul-floors/mul-floors.js +1 -0
- package/lib/src/plugins/nav-path/nav-path.js +51 -59
- package/lib/src/plugins/nav-path/path.worker.js +4 -2
- package/lib/src/plugins/navigation/navigation.js +206 -214
- package/lib/src/plugins/navigation/path.js +34 -30
- package/lib/src/plugins/navigation/position-navigation.js +53 -53
- package/lib/src/plugins/navigation/start-rotate-helper-poi.js +18 -6
- package/lib/src/plugins/pdr-position/imu-position.js +13 -9
- package/lib/src/plugins/pdr-position/particle.js +4 -2
- package/lib/src/plugins/pdr-position/pdr.js +5 -4
- package/lib/src/plugins/pdr-position/position.js +5 -2
- package/lib/src/plugins/pdr-position/sensor.js +20 -25
- package/lib/src/plugins/select/select.js +11 -1
- package/lib/src/utils/camera-bound.js +3 -1
- package/lib/src/utils/color.js +8 -4
- package/lib/src/utils/coordinate.js +1 -0
- package/lib/src/utils/create.js +4 -2
- package/lib/src/utils/events.js +15 -4
- package/lib/src/utils/index-db.js +18 -11
- package/lib/src/utils/init-helper.js +7 -2
- package/lib/src/utils/obj-utils.js +3 -2
- package/lib/src/utils/os.js +1 -0
- package/lib/src/utils/path.js +15 -4
- package/lib/src/utils/promise.js +3 -1
- package/lib/src/utils/proxy.js +2 -1
- package/lib/src/utils/road.js +20 -14
- package/lib/src/utils/road2.js +60 -39
- package/lib/src/utils/rules.js +1 -0
- package/lib/src/utils/string.js +3 -1
- package/lib/src/utils/svg.js +12 -11
- package/lib/src/utils/taskQueue.js +29 -29
- package/lib/src/utils/timer.js +8 -0
- package/lib/src/utils/translate.js +3 -1
- package/lib/src/utils/tween.js +8 -0
- package/lib/src/utils/webworker.js +10 -9
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// 加载Aibee地图/路网数据
|
|
2
|
-
import
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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,
|
|
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,
|
|
48
|
+
return this.initDbPromise.then(()=>get(storeName, "" + key, this.db));
|
|
55
49
|
}
|
|
56
50
|
getFloorCacheKey(floorInfo) {
|
|
57
|
-
return
|
|
51
|
+
return "" + floorInfo.floor_id;
|
|
58
52
|
}
|
|
59
|
-
getFloorData(floor) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
71
|
-
return
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
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 =
|
|
100
|
-
if (cacheVersion ===
|
|
101
|
-
const res =
|
|
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
|
-
|
|
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
|
-
|
|
109
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
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
|
-
|
|
195
|
-
return
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
-
|
|
362
|
-
|
|
318
|
+
}
|
|
319
|
+
return floor;
|
|
363
320
|
}
|
|
364
|
-
clear() {
|
|
365
|
-
var
|
|
366
|
-
|
|
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 =
|
|
46
|
+
let key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + strokeColor.toLowerCase() + "-" + strokeOpacity + "-" + height + "-" + airHeight;
|
|
45
47
|
if (strokeOpacity === 0) {
|
|
46
|
-
key =
|
|
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 =
|
|
74
|
+
let key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + strokeColor.toLowerCase() + "-" + strokeOpacity + "-" + height;
|
|
73
75
|
if (strokeOpacity === 0) {
|
|
74
|
-
key =
|
|
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 =
|
|
100
|
+
let key = fillColor.toLowerCase() + "-" + fillOpacity + "-" + strokeColor.toLowerCase() + "-" + strokeOpacity;
|
|
99
101
|
if (strokeOpacity === 0) {
|
|
100
|
-
key =
|
|
102
|
+
key = fillColor.toLowerCase() + "-" + fillOpacity;
|
|
101
103
|
}
|
|
102
104
|
if (obj[key]) {
|
|
103
105
|
obj[key].push(options);
|