@aibee/crc-bmap 0.0.41 → 0.0.42
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 +1 -1
- package/lib/bmap.cjs.min.js +2 -2
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +73 -10
- 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 +8 -1
- package/lib/src/context.d.ts +5 -0
- 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) {
|
|
@@ -2157,6 +2159,14 @@ var Context = class extends EventDispatcher5 {
|
|
|
2157
2159
|
* @param polar 弧度
|
|
2158
2160
|
*/
|
|
2159
2161
|
setPolarAngle(polar, duration = 500) {
|
|
2162
|
+
if (duration === 0) {
|
|
2163
|
+
this.control.maxPolarAngle = polar;
|
|
2164
|
+
this.control.minPolarAngle = polar;
|
|
2165
|
+
this.control.update();
|
|
2166
|
+
this.control.maxPolarAngle = this.config.control.maxPolar;
|
|
2167
|
+
this.control.minPolarAngle = 0;
|
|
2168
|
+
return Promise.resolve();
|
|
2169
|
+
}
|
|
2160
2170
|
return timeoutPromise(
|
|
2161
2171
|
new Promise((resolve) => {
|
|
2162
2172
|
const start = { polar: this.control.getPolarAngle() };
|
|
@@ -2178,6 +2188,40 @@ var Context = class extends EventDispatcher5 {
|
|
|
2178
2188
|
duration + 500
|
|
2179
2189
|
);
|
|
2180
2190
|
}
|
|
2191
|
+
/**
|
|
2192
|
+
* 设置横向旋转角度
|
|
2193
|
+
* @param azimuthal 弧度
|
|
2194
|
+
*/
|
|
2195
|
+
setAzimuthalAngle(azimuthal, duration = 500) {
|
|
2196
|
+
if (duration === 0) {
|
|
2197
|
+
this.control.maxAzimuthAngle = azimuthal;
|
|
2198
|
+
this.control.minAzimuthAngle = azimuthal;
|
|
2199
|
+
this.control.update();
|
|
2200
|
+
this.control.maxAzimuthAngle = Infinity;
|
|
2201
|
+
this.control.minAzimuthAngle = Infinity;
|
|
2202
|
+
return Promise.resolve();
|
|
2203
|
+
}
|
|
2204
|
+
return timeoutPromise(
|
|
2205
|
+
new Promise((resolve) => {
|
|
2206
|
+
const start = { azimuthal: this.control.getAzimuthalAngle() };
|
|
2207
|
+
const end = { azimuthal };
|
|
2208
|
+
const tween = new Tween(start, this.tweenGroup).to(end, duration).onUpdate(() => {
|
|
2209
|
+
this.control.maxAzimuthAngle = start.azimuthal;
|
|
2210
|
+
this.control.minAzimuthAngle = start.azimuthal;
|
|
2211
|
+
this.control.update();
|
|
2212
|
+
}).onComplete(() => {
|
|
2213
|
+
this.control.enabled = true;
|
|
2214
|
+
this.control.maxAzimuthAngle = Infinity;
|
|
2215
|
+
this.control.minAzimuthAngle = Infinity;
|
|
2216
|
+
this.tweenGroup.remove(tween);
|
|
2217
|
+
resolve(true);
|
|
2218
|
+
}).onStart(() => {
|
|
2219
|
+
this.control.enabled = false;
|
|
2220
|
+
}).start();
|
|
2221
|
+
}),
|
|
2222
|
+
duration + 500
|
|
2223
|
+
);
|
|
2224
|
+
}
|
|
2181
2225
|
getCameraLookAt() {
|
|
2182
2226
|
return new Vector38().subVectors(this.control.target, this.camera.position);
|
|
2183
2227
|
}
|
|
@@ -2226,18 +2270,21 @@ var Context = class extends EventDispatcher5 {
|
|
|
2226
2270
|
*/
|
|
2227
2271
|
fitCameraToObject(object, padding = [20, 20, 20, 20], duration = 500) {
|
|
2228
2272
|
const [top, right, bottom, left] = padding;
|
|
2229
|
-
const {
|
|
2273
|
+
const { clientSize: { width, height } } = this;
|
|
2274
|
+
const polar = this.control.getPolarAngle();
|
|
2275
|
+
this.setPolarAngle(0, 0);
|
|
2230
2276
|
const boundingBox = new Box36().setFromObject(object);
|
|
2277
|
+
this.setPolarAngle(polar, 0);
|
|
2231
2278
|
const { max, min } = boundingBox;
|
|
2232
|
-
const max2d = vector3ToDevice(max, this.camera,
|
|
2233
|
-
const min2d = vector3ToDevice(min, this.camera,
|
|
2279
|
+
const max2d = vector3ToDevice(max, this.camera, width, height);
|
|
2280
|
+
const min2d = vector3ToDevice(min, this.camera, width, height);
|
|
2234
2281
|
const boundingBox2d = new Box2().setFromPoints([
|
|
2235
2282
|
new Vector23(max2d.x, max2d.y),
|
|
2236
2283
|
new Vector23(min2d.x, min2d.y)
|
|
2237
2284
|
]);
|
|
2238
2285
|
const size = boundingBox2d.getSize(new Vector23());
|
|
2239
|
-
const xScale = (
|
|
2240
|
-
const yScale = (
|
|
2286
|
+
const xScale = (width - right - left) / size.x;
|
|
2287
|
+
const yScale = (height - top - bottom) / size.y;
|
|
2241
2288
|
const scale = Math.min(xScale, yScale);
|
|
2242
2289
|
const center2 = new Vector38((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
|
|
2243
2290
|
return this.setZoom(scale * this.camera.zoom, center2, duration);
|
|
@@ -2341,6 +2388,11 @@ function getConfig(config) {
|
|
|
2341
2388
|
}
|
|
2342
2389
|
|
|
2343
2390
|
// src/bmap.ts
|
|
2391
|
+
var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
|
|
2392
|
+
MapTypePolar2[MapTypePolar2["D2"] = 0] = "D2";
|
|
2393
|
+
MapTypePolar2[MapTypePolar2["D3"] = 0.9] = "D3";
|
|
2394
|
+
return MapTypePolar2;
|
|
2395
|
+
})(MapTypePolar || {});
|
|
2344
2396
|
var BMap = class extends EventDispatcher6 {
|
|
2345
2397
|
constructor(container, config = {}) {
|
|
2346
2398
|
super();
|
|
@@ -2353,6 +2405,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2353
2405
|
__publicField(this, "svgPolygon");
|
|
2354
2406
|
__publicField(this, "basicZoom", 1);
|
|
2355
2407
|
__publicField(this, "prevCameraZoom", 1);
|
|
2408
|
+
__publicField(this, "type", "2d");
|
|
2356
2409
|
__publicField(this, "floorDataMap", /* @__PURE__ */ new Map());
|
|
2357
2410
|
__publicField(this, "buildingGroundMap", /* @__PURE__ */ new Map());
|
|
2358
2411
|
__publicField(this, "currentBuildGround", null);
|
|
@@ -2484,8 +2537,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2484
2537
|
curFloor.addGrounds(groundGraphics);
|
|
2485
2538
|
const graphicData = data.filter((item) => item.info.group !== "ground");
|
|
2486
2539
|
graphicData.forEach((item, index) => {
|
|
2487
|
-
item.info.
|
|
2488
|
-
item.info.height = 5 + index * 1e-4;
|
|
2540
|
+
item.info.height = 5;
|
|
2489
2541
|
});
|
|
2490
2542
|
const legacyToGraphicMap = /* @__PURE__ */ new Map();
|
|
2491
2543
|
const graphics = graphicData.map((item) => {
|
|
@@ -2511,6 +2563,7 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2511
2563
|
this.context.switchFloor(createdFloor.curFloor);
|
|
2512
2564
|
this.context.control.minZoom = 0;
|
|
2513
2565
|
this.context.control.maxZoom = Infinity;
|
|
2566
|
+
yield this.context.setAzimuthalAngle(0, 0);
|
|
2514
2567
|
yield this.context.fitCameraToGround(void 0, 0);
|
|
2515
2568
|
this.basicZoom = this.context.camera.zoom;
|
|
2516
2569
|
this.context.control.minZoom = this.basicZoom;
|
|
@@ -2586,12 +2639,21 @@ var BMap = class extends EventDispatcher6 {
|
|
|
2586
2639
|
* @param duration
|
|
2587
2640
|
*/
|
|
2588
2641
|
changeMapType(type, duration = 500) {
|
|
2642
|
+
this.type = type;
|
|
2589
2643
|
if (type === "2d") {
|
|
2590
|
-
return this.context.setPolarAngle(0
|
|
2644
|
+
return this.context.setPolarAngle(0 /* D2 */, duration);
|
|
2591
2645
|
} else {
|
|
2592
|
-
return this.context.setPolarAngle(0.9
|
|
2646
|
+
return this.context.setPolarAngle(0.9 /* D3 */, duration);
|
|
2593
2647
|
}
|
|
2594
2648
|
}
|
|
2649
|
+
resetView(duration = 300) {
|
|
2650
|
+
return __async(this, null, function* () {
|
|
2651
|
+
const time = duration / 3;
|
|
2652
|
+
yield this.context.setAzimuthalAngle(0, time);
|
|
2653
|
+
yield this.changeMapType(this.type, time);
|
|
2654
|
+
yield this.context.fitCameraToGround(void 0, time);
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2595
2657
|
/**
|
|
2596
2658
|
* 缩小地图
|
|
2597
2659
|
* @param zoom
|
|
@@ -2776,6 +2838,7 @@ export {
|
|
|
2776
2838
|
HeatmapElement,
|
|
2777
2839
|
HoverHelper,
|
|
2778
2840
|
Layer,
|
|
2841
|
+
MapTypePolar,
|
|
2779
2842
|
Overlay,
|
|
2780
2843
|
Poi,
|
|
2781
2844
|
PoiLayer,
|