@aibee/crc-bmap 0.0.41 → 0.0.43
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/example/src/main.ts +5 -5
- package/lib/bmap.cjs.min.js +2 -2
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +115 -45
- package/lib/bmap.esm.js.map +3 -3
- package/lib/bmap.esm.min.js +2 -2
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +2 -2
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/bmap.d.ts +9 -2
- package/lib/src/context.d.ts +5 -0
- package/lib/src/operations/hover/hover-helper.d.ts +3 -2
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -1231,6 +1231,7 @@ var Floor = class extends Object3D7 {
|
|
|
1231
1231
|
addGrounds(grounds) {
|
|
1232
1232
|
grounds.forEach((ground) => {
|
|
1233
1233
|
if (!this.grounds.has(ground)) {
|
|
1234
|
+
ground.options.height += ground.options.zIndex / 1e5;
|
|
1234
1235
|
this.grounds.add(ground);
|
|
1235
1236
|
this.groundUpper.add(ground);
|
|
1236
1237
|
}
|
|
@@ -1240,6 +1241,7 @@ var Floor = class extends Object3D7 {
|
|
|
1240
1241
|
changeGroundMaxHeight() {
|
|
1241
1242
|
const grounds = Array.from(this.grounds);
|
|
1242
1243
|
this.groundMaxHeight = this.grounds.size > 0 ? Math.max(...grounds.map((ground) => ground.options.height + ground.options.airHeight)) : 0;
|
|
1244
|
+
this.graphicLayer.position.z = this.groundMaxHeight;
|
|
1243
1245
|
}
|
|
1244
1246
|
get hasElement() {
|
|
1245
1247
|
return !!(this.grounds.size || this.graphicLayer.children.length);
|
|
@@ -1256,7 +1258,7 @@ var Floor = class extends Object3D7 {
|
|
|
1256
1258
|
this.add(this.shadow);
|
|
1257
1259
|
}
|
|
1258
1260
|
addGraphic(graphicOptions) {
|
|
1259
|
-
graphicOptions.
|
|
1261
|
+
graphicOptions.height += (graphicOptions.height || 0) / 1e5;
|
|
1260
1262
|
return this.graphicLayer.createGraphic(graphicOptions);
|
|
1261
1263
|
}
|
|
1262
1264
|
addPoi(poiOptions) {
|
|
@@ -1919,14 +1921,19 @@ var HoverHelper = class extends EventDispatcher4 {
|
|
|
1919
1921
|
__publicField(this, "curGraphics", /* @__PURE__ */ new Set());
|
|
1920
1922
|
__publicField(this, "timer", new Timer());
|
|
1921
1923
|
__publicField(this, "graphicTimerMap", /* @__PURE__ */ new Map());
|
|
1922
|
-
__publicField(this, "onPointerMove", ({ graphics }) => {
|
|
1923
|
-
|
|
1924
|
+
__publicField(this, "onPointerMove", ({ graphics, pois }) => {
|
|
1925
|
+
const poiGraphics = pois.map((item) => {
|
|
1926
|
+
var _a;
|
|
1927
|
+
return (_a = this.context.currentFloor) == null ? void 0 : _a.graphicLayer.graphicMap.get(item.options.id);
|
|
1928
|
+
});
|
|
1929
|
+
if (!graphics.length && !poiGraphics && this.curGraphics.size) {
|
|
1924
1930
|
this.curGraphics.clear();
|
|
1925
1931
|
this.handleHoverGraphicsChange();
|
|
1926
1932
|
return;
|
|
1927
1933
|
}
|
|
1928
1934
|
const { time } = this.context.config.hover;
|
|
1929
|
-
graphics
|
|
1935
|
+
const allGraphics = /* @__PURE__ */ new Set([...graphics, ...poiGraphics]);
|
|
1936
|
+
allGraphics.forEach((graphic) => {
|
|
1930
1937
|
if (this.graphicTimerMap.get(graphic)) {
|
|
1931
1938
|
return;
|
|
1932
1939
|
}
|
|
@@ -1940,14 +1947,14 @@ var HoverHelper = class extends EventDispatcher4 {
|
|
|
1940
1947
|
this.graphicTimerMap.set(graphic, timer);
|
|
1941
1948
|
});
|
|
1942
1949
|
this.graphicTimerMap.forEach((timer, graphic) => {
|
|
1943
|
-
if (!
|
|
1950
|
+
if (!allGraphics.has(graphic)) {
|
|
1944
1951
|
this.timer.clearTimeout(timer);
|
|
1945
1952
|
this.graphicTimerMap.delete(graphic);
|
|
1946
1953
|
}
|
|
1947
1954
|
});
|
|
1948
1955
|
const size = this.curGraphics.size;
|
|
1949
1956
|
this.curGraphics.forEach((graphic) => {
|
|
1950
|
-
if (!
|
|
1957
|
+
if (!allGraphics.has(graphic)) {
|
|
1951
1958
|
this.curGraphics.delete(graphic);
|
|
1952
1959
|
}
|
|
1953
1960
|
});
|
|
@@ -1962,7 +1969,7 @@ var HoverHelper = class extends EventDispatcher4 {
|
|
|
1962
1969
|
this.registryEvent();
|
|
1963
1970
|
}
|
|
1964
1971
|
handleHoverGraphicsChange(graphics = this.curGraphics) {
|
|
1965
|
-
this.dispatchEvent({ type: "hover-change", graphics: Array.from(
|
|
1972
|
+
this.dispatchEvent({ type: "hover-change", graphics: Array.from(graphics) });
|
|
1966
1973
|
}
|
|
1967
1974
|
registryEvent() {
|
|
1968
1975
|
this.context.addEventListener("pointer-over", this.onPointerMove);
|
|
@@ -2157,6 +2164,14 @@ var Context = class extends EventDispatcher5 {
|
|
|
2157
2164
|
* @param polar 弧度
|
|
2158
2165
|
*/
|
|
2159
2166
|
setPolarAngle(polar, duration = 500) {
|
|
2167
|
+
if (duration === 0) {
|
|
2168
|
+
this.control.maxPolarAngle = polar;
|
|
2169
|
+
this.control.minPolarAngle = polar;
|
|
2170
|
+
this.control.update();
|
|
2171
|
+
this.control.maxPolarAngle = this.config.control.maxPolar;
|
|
2172
|
+
this.control.minPolarAngle = 0;
|
|
2173
|
+
return Promise.resolve();
|
|
2174
|
+
}
|
|
2160
2175
|
return timeoutPromise(
|
|
2161
2176
|
new Promise((resolve) => {
|
|
2162
2177
|
const start = { polar: this.control.getPolarAngle() };
|
|
@@ -2178,6 +2193,39 @@ var Context = class extends EventDispatcher5 {
|
|
|
2178
2193
|
duration + 500
|
|
2179
2194
|
);
|
|
2180
2195
|
}
|
|
2196
|
+
/**
|
|
2197
|
+
* 设置横向旋转角度
|
|
2198
|
+
* @param azimuthal 弧度
|
|
2199
|
+
*/
|
|
2200
|
+
setAzimuthalAngle(azimuthal, duration = 500) {
|
|
2201
|
+
if (duration === 0) {
|
|
2202
|
+
this.control.maxAzimuthAngle = azimuthal;
|
|
2203
|
+
this.control.minAzimuthAngle = azimuthal;
|
|
2204
|
+
this.control.update();
|
|
2205
|
+
this.control.maxAzimuthAngle = Infinity;
|
|
2206
|
+
this.control.minAzimuthAngle = Infinity;
|
|
2207
|
+
}
|
|
2208
|
+
return timeoutPromise(
|
|
2209
|
+
new Promise((resolve) => {
|
|
2210
|
+
const start = { azimuthal: this.control.getAzimuthalAngle() };
|
|
2211
|
+
const end = { azimuthal };
|
|
2212
|
+
const tween = new Tween(start, this.tweenGroup).to(end, duration).onUpdate(() => {
|
|
2213
|
+
this.control.maxAzimuthAngle = start.azimuthal;
|
|
2214
|
+
this.control.minAzimuthAngle = start.azimuthal;
|
|
2215
|
+
this.control.update();
|
|
2216
|
+
}).onComplete(() => {
|
|
2217
|
+
this.control.enabled = true;
|
|
2218
|
+
this.control.maxAzimuthAngle = Infinity;
|
|
2219
|
+
this.control.minAzimuthAngle = Infinity;
|
|
2220
|
+
this.tweenGroup.remove(tween);
|
|
2221
|
+
resolve(true);
|
|
2222
|
+
}).onStart(() => {
|
|
2223
|
+
this.control.enabled = false;
|
|
2224
|
+
}).start();
|
|
2225
|
+
}),
|
|
2226
|
+
duration + 500
|
|
2227
|
+
);
|
|
2228
|
+
}
|
|
2181
2229
|
getCameraLookAt() {
|
|
2182
2230
|
return new Vector38().subVectors(this.control.target, this.camera.position);
|
|
2183
2231
|
}
|
|
@@ -2188,13 +2236,18 @@ var Context = class extends EventDispatcher5 {
|
|
|
2188
2236
|
* @returns
|
|
2189
2237
|
*/
|
|
2190
2238
|
setZoom(zoom, center2, duration = 500) {
|
|
2239
|
+
const lookAtVector = this.getCameraLookAt();
|
|
2240
|
+
const start = {
|
|
2241
|
+
zoom: this.camera.zoom,
|
|
2242
|
+
target: this.control.target.clone()
|
|
2243
|
+
};
|
|
2244
|
+
if (!duration) {
|
|
2245
|
+
this.camera.position.copy(start.target.clone().sub(lookAtVector));
|
|
2246
|
+
this.control.target.copy(start.target);
|
|
2247
|
+
this.camera.zoom = start.zoom;
|
|
2248
|
+
}
|
|
2191
2249
|
return timeoutPromise(
|
|
2192
2250
|
new Promise((resolve) => {
|
|
2193
|
-
const start = {
|
|
2194
|
-
zoom: this.camera.zoom,
|
|
2195
|
-
target: this.control.target.clone()
|
|
2196
|
-
};
|
|
2197
|
-
const lookAtVector = this.getCameraLookAt();
|
|
2198
2251
|
const tween = new Tween(start, this.tweenGroup).to(
|
|
2199
2252
|
{
|
|
2200
2253
|
zoom,
|
|
@@ -2226,18 +2279,21 @@ var Context = class extends EventDispatcher5 {
|
|
|
2226
2279
|
*/
|
|
2227
2280
|
fitCameraToObject(object, padding = [20, 20, 20, 20], duration = 500) {
|
|
2228
2281
|
const [top, right, bottom, left] = padding;
|
|
2229
|
-
const {
|
|
2282
|
+
const { clientSize: { width, height } } = this;
|
|
2283
|
+
const polar = this.control.getPolarAngle();
|
|
2284
|
+
this.setPolarAngle(0, 0);
|
|
2230
2285
|
const boundingBox = new Box36().setFromObject(object);
|
|
2286
|
+
this.setPolarAngle(polar, 0);
|
|
2231
2287
|
const { max, min } = boundingBox;
|
|
2232
|
-
const max2d = vector3ToDevice(max, this.camera,
|
|
2233
|
-
const min2d = vector3ToDevice(min, this.camera,
|
|
2288
|
+
const max2d = vector3ToDevice(max, this.camera, width, height);
|
|
2289
|
+
const min2d = vector3ToDevice(min, this.camera, width, height);
|
|
2234
2290
|
const boundingBox2d = new Box2().setFromPoints([
|
|
2235
2291
|
new Vector23(max2d.x, max2d.y),
|
|
2236
2292
|
new Vector23(min2d.x, min2d.y)
|
|
2237
2293
|
]);
|
|
2238
2294
|
const size = boundingBox2d.getSize(new Vector23());
|
|
2239
|
-
const xScale = (
|
|
2240
|
-
const yScale = (
|
|
2295
|
+
const xScale = (width - right - left) / size.x;
|
|
2296
|
+
const yScale = (height - top - bottom) / size.y;
|
|
2241
2297
|
const scale = Math.min(xScale, yScale);
|
|
2242
2298
|
const center2 = new Vector38((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
|
|
2243
2299
|
return this.setZoom(scale * this.camera.zoom, center2, duration);
|
|
@@ -2341,6 +2397,11 @@ function getConfig(config) {
|
|
|
2341
2397
|
}
|
|
2342
2398
|
|
|
2343
2399
|
// src/bmap.ts
|
|
2400
|
+
var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
|
|
2401
|
+
MapTypePolar2[MapTypePolar2["D2"] = 0] = "D2";
|
|
2402
|
+
MapTypePolar2[MapTypePolar2["D3"] = 0.9] = "D3";
|
|
2403
|
+
return MapTypePolar2;
|
|
2404
|
+
})(MapTypePolar || {});
|
|
2344
2405
|
var BMap = class extends EventDispatcher6 {
|
|
2345
2406
|
constructor(container, config = {}) {
|
|
2346
2407
|
super();
|
|
@@ -2353,6 +2414,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2353
2414
|
__publicField(this, "svgPolygon");
|
|
2354
2415
|
__publicField(this, "basicZoom", 1);
|
|
2355
2416
|
__publicField(this, "prevCameraZoom", 1);
|
|
2417
|
+
__publicField(this, "type", "2d");
|
|
2356
2418
|
__publicField(this, "floorDataMap", /* @__PURE__ */ new Map());
|
|
2357
2419
|
__publicField(this, "buildingGroundMap", /* @__PURE__ */ new Map());
|
|
2358
2420
|
__publicField(this, "currentBuildGround", null);
|
|
@@ -2484,8 +2546,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2484
2546
|
curFloor.addGrounds(groundGraphics);
|
|
2485
2547
|
const graphicData = data.filter((item) => item.info.group !== "ground");
|
|
2486
2548
|
graphicData.forEach((item, index) => {
|
|
2487
|
-
item.info.
|
|
2488
|
-
item.info.height = 5 + index * 1e-4;
|
|
2549
|
+
item.info.height = 5;
|
|
2489
2550
|
});
|
|
2490
2551
|
const legacyToGraphicMap = /* @__PURE__ */ new Map();
|
|
2491
2552
|
const graphics = graphicData.map((item) => {
|
|
@@ -2498,32 +2559,31 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2498
2559
|
curFloor.userData.legacyToGraphicMap = legacyToGraphicMap;
|
|
2499
2560
|
return { curFloor, graphics };
|
|
2500
2561
|
}
|
|
2501
|
-
switchFloor(
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
} else {
|
|
2521
|
-
console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
|
|
2522
|
-
}
|
|
2562
|
+
switchFloor({ brand, project, phase, building, floor, ts, resource_type_list }) {
|
|
2563
|
+
const floorKey = this.getFloorKey({ brand, project, phase, building, floor, ts, resource_type_list });
|
|
2564
|
+
const curFloorData = this.floorDataMap.get(floorKey);
|
|
2565
|
+
this.context.control.removeEventListener("change", this.onControlChange);
|
|
2566
|
+
if (curFloorData) {
|
|
2567
|
+
const buildingKey = this.getBuildingKey({ brand, project, phase, building });
|
|
2568
|
+
this.currentBuildGround = this.buildingGroundMap.get(buildingKey) || null;
|
|
2569
|
+
const createdFloor = this.createFloor(curFloorData);
|
|
2570
|
+
if (createdFloor) {
|
|
2571
|
+
this.context.switchFloor(createdFloor.curFloor);
|
|
2572
|
+
this.context.control.minZoom = 0;
|
|
2573
|
+
this.context.control.maxZoom = Infinity;
|
|
2574
|
+
this.context.setAzimuthalAngle(0, 0);
|
|
2575
|
+
this.context.fitCameraToGround(void 0, 0);
|
|
2576
|
+
this.basicZoom = this.context.camera.zoom;
|
|
2577
|
+
this.context.control.minZoom = this.basicZoom;
|
|
2578
|
+
this.context.control.maxZoom = this.basicZoom * 25;
|
|
2579
|
+
this.context.control.addEventListener("change", this.onControlChange);
|
|
2580
|
+
this.onControlChange();
|
|
2523
2581
|
} else {
|
|
2524
|
-
console.warn("[switchFloor error] \
|
|
2582
|
+
console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
|
|
2525
2583
|
}
|
|
2526
|
-
}
|
|
2584
|
+
} else {
|
|
2585
|
+
console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42");
|
|
2586
|
+
}
|
|
2527
2587
|
}
|
|
2528
2588
|
addHeatmap(data) {
|
|
2529
2589
|
var _a;
|
|
@@ -2586,12 +2646,21 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2586
2646
|
* @param duration
|
|
2587
2647
|
*/
|
|
2588
2648
|
changeMapType(type, duration = 500) {
|
|
2649
|
+
this.type = type;
|
|
2589
2650
|
if (type === "2d") {
|
|
2590
|
-
return this.context.setPolarAngle(0
|
|
2651
|
+
return this.context.setPolarAngle(0 /* D2 */, duration);
|
|
2591
2652
|
} else {
|
|
2592
|
-
return this.context.setPolarAngle(0.9
|
|
2653
|
+
return this.context.setPolarAngle(0.9 /* D3 */, duration);
|
|
2593
2654
|
}
|
|
2594
2655
|
}
|
|
2656
|
+
resetView(duration = 300) {
|
|
2657
|
+
return __async(this, null, function* () {
|
|
2658
|
+
const time = duration / 3;
|
|
2659
|
+
yield this.context.setAzimuthalAngle(0, time);
|
|
2660
|
+
yield this.changeMapType(this.type, time);
|
|
2661
|
+
yield this.context.fitCameraToGround(void 0, time);
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2595
2664
|
/**
|
|
2596
2665
|
* 缩小地图
|
|
2597
2666
|
* @param zoom
|
|
@@ -2776,6 +2845,7 @@ export {
|
|
|
2776
2845
|
HeatmapElement,
|
|
2777
2846
|
HoverHelper,
|
|
2778
2847
|
Layer,
|
|
2848
|
+
MapTypePolar,
|
|
2779
2849
|
Overlay,
|
|
2780
2850
|
Poi,
|
|
2781
2851
|
PoiLayer,
|