@aibee/crc-bmap 0.0.49 → 0.0.50

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 EventDispatcher6 } from "three";
47
+ import { EventDispatcher as EventDispatcher7 } from "three";
48
48
 
49
49
  // src/utils/timer.ts
50
50
  var Timer = class {
@@ -372,6 +372,11 @@ function setRectPosition(rect, x, y, w, h) {
372
372
  function sleepOnePromise() {
373
373
  return Promise.resolve();
374
374
  }
375
+ function sleepOneRf() {
376
+ return new Promise((resolve) => {
377
+ requestAnimationFrame(resolve);
378
+ });
379
+ }
375
380
 
376
381
  // src/utils/color.ts
377
382
  function strToNumber(str) {
@@ -390,9 +395,9 @@ function addAlphaToHexColor(hexColor, alpha) {
390
395
 
391
396
  // src/context.ts
392
397
  import {
393
- EventDispatcher as EventDispatcher5,
398
+ EventDispatcher as EventDispatcher6,
394
399
  Box2,
395
- Vector3 as Vector38,
400
+ Vector3 as Vector39,
396
401
  Vector2 as Vector23,
397
402
  Raycaster as Raycaster3,
398
403
  Box3 as Box36,
@@ -402,7 +407,7 @@ import {
402
407
  import { Group as TweenGroup, Tween } from "@tweenjs/tween.js";
403
408
 
404
409
  // src/operations/selection/selection.ts
405
- import { EventDispatcher as EventDispatcher3 } from "three";
410
+ import { EventDispatcher as EventDispatcher4 } from "three";
406
411
 
407
412
  // src/elements/graphic.ts
408
413
  import {
@@ -715,7 +720,7 @@ var Shadow = class extends Object3D2 {
715
720
  };
716
721
 
717
722
  // src/elements/poi.ts
718
- import { Object3D as Object3D4 } from "three";
723
+ import { EventDispatcher as EventDispatcher2, Vector3 as Vector34 } from "three";
719
724
 
720
725
  // src/elements/overlay.ts
721
726
  import { Box3 as Box32, EventDispatcher, Vector3 as Vector33 } from "three";
@@ -736,8 +741,7 @@ var Overlay = class extends EventDispatcher {
736
741
  return;
737
742
  }
738
743
  this.clientPos = { x, y };
739
- this.div.style.left = `${x}px`;
740
- this.div.style.top = `${y}px`;
744
+ this.div.style.transform = `translate3d(${x}px, ${-height + y}px, 0)`;
741
745
  });
742
746
  this.registryEvent();
743
747
  this.div = this.initDiv();
@@ -805,18 +809,20 @@ var defaultOptions2 = {
805
809
  id: "",
806
810
  position: { x: 0, y: 0, z: 0 }
807
811
  };
808
- var Poi = class extends Object3D4 {
812
+ var Poi = class extends EventDispatcher2 {
809
813
  constructor(context, options) {
810
814
  var _a, _b, _c;
811
815
  super();
812
816
  this.context = context;
817
+ __publicField(this, "div");
813
818
  __publicField(this, "textDiv");
814
819
  __publicField(this, "img");
815
820
  __publicField(this, "overlay");
816
821
  __publicField(this, "options");
817
822
  __publicField(this, "size", { width: 0, height: 0 });
823
+ __publicField(this, "position", new Vector34());
818
824
  __publicField(this, "_changePosition", () => {
819
- this.overlay.div.style.transform = `translate3d(-50%, ${this.options.icon ? "-100%" : "-50%"}, 0)`;
825
+ this.div.style.transform = `translate3d(-50%, ${this.options.icon ? "-100%" : "-50%"}, 0)`;
820
826
  });
821
827
  this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions2), options), this);
822
828
  this.position.set(((_a = options.position) == null ? void 0 : _a.x) || 0, ((_b = options.position) == null ? void 0 : _b.y) || 0, ((_c = options.position) == null ? void 0 : _c.z) || 0);
@@ -827,19 +833,20 @@ var Poi = class extends Object3D4 {
827
833
  this.addEventListener("change-icon", ({ value }) => {
828
834
  if (value) {
829
835
  if (!this.img) {
830
- this.overlay.div.appendChild(this.initIcon());
836
+ this.div.appendChild(this.initIcon());
831
837
  } else {
832
838
  this.img.setAttribute("src", value);
833
839
  }
834
840
  } else {
835
- this.img && this.overlay.div.removeChild(this.img);
841
+ this.img && this.div.removeChild(this.img);
836
842
  this.img = void 0;
843
+ this._changePosition();
837
844
  this.resetSize();
838
845
  }
839
846
  });
840
847
  this.addEventListener("change-texts", ({ value }) => {
841
- this.overlay.div.removeChild(this.textDiv);
842
- this.overlay.div.appendChild(this.initText());
848
+ this.div.removeChild(this.textDiv);
849
+ this.div.appendChild(this.initText());
843
850
  this.resetSize();
844
851
  });
845
852
  this.addEventListener("change-opacity", ({ value }) => {
@@ -858,24 +865,25 @@ var Poi = class extends Object3D4 {
858
865
  }
859
866
  resetSize() {
860
867
  return __async(this, null, function* () {
861
- const visible = this.overlay.visible;
862
- this.setVisible(true);
863
868
  yield sleepOnePromise();
864
- const { width, height } = this.overlay.div.getBoundingClientRect();
869
+ const { width, height } = this.div.getBoundingClientRect();
865
870
  this.size = {
866
- width,
867
- height
871
+ width: width + 4,
872
+ height: height + 4
868
873
  };
869
- yield sleepOnePromise();
870
- this._changePosition();
871
- this.setVisible(visible);
872
874
  });
873
875
  }
876
+ renderHelperBox() {
877
+ const div = document.createElement("div");
878
+ const box = this.getBox();
879
+ div.style.cssText = `position: absolute; top: ${box.top}px;left: ${box.left}px;width: ${box.right - box.left}px;height: ${box.bottom - box.top}px;border: 1px solid red;`;
880
+ this.context.container.appendChild(div);
881
+ }
874
882
  get clientPos() {
875
883
  return this.overlay.clientPos;
876
884
  }
877
885
  initDiv() {
878
- const div = this.overlay.div;
886
+ const div = document.createElement("div");
879
887
  div.appendChild(this.initText());
880
888
  if (this.options.icon) {
881
889
  div.appendChild(this.initIcon());
@@ -886,9 +894,12 @@ var Poi = class extends Object3D4 {
886
894
  div.style.flexDirection = `column`;
887
895
  div.style.justifyContent = `center`;
888
896
  div.style.alignItems = `center`;
889
- div.style.pointerEvents = `none`;
890
- div.style.userSelect = `none`;
891
897
  this.overlay.setOpacity(this.options.opacity);
898
+ this.overlay.div.style.pointerEvents = `none`;
899
+ this.overlay.div.style.userSelect = `none`;
900
+ this.overlay.div.appendChild(div);
901
+ this.div = div;
902
+ this._changePosition();
892
903
  this.resetSize();
893
904
  return div;
894
905
  }
@@ -899,11 +910,6 @@ var Poi = class extends Object3D4 {
899
910
  const textDiv = document.createElement("div");
900
911
  textDiv.appendChild(this.createTextFragment());
901
912
  if (this.options.texts.length > 1) {
902
- textDiv.style.background = "rgba(255, 255, 255, .7)";
903
- textDiv.style.padding = "2px 4px";
904
- textDiv.style.borderRadius = "4px";
905
- textDiv.style.fontSize = "12px";
906
- textDiv.style.lineHeight = "16px";
907
913
  }
908
914
  this.textDiv = textDiv;
909
915
  return textDiv;
@@ -930,6 +936,7 @@ var Poi = class extends Object3D4 {
930
936
  img.style.width = `${((_a = this.options.icon_size) == null ? void 0 : _a[0]) || 32}px`;
931
937
  img.style.height = `${((_b = this.options.icon_size) == null ? void 0 : _b[1]) || 32}px`;
932
938
  img.onload = () => {
939
+ this._changePosition();
933
940
  this.resetSize();
934
941
  };
935
942
  this.img = img;
@@ -940,7 +947,11 @@ var Poi = class extends Object3D4 {
940
947
  unRegistryEvent() {
941
948
  }
942
949
  setVisible(visible) {
943
- this.overlay.setVisible(visible, "flex");
950
+ if (visible === this.overlay.visible) {
951
+ return;
952
+ }
953
+ this.overlay.visible = visible;
954
+ this.overlay.div.style.visibility = visible ? "visible" : "hidden";
944
955
  }
945
956
  getBox() {
946
957
  const { width, height } = this.size;
@@ -961,6 +972,7 @@ var Poi = class extends Object3D4 {
961
972
  }
962
973
  dispose() {
963
974
  this.unRegistryEvent();
975
+ this.div = null;
964
976
  this.textDiv = null;
965
977
  this.img = void 0;
966
978
  this.overlay.dispose();
@@ -968,10 +980,10 @@ var Poi = class extends Object3D4 {
968
980
  };
969
981
 
970
982
  // src/elements/floor.ts
971
- import { Box3 as Box34, Object3D as Object3D7, Vector3 as Vector35 } from "three";
983
+ import { Box3 as Box34, Object3D as Object3D7, Vector3 as Vector36 } from "three";
972
984
 
973
985
  // src/layer/graphic-layer.ts
974
- import { Box3 as Box33, Vector3 as Vector34 } from "three";
986
+ import { Box3 as Box33, Vector3 as Vector35 } from "three";
975
987
 
976
988
  // src/layer/layer.ts
977
989
  import { Object3D as Object3D5 } from "three";
@@ -994,7 +1006,7 @@ var GraphicLayer = class extends Layer {
994
1006
  }
995
1007
  getCenter() {
996
1008
  const box = new Box33().setFromObject(this);
997
- return box.getCenter(new Vector34());
1009
+ return box.getCenter(new Vector35());
998
1010
  }
999
1011
  createGraphic(options) {
1000
1012
  const graphic = new Graphic(this.context, options);
@@ -1069,7 +1081,6 @@ var PoiLayer = class extends Layer {
1069
1081
  }
1070
1082
  createPoi(options) {
1071
1083
  const poi = new Poi(this.context, options);
1072
- this.add(poi);
1073
1084
  this.pushPoi(poi);
1074
1085
  poi.addEventListener("change-level", () => this.changePoiLevelOrCollisionEnable(poi));
1075
1086
  poi.addEventListener("change-collision_enable", () => this.changePoiLevelOrCollisionEnable(poi));
@@ -1092,7 +1103,6 @@ var PoiLayer = class extends Layer {
1092
1103
  return;
1093
1104
  }
1094
1105
  this.pois.splice(index, 1);
1095
- this.remove(poi);
1096
1106
  poi.dispose();
1097
1107
  }
1098
1108
  removePoiById(id) {
@@ -1131,7 +1141,7 @@ var PoiLayer = class extends Layer {
1131
1141
  this.pois.push(poi);
1132
1142
  }
1133
1143
  getPoiByDeviceXy(x, y) {
1134
- const pois = this.children.filter((item) => {
1144
+ const pois = this.pois.filter((item) => {
1135
1145
  return item instanceof Poi && item.isContain(x, y);
1136
1146
  });
1137
1147
  return pois;
@@ -1140,7 +1150,6 @@ var PoiLayer = class extends Layer {
1140
1150
  * 碰撞检测
1141
1151
  */
1142
1152
  collisionDetection() {
1143
- const { clientSize: { width, height } } = this.context;
1144
1153
  const range = [];
1145
1154
  const pois = this.pois.filter((item) => item.withinDisplayRange);
1146
1155
  pois.forEach((item, index) => {
@@ -1314,12 +1323,12 @@ var Floor = class extends Object3D7 {
1314
1323
  return !!(this.grounds.size || this.graphicLayer.children.length);
1315
1324
  }
1316
1325
  getCenter() {
1317
- return new Box34().setFromObject(this.groundUpper).getCenter(new Vector35());
1326
+ return new Box34().setFromObject(this.groundUpper).getCenter(new Vector36());
1318
1327
  }
1319
1328
  addShadow() {
1320
1329
  const box = new Box34().setFromObject(this.groundUpper);
1321
- const center2 = box.getCenter(new Vector35());
1322
- const size = box.getSize(new Vector35());
1330
+ const center2 = box.getCenter(new Vector36());
1331
+ const size = box.getSize(new Vector36());
1323
1332
  this.shadow.setPosition(center2);
1324
1333
  this.shadow.changeLightCamera(size);
1325
1334
  this.add(this.shadow);
@@ -1367,8 +1376,8 @@ var Floor = class extends Object3D7 {
1367
1376
  };
1368
1377
 
1369
1378
  // src/elements/base-svg.ts
1370
- import { EventDispatcher as EventDispatcher2, Vector3 as Vector36 } from "three";
1371
- var BaseSvg = class extends EventDispatcher2 {
1379
+ import { EventDispatcher as EventDispatcher3, Vector3 as Vector37 } from "three";
1380
+ var BaseSvg = class extends EventDispatcher3 {
1372
1381
  constructor(context) {
1373
1382
  super();
1374
1383
  this.context = context;
@@ -1392,7 +1401,7 @@ var BaseSvg = class extends EventDispatcher2 {
1392
1401
  const { clientWidth, clientHeight } = renderer.domElement;
1393
1402
  const nx = x / clientWidth * 2 - 1;
1394
1403
  const ny = 1 - y / clientHeight * 2;
1395
- const v = new Vector36(nx, ny, 0);
1404
+ const v = new Vector37(nx, ny, 0);
1396
1405
  return v.unproject(camera);
1397
1406
  }
1398
1407
  getSvgCoordinate(vector) {
@@ -1880,7 +1889,7 @@ var BoxSelection = class extends BaseSvg {
1880
1889
  };
1881
1890
 
1882
1891
  // src/operations/selection/selection.ts
1883
- var Selection = class extends EventDispatcher3 {
1892
+ var Selection = class extends EventDispatcher4 {
1884
1893
  constructor(context) {
1885
1894
  super();
1886
1895
  this.context = context;
@@ -1980,8 +1989,8 @@ var Selection = class extends EventDispatcher3 {
1980
1989
  };
1981
1990
 
1982
1991
  // src/operations/hover/hover-helper.ts
1983
- import { EventDispatcher as EventDispatcher4 } from "three";
1984
- var HoverHelper = class extends EventDispatcher4 {
1992
+ import { EventDispatcher as EventDispatcher5 } from "three";
1993
+ var HoverHelper = class extends EventDispatcher5 {
1985
1994
  constructor(context) {
1986
1995
  super();
1987
1996
  this.context = context;
@@ -2102,7 +2111,7 @@ var MaterialFactory = class {
2102
2111
  };
2103
2112
 
2104
2113
  // src/context.ts
2105
- var Context = class extends EventDispatcher5 {
2114
+ var Context = class extends EventDispatcher6 {
2106
2115
  constructor(container, config) {
2107
2116
  super();
2108
2117
  this.container = container;
@@ -2204,7 +2213,7 @@ var Context = class extends EventDispatcher5 {
2204
2213
  /**
2205
2214
  * 获取两个点之间的像素数
2206
2215
  */
2207
- getRatio(point1 = new Vector38(0, 0, 0), point22 = new Vector38(100, 0, 0)) {
2216
+ getRatio(point1 = new Vector39(0, 0, 0), point22 = new Vector39(100, 0, 0)) {
2208
2217
  const { clientWidth, clientHeight } = this.container;
2209
2218
  const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
2210
2219
  const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
@@ -2344,7 +2353,7 @@ var Context = class extends EventDispatcher5 {
2344
2353
  );
2345
2354
  }
2346
2355
  getCameraLookAt() {
2347
- return new Vector38().subVectors(this.control.target, this.camera.position);
2356
+ return new Vector39().subVectors(this.control.target, this.camera.position);
2348
2357
  }
2349
2358
  /**
2350
2359
  * 按照一个中心点设置相机的放大缩小
@@ -2414,7 +2423,7 @@ var Context = class extends EventDispatcher5 {
2414
2423
  const xScale = (width - right - left) / size.x;
2415
2424
  const yScale = (height - top - bottom) / size.y;
2416
2425
  const scale = Math.min(xScale, yScale);
2417
- const center2 = new Vector38((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
2426
+ const center2 = new Vector39((max.x + min.x) / 2, (max.y + min.y) / 2, max.z);
2418
2427
  return this.setZoom(scale * this.camera.zoom, center2, duration);
2419
2428
  }
2420
2429
  fitCameraToGround(padding = [20, 20, 20, 20], duration = 500) {
@@ -2515,7 +2524,7 @@ var defaultConfig = {
2515
2524
  ground: {
2516
2525
  color: "#ffffff",
2517
2526
  opacity: 1,
2518
- height: 5,
2527
+ height: 3,
2519
2528
  stroke: true,
2520
2529
  strokeColor: "#E6E6E6",
2521
2530
  strokeOpacity: 1
@@ -2539,7 +2548,7 @@ var MapTypePolar = /* @__PURE__ */ ((MapTypePolar2) => {
2539
2548
  MapTypePolar2[MapTypePolar2["D3"] = 0.9] = "D3";
2540
2549
  return MapTypePolar2;
2541
2550
  })(MapTypePolar || {});
2542
- var BMap = class extends EventDispatcher6 {
2551
+ var BMap = class extends EventDispatcher7 {
2543
2552
  constructor(container, config = {}) {
2544
2553
  super();
2545
2554
  this.container = container;
@@ -2774,7 +2783,7 @@ var BMap = class extends EventDispatcher6 {
2774
2783
  * @param duration
2775
2784
  */
2776
2785
  translateElementToCenter(ele, duration = 500) {
2777
- const position = ele.position.clone().setFromMatrixPosition(ele.matrixWorld);
2786
+ const position = ele.getPosition();
2778
2787
  return this.context.setCameraPosition(position, duration);
2779
2788
  }
2780
2789
  /**
@@ -3036,6 +3045,7 @@ export {
3036
3045
  setLineStartEnd,
3037
3046
  setRectPosition,
3038
3047
  sleepOnePromise,
3048
+ sleepOneRf,
3039
3049
  strToNumber,
3040
3050
  timeoutPromise,
3041
3051
  vector3ToDevice