@aibee/crc-bmap 0.8.0 → 0.8.2

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
@@ -8625,7 +8625,7 @@ var ContextScene = class extends Scene {
8625
8625
  import { OrthographicCamera as OrthographicCamera2 } from "three";
8626
8626
  var ContextCamera = class extends OrthographicCamera2 {
8627
8627
  constructor(width, height) {
8628
- super(-width / 2, width / 2, height / 2, -height / 2, -1e3, 5e3);
8628
+ super(-width / 2, width / 2, height / 2, -height / 2, -1e4, 5e4);
8629
8629
  this.up.set(0, 0, 1);
8630
8630
  this.position.set(0, 0, 100);
8631
8631
  this.lookAt(0, 0, 0);
@@ -10776,6 +10776,159 @@ var TaskQueue = class extends EventDispatcher13 {
10776
10776
  }
10777
10777
  };
10778
10778
 
10779
+ // src/plugins/navigation/start-rotate-helper-poi.ts
10780
+ import { DataTexture as DataTexture2, LinearFilter as LinearFilter3, RGBAFormat as RGBAFormat3, Sprite as Sprite2, SpriteMaterial as SpriteMaterial2 } from "three";
10781
+ var StartRotateHelperPoi = class _StartRotateHelperPoi extends Poi2 {
10782
+ constructor(bmap, config4) {
10783
+ super(bmap.context, {
10784
+ icon_size: config4.size,
10785
+ collision_enable: false,
10786
+ level: 2
10787
+ });
10788
+ this.bmap = bmap;
10789
+ this.config = config4;
10790
+ _StartRotateHelperPoi.canvas.width = config4.size[0];
10791
+ _StartRotateHelperPoi.canvas.height = config4.size[1];
10792
+ }
10793
+ static canvas = document.createElement("canvas");
10794
+ static ctx = this.canvas.getContext("2d", { willReadFrequently: true });
10795
+ static textureMap = /* @__PURE__ */ new Map();
10796
+ addDebug() {
10797
+ _StartRotateHelperPoi.canvas.style.cssText = `
10798
+ position: fixed;
10799
+ top: 0;
10800
+ left: 0;
10801
+ z-index: 9999;
10802
+ `;
10803
+ document.body.appendChild(_StartRotateHelperPoi.canvas);
10804
+ }
10805
+ setAngle(angle) {
10806
+ console.log("angle", angle);
10807
+ if (_StartRotateHelperPoi.textureMap.has(angle)) {
10808
+ this._initIcon(_StartRotateHelperPoi.textureMap.get(angle));
10809
+ } else {
10810
+ this.draw(angle);
10811
+ const texture = this.getTexture(this.getImageData());
10812
+ _StartRotateHelperPoi.textureMap.set(angle, texture);
10813
+ this._initIcon(texture);
10814
+ this._initScale({ zoom: this.bmap.context.camera.zoom });
10815
+ }
10816
+ }
10817
+ _initIcon(texture) {
10818
+ if (this.spriteIcon) {
10819
+ this.spriteIcon.material.map = texture;
10820
+ texture.needsUpdate = true;
10821
+ } else {
10822
+ const spriteIcon = new Sprite2(
10823
+ new SpriteMaterial2({
10824
+ map: texture,
10825
+ transparent: true,
10826
+ alphaTest: 0.2,
10827
+ depthTest: this.options.depth_test,
10828
+ rotation: this.options.icon_rotate / 180 * Math.PI
10829
+ })
10830
+ );
10831
+ spriteIcon.renderOrder = 1e5 + this.options.level;
10832
+ texture.needsUpdate = true;
10833
+ this.add(spriteIcon);
10834
+ spriteIcon.center.set(0.5, 0.5);
10835
+ this.spriteIcon = spriteIcon;
10836
+ }
10837
+ }
10838
+ initSize() {
10839
+ if (this.spriteIcon) {
10840
+ this.spriteIcon.center.set(0.5, 0.5);
10841
+ }
10842
+ }
10843
+ draw(angle) {
10844
+ const { ctx } = _StartRotateHelperPoi;
10845
+ const { config: { size: size2 } } = this;
10846
+ const halfWidth = size2[0] / 2;
10847
+ const halfHeight = size2[1] / 2;
10848
+ const cr = 4;
10849
+ const crLineWidth = 1;
10850
+ const solidPointWidth = cr + crLineWidth;
10851
+ ctx.clearRect(0, 0, size2[0], size2[1]);
10852
+ ctx.setLineDash([10, 10]);
10853
+ ctx.strokeStyle = "#fff";
10854
+ ctx.lineWidth = 2;
10855
+ ctx.beginPath();
10856
+ ctx.arc(halfWidth, halfHeight, halfHeight - solidPointWidth, -Math.PI / 2, Math.PI * 2 - Math.PI / 2, angle < Math.PI);
10857
+ ctx.stroke();
10858
+ ctx.strokeStyle = "#0A7AFF";
10859
+ if (angle < Math.PI) {
10860
+ const startAngle = -Math.PI / 2;
10861
+ const endAngle = startAngle - angle;
10862
+ ctx.beginPath();
10863
+ ctx.arc(halfWidth, halfHeight, halfHeight - solidPointWidth, startAngle, endAngle, true);
10864
+ } else {
10865
+ const startAngle = -Math.PI / 2;
10866
+ const endAngle = startAngle + Math.PI * 2 - angle;
10867
+ ctx.beginPath();
10868
+ ctx.arc(halfWidth, halfHeight, halfHeight - solidPointWidth, startAngle, endAngle, false);
10869
+ }
10870
+ ctx.stroke();
10871
+ ctx.clearRect(halfWidth - solidPointWidth * 2, 0, solidPointWidth * 4, solidPointWidth * 4);
10872
+ ctx.beginPath();
10873
+ ctx.arc(halfWidth, solidPointWidth, cr, 0, Math.PI * 2);
10874
+ ctx.fillStyle = "#0A7AFF";
10875
+ ctx.fill();
10876
+ ctx.setLineDash([10, 0]);
10877
+ ctx.strokeStyle = "#fff";
10878
+ ctx.lineWidth = crLineWidth;
10879
+ ctx.stroke();
10880
+ ctx.clearRect(0, halfHeight - 5, 10, 10);
10881
+ ctx.clearRect(halfWidth - 5, size2[1] - 10, 10, 10);
10882
+ ctx.clearRect(size2[0] - 10, halfHeight - 5, 10, 10);
10883
+ if (angle > Math.PI / 2 && angle < Math.PI) {
10884
+ ctx.fillStyle = "#0A7AFF";
10885
+ } else {
10886
+ ctx.fillStyle = "#fff";
10887
+ }
10888
+ ctx.fillRect(0, halfHeight - 1, 10, 2);
10889
+ ctx.fillStyle = "#fff";
10890
+ ctx.fillRect(halfWidth - 1, size2[1] - 10, 2, 10);
10891
+ if (angle > Math.PI && angle < Math.PI / 2 * 3) {
10892
+ ctx.fillStyle = "#0A7AFF";
10893
+ } else {
10894
+ ctx.fillStyle = "#fff";
10895
+ }
10896
+ ctx.fillRect(size2[0] - 10, halfHeight - 1, 10, 2);
10897
+ }
10898
+ getImageData() {
10899
+ const { ctx } = _StartRotateHelperPoi;
10900
+ const { config: { size: size2 } } = this;
10901
+ return ctx.getImageData(0, 0, size2[0], size2[1]);
10902
+ }
10903
+ getTexture(imageData) {
10904
+ const { config: { size: size2 } } = this;
10905
+ const texture = new DataTexture2(
10906
+ Uint8Array.from(imageData.data),
10907
+ size2[0],
10908
+ size2[1],
10909
+ RGBAFormat3
10910
+ );
10911
+ texture.format = RGBAFormat3;
10912
+ texture.magFilter = LinearFilter3;
10913
+ texture.minFilter = LinearFilter3;
10914
+ texture.colorSpace = "srgb";
10915
+ texture.flipY = true;
10916
+ return texture;
10917
+ }
10918
+ dispose() {
10919
+ super.dispose();
10920
+ this.spriteIcon?.material.dispose();
10921
+ }
10922
+ static dispose() {
10923
+ this.textureMap.forEach((v) => {
10924
+ v.dispose();
10925
+ });
10926
+ this.textureMap.clear();
10927
+ this.ctx = null;
10928
+ this.canvas = null;
10929
+ }
10930
+ };
10931
+
10779
10932
  // src/plugins/navigation/navigation.ts
10780
10933
  var defaultConfig4 = {
10781
10934
  path: {},
@@ -10804,6 +10957,8 @@ var Navigation = class extends Plugin {
10804
10957
  options;
10805
10958
  pathTween = null;
10806
10959
  startPoi = null;
10960
+ startRotateHelperPoi = null;
10961
+ needStartRotateHelperPoi = false;
10807
10962
  movedDistance = 0;
10808
10963
  pathStart = [0, 0];
10809
10964
  tweenUtil = new TweenUtil();
@@ -10851,6 +11006,37 @@ var Navigation = class extends Plugin {
10851
11006
  this.toPositionByTask(info.pos);
10852
11007
  }
10853
11008
  };
11009
+ showStartRotateHelperPoi() {
11010
+ this.needStartRotateHelperPoi = true;
11011
+ if (!this.startPoi) {
11012
+ return;
11013
+ }
11014
+ if (this.startRotateHelperPoi) {
11015
+ return;
11016
+ }
11017
+ const size2 = this.startPoi.options.icon_size;
11018
+ this.startRotateHelperPoi = new StartRotateHelperPoi(this.bmap, {
11019
+ size: [size2[0] + 20, size2[1] + 20]
11020
+ });
11021
+ this.startRotateHelperPoi.setAngle(0);
11022
+ this.startRotateHelperPoi.position.setZ(0.51);
11023
+ this.bmap.context.currentFloor?.poiLayer2.pushPoi(this.startRotateHelperPoi);
11024
+ }
11025
+ hideStartRotateHelperPoi() {
11026
+ this.needStartRotateHelperPoi = false;
11027
+ if (this.startRotateHelperPoi) {
11028
+ this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startRotateHelperPoi);
11029
+ this.startRotateHelperPoi = null;
11030
+ }
11031
+ }
11032
+ setStartPoiPosition(x, y) {
11033
+ if (this.startPoi) {
11034
+ this.startPoi.position.setX(x).setY(y);
11035
+ if (this.startRotateHelperPoi) {
11036
+ this.startRotateHelperPoi.position.setX(x).setY(y);
11037
+ }
11038
+ }
11039
+ }
10854
11040
  toPositionByTask(pos) {
10855
11041
  const tasks = this.taskQueue.getTasks();
10856
11042
  const tid = tasks.find((item) => item.meta.type === "toPosition")?.tid;
@@ -10901,6 +11087,10 @@ var Navigation = class extends Plugin {
10901
11087
  if (this.startPoi) {
10902
11088
  this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
10903
11089
  this.startPoi = null;
11090
+ if (this.startRotateHelperPoi) {
11091
+ this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startRotateHelperPoi);
11092
+ this.startRotateHelperPoi = null;
11093
+ }
10904
11094
  }
10905
11095
  this.translatePath = null;
10906
11096
  }
@@ -10986,6 +11176,10 @@ var Navigation = class extends Plugin {
10986
11176
  if (this.startPoi) {
10987
11177
  this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
10988
11178
  this.startPoi = null;
11179
+ if (this.startRotateHelperPoi) {
11180
+ this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startRotateHelperPoi);
11181
+ this.startRotateHelperPoi = null;
11182
+ }
10989
11183
  }
10990
11184
  if (this.options.needStartPoi) {
10991
11185
  this.startPoi = new Poi2(this.bmap.context, {
@@ -10995,6 +11189,10 @@ var Navigation = class extends Plugin {
10995
11189
  collision_enable: false
10996
11190
  }) || null;
10997
11191
  this.bmap.context.currentFloor?.poiLayer2.pushPoi(this.startPoi);
11192
+ if (this.needStartRotateHelperPoi) {
11193
+ this.showStartRotateHelperPoi();
11194
+ }
11195
+ console.log(this.startRotateHelperPoi);
10998
11196
  }
10999
11197
  this.dispatchEvent({
11000
11198
  type: "render-path",
@@ -11099,7 +11297,6 @@ var Navigation = class extends Plugin {
11099
11297
  const device = vector3ToDevice(this.startPoi.position, camera, width, height);
11100
11298
  const offsetX = device.x - halfWidth;
11101
11299
  const offsetY = halfHeight - device.y + this.options.offsetY;
11102
- console.log("start", target.clone());
11103
11300
  if (Math.abs(offsetX) <= 1 && Math.abs(offsetY) <= 1) {
11104
11301
  return;
11105
11302
  }
@@ -11117,7 +11314,6 @@ var Navigation = class extends Plugin {
11117
11314
  v3.multiplyScalar(offsetY / camera.zoom);
11118
11315
  target.add(new Vector326(v3.x, v3.y, 0));
11119
11316
  }
11120
- console.log("start1", target.clone());
11121
11317
  return timeoutPromise(
11122
11318
  new Promise((resolve) => {
11123
11319
  const start = control.target.clone();
@@ -11145,7 +11341,7 @@ var Navigation = class extends Plugin {
11145
11341
  const { clientSize: { width, height }, currentFloor } = this.bmap.context;
11146
11342
  const { max: max2, min: min2 } = currentFloor.box;
11147
11343
  const baseScale = Math.min(width / (max2.x - min2.x), height / (max2.y - min2.y));
11148
- const zoom = baseScale * (max2.x - min2.x) / 40;
11344
+ const zoom = baseScale * (max2.x - min2.x) / 45;
11149
11345
  return this.bmap.context.setZoom(
11150
11346
  zoom,
11151
11347
  this.startPoi.position,
@@ -11208,7 +11404,7 @@ var Navigation = class extends Plugin {
11208
11404
  this.currentPathPosition = pos;
11209
11405
  const translatePos = this.translatePoints([pos])[0];
11210
11406
  if (this.startPoi) {
11211
- this.startPoi.position.setX(translatePos[0]).setY(translatePos[1]);
11407
+ this.setStartPoiPosition(translatePos[0], translatePos[1]);
11212
11408
  if (!this.options.disablePathAnimation) {
11213
11409
  this.bmap.context.control.setTargetByOffset(this.options.offsetY, this.startPoi.position.clone());
11214
11410
  }
@@ -11224,6 +11420,9 @@ var Navigation = class extends Plugin {
11224
11420
  const azimuthalAngle = this.bmap.context.control.getAzimuthalAngle();
11225
11421
  const azimuthal = (azimuthalAngle * 180 / Math.PI + 360) % 360;
11226
11422
  this.startPoi.options.icon_rotate = (360 - rotate - azimuthal) % 360;
11423
+ if (this.startRotateHelperPoi) {
11424
+ this.startRotateHelperPoi.setAngle((360 - rotate - azimuthal) % 360);
11425
+ }
11227
11426
  }
11228
11427
  }
11229
11428
  dispose() {
@@ -11234,6 +11433,8 @@ var Navigation = class extends Plugin {
11234
11433
  this.tweenUtil.dispose();
11235
11434
  this.unRegistryEvent();
11236
11435
  this.startPoi?.dispose();
11436
+ this.startRotateHelperPoi?.dispose();
11437
+ StartRotateHelperPoi.dispose();
11237
11438
  this.positionNavigation.dispose();
11238
11439
  }
11239
11440
  };
@@ -23181,7 +23382,7 @@ var ImuPosition = class {
23181
23382
  abnor_peak_time = 0;
23182
23383
  abnor_peak_accH = 0;
23183
23384
  // step length
23184
- const_step_length = 0.65;
23385
+ const_step_length = 0.75;
23185
23386
  // mean step length, can be changed
23186
23387
  // rotation parsing
23187
23388
  last_rot = [];
@@ -24584,8 +24785,8 @@ var AibeeLoader = class {
24584
24785
  data.layers.forEach((layer) => {
24585
24786
  switch (layer.l_type) {
24586
24787
  case "range":
24587
- const data2 = layer.elements[0];
24588
- center2 = [data2.center_x, data2.center_y];
24788
+ const rangeData = layer.elements[0];
24789
+ center2 = [rangeData.center_x, rangeData.center_y];
24589
24790
  break;
24590
24791
  case "graph":
24591
24792
  transformGraphicData(layer.elements, center2);
@@ -24736,6 +24937,7 @@ var AibeeLoader = class {
24736
24937
  if (poi) {
24737
24938
  poi.userData.type = "store";
24738
24939
  poi.userData.data = options;
24940
+ poi.userData.floor = data.floor;
24739
24941
  }
24740
24942
  } catch (e2) {
24741
24943
  console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25", e2, options);
@@ -24764,6 +24966,7 @@ var AibeeLoader = class {
24764
24966
  floor2.poiLayer2.pushPoi(poi);
24765
24967
  poi.userData.type = "facility";
24766
24968
  poi.userData.data = options;
24969
+ poi.userData.floor = data.floor;
24767
24970
  } else {
24768
24971
  console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info", options);
24769
24972
  }
@@ -24794,6 +24997,7 @@ var AibeeLoader = class {
24794
24997
  if (poi) {
24795
24998
  poi.userData.type = "parkingSpace";
24796
24999
  poi.userData.data = options;
25000
+ poi.userData.floor = data.floor;
24797
25001
  }
24798
25002
  floor2.poiLayer2.pushPoi(poi);
24799
25003
  }
@@ -24841,7 +25045,9 @@ var AibeeLoader = class {
24841
25045
  });
24842
25046
  floor2.updateBox();
24843
25047
  floor2.userData.center = center2;
24844
- floor2.userData.height = floor2.box.getSize(new Vector330()).z + data.floorHeight * 10;
25048
+ const size2 = floor2.box.getSize(new Vector330());
25049
+ const max2 = Math.max(size2.x, size2.y, size2.z);
25050
+ floor2.userData.height = max2 / 4 + data.floorHeight;
24845
25051
  floor2.name = data.floor;
24846
25052
  floor2.userData.data = data;
24847
25053
  return floor2;