@aibee/crc-bmap 0.0.65 → 0.0.67

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.esm.js CHANGED
@@ -44,7 +44,7 @@ var __async = (__this, __arguments, generator) => {
44
44
  };
45
45
 
46
46
  // src/bmap.ts
47
- import { EventDispatcher as EventDispatcher7 } from "three";
47
+ import { EventDispatcher as EventDispatcher7, Vector3 as Vector313 } from "three";
48
48
 
49
49
  // src/utils/timer.ts
50
50
  var Timer = class {
@@ -277,6 +277,7 @@ function clearCanvas() {
277
277
  }
278
278
 
279
279
  // src/utils/coordinate.ts
280
+ import { Vector3 } from "three";
280
281
  import { point, featureCollection, center } from "@turf/turf";
281
282
  function vector3ToDevice(vector, camera, w, h) {
282
283
  const _vector = vector.clone().project(camera);
@@ -294,6 +295,20 @@ function getCenter(coordinates) {
294
295
  function isContain(point3, start, end) {
295
296
  return point3.x >= start.x && point3.x <= end.x && point3.y >= start.y && point3.y <= end.y;
296
297
  }
298
+ function getLongestSideDir(cds) {
299
+ let maxDistance = 0;
300
+ let dir = new Vector3();
301
+ for (let i = 1; i < cds.length; i++) {
302
+ const point_0 = new Vector3(cds[i - 1][0], cds[i - 1][1], 0);
303
+ const point_1 = new Vector3(cds[i][0], cds[i][1], 0);
304
+ const distance = point_1.distanceTo(point_0);
305
+ if (distance > maxDistance) {
306
+ maxDistance = distance;
307
+ dir = point_1.clone().sub(point_0).normalize();
308
+ }
309
+ }
310
+ return dir;
311
+ }
297
312
 
298
313
  // src/utils/proxy.ts
299
314
  function proxyOptions(target, master) {
@@ -396,14 +411,46 @@ function addAlphaToHexColor(hexColor, alpha) {
396
411
  return newHexColor;
397
412
  }
398
413
 
414
+ // src/utils/model.ts
415
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
416
+ function createLoader() {
417
+ const loader2 = new GLTFLoader();
418
+ return loader2;
419
+ }
420
+ var loader = null;
421
+ var modelMap = /* @__PURE__ */ new Map();
422
+ function loadModel(url) {
423
+ if (modelMap.has(url)) {
424
+ const gltf = modelMap.get(url).then((gltf2) => {
425
+ gltf2.scene = gltf2.scene.clone();
426
+ return gltf2;
427
+ });
428
+ }
429
+ if (!loader) {
430
+ loader = createLoader();
431
+ }
432
+ const p = new Promise((resolve, reject) => {
433
+ loader.load(url, resolve, void 0, reject);
434
+ });
435
+ modelMap.set(url, p);
436
+ return p.then((gltf) => {
437
+ gltf.scene = gltf.scene.clone();
438
+ return gltf;
439
+ });
440
+ }
441
+ function disposeLoader() {
442
+ loader = null;
443
+ modelMap.clear();
444
+ }
445
+
399
446
  // src/context.ts
400
447
  import {
401
448
  EventDispatcher as EventDispatcher6,
402
449
  Box2,
403
- Vector3 as Vector39,
450
+ Vector3 as Vector312,
404
451
  Vector2 as Vector23,
405
452
  Raycaster as Raycaster3,
406
- Box3 as Box36,
453
+ Box3 as Box38,
407
454
  Color as Color4,
408
455
  AmbientLight as AmbientLight2
409
456
  } from "three";
@@ -418,7 +465,7 @@ import {
418
465
  ExtrudeGeometry,
419
466
  Mesh,
420
467
  Box3,
421
- Vector3,
468
+ Vector3 as Vector32,
422
469
  BufferGeometry,
423
470
  LineSegments
424
471
  } from "three";
@@ -529,7 +576,7 @@ var Graphic = class extends Object3D {
529
576
  if (this.options.geometry.type === "point") {
530
577
  return this.position.clone();
531
578
  }
532
- const center2 = new Vector3();
579
+ const center2 = new Vector32();
533
580
  const box = new Box3();
534
581
  box.setFromObject(this);
535
582
  box.getCenter(center2);
@@ -537,10 +584,10 @@ var Graphic = class extends Object3D {
537
584
  }
538
585
  getSize() {
539
586
  if (this.options.geometry.type === "point") {
540
- return new Vector3(0, 0, 0);
587
+ return new Vector32(0, 0, 0);
541
588
  }
542
589
  const box = new Box3();
543
- const size = new Vector3();
590
+ const size = new Vector32();
544
591
  box.setFromObject(this);
545
592
  box.getSize(size);
546
593
  return size;
@@ -606,8 +653,8 @@ var Graphic = class extends Object3D {
606
653
  for (let i = 0; i < curCds.length; i++) {
607
654
  const cur = curCds[i];
608
655
  const next = i + 1 === curCds.length ? curCds[0] : curCds[i + 1];
609
- points.push(new Vector3(cur[0], cur[1], height));
610
- points.push(new Vector3(next[0], next[1], height));
656
+ points.push(new Vector32(cur[0], cur[1], height));
657
+ points.push(new Vector32(next[0], next[1], height));
611
658
  }
612
659
  }
613
660
  return points;
@@ -724,10 +771,10 @@ var Shadow = class extends Object3D2 {
724
771
  };
725
772
 
726
773
  // src/elements/poi.ts
727
- import { EventDispatcher as EventDispatcher2, Vector3 as Vector34 } from "three";
774
+ import { EventDispatcher as EventDispatcher2, Vector3 as Vector35 } from "three";
728
775
 
729
776
  // src/elements/overlay.ts
730
- import { Box3 as Box32, EventDispatcher, Vector3 as Vector33 } from "three";
777
+ import { Box3 as Box32, EventDispatcher, Vector3 as Vector34 } from "three";
731
778
  var defaultOptions2 = {
732
779
  autoUpdate: true
733
780
  };
@@ -737,7 +784,7 @@ var Overlay = class extends EventDispatcher {
737
784
  this.context = context;
738
785
  __publicField(this, "div");
739
786
  __publicField(this, "element");
740
- __publicField(this, "position", new Vector33());
787
+ __publicField(this, "position", new Vector34());
741
788
  __publicField(this, "clientPos", { x: 0, y: 0 });
742
789
  __publicField(this, "visible", true);
743
790
  __publicField(this, "options");
@@ -788,7 +835,7 @@ var Overlay = class extends EventDispatcher {
788
835
  return this.element.getPosition();
789
836
  }
790
837
  const box = new Box32().setFromObject(this.element);
791
- const center2 = box.getCenter(new Vector33());
838
+ const center2 = box.getCenter(new Vector34());
792
839
  return center2;
793
840
  } else {
794
841
  return this.position;
@@ -837,7 +884,7 @@ var Poi = class extends EventDispatcher2 {
837
884
  __publicField(this, "options");
838
885
  __publicField(this, "visible", true);
839
886
  __publicField(this, "size", { width: 0, height: 0 });
840
- __publicField(this, "position", new Vector34());
887
+ __publicField(this, "position", new Vector35());
841
888
  __publicField(this, "_changePosition", () => {
842
889
  });
843
890
  this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions3), options), this);
@@ -1031,10 +1078,10 @@ var Poi = class extends EventDispatcher2 {
1031
1078
  };
1032
1079
 
1033
1080
  // src/elements/floor.ts
1034
- import { Box3 as Box34, Object3D as Object3D7, Vector3 as Vector36 } from "three";
1081
+ import { Box3 as Box35, Object3D as Object3D8, Vector3 as Vector38 } from "three";
1035
1082
 
1036
1083
  // src/layer/graphic-layer.ts
1037
- import { Box3 as Box33, Vector3 as Vector35 } from "three";
1084
+ import { Box3 as Box33, Vector3 as Vector36 } from "three";
1038
1085
 
1039
1086
  // src/layer/layer.ts
1040
1087
  import { Object3D as Object3D5 } from "three";
@@ -1057,7 +1104,7 @@ var GraphicLayer = class extends Layer {
1057
1104
  }
1058
1105
  getCenter() {
1059
1106
  const box = new Box33().setFromObject(this);
1060
- return box.getCenter(new Vector35());
1107
+ return box.getCenter(new Vector36());
1061
1108
  }
1062
1109
  createGraphic(options) {
1063
1110
  const graphic = new Graphic(this.context, options);
@@ -1337,8 +1384,63 @@ var HeatmapElement = class extends Object3D6 {
1337
1384
  }
1338
1385
  };
1339
1386
 
1387
+ // src/elements/model.ts
1388
+ import { Box3 as Box34, Object3D as Object3D7, Vector3 as Vector37 } from "three";
1389
+ var Model = class extends Object3D7 {
1390
+ constructor(context, options) {
1391
+ super();
1392
+ this.context = context;
1393
+ this.options = options;
1394
+ __publicField(this, "overlay", null);
1395
+ __publicField(this, "model", null);
1396
+ this.position.copy(options.position || new Vector37(0, 0, 0));
1397
+ this.loadModel();
1398
+ }
1399
+ loadModel() {
1400
+ return __async(this, null, function* () {
1401
+ const object = yield loadModel(this.options.modelUrl);
1402
+ console.log(object);
1403
+ object.scene.rotation.set(Math.PI / 2, Math.PI / 2, 0);
1404
+ this.add(object.scene);
1405
+ this.model = object;
1406
+ this.initOverlay();
1407
+ });
1408
+ }
1409
+ initOverlay() {
1410
+ var _a, _b;
1411
+ if (!this.options.icon) {
1412
+ return;
1413
+ }
1414
+ if (this.model) {
1415
+ const w = ((_a = this.options.icon_size) == null ? void 0 : _a[0]) || 14;
1416
+ const h = ((_b = this.options.icon_size) == null ? void 0 : _b[1]) || 14;
1417
+ const box = new Box34().setFromObject(this);
1418
+ const overlay = new Overlay(this.context, { autoUpdate: false });
1419
+ overlay.addEventListener("update-position", ({ x, y, height }) => {
1420
+ overlay.div.style.transform = `translate3d(${x - w / 2}px, ${-height + y - h}px, 0)`;
1421
+ });
1422
+ const img = document.createElement("img");
1423
+ img.src = this.options.icon;
1424
+ img.style.width = `${w}px`;
1425
+ img.style.height = `${h}px`;
1426
+ overlay.div.appendChild(img);
1427
+ const center2 = box.getCenter(new Vector37());
1428
+ overlay.position = center2;
1429
+ this.overlay = overlay;
1430
+ }
1431
+ }
1432
+ dispose() {
1433
+ dispose(this);
1434
+ this.model = null;
1435
+ if (this.overlay) {
1436
+ this.overlay.dispose();
1437
+ this.overlay = null;
1438
+ }
1439
+ }
1440
+ };
1441
+
1340
1442
  // src/elements/floor.ts
1341
- var Floor = class extends Object3D7 {
1443
+ var Floor = class extends Object3D8 {
1342
1444
  constructor(context) {
1343
1445
  super();
1344
1446
  this.context = context;
@@ -1347,13 +1449,15 @@ var Floor = class extends Object3D7 {
1347
1449
  __publicField(this, "grounds", /* @__PURE__ */ new Set());
1348
1450
  __publicField(this, "shadow", new Shadow());
1349
1451
  __publicField(this, "heatmap");
1350
- __publicField(this, "groundUpper", new Object3D7());
1452
+ __publicField(this, "groundUpper", new Object3D8());
1453
+ __publicField(this, "models", new Object3D8());
1351
1454
  __publicField(this, "groundMaxHeight", 0);
1352
1455
  this.graphicLayer = new GraphicLayer(this.context);
1353
1456
  this.poiLayer = new PoiLayer(this.context);
1354
1457
  this.groundUpper.add(this.graphicLayer);
1355
1458
  this.groundUpper.add(this.poiLayer);
1356
1459
  this.add(this.groundUpper);
1460
+ this.add(this.models);
1357
1461
  }
1358
1462
  createGround(options) {
1359
1463
  const ground = new Graphic(this.context, options);
@@ -1373,17 +1477,23 @@ var Floor = class extends Object3D7 {
1373
1477
  const grounds = Array.from(this.grounds);
1374
1478
  this.groundMaxHeight = this.grounds.size > 0 ? Math.max(...grounds.map((ground) => ground.options.height + ground.options.airHeight + ground.options.deltaHeight)) : 0;
1375
1479
  this.graphicLayer.position.z = this.groundMaxHeight;
1480
+ this.models.position.z = this.groundMaxHeight;
1376
1481
  }
1377
1482
  get hasElement() {
1378
1483
  return !!(this.grounds.size || this.graphicLayer.children.length);
1379
1484
  }
1380
1485
  getCenter() {
1381
- return new Box34().setFromObject(this.groundUpper).getCenter(new Vector36());
1486
+ return new Box35().setFromObject(this.groundUpper).getCenter(new Vector38());
1487
+ }
1488
+ addModel(options) {
1489
+ const model = new Model(this.context, options);
1490
+ this.models.add(model);
1491
+ return model;
1382
1492
  }
1383
1493
  addShadow() {
1384
- const box = new Box34().setFromObject(this.groundUpper);
1385
- const center2 = box.getCenter(new Vector36());
1386
- const size = box.getSize(new Vector36());
1494
+ const box = new Box35().setFromObject(this.groundUpper);
1495
+ const center2 = box.getCenter(new Vector38());
1496
+ const size = box.getSize(new Vector38());
1387
1497
  this.shadow.setPosition(center2);
1388
1498
  this.shadow.changeLightCamera(size);
1389
1499
  this.add(this.shadow);
@@ -1400,7 +1510,7 @@ var Floor = class extends Object3D7 {
1400
1510
  this.add(this.heatmap);
1401
1511
  }
1402
1512
  this.heatmap.loadData(data);
1403
- const box = new Box34().setFromObject(this.graphicLayer);
1513
+ const box = new Box35().setFromObject(this.graphicLayer);
1404
1514
  this.heatmap.position.setZ(box.max.z);
1405
1515
  return this.heatmap;
1406
1516
  }
@@ -1425,12 +1535,14 @@ var Floor = class extends Object3D7 {
1425
1535
  this.grounds.forEach((ground) => ground.dispose());
1426
1536
  (_a = this.heatmap) == null ? void 0 : _a.dispose();
1427
1537
  this.groundUpper.clear();
1538
+ this.models.children.forEach((model) => model.dispose());
1539
+ this.models.clear();
1428
1540
  this.clear();
1429
1541
  }
1430
1542
  };
1431
1543
 
1432
1544
  // src/elements/base-svg.ts
1433
- import { EventDispatcher as EventDispatcher3, Vector3 as Vector37 } from "three";
1545
+ import { EventDispatcher as EventDispatcher3, Vector3 as Vector39 } from "three";
1434
1546
  var BaseSvg = class extends EventDispatcher3 {
1435
1547
  constructor(context) {
1436
1548
  super();
@@ -1468,7 +1580,7 @@ var BaseSvg = class extends EventDispatcher3 {
1468
1580
  const { clientWidth, clientHeight } = renderer.domElement;
1469
1581
  const nx = x / clientWidth * 2 - 1;
1470
1582
  const ny = 1 - y / clientHeight * 2;
1471
- const v = new Vector37(nx, ny, 0);
1583
+ const v = new Vector39(nx, ny, 0);
1472
1584
  return v.unproject(camera);
1473
1585
  }
1474
1586
  getSvgCoordinate(vector) {
@@ -1722,7 +1834,7 @@ var SvgPolygon = class extends BaseSvg {
1722
1834
  };
1723
1835
 
1724
1836
  // src/elements/select-box.ts
1725
- import { Box3 as Box35 } from "three";
1837
+ import { Box3 as Box36 } from "three";
1726
1838
  var SelectBox = class extends BaseSvg {
1727
1839
  constructor(context) {
1728
1840
  super(context);
@@ -1741,7 +1853,7 @@ var SelectBox = class extends BaseSvg {
1741
1853
  setRectPosition(this.centerRect[i], 0, 0, 0, 0);
1742
1854
  }
1743
1855
  } else {
1744
- const box = new Box35().setFromObject(this.graphic);
1856
+ const box = new Box36().setFromObject(this.graphic);
1745
1857
  const { camera, container: { clientWidth: w, clientHeight: h } } = this.context;
1746
1858
  const { min, max } = box;
1747
1859
  const leftBottom = vector3ToDevice(min, camera, w, h);
@@ -2186,6 +2298,92 @@ var MaterialFactory = class {
2186
2298
  }
2187
2299
  };
2188
2300
 
2301
+ // src/utils/camera-bound.ts
2302
+ import { Box3 as Box37, Vector3 as Vector311 } from "three";
2303
+ var CameraBound = class {
2304
+ constructor(context) {
2305
+ this.context = context;
2306
+ __publicField(this, "prevCamera", {
2307
+ position: new Vector311(),
2308
+ zoom: 1,
2309
+ target: new Vector311()
2310
+ });
2311
+ __publicField(this, "enable", true);
2312
+ __publicField(this, "onCameraChange", () => {
2313
+ const bound = this.getCurFloorScreenPosition();
2314
+ if (bound) {
2315
+ const { leftBottom, rightTop } = bound;
2316
+ const isInBound = this.checkDistanceToScreenEdge(leftBottom, rightTop);
2317
+ if (isInBound) {
2318
+ this.changePrevCamera();
2319
+ } else {
2320
+ this.backToPrevCamera();
2321
+ }
2322
+ }
2323
+ });
2324
+ this.registryEvent();
2325
+ this.changePrevCamera();
2326
+ }
2327
+ setEnable(enable) {
2328
+ this.enable = enable;
2329
+ if (enable) {
2330
+ this.registryEvent();
2331
+ } else {
2332
+ this.unRegistryEvent();
2333
+ }
2334
+ }
2335
+ changePrevCamera() {
2336
+ this.prevCamera = {
2337
+ position: this.context.camera.position.clone(),
2338
+ zoom: this.context.camera.zoom,
2339
+ target: this.context.control.target.clone()
2340
+ };
2341
+ }
2342
+ backToPrevCamera() {
2343
+ this.setEnable(false);
2344
+ this.context.camera.position.copy(this.prevCamera.position);
2345
+ this.context.camera.zoom = this.prevCamera.zoom;
2346
+ this.context.control.target.copy(this.prevCamera.target);
2347
+ this.context.control.update();
2348
+ this.setEnable(true);
2349
+ }
2350
+ registryEvent() {
2351
+ this.context.addEventListener("control-change", this.onCameraChange);
2352
+ }
2353
+ unRegistryEvent() {
2354
+ this.context.removeEventListener("control-change", this.onCameraChange);
2355
+ }
2356
+ getCurFloorScreenPosition() {
2357
+ if (!this.context.currentFloor) {
2358
+ return null;
2359
+ }
2360
+ const box = new Box37().setFromObject(this.context.currentFloor.groundUpper);
2361
+ const { camera, container: { clientWidth: w, clientHeight: h } } = this.context;
2362
+ const { min, max } = box;
2363
+ const leftBottom = vector3ToDevice(min, camera, w, h);
2364
+ const rightTop = vector3ToDevice(max, camera, w, h);
2365
+ return { leftBottom, rightTop };
2366
+ }
2367
+ /**
2368
+ * 检测地图是不是在显示范围
2369
+ * @param leftBottom
2370
+ * @param rightTop
2371
+ * @returns { boolean }
2372
+ */
2373
+ checkDistanceToScreenEdge(leftBottom, rightTop) {
2374
+ const { width, height } = this.context.clientSize;
2375
+ const [pt, pr, pb, pl] = this.context.config.cameraBound.padding;
2376
+ const left = leftBottom.x;
2377
+ const right = width - rightTop.x;
2378
+ const top = rightTop.y;
2379
+ const bottom = height - leftBottom.y;
2380
+ return left < pl && right < pr && top < pt && bottom < pb;
2381
+ }
2382
+ dispose() {
2383
+ this.unRegistryEvent();
2384
+ }
2385
+ };
2386
+
2189
2387
  // src/context.ts
2190
2388
  var Context = class extends EventDispatcher6 {
2191
2389
  constructor(container, config) {
@@ -2206,7 +2404,7 @@ var Context = class extends EventDispatcher6 {
2206
2404
  __publicField(this, "basicRatio");
2207
2405
  // zoom=1的时候,100M对应的像素个数
2208
2406
  __publicField(this, "materialFactory");
2209
- __publicField(this, "observe", null);
2407
+ __publicField(this, "cameraBound");
2210
2408
  __publicField(this, "clientSize", {
2211
2409
  width: 0,
2212
2410
  height: 0
@@ -2289,11 +2487,12 @@ var Context = class extends EventDispatcher6 {
2289
2487
  this.dispatchEvent({ type: "change-ratio", px: (this.basicRatio || 0) * this.camera.zoom });
2290
2488
  this.dispatchEvent({ type: "control-change" });
2291
2489
  });
2490
+ this.cameraBound = new CameraBound(this);
2292
2491
  }
2293
2492
  /**
2294
2493
  * 获取两个点之间的像素数
2295
2494
  */
2296
- getRatio(point1 = new Vector39(0, 0, 0), point22 = new Vector39(100, 0, 0)) {
2495
+ getRatio(point1 = new Vector312(0, 0, 0), point22 = new Vector312(100, 0, 0)) {
2297
2496
  const { clientWidth, clientHeight } = this.container;
2298
2497
  const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
2299
2498
  const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
@@ -2433,7 +2632,7 @@ var Context = class extends EventDispatcher6 {
2433
2632
  );
2434
2633
  }
2435
2634
  getCameraLookAt() {
2436
- return new Vector39().subVectors(this.control.target, this.camera.position);
2635
+ return new Vector312().subVectors(this.control.target, this.camera.position);
2437
2636
  }
2438
2637
  /**
2439
2638
  * 按照一个中心点设置相机的放大缩小
@@ -2492,7 +2691,7 @@ var Context = class extends EventDispatcher6 {
2492
2691
  if (force2DView) {
2493
2692
  this.setPolarAngle(0, 0);
2494
2693
  }
2495
- const boundingBox = new Box36().setFromObject(object);
2694
+ const boundingBox = new Box38().setFromObject(object);
2496
2695
  this.setPolarAngle(polar, 0);
2497
2696
  const { max, min } = boundingBox;
2498
2697
  const max2d = vector3ToDevice(max, this.camera, width, height);
@@ -2505,7 +2704,7 @@ var Context = class extends EventDispatcher6 {
2505
2704
  const xScale = (width - right - left) / size.x;
2506
2705
  const yScale = (height - top - bottom) / size.y;
2507
2706
  const scale = Math.min(xScale, yScale);
2508
- const center2 = new Vector39((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
2707
+ const center2 = new Vector312((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
2509
2708
  return this.setZoom(scale * this.camera.zoom, center2, duration);
2510
2709
  }
2511
2710
  fitCameraToGround(padding = [20, 20, 20, 20], duration = 500, force2DView = true) {
@@ -2551,6 +2750,7 @@ var Context = class extends EventDispatcher6 {
2551
2750
  this.tweenGroup.update();
2552
2751
  }
2553
2752
  dispose() {
2753
+ this.cameraBound.dispose();
2554
2754
  this.selection.dispose();
2555
2755
  this.hoverHelper.dispose();
2556
2756
  this.tweenGroup.getAll().forEach((item) => item.stop());
@@ -2625,6 +2825,9 @@ var defaultConfig = {
2625
2825
  },
2626
2826
  graphic: {
2627
2827
  fillOpacity: 1
2828
+ },
2829
+ cameraBound: {
2830
+ padding: [150, 150, 150, 150]
2628
2831
  }
2629
2832
  };
2630
2833
  function getConfig(config) {
@@ -2689,6 +2892,7 @@ var BMap = class extends EventDispatcher7 {
2689
2892
  }
2690
2893
  });
2691
2894
  __publicField(this, "resize", () => {
2895
+ this.context.cameraBound.setEnable(false);
2692
2896
  this.context.onWindowResize();
2693
2897
  const azimuthal = this.context.control.getAzimuthalAngle();
2694
2898
  const zoom = this.context.camera.zoom;
@@ -2703,6 +2907,7 @@ var BMap = class extends EventDispatcher7 {
2703
2907
  this.context.camera.zoom = zoom;
2704
2908
  this.context.control.addEventListener("change", this.onControlChange);
2705
2909
  this.context.setAzimuthalAngle(azimuthal, 0);
2910
+ this.context.cameraBound.setEnable(true);
2706
2911
  });
2707
2912
  this.config = getConfig(config);
2708
2913
  this.context = new Context(container, this.config);
@@ -2842,6 +3047,7 @@ var BMap = class extends EventDispatcher7 {
2842
3047
  this.currentBuildGround = this.buildingGroundMap.get(buildingKey) || null;
2843
3048
  const createdFloor = this.createFloor(curFloorData);
2844
3049
  if (createdFloor) {
3050
+ this.context.cameraBound.setEnable(false);
2845
3051
  this.context.switchFloor(createdFloor.curFloor);
2846
3052
  this.context.control.minZoom = 0;
2847
3053
  this.context.control.maxZoom = Infinity;
@@ -2856,6 +3062,7 @@ var BMap = class extends EventDispatcher7 {
2856
3062
  this.context.fitCameraToGround([80, 20, 80, 20], 0, false);
2857
3063
  }
2858
3064
  this.onControlChange();
3065
+ this.context.cameraBound.setEnable(true);
2859
3066
  } else {
2860
3067
  console.warn("[switchFloor error] [" + floor + "] \u697C\u5C42\u6CA1\u6709\u6570\u636E");
2861
3068
  }
@@ -2863,6 +3070,20 @@ var BMap = class extends EventDispatcher7 {
2863
3070
  console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42");
2864
3071
  }
2865
3072
  }
3073
+ // 扶梯
3074
+ addModel(graphic, options) {
3075
+ var _a;
3076
+ if (graphic.options.geometry.type === "polygon") {
3077
+ const model = (_a = this.context.currentFloor) == null ? void 0 : _a.addModel(__spreadProps(__spreadValues({}, options), {
3078
+ position: graphic.getPosition().setZ(0.1)
3079
+ }));
3080
+ if (model) {
3081
+ const dir = getLongestSideDir(graphic.options.geometry.cds[0]);
3082
+ const angleY = dir.angleTo(new Vector313(0, 1, 0));
3083
+ model.rotateZ(angleY);
3084
+ }
3085
+ }
3086
+ }
2866
3087
  addHeatmap(data) {
2867
3088
  var _a;
2868
3089
  return (_a = this.context.currentFloor) == null ? void 0 : _a.addHeatmap(data);
@@ -2905,6 +3126,18 @@ var BMap = class extends EventDispatcher7 {
2905
3126
  const position = ele.getPosition();
2906
3127
  return this.context.setCameraPosition(position, duration);
2907
3128
  }
3129
+ /**
3130
+ * 移动相机位置让选中的元素居中显示
3131
+ * @param ele { Graphic | Poi }
3132
+ * @param duration
3133
+ */
3134
+ translateElementToCenterX(ele, duration = 500) {
3135
+ const { y, z } = this.context.camera.position;
3136
+ const position = ele.getPosition();
3137
+ position.setY(y);
3138
+ position.setZ(z);
3139
+ return this.context.setCameraPosition(position, duration);
3140
+ }
2908
3141
  /**
2909
3142
  * 获取物体的屏幕坐标
2910
3143
  */
@@ -3119,6 +3352,7 @@ var BMap = class extends EventDispatcher7 {
3119
3352
  this.buildingGroundMap.clear();
3120
3353
  clearTextTexture();
3121
3354
  clearCanvas();
3355
+ disposeLoader();
3122
3356
  this.unRegistryEvent();
3123
3357
  }
3124
3358
  };
@@ -3133,6 +3367,7 @@ export {
3133
3367
  HoverHelper,
3134
3368
  Layer,
3135
3369
  MapTypePolar,
3370
+ Model,
3136
3371
  Overlay,
3137
3372
  Poi,
3138
3373
  PoiLayer,
@@ -3153,8 +3388,10 @@ export {
3153
3388
  createSvgElement,
3154
3389
  defaultConfig,
3155
3390
  dispose,
3391
+ disposeLoader,
3156
3392
  getCenter,
3157
3393
  getConfig,
3394
+ getLongestSideDir,
3158
3395
  getTextureByText,
3159
3396
  hasChinese,
3160
3397
  initCamera,
@@ -3166,6 +3403,7 @@ export {
3166
3403
  initScene,
3167
3404
  initShape,
3168
3405
  isContain,
3406
+ loadModel,
3169
3407
  proxyOptions,
3170
3408
  setCirclePosition,
3171
3409
  setLineStartEnd,