@aibee/crc-bmap 0.5.4 → 0.5.6

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
@@ -4322,7 +4322,8 @@ var PoiLayer2 = class extends Layer {
4322
4322
  m4.multiply(camera.matrixWorldInverse);
4323
4323
  const pois = this.pois.filter((item) => {
4324
4324
  if (item.visible) {
4325
- const vector = new Vector310().setFromMatrixPosition(item.matrixWorld);
4325
+ const matrixWorld = item.spriteIcon ? item.spriteIcon?.matrixWorld : item.spriteText?.matrixWorld || item.matrixWorld;
4326
+ const vector = new Vector310().setFromMatrixPosition(matrixWorld);
4326
4327
  vector.applyMatrix4(m4);
4327
4328
  item.screenPosition = vector;
4328
4329
  return isValid(vector.x) && isValid(vector.y) && isValid(vector.z);
@@ -5535,7 +5536,8 @@ var defaultOptions4 = {
5535
5536
  id: "",
5536
5537
  position: { x: 0, y: 0, z: 0 },
5537
5538
  text_font_size: 14,
5538
- icon_rotate: 0
5539
+ icon_rotate: 0,
5540
+ depth_test: false
5539
5541
  };
5540
5542
  var Poi2 = class extends Object3D14 {
5541
5543
  constructor(context, options) {
@@ -5579,7 +5581,11 @@ var Poi2 = class extends Object3D14 {
5579
5581
  return this.options.text ? this.options.text_font_size : 0;
5580
5582
  }
5581
5583
  get deltaZ() {
5582
- return 0.1;
5584
+ if (!this.options.icon && this.options.text) {
5585
+ return 0.1 + this.offset * (this.iconHeight + this.durIconAndText + this.textHeight) / this.context.camera.zoom;
5586
+ } else {
5587
+ return 0.1;
5588
+ }
5583
5589
  }
5584
5590
  get canSelect() {
5585
5591
  return this.visible && (this.spriteIcon ? this.spriteIcon.visible : true) && (this.spriteText ? this.spriteText.visible : true);
@@ -5617,6 +5623,14 @@ var Poi2 = class extends Object3D14 {
5617
5623
  this._initScale({ zoom: this.context.camera.zoom });
5618
5624
  }
5619
5625
  });
5626
+ this.addEventListener("change-depth_test", ({ value }) => {
5627
+ if (this.spriteIcon) {
5628
+ this.spriteIcon.material.depthTest = value;
5629
+ }
5630
+ if (this.spriteText) {
5631
+ this.spriteText.material.depthTest = value;
5632
+ }
5633
+ });
5620
5634
  }
5621
5635
  unRegistryEvent() {
5622
5636
  this.context.removeEventListener("control-zoom-change", this._initScale);
@@ -5633,7 +5647,7 @@ var Poi2 = class extends Object3D14 {
5633
5647
  map: texture,
5634
5648
  transparent: true,
5635
5649
  alphaTest: 0.2,
5636
- depthTest: false,
5650
+ depthTest: this.options.depth_test,
5637
5651
  rotation: this.options.icon_rotate / 180 * Math.PI
5638
5652
  })
5639
5653
  );
@@ -5657,7 +5671,7 @@ var Poi2 = class extends Object3D14 {
5657
5671
  map: texture,
5658
5672
  transparent: true,
5659
5673
  alphaTest: 0.2,
5660
- depthTest: false
5674
+ depthTest: this.options.depth_test
5661
5675
  })
5662
5676
  );
5663
5677
  spriteText.visible = false;
@@ -5744,18 +5758,18 @@ var Poi2 = class extends Object3D14 {
5744
5758
  renderBoxHelper(x, y) {
5745
5759
  if (!this.boxHelper) {
5746
5760
  const div = document.createElement("div");
5747
- div.style.position = "fixed";
5761
+ div.style.position = "absolute";
5762
+ div.style.zIndex = "999";
5748
5763
  div.style.border = "1px solid red";
5749
5764
  div.style.pointerEvents = "none";
5750
5765
  this.boxHelper = div;
5751
5766
  this.context.container.appendChild(div);
5752
5767
  }
5753
5768
  if (x && y) {
5754
- console.log(x, y);
5755
5769
  this.boxHelper.style.left = x + "px";
5756
5770
  this.boxHelper.style.top = y + "px";
5757
- this.boxHelper.style.width = "10px";
5758
- this.boxHelper.style.height = "10px";
5771
+ this.boxHelper.style.width = "2px";
5772
+ this.boxHelper.style.height = "2px";
5759
5773
  } else {
5760
5774
  this.boxHelper.style.left = this.box.min.x + "px";
5761
5775
  this.boxHelper.style.top = this.box.min.y + "px";
@@ -9049,11 +9063,13 @@ var MulFloors = class extends Plugin {
9049
9063
  show(floors) {
9050
9064
  let height = floors[0].userData.height;
9051
9065
  floors.forEach((floor) => {
9052
- floor.poiLayer.pois.forEach((poi) => {
9066
+ floor.poiLayer2.pois.forEach((poi) => {
9067
+ poi.position.setZ(poi.position.z + height);
9068
+ poi.options.depth_test = true;
9053
9069
  this.poiLayer.pushPoi(poi);
9054
9070
  });
9055
- floor.poiLayer.pois.length = 0;
9056
- floor.poiLayer.dispose();
9071
+ floor.poiLayer2.pois.length = 0;
9072
+ floor.poiLayer2.dispose();
9057
9073
  floor.position.z = height;
9058
9074
  height += floor.userData.height;
9059
9075
  });
@@ -9065,12 +9081,13 @@ var MulFloors = class extends Plugin {
9065
9081
  this.group.add(this.poiLayer, ...floors);
9066
9082
  scene.add(this.group);
9067
9083
  this.floors = floors;
9084
+ this.fitCamera();
9068
9085
  this.bmap.context.cameraBound.updateBox();
9069
9086
  }
9070
9087
  hide() {
9071
9088
  const { scene } = this.bmap.context;
9072
9089
  scene.remove(this.group);
9073
- this.poiLayer.clear(true);
9090
+ this.poiLayer.clear();
9074
9091
  this.floors.forEach((floor) => {
9075
9092
  floor.dispose();
9076
9093
  });