@aibee/crc-bmap 0.1.3 → 0.1.5

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
@@ -2273,7 +2273,7 @@ import {
2273
2273
  Vector2 as Vector211,
2274
2274
  Raycaster as Raycaster4,
2275
2275
  Box3 as Box39,
2276
- Color as Color6,
2276
+ Color as Color7,
2277
2277
  AmbientLight as AmbientLight2
2278
2278
  } from "three";
2279
2279
 
@@ -5318,7 +5318,8 @@ var defaultOptions4 = {
5318
5318
  opacity: 1,
5319
5319
  id: "",
5320
5320
  position: { x: 0, y: 0, z: 0 },
5321
- text_font_size: 14
5321
+ text_font_size: 14,
5322
+ icon_rotate: 0
5322
5323
  };
5323
5324
  var Poi2 = class extends Object3D14 {
5324
5325
  constructor(context, options) {
@@ -5386,6 +5387,11 @@ var Poi2 = class extends Object3D14 {
5386
5387
  this.initSize();
5387
5388
  this._initScale({ zoom: this.context.camera.zoom });
5388
5389
  });
5390
+ this.addEventListener("change-icon_rotate", ({ value }) => {
5391
+ if (this.spriteIcon) {
5392
+ this.spriteIcon.material.rotation = value / 180 * Math.PI;
5393
+ }
5394
+ });
5389
5395
  }
5390
5396
  unRegistryEvent() {
5391
5397
  this.context.removeEventListener("control-zoom-change", this._initScale);
@@ -5398,7 +5404,8 @@ var Poi2 = class extends Object3D14 {
5398
5404
  map: texture,
5399
5405
  transparent: true,
5400
5406
  alphaTest: 0.2,
5401
- depthTest: false
5407
+ depthTest: false,
5408
+ rotation: this.options.icon_rotate / 180 * Math.PI
5402
5409
  })
5403
5410
  );
5404
5411
  spriteIcon.visible = false;
@@ -5770,7 +5777,7 @@ var Selection = class extends EventDispatcher4 {
5770
5777
  return this._list;
5771
5778
  }
5772
5779
  enableBoxSelection() {
5773
- if (this.isMultipleSelect) {
5780
+ if (this.isMultipleSelect || !this.context.config.enableBoxSelect) {
5774
5781
  return;
5775
5782
  }
5776
5783
  this.isMultipleSelect = true;
@@ -6299,11 +6306,10 @@ var Renderer = class extends WebGLRenderer {
6299
6306
  constructor(options) {
6300
6307
  super({
6301
6308
  antialias: true,
6309
+ alpha: true,
6302
6310
  ...options
6303
6311
  });
6304
6312
  this.autoClear = true;
6305
- this.setClearAlpha(1);
6306
- this.setClearColor(16777215);
6307
6313
  this.setPixelRatio(window.devicePixelRatio);
6308
6314
  this.shadowMap.enabled = true;
6309
6315
  this.shadowMap.autoUpdate = true;
@@ -6342,11 +6348,10 @@ var Renderer = class extends WebGLRenderer {
6342
6348
  };
6343
6349
 
6344
6350
  // src/context/scene.ts
6345
- import { Color as Color5, Scene } from "three";
6351
+ import { Scene } from "three";
6346
6352
  var ContextScene = class extends Scene {
6347
6353
  constructor() {
6348
6354
  super();
6349
- this.background = new Color5(16777215);
6350
6355
  }
6351
6356
  };
6352
6357
 
@@ -6437,7 +6442,7 @@ var Context = class extends EventDispatcher7 {
6437
6442
  changeAmbientLightColor(color) {
6438
6443
  this.lights.children.forEach((item) => {
6439
6444
  if (item instanceof AmbientLight2) {
6440
- item.color = new Color6(color);
6445
+ item.color = new Color7(color);
6441
6446
  }
6442
6447
  });
6443
6448
  }
@@ -6671,6 +6676,7 @@ var defaultConfig = {
6671
6676
  equipmentList: "/api/inception-map/equipment/get",
6672
6677
  roadNetwork: "/api/inception-map/road_network/get"
6673
6678
  },
6679
+ enableBoxSelect: true,
6674
6680
  resizeObserver: false,
6675
6681
  initTransToMark: false,
6676
6682
  heatMap: {
@@ -7259,7 +7265,7 @@ import {
7259
7265
  Mesh as Mesh11,
7260
7266
  Object3D as Object3D18,
7261
7267
  TextureLoader as TextureLoader2,
7262
- Color as Color8,
7268
+ Color as Color9,
7263
7269
  Vector2 as Vector213,
7264
7270
  Vector3 as Vector324,
7265
7271
  NormalBlending,
@@ -7278,7 +7284,7 @@ import {
7278
7284
  ShaderChunk,
7279
7285
  ShaderMaterial as ShaderMaterial5,
7280
7286
  UniformsLib,
7281
- Color as Color7,
7287
+ Color as Color8,
7282
7288
  Vector2 as Vector212
7283
7289
  } from "three";
7284
7290
  var MeshLine = class extends BufferGeometry6 {
@@ -7711,7 +7717,7 @@ var MeshLineMaterial = class extends ShaderMaterial5 {
7711
7717
  useMap: { value: 0 },
7712
7718
  alphaMap: { value: null },
7713
7719
  useAlphaMap: { value: 0 },
7714
- color: { value: new Color7(16777215) },
7720
+ color: { value: new Color8(16777215) },
7715
7721
  opacity: { value: 1 },
7716
7722
  resolution: { value: new Vector212(1, 1) },
7717
7723
  sizeAttenuation: { value: 1 },
@@ -7943,6 +7949,7 @@ var Path2 = class extends Object3D18 {
7943
7949
  this.onControlChange
7944
7950
  );
7945
7951
  this.navigation.bmap.context.addEventListener("update", this.onUpdate);
7952
+ this.navigation.bmap.context.addEventListener("resize", this.onResize);
7946
7953
  }
7947
7954
  unRegistryEvent() {
7948
7955
  this.navigation.bmap.context.removeEventListener(
@@ -7950,6 +7957,7 @@ var Path2 = class extends Object3D18 {
7950
7957
  this.onControlChange
7951
7958
  );
7952
7959
  this.navigation.bmap.context.removeEventListener("update", this.onUpdate);
7960
+ this.navigation.bmap.context.removeEventListener("resize", this.onResize);
7953
7961
  }
7954
7962
  onControlChange = () => {
7955
7963
  const zoom = this.navigation.bmap.context.camera.zoom;
@@ -7963,6 +7971,12 @@ var Path2 = class extends Object3D18 {
7963
7971
  return;
7964
7972
  }
7965
7973
  };
7974
+ onResize = () => {
7975
+ if (this.material) {
7976
+ const { width, height } = this.navigation.bmap.context.clientSize;
7977
+ this.material.resolution.set(width, height);
7978
+ }
7979
+ };
7966
7980
  getRepeat() {
7967
7981
  const {
7968
7982
  points,
@@ -8025,7 +8039,7 @@ var Path2 = class extends Object3D18 {
8025
8039
  }
8026
8040
  const material = this.material = new MeshLineMaterial({
8027
8041
  useMap: true,
8028
- color: new Color8(this.config.color),
8042
+ color: new Color9(this.config.color),
8029
8043
  transparent: true,
8030
8044
  resolution: new Vector213(
8031
8045
  this.navigation.bmap.context.clientSize.width,
@@ -8219,10 +8233,6 @@ var Navigation = class extends Plugin {
8219
8233
  this.path.position.z = this.bmap.context.currentFloor.groundMaxHeight + 0.5;
8220
8234
  this.bmap.context.scene.add(this.path);
8221
8235
  }
8222
- this.dispatchEvent({
8223
- type: "render-path",
8224
- path: this.path
8225
- });
8226
8236
  if (this.startPoi) {
8227
8237
  this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
8228
8238
  this.startPoi = null;
@@ -8236,6 +8246,10 @@ var Navigation = class extends Plugin {
8236
8246
  }) || null;
8237
8247
  this.bmap.context.currentFloor?.poiLayer2.pushPoi(this.startPoi);
8238
8248
  }
8249
+ this.dispatchEvent({
8250
+ type: "render-path",
8251
+ path: this.path
8252
+ });
8239
8253
  }
8240
8254
  catmullRomCurve3(points) {
8241
8255
  return simplifyPath(points, false, true, 0.1, 170, 2.5);
@@ -8497,27 +8511,37 @@ var Navigation = class extends Plugin {
8497
8511
  });
8498
8512
  }
8499
8513
  // 吸附路线
8500
- adsorb(position) {
8514
+ adsorb(floor, position) {
8501
8515
  if (!this.curFloorPathPoints.length) {
8502
8516
  return null;
8503
8517
  }
8504
8518
  let path = this.curFloorPathPoints;
8505
8519
  if (this.currentPathPosition) {
8506
- const index = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
8507
- path = path.slice(index + 1);
8520
+ const index2 = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
8521
+ path = path.slice(index2 + 1);
8508
8522
  path.unshift(this.currentPathPosition);
8509
8523
  }
8510
- const { distance, closestPoint } = path.reduce((obj, cur, index, arr) => {
8511
- if (!arr[index + 1]) {
8512
- return obj;
8513
- }
8514
- const { distance: distance2, closestPoint: closestPoint2 } = distancePointToSegment(position, cur, arr[index + 1]);
8524
+ const paths = [
8525
+ { floor: this.curFloorPath?.floor, points: path },
8526
+ ...this.paths.slice(this.curPathIndex + 1)
8527
+ ].filter((item) => item.floor === floor);
8528
+ const { distance, closestPoint, index } = paths.reduce((obj, cur, index2) => {
8529
+ const { distance: distance2, closestPoint: closestPoint2 } = cur.points.reduce((obj2, cur2, index3, arr) => {
8530
+ if (!arr[index3 + 1]) {
8531
+ return obj2;
8532
+ }
8533
+ const { distance: distance3, closestPoint: closestPoint3 } = distancePointToSegment(position, cur2, arr[index3 + 1]);
8534
+ if (distance3 < obj2.distance) {
8535
+ return { distance: distance3, closestPoint: closestPoint3 };
8536
+ }
8537
+ return obj2;
8538
+ }, { distance: Infinity, closestPoint: path[0] });
8515
8539
  if (distance2 < obj.distance) {
8516
- return { distance: distance2, closestPoint: closestPoint2 };
8540
+ return { distance: distance2, closestPoint: closestPoint2, index: index2 };
8517
8541
  }
8518
8542
  return obj;
8519
- }, { distance: Infinity, closestPoint: path[0] });
8520
- return { distance, closestPoint };
8543
+ }, { distance: Infinity, closestPoint: path[0], index: 0 });
8544
+ return { distance, closestPoint, index: index + this.curPathIndex };
8521
8545
  }
8522
8546
  // 计算剩余距离
8523
8547
  getRemainDistance() {
@@ -8568,9 +8592,17 @@ var Navigation = class extends Plugin {
8568
8592
  type: "navigation-info",
8569
8593
  dir,
8570
8594
  distance: remainDistance,
8571
- nextDirDistance: distance
8595
+ nextDirDistance: distance,
8596
+ pos: this.currentPathPosition
8572
8597
  });
8573
8598
  }
8599
+ setStartPoiRotate(rotate) {
8600
+ if (this.startPoi) {
8601
+ const azimuthalAngle = this.bmap.context.control.getAzimuthalAngle();
8602
+ const azimuthal = azimuthalAngle * 180 / Math.PI;
8603
+ this.startPoi.options.icon_rotate = rotate - azimuthal;
8604
+ }
8605
+ }
8574
8606
  dispose() {
8575
8607
  this.tweenUtil.dispose();
8576
8608
  this.unRegistryEvent();
@@ -9389,17 +9421,21 @@ var AibeeLoader = class {
9389
9421
  const graphic = floor.addGraphic(options);
9390
9422
  floor.userData.graphics.push(graphic);
9391
9423
  floor.userData.graphicMap.set(options.id, graphic);
9392
- const poi = new Poi2(this.bmap.context, {
9393
- id: options.id,
9394
- icon: options.poi_info.icon,
9395
- text: options.poi_info.showName || options.store_name || options.poi_info.text,
9396
- position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
9397
- icon_size: [18, 18]
9398
- });
9399
- floor.poiLayer2.pushPoi(poi);
9400
- if (poi) {
9401
- poi.userData.type = "store";
9402
- poi.userData.data = options;
9424
+ try {
9425
+ const poi = new Poi2(this.bmap.context, {
9426
+ id: options.id,
9427
+ icon: options.poi_info.icon,
9428
+ text: options.poi_info.showName || options.store_name || options.poi_info.text,
9429
+ position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
9430
+ icon_size: [18, 18]
9431
+ });
9432
+ floor.poiLayer2.pushPoi(poi);
9433
+ if (poi) {
9434
+ poi.userData.type = "store";
9435
+ poi.userData.data = options;
9436
+ }
9437
+ } catch (e) {
9438
+ console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25", e, options);
9403
9439
  }
9404
9440
  });
9405
9441
  break;
@@ -9424,6 +9460,8 @@ var AibeeLoader = class {
9424
9460
  floor.poiLayer2.pushPoi(poi);
9425
9461
  poi.userData.type = "facility";
9426
9462
  poi.userData.data = options;
9463
+ } else {
9464
+ console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info", options);
9427
9465
  }
9428
9466
  });
9429
9467
  break;