@aibee/crc-bmap 0.0.52 → 0.0.54

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
@@ -724,8 +724,11 @@ import { EventDispatcher as EventDispatcher2, Vector3 as Vector34 } from "three"
724
724
 
725
725
  // src/elements/overlay.ts
726
726
  import { Box3 as Box32, EventDispatcher, Vector3 as Vector33 } from "three";
727
+ var defaultOptions2 = {
728
+ autoUpdate: true
729
+ };
727
730
  var Overlay = class extends EventDispatcher {
728
- constructor(context) {
731
+ constructor(context, options = {}) {
729
732
  super();
730
733
  this.context = context;
731
734
  __publicField(this, "div");
@@ -733,6 +736,7 @@ var Overlay = class extends EventDispatcher {
733
736
  __publicField(this, "position", new Vector33());
734
737
  __publicField(this, "clientPos", { x: 0, y: 0 });
735
738
  __publicField(this, "visible", true);
739
+ __publicField(this, "options");
736
740
  __publicField(this, "onUpdate", () => {
737
741
  const vector = this.getPosition();
738
742
  const { width, height } = this.context.clientSize;
@@ -741,8 +745,13 @@ var Overlay = class extends EventDispatcher {
741
745
  return;
742
746
  }
743
747
  this.clientPos = { x, y };
744
- this.div.style.transform = `translate3d(${x}px, ${-height + y}px, 0)`;
748
+ if (this.options.autoUpdate) {
749
+ this.div.style.transform = `translate3d(${x}px, ${-height + y}px, 0)`;
750
+ } else {
751
+ this.dispatchEvent({ type: "update-position", x, y, width, height });
752
+ }
745
753
  });
754
+ this.options = __spreadValues(__spreadValues({}, defaultOptions2), options);
746
755
  this.registryEvent();
747
756
  this.div = this.initDiv();
748
757
  this.context.container.appendChild(this.div);
@@ -801,7 +810,7 @@ var Overlay = class extends EventDispatcher {
801
810
  };
802
811
 
803
812
  // src/elements/poi.ts
804
- var defaultOptions2 = {
813
+ var defaultOptions3 = {
805
814
  texts: [{ text: "" }],
806
815
  level: 1,
807
816
  collision_enable: true,
@@ -824,7 +833,7 @@ var Poi = class extends EventDispatcher2 {
824
833
  __publicField(this, "_changePosition", () => {
825
834
  this.div.style.transform = `translate3d(-50%, ${this.options.icon ? "-100%" : "-50%"}, 0)`;
826
835
  });
827
- this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions2), options), this);
836
+ this.options = proxyOptions(__spreadValues(__spreadValues({}, defaultOptions3), options), this);
828
837
  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);
829
838
  this.overlay = new Overlay(this.context);
830
839
  this.overlay.bindElement(this);
@@ -1384,8 +1393,21 @@ var BaseSvg = class extends EventDispatcher3 {
1384
1393
  __publicField(this, "points", []);
1385
1394
  __publicField(this, "svg");
1386
1395
  __publicField(this, "enable", true);
1396
+ __publicField(this, "_onResize", ({ width, height }) => {
1397
+ if (this.svg) {
1398
+ this.svg.setAttribute("width", `${width}`);
1399
+ this.svg.setAttribute("height", `${height}`);
1400
+ }
1401
+ });
1387
1402
  this.svg = createSvg(`${context.container.clientWidth}`, `${context.container.clientHeight}`);
1388
1403
  context.container.appendChild(this.svg);
1404
+ this._registryEvent();
1405
+ }
1406
+ _registryEvent() {
1407
+ this.context.addEventListener("resize", this._onResize);
1408
+ }
1409
+ _unRegistryEvent() {
1410
+ this.context.removeEventListener("resize", this._onResize);
1389
1411
  }
1390
1412
  setEnable(enable) {
1391
1413
  this.enable = enable;
@@ -1410,6 +1432,7 @@ var BaseSvg = class extends EventDispatcher3 {
1410
1432
  return coord;
1411
1433
  }
1412
1434
  dispose() {
1435
+ this._unRegistryEvent();
1413
1436
  this.context.container.removeChild(this.svg);
1414
1437
  this.svg = null;
1415
1438
  }
@@ -2144,6 +2167,7 @@ var Context = class extends EventDispatcher6 {
2144
2167
  camera.updateProjectionMatrix();
2145
2168
  renderer.setSize(w, h);
2146
2169
  this.resizeClientSize(w, h);
2170
+ this.dispatchEvent({ type: "resize", width: w, height: h });
2147
2171
  });
2148
2172
  __publicField(this, "onClick", (e) => {
2149
2173
  const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
@@ -2248,8 +2272,8 @@ var Context = class extends EventDispatcher6 {
2248
2272
  getGraphicsByDeviceXy(x, y) {
2249
2273
  var _a;
2250
2274
  const point3 = new Vector23();
2251
- point3.x = x / this.container.clientWidth * 2 - 1;
2252
- point3.y = y / this.container.clientHeight * -2 + 1;
2275
+ point3.x = x / this.clientSize.width * 2 - 1;
2276
+ point3.y = y / this.clientSize.height * -2 + 1;
2253
2277
  const raycaster = new Raycaster3();
2254
2278
  raycaster.setFromCamera(point3, this.camera);
2255
2279
  const res = (_a = this.currentFloor) == null ? void 0 : _a.graphicLayer.getGraphicByRaycaster(raycaster);