@aibee/crc-bmap 0.0.129 → 0.0.130

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
@@ -454,7 +454,7 @@ var require_Graph = __commonJS({
454
454
  });
455
455
 
456
456
  // src/bmap.ts
457
- import { EventDispatcher as EventDispatcher7, Vector3 as Vector318 } from "three";
457
+ import { EventDispatcher as EventDispatcher7, Vector3 as Vector320 } from "three";
458
458
 
459
459
  // src/utils/timer.ts
460
460
  var Timer = class {
@@ -624,8 +624,10 @@ function hasChinese(str) {
624
624
  }
625
625
 
626
626
  // src/utils/texture.ts
627
- import { DataTexture, RGBAFormat, LinearFilter } from "three";
627
+ import { DataTexture, RGBAFormat, LinearFilter, TextureLoader } from "three";
628
+ var urlTextureMap = /* @__PURE__ */ new Map();
628
629
  var textTextureMap = /* @__PURE__ */ new Map();
630
+ var textureLoader = new TextureLoader();
629
631
  function initCanvas() {
630
632
  const canvas2 = document.createElement("canvas");
631
633
  canvas2.width = 1024;
@@ -675,12 +677,38 @@ function getTextureByText(text) {
675
677
  return texture;
676
678
  }
677
679
  function clearTextTexture() {
680
+ textTextureMap.forEach((v, _) => {
681
+ v.dispose();
682
+ });
683
+ urlTextureMap.forEach((v) => {
684
+ if (v instanceof Promise) {
685
+ v.then((r) => r.dispose());
686
+ } else {
687
+ v.dispose();
688
+ }
689
+ });
678
690
  textTextureMap.clear();
691
+ urlTextureMap.clear();
679
692
  }
680
693
  function clearCanvas() {
681
694
  ctx = null;
682
695
  canvas = null;
683
696
  }
697
+ async function getTextureByUrl(url) {
698
+ if (urlTextureMap.has(url)) {
699
+ return urlTextureMap.get(url);
700
+ }
701
+ const texturePromise = textureLoader.loadAsync(url);
702
+ texturePromise.then((texture) => {
703
+ texture.format = RGBAFormat;
704
+ texture.magFilter = LinearFilter;
705
+ texture.minFilter = LinearFilter;
706
+ texture.colorSpace = "srgb";
707
+ urlTextureMap.set(url, texture);
708
+ });
709
+ urlTextureMap.set(url, texturePromise);
710
+ return texturePromise;
711
+ }
684
712
 
685
713
  // src/utils/coordinate.ts
686
714
  import { Vector3, Vector2 as Vector22 } from "three";
@@ -1152,6 +1180,9 @@ function moveOnRoute(startPoint, endPoint, distance) {
1152
1180
  const [startX, startY] = startPoint;
1153
1181
  const [endX, endY] = endPoint;
1154
1182
  const routeLength = Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));
1183
+ if (routeLength === 0 || routeLength < distance) {
1184
+ return [...endPoint];
1185
+ }
1155
1186
  const ratio = distance / routeLength;
1156
1187
  const newX = startX + (endX - startX) * ratio;
1157
1188
  const newY = startY + (endY - startY) * ratio;
@@ -2012,11 +2043,11 @@ function toWebWorker(obj) {
2012
2043
  // src/context.ts
2013
2044
  import {
2014
2045
  EventDispatcher as EventDispatcher6,
2015
- Box2,
2016
- Vector3 as Vector317,
2017
- Vector2 as Vector26,
2018
- Raycaster as Raycaster3,
2019
- Box3 as Box39,
2046
+ Box2 as Box23,
2047
+ Vector3 as Vector319,
2048
+ Vector2 as Vector29,
2049
+ Raycaster as Raycaster5,
2050
+ Box3 as Box310,
2020
2051
  Color as Color6,
2021
2052
  AmbientLight as AmbientLight2
2022
2053
  } from "three";
@@ -3007,14 +3038,14 @@ var Poi = class extends EventDispatcher2 {
3007
3038
  };
3008
3039
 
3009
3040
  // src/elements/floor.ts
3010
- import { Box3 as Box35, Object3D as Object3D8, Vector3 as Vector38 } from "three";
3041
+ import { Box3 as Box35, Object3D as Object3D8, Vector3 as Vector39 } from "three";
3011
3042
 
3012
3043
  // src/elements/heatmap.ts
3013
3044
  import {
3014
3045
  MeshBasicMaterial as MeshBasicMaterial2,
3015
3046
  Object3D as Object3D5,
3016
3047
  PlaneGeometry as PlaneGeometry2,
3017
- Texture,
3048
+ Texture as Texture2,
3018
3049
  DoubleSide as DoubleSide2,
3019
3050
  Mesh as Mesh3,
3020
3051
  Matrix3,
@@ -3055,7 +3086,7 @@ var HeatmapElement = class extends Object3D5 {
3055
3086
  this.remove(this.plane);
3056
3087
  }
3057
3088
  const geometry = new PlaneGeometry2(width, height);
3058
- const texture = new Texture(this.div.firstChild);
3089
+ const texture = new Texture2(this.div.firstChild);
3059
3090
  texture.needsUpdate = true;
3060
3091
  const material = new MeshBasicMaterial2({
3061
3092
  transparent: true,
@@ -3338,6 +3369,160 @@ var PoiLayer = class extends Layer {
3338
3369
  }
3339
3370
  };
3340
3371
 
3372
+ // src/layer/poi-layer2.ts
3373
+ import { debounce as debounce3 } from "lodash";
3374
+ import { Vector2 as Vector25, Vector3 as Vector38 } from "three";
3375
+ var PoiLayer2 = class extends Layer {
3376
+ pois = [];
3377
+ debounceCollisionDetection;
3378
+ timer = new Timer();
3379
+ constructor(context) {
3380
+ super(context);
3381
+ this.registryEvent();
3382
+ this.debounceCollisionDetection = debounce3(this.collisionDetection, 10);
3383
+ }
3384
+ clear() {
3385
+ this.pois.forEach((item) => {
3386
+ item.dispose();
3387
+ });
3388
+ this.pois = [];
3389
+ return this;
3390
+ }
3391
+ createPoi(options) {
3392
+ const poi = new Poi2(this.context, options);
3393
+ this.pushPoi(poi);
3394
+ poi.addEventListener(
3395
+ "change-level",
3396
+ () => this.changePoiLevelOrCollisionEnable(poi)
3397
+ );
3398
+ poi.addEventListener(
3399
+ "change-collision_enable",
3400
+ () => this.changePoiLevelOrCollisionEnable(poi)
3401
+ );
3402
+ Promise.resolve().then(() => {
3403
+ this.debounceCollisionDetection();
3404
+ });
3405
+ return poi;
3406
+ }
3407
+ changePoiLevelOrCollisionEnable(poi) {
3408
+ const index = this.pois.findIndex((item) => item === poi);
3409
+ if (index === -1) {
3410
+ return;
3411
+ }
3412
+ this.pois.splice(index, 1);
3413
+ this.pushPoi(poi);
3414
+ }
3415
+ removePoi(poi) {
3416
+ const index = this.pois.findIndex((item) => item === poi);
3417
+ if (index === -1) {
3418
+ return;
3419
+ }
3420
+ this.remove(poi);
3421
+ this.pois.splice(index, 1);
3422
+ poi.dispose();
3423
+ }
3424
+ removePoiById(id) {
3425
+ const poi = this.pois.find((item) => item.options.id === id);
3426
+ if (poi) {
3427
+ this.removePoi(poi);
3428
+ }
3429
+ }
3430
+ getPoiById(id) {
3431
+ const poi = this.pois.find((item) => item.options.id === id);
3432
+ return poi || null;
3433
+ }
3434
+ /**
3435
+ * 保存poi按照level排序
3436
+ * @param poi
3437
+ */
3438
+ pushPoi(poi) {
3439
+ this.add(poi);
3440
+ if (!poi.options.collision_enable) {
3441
+ this.pois.unshift(poi);
3442
+ return;
3443
+ }
3444
+ if (poi.options.level === 0) {
3445
+ this.pois.push(poi);
3446
+ return;
3447
+ }
3448
+ for (let i = 0; i < this.pois.length; i++) {
3449
+ const item = this.pois[i];
3450
+ if (!item.options.collision_enable) {
3451
+ continue;
3452
+ }
3453
+ if (item.options.level <= poi.options.level) {
3454
+ this.pois.splice(i, 0, poi);
3455
+ return;
3456
+ }
3457
+ }
3458
+ this.pois.push(poi);
3459
+ }
3460
+ getPoiByDeviceXy(x, y) {
3461
+ const v2 = new Vector25(x, y);
3462
+ const pois = this.pois.filter((item) => {
3463
+ return item instanceof Poi2 && item.box.containsPoint(v2);
3464
+ });
3465
+ return pois;
3466
+ }
3467
+ onUpdate = () => {
3468
+ this.timer.requestAnimationFrame(() => {
3469
+ this.collisionDetection();
3470
+ });
3471
+ };
3472
+ /**
3473
+ * 碰撞检测
3474
+ */
3475
+ collisionDetection() {
3476
+ const range = [];
3477
+ const { camera } = this.context;
3478
+ camera.updateMatrixWorld();
3479
+ const isValid = (n) => n <= 1 && n >= -1;
3480
+ const m4 = camera.projectionMatrix.clone();
3481
+ m4.multiply(camera.matrixWorldInverse);
3482
+ const pois = this.pois.filter((item) => {
3483
+ if (item.visible) {
3484
+ const vector = new Vector38().setFromMatrixPosition(item.matrixWorld);
3485
+ vector.applyMatrix4(m4);
3486
+ item.screenPosition = vector;
3487
+ return isValid(vector.x) && isValid(vector.y) && isValid(vector.z);
3488
+ }
3489
+ return false;
3490
+ });
3491
+ pois.forEach((item, index) => {
3492
+ const box = item.getBox(
3493
+ item.screenPosition
3494
+ );
3495
+ if (index === 0 || !item.options.collision_enable) {
3496
+ range.push(box);
3497
+ item.parentSetVisible(true);
3498
+ return;
3499
+ }
3500
+ const valid = range.some((rangeBox) => {
3501
+ return rangeBox.intersectsBox(box);
3502
+ });
3503
+ item.parentSetVisible(!valid);
3504
+ if (!valid) {
3505
+ range.push(box);
3506
+ }
3507
+ });
3508
+ }
3509
+ registryEvent() {
3510
+ this.context.addEventListener("update", this.onUpdate);
3511
+ }
3512
+ unRegistryEvent() {
3513
+ this.context.removeEventListener("update", this.onUpdate);
3514
+ }
3515
+ dispose() {
3516
+ this.timer.dispose();
3517
+ this.pois.forEach((item) => item.dispose());
3518
+ this.pois.length = 0;
3519
+ this.debounceCollisionDetection = () => {
3520
+ };
3521
+ super.dispose();
3522
+ this.unRegistryEvent();
3523
+ }
3524
+ };
3525
+
3341
3526
  // src/elements/floor.ts
3342
3527
  var Floor = class extends Object3D8 {
3343
3528
  constructor(context) {
@@ -3346,6 +3531,7 @@ var Floor = class extends Object3D8 {
3346
3531
  this.groundLayer = new Layer(this.context);
3347
3532
  this.graphicLayer = new GraphicLayer(this.context);
3348
3533
  this.poiLayer = new PoiLayer(this.context);
3534
+ this.poiLayer2 = new PoiLayer2(this.context);
3349
3535
  this.wallLayer = new Layer(this.context);
3350
3536
  this.textureLayer = new Layer(this.context);
3351
3537
  this.glbModelLayer = new Layer(this.context);
@@ -3353,6 +3539,7 @@ var Floor = class extends Object3D8 {
3353
3539
  this.mergeGraphicLayer = new Layer(this.context);
3354
3540
  this.groundUpper.add(this.graphicLayer);
3355
3541
  this.groundUpper.add(this.poiLayer);
3542
+ this.groundUpper.add(this.poiLayer2);
3356
3543
  this.groundUpper.add(this.wallLayer);
3357
3544
  this.groundUpper.add(this.textureLayer);
3358
3545
  this.groundUpper.add(this.glbModelLayer);
@@ -3364,6 +3551,7 @@ var Floor = class extends Object3D8 {
3364
3551
  }
3365
3552
  graphicLayer;
3366
3553
  poiLayer;
3554
+ poiLayer2;
3367
3555
  wallLayer;
3368
3556
  textureLayer;
3369
3557
  glbModelLayer;
@@ -3379,9 +3567,10 @@ var Floor = class extends Object3D8 {
3379
3567
  groundMaxHeight = 0;
3380
3568
  name = "";
3381
3569
  key = "";
3570
+ box = new Box35();
3382
3571
  getPosition() {
3383
3572
  const box = new Box35().setFromObject(this);
3384
- return box.getCenter(new Vector38());
3573
+ return box.getCenter(new Vector39());
3385
3574
  }
3386
3575
  createGround(options) {
3387
3576
  const ground = new Graphic(this.context, options);
@@ -3406,7 +3595,7 @@ var Floor = class extends Object3D8 {
3406
3595
  return !!(this.grounds.size || this.graphicLayer.children.length);
3407
3596
  }
3408
3597
  getCenter() {
3409
- return new Box35().setFromObject(this).getCenter(new Vector38());
3598
+ return new Box35().setFromObject(this).getCenter(new Vector39());
3410
3599
  }
3411
3600
  addModel(options) {
3412
3601
  const model = new Model(this.context, options);
@@ -3416,8 +3605,8 @@ var Floor = class extends Object3D8 {
3416
3605
  }
3417
3606
  addShadow() {
3418
3607
  const box = new Box35().setFromObject(this.groundUpper);
3419
- const center2 = box.getCenter(new Vector38());
3420
- const size = box.getSize(new Vector38());
3608
+ const center2 = box.getCenter(new Vector39());
3609
+ const size = box.getSize(new Vector39());
3421
3610
  this.shadow.setPosition(center2);
3422
3611
  this.shadow.changeLightCamera(size);
3423
3612
  }
@@ -3450,11 +3639,15 @@ var Floor = class extends Object3D8 {
3450
3639
  setShadowVisible(visible) {
3451
3640
  this.shadow.visible = visible;
3452
3641
  }
3642
+ updateBox() {
3643
+ this.box.setFromObject(this);
3644
+ }
3453
3645
  dispose() {
3454
3646
  this.shadow.dispose();
3455
3647
  this.groundLayer.dispose();
3456
3648
  this.graphicLayer.dispose();
3457
3649
  this.poiLayer.dispose();
3650
+ this.poiLayer2.dispose();
3458
3651
  this.wallLayer.dispose();
3459
3652
  this.textureLayer.dispose();
3460
3653
  this.glbModelLayer.dispose();
@@ -3471,7 +3664,7 @@ var Floor = class extends Object3D8 {
3471
3664
  };
3472
3665
 
3473
3666
  // src/elements/base-svg.ts
3474
- import { EventDispatcher as EventDispatcher3, Vector3 as Vector39 } from "three";
3667
+ import { EventDispatcher as EventDispatcher3, Vector3 as Vector310 } from "three";
3475
3668
  var BaseSvg = class extends EventDispatcher3 {
3476
3669
  constructor(context) {
3477
3670
  super();
@@ -3509,7 +3702,7 @@ var BaseSvg = class extends EventDispatcher3 {
3509
3702
  const { clientWidth, clientHeight } = renderer.domElement;
3510
3703
  const nx = x / clientWidth * 2 - 1;
3511
3704
  const ny = 1 - y / clientHeight * 2;
3512
- const v = new Vector39(nx, ny, 0);
3705
+ const v = new Vector310(nx, ny, 0);
3513
3706
  return v.unproject(camera);
3514
3707
  }
3515
3708
  getSvgCoordinate(vector) {
@@ -3868,7 +4061,7 @@ import {
3868
4061
  Mesh as Mesh4,
3869
4062
  Object3D as Object3D9,
3870
4063
  ShaderMaterial as ShaderMaterial2,
3871
- Vector3 as Vector310
4064
+ Vector3 as Vector311
3872
4065
  } from "three";
3873
4066
  import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils";
3874
4067
  var Wall = class extends Object3D9 {
@@ -3978,8 +4171,8 @@ var Wall = class extends Object3D9 {
3978
4171
  for (let i = 0; i < curCds.length; i++) {
3979
4172
  const cur = curCds[i];
3980
4173
  const next = i + 1 === curCds.length ? curCds[0] : curCds[i + 1];
3981
- points.push(new Vector310(cur[0], cur[1], _height));
3982
- points.push(new Vector310(next[0], next[1], _height));
4174
+ points.push(new Vector311(cur[0], cur[1], _height));
4175
+ points.push(new Vector311(next[0], next[1], _height));
3983
4176
  }
3984
4177
  }
3985
4178
  return points;
@@ -4084,7 +4277,7 @@ var GroundTexture = class extends Object3D10 {
4084
4277
  };
4085
4278
 
4086
4279
  // src/elements/glb-model.ts
4087
- import { Box3 as Box37, Object3D as Object3D11, Vector3 as Vector311 } from "three";
4280
+ import { Box3 as Box37, Object3D as Object3D11, Vector3 as Vector312 } from "three";
4088
4281
  var defaultGlbOptions = {
4089
4282
  url: "",
4090
4283
  geometry: { type: "polygon", cds: [], coords: [], curveCpt: [], curveIndex: [] },
@@ -4109,7 +4302,7 @@ var GlbModel = class extends Object3D11 {
4109
4302
  const object = await loadModel(this.options.url);
4110
4303
  object.scene.rotation.set(Math.PI / 2, 0, 0);
4111
4304
  const box = new Box37().setFromObject(object.scene);
4112
- const size = box.getSize(new Vector311());
4305
+ const size = box.getSize(new Vector312());
4113
4306
  const max = Math.max(size.x, size.y);
4114
4307
  const scale = this.options.width / max;
4115
4308
  this.scale.set(scale, scale, scale);
@@ -4126,7 +4319,7 @@ var GlbModel = class extends Object3D11 {
4126
4319
  };
4127
4320
 
4128
4321
  // src/elements/lane.ts
4129
- import { BufferGeometry as BufferGeometry3, LineSegments as LineSegments3, Mesh as Mesh6, Object3D as Object3D12, ShapeGeometry as ShapeGeometry2, Vector3 as Vector312 } from "three";
4322
+ import { BufferGeometry as BufferGeometry3, LineSegments as LineSegments3, Mesh as Mesh6, Object3D as Object3D12, ShapeGeometry as ShapeGeometry2, Vector3 as Vector313 } from "three";
4130
4323
  import { mergeGeometries as mergeGeometries3 } from "three/examples/jsm/utils/BufferGeometryUtils";
4131
4324
  import { Line2 } from "three/examples/jsm/lines/Line2";
4132
4325
  import { LineGeometry } from "three/examples/jsm/lines/LineGeometry";
@@ -4187,8 +4380,8 @@ var Lane = class extends Object3D12 {
4187
4380
  for (let i = 0; i < curCds.length; i++) {
4188
4381
  const cur = curCds[i];
4189
4382
  const next = i + 1 === curCds.length ? curCds[0] : curCds[i + 1];
4190
- points.push(new Vector312(cur[0], cur[1], _height));
4191
- points.push(new Vector312(next[0], next[1], _height));
4383
+ points.push(new Vector313(cur[0], cur[1], _height));
4384
+ points.push(new Vector313(next[0], next[1], _height));
4192
4385
  }
4193
4386
  }
4194
4387
  return points;
@@ -4263,7 +4456,7 @@ import {
4263
4456
  Object3D as Object3D13,
4264
4457
  ExtrudeGeometry as ExtrudeGeometry3,
4265
4458
  Mesh as Mesh7,
4266
- Vector3 as Vector313,
4459
+ Vector3 as Vector314,
4267
4460
  BufferGeometry as BufferGeometry4,
4268
4461
  LineSegments as LineSegments4,
4269
4462
  ShaderMaterial as ShaderMaterial3,
@@ -4391,8 +4584,8 @@ var MergeGraphic = class extends Object3D13 {
4391
4584
  for (let i = 0; i < curCds.length; i++) {
4392
4585
  const cur = curCds[i];
4393
4586
  const next = i + 1 === curCds.length ? curCds[0] : curCds[i + 1];
4394
- points.push(new Vector313(cur[0], cur[1], height));
4395
- points.push(new Vector313(next[0], next[1], height));
4587
+ points.push(new Vector314(cur[0], cur[1], height));
4588
+ points.push(new Vector314(next[0], next[1], height));
4396
4589
  }
4397
4590
  }
4398
4591
  });
@@ -4424,13 +4617,241 @@ var MergeGraphic = class extends Object3D13 {
4424
4617
  }
4425
4618
  };
4426
4619
 
4620
+ // src/elements/poi2.ts
4621
+ import {
4622
+ Box2 as Box22,
4623
+ Object3D as Object3D14,
4624
+ Sprite,
4625
+ SpriteMaterial,
4626
+ Vector2 as Vector26
4627
+ } from "three";
4628
+ var defaultOptions4 = {
4629
+ text: "",
4630
+ icon: "",
4631
+ icon_size: [18, 18],
4632
+ level: 1,
4633
+ collision_enable: true,
4634
+ opacity: 1,
4635
+ id: "",
4636
+ position: { x: 0, y: 0, z: 0 },
4637
+ text_font_size: 14
4638
+ };
4639
+ var Poi2 = class extends Object3D14 {
4640
+ constructor(context, options) {
4641
+ super();
4642
+ this.context = context;
4643
+ this.options = proxyOptions(
4644
+ { ...defaultOptions4, ...options },
4645
+ this
4646
+ );
4647
+ this.position.set(
4648
+ this.options.position.x,
4649
+ this.options.position.y,
4650
+ this.options.position.z
4651
+ );
4652
+ this.registryEvent();
4653
+ this.init();
4654
+ }
4655
+ options;
4656
+ textAspect = 1;
4657
+ spriteText;
4658
+ spriteIcon;
4659
+ box = new Box22();
4660
+ boxHelper;
4661
+ get durIconAndText() {
4662
+ return this.options.icon && this.options.text ? 2 : 0;
4663
+ }
4664
+ get offset() {
4665
+ return this.options.icon && this.options.text ? 0 : 0.5;
4666
+ }
4667
+ get iconWidth() {
4668
+ return this.options.icon ? this.options.icon_size[0] : 0;
4669
+ }
4670
+ get iconHeight() {
4671
+ return this.options.icon ? this.options.icon_size[1] : 0;
4672
+ }
4673
+ get textWidth() {
4674
+ return this.options.text ? this.options.text_font_size * this.textAspect : 0;
4675
+ }
4676
+ get textHeight() {
4677
+ return this.options.text ? this.options.text_font_size : 0;
4678
+ }
4679
+ get deltaZ() {
4680
+ const { offset, iconHeight, durIconAndText, textHeight } = this;
4681
+ let dz = offset * (iconHeight + durIconAndText + textHeight) / this.context.camera.zoom;
4682
+ dz += 0.1;
4683
+ return dz;
4684
+ }
4685
+ registryEvent() {
4686
+ this.context.addEventListener("control-zoom-change", this._initScale);
4687
+ this.addEventListener("change-icon", async ({ value }) => {
4688
+ if (this.spriteIcon) {
4689
+ this.remove(this.spriteIcon);
4690
+ this.spriteIcon = void 0;
4691
+ }
4692
+ await this.initIcon();
4693
+ this.initSize();
4694
+ this._initScale({ zoom: this.context.camera.zoom });
4695
+ });
4696
+ this.addEventListener("change-text", ({ value }) => {
4697
+ if (this.spriteText) {
4698
+ this.remove(this.spriteText);
4699
+ this.spriteText = void 0;
4700
+ }
4701
+ this.initText();
4702
+ this.initSize();
4703
+ this._initScale({ zoom: this.context.camera.zoom });
4704
+ });
4705
+ }
4706
+ unRegistryEvent() {
4707
+ this.context.removeEventListener("control-zoom-change", this._initScale);
4708
+ }
4709
+ async initIcon() {
4710
+ if (this.options.icon) {
4711
+ const texture = await getTextureByUrl(this.options.icon);
4712
+ const spriteIcon = new Sprite(
4713
+ new SpriteMaterial({
4714
+ map: texture,
4715
+ transparent: true,
4716
+ alphaTest: 0.2
4717
+ })
4718
+ );
4719
+ spriteIcon.renderOrder = 1e5;
4720
+ texture.needsUpdate = true;
4721
+ this.add(spriteIcon);
4722
+ this.spriteIcon = spriteIcon;
4723
+ }
4724
+ }
4725
+ initText() {
4726
+ if (this.options.text) {
4727
+ const texture = getTextureByText(this.options.text);
4728
+ this.textAspect = texture.image.width / texture.image.height;
4729
+ const spriteText = new Sprite(
4730
+ new SpriteMaterial({
4731
+ map: texture,
4732
+ transparent: true,
4733
+ alphaTest: 0.2
4734
+ })
4735
+ );
4736
+ spriteText.renderOrder = 100001;
4737
+ texture.needsUpdate = true;
4738
+ this.spriteText = spriteText;
4739
+ this.add(spriteText);
4740
+ }
4741
+ }
4742
+ initSize() {
4743
+ let iconCenterY = 0;
4744
+ let textCenterY = 0;
4745
+ const { icon, text } = this.options;
4746
+ if (icon) {
4747
+ if (text) {
4748
+ iconCenterY = 0;
4749
+ textCenterY = iconCenterY * (this.iconHeight / this.textHeight) - this.iconHeight / this.textHeight - this.durIconAndText / this.textHeight;
4750
+ } else {
4751
+ iconCenterY = 0.5;
4752
+ textCenterY = 0;
4753
+ }
4754
+ } else if (text) {
4755
+ textCenterY = 0.5;
4756
+ iconCenterY = 0;
4757
+ } else {
4758
+ iconCenterY = 0;
4759
+ textCenterY = 0;
4760
+ }
4761
+ this.spriteIcon?.center.set(0.5, iconCenterY);
4762
+ this.spriteText?.center.set(0.5, textCenterY);
4763
+ }
4764
+ async init() {
4765
+ await this.initIcon();
4766
+ this.initText();
4767
+ this.initSize();
4768
+ this._initScale({ zoom: this.context.camera.zoom });
4769
+ }
4770
+ _initScale = ({ zoom }) => {
4771
+ if (this.spriteText) {
4772
+ const scaleText = this.textHeight / zoom;
4773
+ this.spriteText.scale.set(this.textAspect * scaleText, scaleText, 0.1);
4774
+ }
4775
+ if (this.spriteIcon) {
4776
+ this.spriteIcon?.scale.set(
4777
+ this.options.icon_size[0] / zoom,
4778
+ this.options.icon_size[1] / zoom,
4779
+ 0.1
4780
+ );
4781
+ }
4782
+ this.resetZ();
4783
+ };
4784
+ resetZ() {
4785
+ const dz = this.deltaZ;
4786
+ if (this.spriteIcon) {
4787
+ this.spriteIcon.position.z = dz;
4788
+ }
4789
+ if (this.spriteText) {
4790
+ this.spriteText.position.z = dz;
4791
+ }
4792
+ }
4793
+ getBox(v3) {
4794
+ const {
4795
+ clientSize: { width, height }
4796
+ } = this.context;
4797
+ const x = width * (v3.x + 1) / 2;
4798
+ let y = height * (-v3.y + 1) / 2;
4799
+ y += this.offset * (this.iconHeight + this.durIconAndText + this.textHeight);
4800
+ const halfIconWidth = this.iconWidth / 2;
4801
+ const boundIcon = new Box22(
4802
+ new Vector26(x - halfIconWidth, y - this.iconHeight),
4803
+ new Vector26(x + halfIconWidth, y)
4804
+ );
4805
+ const halfTextWidth = this.textWidth / 2;
4806
+ const boundText = new Box22(
4807
+ new Vector26(x - halfTextWidth, y - this.textHeight - this.durIconAndText - this.iconHeight),
4808
+ new Vector26(
4809
+ x + halfTextWidth,
4810
+ y - this.iconHeight - this.durIconAndText
4811
+ )
4812
+ );
4813
+ this.box = boundText.union(boundIcon);
4814
+ return this.box;
4815
+ }
4816
+ renderBoxHelper() {
4817
+ if (!this.boxHelper) {
4818
+ const div = document.createElement("div");
4819
+ div.style.position = "fixed";
4820
+ this.boxHelper = div;
4821
+ div.style.border = "1px solid red";
4822
+ div.style.pointerEvents = "none";
4823
+ this.context.container.appendChild(div);
4824
+ }
4825
+ this.boxHelper.style.left = this.box.min.x + "px";
4826
+ this.boxHelper.style.top = this.box.min.y + "px";
4827
+ this.boxHelper.style.width = this.box.max.x - this.box.min.x + "px";
4828
+ this.boxHelper.style.height = this.box.max.y - this.box.min.y + "px";
4829
+ }
4830
+ // 碰撞检测设置显隐
4831
+ parentSetVisible(visible) {
4832
+ if (this.spriteText) {
4833
+ this.spriteText.visible = visible;
4834
+ }
4835
+ if (this.spriteIcon) {
4836
+ this.spriteIcon.visible = visible;
4837
+ }
4838
+ if (this.boxHelper) {
4839
+ this.boxHelper.style.display = visible ? "block" : "none";
4840
+ }
4841
+ }
4842
+ dispose() {
4843
+ this.unRegistryEvent();
4844
+ this.spriteText = void 0;
4845
+ }
4846
+ };
4847
+
4427
4848
  // src/operations/selection/box-selection.ts
4428
- import { Frustum } from "three";
4849
+ import { Frustum as Frustum2 } from "three";
4429
4850
  var BoxSelection = class extends BaseSvg {
4430
4851
  startPoint;
4431
4852
  endPoint;
4432
4853
  rect;
4433
- frustum = new Frustum();
4854
+ frustum = new Frustum2();
4434
4855
  constructor(context) {
4435
4856
  super(context);
4436
4857
  const { config: { selectBox: { fill, stroke } } } = context;
@@ -4681,7 +5102,7 @@ var Selection = class extends EventDispatcher4 {
4681
5102
  };
4682
5103
 
4683
5104
  // src/operations/hover/hover-helper.ts
4684
- import { EventDispatcher as EventDispatcher5 } from "three";
5105
+ import { EventDispatcher as EventDispatcher5, Vector2 as Vector27 } from "three";
4685
5106
  var HoverHelper = class extends EventDispatcher5 {
4686
5107
  constructor(context) {
4687
5108
  super();
@@ -4705,11 +5126,20 @@ var HoverHelper = class extends EventDispatcher5 {
4705
5126
  let distance = 1e4;
4706
5127
  poiGraphics.forEach((graphic) => {
4707
5128
  const poi = pois.find((poi2) => poi2.options.id === graphic.options.id);
4708
- const { x, y } = poi.clientPos;
4709
- let curDistance = Math.sqrt((x - e.offsetX) ** 2 + (y - e.offsetY) ** 2);
4710
- if (curDistance < distance) {
4711
- distance = curDistance;
4712
- resGraphic = graphic;
5129
+ if (poi instanceof Poi) {
5130
+ const { x, y } = poi.clientPos;
5131
+ let curDistance = Math.sqrt((x - e.offsetX) ** 2 + (y - e.offsetY) ** 2);
5132
+ if (curDistance < distance) {
5133
+ distance = curDistance;
5134
+ resGraphic = graphic;
5135
+ }
5136
+ } else if (poi instanceof Poi2) {
5137
+ const { x, y } = poi.box.getCenter(new Vector27());
5138
+ let curDistance = Math.sqrt((x - e.offsetX) ** 2 + (y - e.offsetY) ** 2);
5139
+ if (curDistance < distance) {
5140
+ distance = curDistance;
5141
+ resGraphic = graphic;
5142
+ }
4713
5143
  }
4714
5144
  });
4715
5145
  allGraphics.add(resGraphic);
@@ -4790,7 +5220,7 @@ import {
4790
5220
  MeshBasicMaterial as MeshBasicMaterial5,
4791
5221
  ShaderMaterial as ShaderMaterial4,
4792
5222
  DoubleSide as DoubleSide4,
4793
- Vector2 as Vector25
5223
+ Vector2 as Vector28
4794
5224
  } from "three";
4795
5225
  function vectorToString(vector) {
4796
5226
  return `${vector.x}-${vector.y}-${vector.z}`;
@@ -4966,7 +5396,7 @@ var MaterialFactory = class {
4966
5396
  dashSize: 1,
4967
5397
  gapSize: 3,
4968
5398
  dashScale: 1,
4969
- resolution: new Vector25(this.context.clientSize.width, this.context.clientSize.height)
5399
+ resolution: new Vector28(this.context.clientSize.width, this.context.clientSize.height)
4970
5400
  });
4971
5401
  this.line2MaterialMap.set(key, material);
4972
5402
  return material;
@@ -5001,7 +5431,7 @@ var MaterialFactory = class {
5001
5431
  };
5002
5432
 
5003
5433
  // src/utils/camera-bound.ts
5004
- import { Box3 as Box38, Vector3 as Vector316 } from "three";
5434
+ import { Box3 as Box39, Vector3 as Vector318 } from "three";
5005
5435
  var CameraBound = class {
5006
5436
  constructor(context) {
5007
5437
  this.context = context;
@@ -5009,11 +5439,15 @@ var CameraBound = class {
5009
5439
  this.changePrevCamera();
5010
5440
  }
5011
5441
  prevCamera = {
5012
- position: new Vector316(),
5442
+ position: new Vector318(),
5013
5443
  zoom: 1,
5014
- target: new Vector316()
5444
+ target: new Vector318()
5015
5445
  };
5016
5446
  enable = true;
5447
+ box = new Box39();
5448
+ updateBox() {
5449
+ this.box.setFromObject(this.context.scene);
5450
+ }
5017
5451
  setEnable(enable) {
5018
5452
  this.enable = enable;
5019
5453
  if (enable) {
@@ -5048,13 +5482,13 @@ var CameraBound = class {
5048
5482
  if (!floors.length) {
5049
5483
  return null;
5050
5484
  }
5051
- const box = new Box38().setFromObject(this.context.scene);
5485
+ const box = this.box;
5052
5486
  const { camera, clientSize: { width: w, height: h } } = this.context;
5053
5487
  const { min, max } = box;
5054
5488
  const lb = vector3ToDevice(min, camera, w, h);
5055
5489
  const rt = vector3ToDevice(max, camera, w, h);
5056
- const lt = vector3ToDevice(new Vector316(min.x, max.y, max.z), camera, w, h);
5057
- const rb = vector3ToDevice(new Vector316(max.x, min.y, min.z), camera, w, h);
5490
+ const lt = vector3ToDevice(new Vector318(min.x, max.y, max.z), camera, w, h);
5491
+ const rb = vector3ToDevice(new Vector318(max.x, min.y, min.z), camera, w, h);
5058
5492
  const left = Math.min(lb.x, rt.x, lt.x, rb.x);
5059
5493
  const right = Math.max(lb.x, rt.x, lt.x, rb.x);
5060
5494
  const top = Math.min(lb.y, rt.y, lt.y, rb.y);
@@ -5093,13 +5527,13 @@ var CameraBound = class {
5093
5527
  };
5094
5528
 
5095
5529
  // src/factory/texture.ts
5096
- import { TextureLoader } from "three";
5530
+ import { TextureLoader as TextureLoader2 } from "three";
5097
5531
  var TextureFactory = class {
5098
5532
  constructor(context) {
5099
5533
  this.context = context;
5100
5534
  }
5101
5535
  textureMap = /* @__PURE__ */ new Map();
5102
- loader = new TextureLoader();
5536
+ loader = new TextureLoader2();
5103
5537
  async getTexture(url) {
5104
5538
  if (this.textureMap.has(url)) {
5105
5539
  return this.textureMap.get(url);
@@ -5162,6 +5596,7 @@ var Context = class extends EventDispatcher6 {
5162
5596
  y: 0
5163
5597
  };
5164
5598
  renderRf = 0;
5599
+ prevCameraZoom = 1;
5165
5600
  resizeClientSize() {
5166
5601
  const { x, y, width, height } = this.container.getBoundingClientRect();
5167
5602
  this.clientSize = {
@@ -5174,6 +5609,7 @@ var Context = class extends EventDispatcher6 {
5174
5609
  init() {
5175
5610
  const { clientWidth: w, clientHeight: h } = this.container;
5176
5611
  this.camera = initCamera(w, h);
5612
+ this.prevCameraZoom = this.camera.zoom;
5177
5613
  this.renderer.setSize(w, h);
5178
5614
  this.control = initControl(this.camera, this.renderer.domElement);
5179
5615
  this.control.maxPolarAngle = this.config.control.maxPolar;
@@ -5185,13 +5621,17 @@ var Context = class extends EventDispatcher6 {
5185
5621
  this.currentFloor?.setShadowOpacity(polarAngle / this.config.control.maxPolar);
5186
5622
  this.dispatchEvent({ type: "change-ratio", px: (this.basicRatio || 0) * this.camera.zoom });
5187
5623
  this.dispatchEvent({ type: "control-change" });
5624
+ if (this.prevCameraZoom !== this.camera.zoom) {
5625
+ this.dispatchEvent({ type: "control-zoom-change", zoom: this.camera.zoom });
5626
+ this.prevCameraZoom = this.camera.zoom;
5627
+ }
5188
5628
  });
5189
5629
  this.cameraBound = new CameraBound(this);
5190
5630
  }
5191
5631
  /**
5192
5632
  * 获取两个点之间的像素数
5193
5633
  */
5194
- getRatio(point1 = new Vector317(0, 0, 0), point22 = new Vector317(100, 0, 0)) {
5634
+ getRatio(point1 = new Vector319(0, 0, 0), point22 = new Vector319(100, 0, 0)) {
5195
5635
  const { clientWidth, clientHeight } = this.container;
5196
5636
  const device1 = vector3ToDevice(point1, this.camera, clientWidth, clientHeight);
5197
5637
  const device2 = vector3ToDevice(point22, this.camera, clientWidth, clientHeight);
@@ -5216,6 +5656,7 @@ var Context = class extends EventDispatcher6 {
5216
5656
  this.lights.position.x = position.x;
5217
5657
  this.lights.position.y = position.y;
5218
5658
  }
5659
+ this.cameraBound.updateBox();
5219
5660
  }
5220
5661
  onWindowResize = () => {
5221
5662
  const { container, camera, renderer } = this;
@@ -5252,10 +5693,10 @@ var Context = class extends EventDispatcher6 {
5252
5693
  * @returns
5253
5694
  */
5254
5695
  getGraphicsByDeviceXy(x, y) {
5255
- const point3 = new Vector26();
5696
+ const point3 = new Vector29();
5256
5697
  point3.x = x / this.clientSize.width * 2 - 1;
5257
5698
  point3.y = y / this.clientSize.height * -2 + 1;
5258
- const raycaster = new Raycaster3();
5699
+ const raycaster = new Raycaster5();
5259
5700
  raycaster.setFromCamera(point3, this.camera);
5260
5701
  raycaster.ray.origin.sub(raycaster.ray.direction.clone().multiplyScalar(100));
5261
5702
  const res = this.currentFloor?.graphicLayer.getGraphicByRaycaster(raycaster);
@@ -5269,7 +5710,8 @@ var Context = class extends EventDispatcher6 {
5269
5710
  */
5270
5711
  getPoisByDeviceXy(x, y) {
5271
5712
  const pois = this.currentFloor?.poiLayer.getPoiByDeviceXy(x, y);
5272
- return pois || [];
5713
+ const res = this.currentFloor?.poiLayer2.getPoiByDeviceXy(x, y);
5714
+ return (pois || []).concat(res || []);
5273
5715
  }
5274
5716
  onPointerover = (e) => {
5275
5717
  const { graphics, position } = this.getGraphicsByDeviceXy(e.offsetX, e.offsetY);
@@ -5392,7 +5834,7 @@ var Context = class extends EventDispatcher6 {
5392
5834
  );
5393
5835
  }
5394
5836
  getCameraLookAt() {
5395
- return new Vector317().subVectors(this.control.target, this.camera.position);
5837
+ return new Vector319().subVectors(this.control.target, this.camera.position);
5396
5838
  }
5397
5839
  /**
5398
5840
  * 按照一个中心点设置相机的放大缩小
@@ -5444,28 +5886,28 @@ var Context = class extends EventDispatcher6 {
5444
5886
  if (force2DView) {
5445
5887
  this.setPolarAngle(0, 0);
5446
5888
  }
5447
- const boundingBox = new Box39().setFromObject(object);
5889
+ const boundingBox = new Box310().setFromObject(object);
5448
5890
  this.setPolarAngle(polar, 0);
5449
5891
  const { max, min } = boundingBox;
5450
- const leftTop = new Vector317(min.x, max.y, max.z);
5451
- const rightTop = new Vector317(max.x, max.y, max.z);
5452
- const rightBottom = new Vector317(max.x, min.y, min.z);
5453
- const leftBottom = new Vector317(min.x, min.y, min.z);
5892
+ const leftTop = new Vector319(min.x, max.y, max.z);
5893
+ const rightTop = new Vector319(max.x, max.y, max.z);
5894
+ const rightBottom = new Vector319(max.x, min.y, min.z);
5895
+ const leftBottom = new Vector319(min.x, min.y, min.z);
5454
5896
  const leftTop2d = vector3ToDevice(leftTop, this.camera, width, height);
5455
5897
  const rightTop2d = vector3ToDevice(rightTop, this.camera, width, height);
5456
5898
  const leftBottom2d = vector3ToDevice(leftBottom, this.camera, width, height);
5457
5899
  const rightBottom2d = vector3ToDevice(rightBottom, this.camera, width, height);
5458
- const boundingBox2d = new Box2().setFromPoints([
5459
- new Vector26(leftTop2d.x, leftTop2d.y),
5460
- new Vector26(rightTop2d.x, rightTop2d.y),
5461
- new Vector26(leftBottom2d.x, leftBottom2d.y),
5462
- new Vector26(rightBottom2d.x, rightBottom2d.y)
5900
+ const boundingBox2d = new Box23().setFromPoints([
5901
+ new Vector29(leftTop2d.x, leftTop2d.y),
5902
+ new Vector29(rightTop2d.x, rightTop2d.y),
5903
+ new Vector29(leftBottom2d.x, leftBottom2d.y),
5904
+ new Vector29(rightBottom2d.x, rightBottom2d.y)
5463
5905
  ]);
5464
- const size = boundingBox2d.getSize(new Vector26());
5906
+ const size = boundingBox2d.getSize(new Vector29());
5465
5907
  const xScale = (width - right - left) / size.x;
5466
5908
  const yScale = (height - top - bottom) / size.y;
5467
5909
  const scale = Math.min(xScale, yScale);
5468
- const center2 = new Vector317((max.x + min.x) / 2, (max.y + min.y) / 2, (max.z + min.z) / 2);
5910
+ const center2 = new Vector319((max.x + min.x) / 2, (max.y + min.y) / 2, (max.z + min.z) / 2);
5469
5911
  return { zoom: scale * this.camera.zoom, center: center2 };
5470
5912
  }
5471
5913
  /**
@@ -5497,10 +5939,17 @@ var Context = class extends EventDispatcher6 {
5497
5939
  * @param duration 动画持续时间
5498
5940
  */
5499
5941
  setCameraPosition(position, duration) {
5942
+ const start = this.camera.position.clone();
5943
+ const lookAtVector = this.getCameraLookAt();
5944
+ if (!duration) {
5945
+ this.control.enabled = false;
5946
+ this.camera.position.copy(position.clone().sub(lookAtVector));
5947
+ this.control.target.copy(position.clone());
5948
+ this.control.update();
5949
+ this.control.enabled = true;
5950
+ }
5500
5951
  return timeoutPromise(
5501
5952
  new Promise((resolve) => {
5502
- const start = this.camera.position.clone();
5503
- const lookAtVector = this.getCameraLookAt();
5504
5953
  const tween = new Tween(start, this.tweenGroup).to(position, duration).onUpdate(() => {
5505
5954
  this.camera.position.copy(start.clone().sub(lookAtVector));
5506
5955
  this.control.target.copy(start.clone());
@@ -5627,7 +6076,7 @@ function getConfig(config) {
5627
6076
  }
5628
6077
 
5629
6078
  // src/bmap.ts
5630
- import { debounce as debounce3 } from "lodash";
6079
+ import { debounce as debounce4 } from "lodash";
5631
6080
 
5632
6081
  // src/api/floor.ts
5633
6082
  async function loadBuildingGround({ brand, project }, config) {
@@ -5877,6 +6326,7 @@ var BMap = class extends EventDispatcher7 {
5877
6326
  if (createdFloor) {
5878
6327
  createdFloor.curFloor.name = floor;
5879
6328
  this.triggerHooks("switch_floor_before" /* SWITCH_FLOOR_BEFORE */, createdFloor);
6329
+ createdFloor.curFloor.updateBox();
5880
6330
  this.context.switchFloor(createdFloor.curFloor);
5881
6331
  this.initialFloorCamera();
5882
6332
  this.triggerHooks("switch_floor_after" /* SWITCH_FLOOR_AFTER */, createdFloor);
@@ -6016,7 +6466,7 @@ var BMap = class extends EventDispatcher7 {
6016
6466
  } = this.context;
6017
6467
  const device = vector3ToDevice(position, camera, width, height);
6018
6468
  const offsetX = device.x - width / 2;
6019
- const v3 = new Vector318();
6469
+ const v3 = new Vector320();
6020
6470
  v3.setFromMatrixColumn(this.context.camera.matrix, 0);
6021
6471
  v3.normalize();
6022
6472
  v3.multiplyScalar(offsetX / this.context.camera.zoom);
@@ -6121,7 +6571,7 @@ var BMap = class extends EventDispatcher7 {
6121
6571
  window.addEventListener("keydown", this.onKeydown);
6122
6572
  window.addEventListener("keyup", this.onKeyUp);
6123
6573
  if (this.config.resizeObserver) {
6124
- const observe = new ResizeObserver(debounce3(this.resize, 5));
6574
+ const observe = new ResizeObserver(debounce4(this.resize, 5));
6125
6575
  observe.observe(this.container);
6126
6576
  this.observe = observe;
6127
6577
  }
@@ -6241,15 +6691,16 @@ var BMap = class extends EventDispatcher7 {
6241
6691
  return this.context.currentFloor?.graphicLayer.createGraphic(options);
6242
6692
  }
6243
6693
  removePoiById(id) {
6244
- return this.context.currentFloor?.poiLayer.removePoiById(id);
6694
+ this.context.currentFloor?.poiLayer.removePoiById(id);
6695
+ this.context.currentFloor?.poiLayer2.removePoiById(id);
6245
6696
  }
6246
6697
  getPoiById(id) {
6247
- return this.context.currentFloor?.poiLayer.getPoiById(id);
6698
+ return this.context.currentFloor?.poiLayer.getPoiById(id) || this.context.currentFloor?.poiLayer2.getPoiById(id);
6248
6699
  }
6249
6700
  getPois() {
6250
- return (this.context.currentFloor?.poiLayer.pois || []).filter(
6701
+ return [...(this.context.currentFloor?.poiLayer.pois || []).filter(
6251
6702
  (item) => !item.options.built_in
6252
- );
6703
+ ), ...this.context.currentFloor?.poiLayer2.pois || []];
6253
6704
  }
6254
6705
  clearPoi() {
6255
6706
  if (this.context.currentFloor) {
@@ -6390,11 +6841,11 @@ function Worker2() {
6390
6841
  // src/plugins/navigation/path.ts
6391
6842
  import {
6392
6843
  Mesh as Mesh8,
6393
- Object3D as Object3D16,
6394
- TextureLoader as TextureLoader2,
6844
+ Object3D as Object3D17,
6845
+ TextureLoader as TextureLoader3,
6395
6846
  Color as Color8,
6396
- Vector2 as Vector28,
6397
- Vector3 as Vector320,
6847
+ Vector2 as Vector211,
6848
+ Vector3 as Vector322,
6398
6849
  NormalBlending,
6399
6850
  RepeatWrapping
6400
6851
  } from "three";
@@ -6402,8 +6853,8 @@ import {
6402
6853
  // src/external/meshLine.js
6403
6854
  import {
6404
6855
  BufferGeometry as BufferGeometry5,
6405
- Matrix4,
6406
- Vector3 as Vector319,
6856
+ Matrix4 as Matrix42,
6857
+ Vector3 as Vector321,
6407
6858
  Ray as Ray2,
6408
6859
  Sphere,
6409
6860
  LineSegments as LineSegments5,
@@ -6412,7 +6863,7 @@ import {
6412
6863
  ShaderMaterial as ShaderMaterial5,
6413
6864
  UniformsLib,
6414
6865
  Color as Color7,
6415
- Vector2 as Vector27
6866
+ Vector2 as Vector210
6416
6867
  } from "three";
6417
6868
  var MeshLine = class extends BufferGeometry5 {
6418
6869
  constructor() {
@@ -6430,7 +6881,7 @@ var MeshLine = class extends BufferGeometry5 {
6430
6881
  this._points = [];
6431
6882
  this._geom = null;
6432
6883
  this.widthCallback = null;
6433
- this.matrixWorld = new Matrix4();
6884
+ this.matrixWorld = new Matrix42();
6434
6885
  Object.defineProperties(this, {
6435
6886
  // this is now a bufferGeometry
6436
6887
  // add getter to support previous api
@@ -6483,7 +6934,7 @@ MeshLine.prototype.setPoints = function(points, wcb) {
6483
6934
  this.widthCallback = wcb;
6484
6935
  this.positions = [];
6485
6936
  this.counters = [];
6486
- if (points.length && points[0] instanceof Vector319) {
6937
+ if (points.length && points[0] instanceof Vector321) {
6487
6938
  for (var j = 0; j < points.length; j++) {
6488
6939
  var p = points[j];
6489
6940
  var c = j / points.length;
@@ -6504,10 +6955,10 @@ MeshLine.prototype.setPoints = function(points, wcb) {
6504
6955
  this.process();
6505
6956
  };
6506
6957
  function MeshLineRaycast(raycaster, intersects) {
6507
- var inverseMatrix = new Matrix4();
6958
+ var inverseMatrix = new Matrix42();
6508
6959
  var ray = new Ray2();
6509
6960
  var sphere = new Sphere();
6510
- var interRay = new Vector319();
6961
+ var interRay = new Vector321();
6511
6962
  var geometry = this.geometry;
6512
6963
  if (!geometry.boundingSphere) geometry.computeBoundingSphere();
6513
6964
  sphere.copy(geometry.boundingSphere);
@@ -6517,9 +6968,9 @@ function MeshLineRaycast(raycaster, intersects) {
6517
6968
  }
6518
6969
  inverseMatrix.copy(this.matrixWorld).invert();
6519
6970
  ray.copy(raycaster.ray).applyMatrix4(inverseMatrix);
6520
- var vStart = new Vector319();
6521
- var vEnd = new Vector319();
6522
- var interSegment = new Vector319();
6971
+ var vStart = new Vector321();
6972
+ var vEnd = new Vector321();
6973
+ var interSegment = new Vector321();
6523
6974
  var step = this instanceof LineSegments5 ? 2 : 1;
6524
6975
  var index = geometry.index;
6525
6976
  var attributes = geometry.attributes;
@@ -6573,8 +7024,8 @@ MeshLine.prototype.getDistance = function(i) {
6573
7024
  let maxLength = 0;
6574
7025
  for (let k = 0; k < i; k++) {
6575
7026
  const index = 6 * k;
6576
- const p0 = new Vector319(this.positions[index], this.positions[index + 1], this.positions[index + 2]);
6577
- const p1 = new Vector319(this.positions[index + 6], this.positions[index + 7], this.positions[index + 8]);
7027
+ const p0 = new Vector321(this.positions[index], this.positions[index + 1], this.positions[index + 2]);
7028
+ const p1 = new Vector321(this.positions[index + 6], this.positions[index + 7], this.positions[index + 8]);
6578
7029
  const distance = p0.distanceTo(p1);
6579
7030
  maxLength += distance;
6580
7031
  }
@@ -6809,6 +7260,7 @@ ShaderChunk["meshline_frag"] = [
6809
7260
  "uniform float visibility;",
6810
7261
  "uniform float alphaTest;",
6811
7262
  "uniform vec2 repeat;",
7263
+ "uniform float thresholdRatio;",
6812
7264
  "",
6813
7265
  "varying vec2 vUV;",
6814
7266
  "varying vec4 vColor;",
@@ -6829,6 +7281,9 @@ ShaderChunk["meshline_frag"] = [
6829
7281
  " gl_FragColor.a *= step(vCounters, visibility);",
6830
7282
  "",
6831
7283
  ShaderChunk.fog_fragment,
7284
+ "if (vUV.x <= thresholdRatio) {",
7285
+ "gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);",
7286
+ "}",
6832
7287
  "}"
6833
7288
  ].join("\n");
6834
7289
  var MeshLineMaterial = class extends ShaderMaterial5 {
@@ -6842,7 +7297,7 @@ var MeshLineMaterial = class extends ShaderMaterial5 {
6842
7297
  useAlphaMap: { value: 0 },
6843
7298
  color: { value: new Color7(16777215) },
6844
7299
  opacity: { value: 1 },
6845
- resolution: { value: new Vector27(1, 1) },
7300
+ resolution: { value: new Vector210(1, 1) },
6846
7301
  sizeAttenuation: { value: 1 },
6847
7302
  dashArray: { value: 0 },
6848
7303
  dashOffset: { value: 0 },
@@ -6850,7 +7305,12 @@ var MeshLineMaterial = class extends ShaderMaterial5 {
6850
7305
  useDash: { value: 0 },
6851
7306
  visibility: { value: 1 },
6852
7307
  alphaTest: { value: 0 },
6853
- repeat: { value: new Vector27(1, 1) }
7308
+ repeat: { value: new Vector210(1, 1) },
7309
+ thresholdRatio: { value: 0 },
7310
+ transparent: { value: true },
7311
+ depthTest: { vale: false },
7312
+ depthWrite: { value: false },
7313
+ alphaTest: { value: 0.2 }
6854
7314
  }),
6855
7315
  vertexShader: ShaderChunk.meshline_vert,
6856
7316
  fragmentShader: ShaderChunk.meshline_frag
@@ -7002,6 +7462,15 @@ var MeshLineMaterial = class extends ShaderMaterial5 {
7002
7462
  set: function(value) {
7003
7463
  this.uniforms.repeat.value.copy(value);
7004
7464
  }
7465
+ },
7466
+ thresholdRatio: {
7467
+ enumerable: true,
7468
+ get: function() {
7469
+ return this.uniforms.thresholdRatio.value;
7470
+ },
7471
+ set: function(value) {
7472
+ this.uniforms.thresholdRatio.value = value;
7473
+ }
7005
7474
  }
7006
7475
  });
7007
7476
  this.setValues(parameters);
@@ -7037,12 +7506,13 @@ var defaultConfig2 = {
7037
7506
  lineWidth: 8,
7038
7507
  color: 16777215
7039
7508
  };
7040
- var Path2 = class extends Object3D16 {
7509
+ var Path2 = class extends Object3D17 {
7041
7510
  constructor(navigation, config) {
7042
7511
  super();
7043
7512
  this.navigation = navigation;
7044
7513
  this.config = Object.assign({}, defaultConfig2, config);
7045
7514
  this.registryEvent();
7515
+ this.prevCameraZoom = this.navigation.bmap.context.camera.zoom;
7046
7516
  }
7047
7517
  mesh = null;
7048
7518
  geometry = null;
@@ -7050,7 +7520,9 @@ var Path2 = class extends Object3D16 {
7050
7520
  texture = null;
7051
7521
  config = defaultConfig2;
7052
7522
  points = [];
7523
+ pathDistance = 0;
7053
7524
  basicRepeat = 1;
7525
+ prevCameraZoom = 0;
7054
7526
  registryEvent() {
7055
7527
  this.navigation.bmap.context.addEventListener(
7056
7528
  "control-change",
@@ -7066,7 +7538,11 @@ var Path2 = class extends Object3D16 {
7066
7538
  this.navigation.bmap.context.removeEventListener("update", this.onUpdate);
7067
7539
  }
7068
7540
  onControlChange = () => {
7069
- this.changeRepeat();
7541
+ const zoom = this.navigation.bmap.context.camera.zoom;
7542
+ if (zoom !== this.prevCameraZoom) {
7543
+ this.prevCameraZoom = zoom;
7544
+ this.changeRepeat();
7545
+ }
7070
7546
  };
7071
7547
  onUpdate = () => {
7072
7548
  if (!this.texture) {
@@ -7086,7 +7562,7 @@ var Path2 = class extends Object3D16 {
7086
7562
  }
7087
7563
  } = this;
7088
7564
  const screenPoints = points.map(
7089
- ([x, y]) => vector3ToDevice(new Vector320(x, y, 0), camera, width, height)
7565
+ ([x, y]) => vector3ToDevice(new Vector322(x, y, 0), camera, width, height)
7090
7566
  ).map(({ x, y }) => [x, y]);
7091
7567
  const pointLength = getPathLength(screenPoints);
7092
7568
  return pointLength / 32;
@@ -7096,11 +7572,11 @@ var Path2 = class extends Object3D16 {
7096
7572
  return;
7097
7573
  }
7098
7574
  const repeat = this.getRepeat();
7099
- this.material.repeat = new Vector28(repeat, 1);
7575
+ this.material.repeat = new Vector211(repeat, 1);
7100
7576
  }
7101
7577
  loadTexture(url) {
7102
7578
  return new Promise((r, j) => {
7103
- new TextureLoader2().load(url, r, void 0, j);
7579
+ new TextureLoader3().load(url, r, void 0, j);
7104
7580
  });
7105
7581
  }
7106
7582
  transformPoints(points) {
@@ -7112,12 +7588,20 @@ var Path2 = class extends Object3D16 {
7112
7588
  }
7113
7589
  updatePoints(points) {
7114
7590
  this.points = points;
7591
+ this.pathDistance = getPathLength(points);
7115
7592
  this.changeRepeat();
7116
7593
  const _points = this.transformPoints(points);
7117
7594
  if (this.geometry) {
7118
7595
  this.geometry.setPoints(_points);
7119
7596
  }
7120
7597
  }
7598
+ movePath(distance) {
7599
+ if (!this.material || !this.pathDistance) {
7600
+ return;
7601
+ }
7602
+ const ratio = distance / this.pathDistance;
7603
+ this.material.thresholdRatio = ratio;
7604
+ }
7121
7605
  async create(points) {
7122
7606
  const lineGeometry = this.geometry = new MeshLine();
7123
7607
  this.updatePoints(points);
@@ -7131,7 +7615,7 @@ var Path2 = class extends Object3D16 {
7131
7615
  useMap: true,
7132
7616
  color: new Color8(this.config.color),
7133
7617
  transparent: true,
7134
- resolution: new Vector28(
7618
+ resolution: new Vector211(
7135
7619
  this.navigation.bmap.context.clientSize.width,
7136
7620
  this.navigation.bmap.context.clientSize.height
7137
7621
  ),
@@ -7140,9 +7624,10 @@ var Path2 = class extends Object3D16 {
7140
7624
  lineWidth: this.config.lineWidth * 2,
7141
7625
  map: this.texture,
7142
7626
  blending: NormalBlending,
7143
- repeat: new Vector28(this.getRepeat(), 1)
7627
+ repeat: new Vector211(this.getRepeat(), 1)
7144
7628
  });
7145
7629
  const mesh = this.mesh = new Mesh8(lineGeometry, material);
7630
+ mesh.renderOrder = 9;
7146
7631
  this.add(mesh);
7147
7632
  return mesh;
7148
7633
  }
@@ -7157,6 +7642,7 @@ var Path2 = class extends Object3D16 {
7157
7642
 
7158
7643
  // src/plugins/navigation/navigation.ts
7159
7644
  import { Group as TweenGroup2, Tween as Tween2 } from "@tweenjs/tween.js";
7645
+ import { Vector3 as Vector323 } from "three";
7160
7646
  var defaultConfig3 = {
7161
7647
  path: {},
7162
7648
  speed: 10,
@@ -7175,6 +7661,8 @@ var Navigation = class extends Plugin {
7175
7661
  options;
7176
7662
  pathTween = new TweenGroup2();
7177
7663
  startPoi = null;
7664
+ movedDistance = 0;
7665
+ pathStart = [0, 0];
7178
7666
  // 处理路线动画
7179
7667
  animationPathOptions = {
7180
7668
  cPathIndex: 0
@@ -7239,6 +7727,10 @@ var Navigation = class extends Plugin {
7239
7727
  this.pathTween.getAll().forEach((item) => item.stop());
7240
7728
  this.pathTween.removeAll();
7241
7729
  }
7730
+ if (this.startPoi) {
7731
+ this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
7732
+ this.startPoi = null;
7733
+ }
7242
7734
  }
7243
7735
  onSwitchFloor = ({ data: { curFloor } }) => {
7244
7736
  if (this.paths.length) {
@@ -7318,6 +7810,8 @@ var Navigation = class extends Plugin {
7318
7810
  this.animationPathOptions = {
7319
7811
  cPathIndex: 0
7320
7812
  };
7813
+ this.movedDistance = 0;
7814
+ this.pathStart = cPath[0];
7321
7815
  if (this.path) {
7322
7816
  this.path.updatePoints(cPath);
7323
7817
  } else {
@@ -7327,15 +7821,17 @@ var Navigation = class extends Plugin {
7327
7821
  this.bmap.context.scene.add(this.path);
7328
7822
  }
7329
7823
  if (this.startPoi) {
7330
- this.startPoi.dispose();
7824
+ this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
7331
7825
  this.startPoi = null;
7332
7826
  }
7333
7827
  if (this.options.needStartPoi) {
7334
- this.startPoi = this.bmap.context.currentFloor?.addPoi({
7828
+ this.startPoi = new Poi2(this.bmap.context, {
7335
7829
  ...this.options.startPoi,
7830
+ id: "navigation_start_poi",
7336
7831
  position: { x: cPath[0][0], y: cPath[0][1], z: 1e-4 },
7337
7832
  collision_enable: false
7338
7833
  }) || null;
7834
+ this.bmap.context.currentFloor?.poiLayer2.pushPoi(this.startPoi);
7339
7835
  }
7340
7836
  }
7341
7837
  catmullRomCurve3(points) {
@@ -7344,7 +7840,7 @@ var Navigation = class extends Plugin {
7344
7840
  /**
7345
7841
  * 按照指定速度移动到目标位置
7346
7842
  * @param point 目标位置
7347
- * @param speed 移动速度
7843
+ * @param speed 移动速度 / 米/s
7348
7844
  */
7349
7845
  async animationTo(point3, speed = this.options.speed) {
7350
7846
  if (point3.floor !== this.bmap.context.currentFloor?.name || !this.path) {
@@ -7354,7 +7850,7 @@ var Navigation = class extends Plugin {
7354
7850
  animationPathOptions: { cPathIndex }
7355
7851
  } = this;
7356
7852
  const currentPath = [
7357
- this.path.points[0],
7853
+ this.pathStart,
7358
7854
  ...this.cPath.slice(cPathIndex + 1)
7359
7855
  ];
7360
7856
  const translatedPos = this.translatePoints([point3.pos])[0];
@@ -7400,40 +7896,169 @@ var Navigation = class extends Plugin {
7400
7896
  moveDistanceArray.push(getLength(currentPath[index], pos));
7401
7897
  moveDistance = moveDistanceArray.reduce((sum, cur) => sum + cur, 0);
7402
7898
  }
7403
- const speedSecond = this.kmPerHourToMetersPerSecond(speed);
7404
- const timeSecond = moveDistance / speedSecond;
7899
+ const timeSecond = moveDistance / speed;
7405
7900
  this.pathTween.getAll().forEach((item) => item.stop());
7406
7901
  this.pathTween.removeAll();
7407
7902
  const start = { distance: 0 };
7903
+ const prevCPathIndex = this.animationPathOptions.cPathIndex;
7904
+ let pastRouteLength = 0;
7905
+ let pastRouteIndex = 0;
7408
7906
  return new Promise((resolve) => {
7409
- const tween = new Tween2(start, this.pathTween).to({ distance: moveDistance }, timeSecond * 1e3).onUpdate(() => {
7410
- for (let i = 0; i < moveDistanceArray.length; i++) {
7411
- const sumDistance = moveDistanceArray.slice(0, i + 1).reduce((sum, cur) => sum + cur, 0);
7412
- if (sumDistance >= start.distance) {
7413
- const prevDistance = sumDistance - moveDistanceArray[i];
7414
- const needDistance = start.distance - prevDistance;
7415
- const startPoint = currentPath[i];
7416
- const nextPoint = currentPath[i + 1];
7417
- const pos2 = moveOnRoute(startPoint, nextPoint, needDistance);
7418
- this.path?.updatePoints([pos2, ...currentPath.slice(i + 1)]);
7419
- this.animationPathOptions.cPathIndex += i;
7420
- if (this.startPoi) {
7421
- this.startPoi.position.setX(pos2[0]).setY(pos2[1]);
7422
- }
7423
- this.dispatchEvent({ type: "path-animation" });
7424
- return;
7425
- }
7907
+ const tween = new Tween2(start, this.pathTween).to({ distance: moveDistance }, timeSecond * 1e3).onUpdate(async () => {
7908
+ let dis = start.distance - pastRouteLength;
7909
+ while (moveDistanceArray.length && dis > moveDistanceArray[0]) {
7910
+ pastRouteLength += moveDistanceArray.shift();
7911
+ pastRouteIndex++;
7912
+ dis = start.distance - pastRouteLength;
7426
7913
  }
7914
+ const startPoint = currentPath[pastRouteIndex];
7915
+ const nextPoint = currentPath[pastRouteIndex + 1];
7916
+ if (!nextPoint) {
7917
+ return;
7918
+ }
7919
+ const pos2 = moveOnRoute(startPoint, nextPoint, dis);
7920
+ this.pathStart = pos2;
7921
+ this.path?.movePath(this.movedDistance + start.distance);
7922
+ this.animationPathOptions.cPathIndex = prevCPathIndex + pastRouteIndex;
7923
+ if (this.startPoi) {
7924
+ this.startPoi.position.setX(pos2[0]).setY(pos2[1]);
7925
+ const target = new Vector323(pos2[0], pos2[1], 0);
7926
+ const offset = new Vector323();
7927
+ offset.setFromMatrixColumn(this.bmap.context.camera.matrix, 1);
7928
+ offset.normalize();
7929
+ offset.multiplyScalar(150 / this.bmap.context.camera.zoom);
7930
+ target.add(offset);
7931
+ this.bmap.context.setCameraPosition(target, 0);
7932
+ }
7933
+ tween.pause();
7934
+ await this.changeCameraToPathUp(200);
7935
+ tween.resume();
7936
+ this.dispatchEvent({ type: "path-animation", pathIndex: this.animationPathOptions.cPathIndex });
7427
7937
  }).onComplete(() => {
7428
7938
  this.pathTween.remove(tween);
7429
7939
  this.dispatchEvent({ type: "path-animation-end" });
7940
+ this.movedDistance += moveDistance;
7430
7941
  resolve(true);
7431
7942
  }).start();
7432
7943
  });
7433
7944
  }
7434
- kmPerHourToMetersPerSecond(speedInKmPerHour) {
7435
- const speedInMetersPerSecond = speedInKmPerHour * 1e3 / 3600;
7436
- return speedInMetersPerSecond;
7945
+ // 计算路线的方向
7946
+ getPathDirection() {
7947
+ const path = this.cPath.slice(this.animationPathOptions.cPathIndex);
7948
+ if (path.length < 3) {
7949
+ return null;
7950
+ }
7951
+ const p0 = path[0];
7952
+ const p1 = path[1];
7953
+ const p2 = path[2];
7954
+ const angle = calc_angle(p0, p1, p2);
7955
+ if (Math.abs(angle) >= 179 && Math.abs(angle) <= 180) {
7956
+ const v1 = new Vector323(p2[0] - p1[0], p2[1] - p1[1], 0).normalize();
7957
+ const v2 = new Vector323(0, 1, 0).normalize();
7958
+ const angle2 = v1.angleTo(v2);
7959
+ const cross = new Vector323().crossVectors(v2, v1);
7960
+ const sign = Object.is(cross.y, 0) ? -1 : 1;
7961
+ const finalAngle = sign * angle2;
7962
+ return finalAngle;
7963
+ } else {
7964
+ return null;
7965
+ }
7966
+ }
7967
+ // 把相机旋转到路线的上方向
7968
+ async changeCameraToPathUp(duration = 100) {
7969
+ let angle = this.getPathDirection();
7970
+ if (angle === null) {
7971
+ return;
7972
+ }
7973
+ const currentAngle = this.bmap.context.control.getAzimuthalAngle();
7974
+ if (Math.abs(currentAngle - angle) > Math.PI) {
7975
+ if (currentAngle > 0) {
7976
+ angle = Math.PI * 2 + angle;
7977
+ } else {
7978
+ angle = angle - Math.PI * 2;
7979
+ }
7980
+ }
7981
+ const diffAngle = Math.abs(angle - this.bmap.context.control.getAzimuthalAngle());
7982
+ if (diffAngle < 0.01) {
7983
+ return;
7984
+ }
7985
+ const { control } = this.bmap.context;
7986
+ return new Promise((resolve) => {
7987
+ const start = { azimuthal: control.getAzimuthalAngle() };
7988
+ const end = { azimuthal: angle };
7989
+ const tween = new Tween2(start, this.pathTween).to(end, duration).onUpdate(() => {
7990
+ control.target.copy(this.startPoi.position);
7991
+ control.maxAzimuthAngle = start.azimuthal;
7992
+ control.minAzimuthAngle = start.azimuthal;
7993
+ control.update();
7994
+ const target = this.startPoi.position.clone();
7995
+ const offset = new Vector323();
7996
+ offset.setFromMatrixColumn(this.bmap.context.camera.matrix, 1);
7997
+ offset.normalize();
7998
+ offset.multiplyScalar(150 / this.bmap.context.camera.zoom);
7999
+ target.add(offset);
8000
+ this.bmap.context.setCameraPosition(target, 0);
8001
+ }).onComplete(() => {
8002
+ control.enabled = true;
8003
+ this.pathTween.remove(tween);
8004
+ resolve(true);
8005
+ }).onStart(() => {
8006
+ control.enabled = false;
8007
+ }).start();
8008
+ });
8009
+ }
8010
+ async initNavigationCamera() {
8011
+ await this.translateCameraToStartPoi(300);
8012
+ await this.changeCameraToPathUp(300);
8013
+ }
8014
+ async translateCameraToStartPoi(duration = 100) {
8015
+ if (!this.startPoi) {
8016
+ return;
8017
+ }
8018
+ const {
8019
+ clientSize: { width, height },
8020
+ camera,
8021
+ control
8022
+ } = this.bmap.context;
8023
+ const halfWidth = Math.round(width / 2);
8024
+ const halfHeight = Math.round(height / 2);
8025
+ const target = control.target.clone();
8026
+ const device = vector3ToDevice(this.startPoi.position, camera, width, height);
8027
+ const offsetX = device.x - halfWidth;
8028
+ const offsetY = halfHeight - device.y + 150;
8029
+ console.log(device, offsetX, offsetY, this.startPoi.position, halfWidth, halfHeight);
8030
+ if (Math.abs(offsetX) < 1 && Math.abs(offsetY) < 1) {
8031
+ return;
8032
+ }
8033
+ if (Math.abs(offsetX) >= 1) {
8034
+ const xv3 = new Vector323();
8035
+ xv3.setFromMatrixColumn(camera.matrix, 0);
8036
+ xv3.normalize();
8037
+ xv3.multiplyScalar(offsetX / camera.zoom);
8038
+ target.add(new Vector323(xv3.x, 0, 0));
8039
+ }
8040
+ if (Math.abs(offsetY) >= 1) {
8041
+ const v3 = new Vector323();
8042
+ v3.setFromMatrixColumn(camera.matrix, 1);
8043
+ v3.normalize();
8044
+ v3.multiplyScalar(offsetY / camera.zoom);
8045
+ target.add(new Vector323(0, v3.y, 0));
8046
+ }
8047
+ return this.bmap.context.setCameraPosition(target, duration);
8048
+ }
8049
+ async initCameraZoom(duration = 100) {
8050
+ if (!this.startPoi) {
8051
+ return;
8052
+ }
8053
+ const { clientSize: { width, height }, currentFloor } = this.bmap.context;
8054
+ const { max, min } = currentFloor.box;
8055
+ const baseScale = Math.min(width / (max.x - min.x), height / (max.y - min.y));
8056
+ const zoom = baseScale * (max.x - min.x) / 20;
8057
+ return this.bmap.context.setZoom(
8058
+ zoom,
8059
+ this.startPoi.position,
8060
+ duration
8061
+ );
7437
8062
  }
7438
8063
  dispose() {
7439
8064
  this.worker.terminate();
@@ -7570,6 +8195,7 @@ var MulFloors = class extends Plugin {
7570
8195
  this.group.add(this.poiLayer, ...floors);
7571
8196
  scene.add(this.group);
7572
8197
  this.floors = floors;
8198
+ this.bmap.context.cameraBound.updateBox();
7573
8199
  }
7574
8200
  hide() {
7575
8201
  const { scene } = this.bmap.context;
@@ -7768,7 +8394,10 @@ var AibeeLoader = class {
7768
8394
  try {
7769
8395
  const cacheVersion = await this.getCacheData(VersionStoreName, cacheKey);
7770
8396
  if (cacheVersion === floorInfo.version_id) {
7771
- const res = await this.getCacheData(MapDataStoreName, cacheKey);
8397
+ const res = await this.getCacheData(
8398
+ MapDataStoreName,
8399
+ cacheKey
8400
+ );
7772
8401
  if (res) {
7773
8402
  return this.getDataByJson(res);
7774
8403
  }
@@ -7782,6 +8411,7 @@ var AibeeLoader = class {
7782
8411
  const cacheKey = this.getFloorCacheKey(floorInfo);
7783
8412
  console.time(`zstd_json`);
7784
8413
  const res1 = await fetch(floorInfo.map_url).then((res) => res.json());
8414
+ res1.floor = floorInfo.floor;
7785
8415
  console.timeEnd(`zstd_json`);
7786
8416
  this.setCacheData(MapDataStoreName, cacheKey, res1);
7787
8417
  this.setCacheData(VersionStoreName, cacheKey, floorInfo.version_id);
@@ -7789,25 +8419,33 @@ var AibeeLoader = class {
7789
8419
  }
7790
8420
  // 获取路网数据
7791
8421
  async getRoadNetworkData() {
7792
- const res = await Promise.all(this.floors.map(async (item) => {
7793
- const cacheKey = this.getFloorCacheKey(item);
7794
- try {
7795
- const cacheVersion = await this.getCacheData(VersionStoreName, cacheKey);
7796
- if (cacheVersion === item.version_id) {
7797
- const res2 = await this.getCacheData(RoadNetworkDataStoreName, cacheKey);
7798
- if (res2) {
7799
- return res2;
8422
+ const res = await Promise.all(
8423
+ this.floors.map(async (item) => {
8424
+ const cacheKey = this.getFloorCacheKey(item);
8425
+ try {
8426
+ const cacheVersion = await this.getCacheData(
8427
+ VersionStoreName,
8428
+ cacheKey
8429
+ );
8430
+ if (cacheVersion === item.version_id) {
8431
+ const res2 = await this.getCacheData(
8432
+ RoadNetworkDataStoreName,
8433
+ cacheKey
8434
+ );
8435
+ if (res2) {
8436
+ return res2;
8437
+ }
7800
8438
  }
8439
+ const route = await fetch(item.route_url).then((res2) => res2.json());
8440
+ this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
8441
+ return route;
8442
+ } catch {
8443
+ const route = await fetch(item.route_url).then((res2) => res2.json());
8444
+ this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
8445
+ return route;
7801
8446
  }
7802
- const route = await fetch(item.route_url).then((res2) => res2.json());
7803
- await this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
7804
- return route;
7805
- } catch {
7806
- const route = await fetch(item.route_url).then((res2) => res2.json());
7807
- await this.setCacheData(RoadNetworkDataStoreName, cacheKey, route);
7808
- return route;
7809
- }
7810
- }));
8447
+ })
8448
+ );
7811
8449
  return res.filter((item) => item.points);
7812
8450
  }
7813
8451
  // 空闲时间请求其他数据
@@ -7815,7 +8453,9 @@ var AibeeLoader = class {
7815
8453
  }
7816
8454
  // 获取多楼层数据
7817
8455
  async getMulFloorsData(floors) {
7818
- return Promise.all(floors.map((floor) => this.getFloorData(floor))).then((data) => data.filter((item) => item));
8456
+ return Promise.all(floors.map((floor) => this.getFloorData(floor))).then(
8457
+ (data) => data.filter((item) => item)
8458
+ );
7819
8459
  }
7820
8460
  async getDataByUrl(url) {
7821
8461
  const data = await fetch(url).then((res) => res.json());
@@ -7848,38 +8488,61 @@ var AibeeLoader = class {
7848
8488
  });
7849
8489
  floor.userData.graphics = graphics;
7850
8490
  floor.userData.graphicMap = graphicMap;
7851
- const group = canMergeGraphics.reduce((obj, options) => {
7852
- const { fillColor, fillOpacity, strokeColor, strokeOpacity, height } = options;
7853
- const key = `${fillColor}-${fillOpacity}-${strokeColor}-${strokeOpacity}-${height}`;
7854
- if (obj[key]) {
7855
- obj[key].push(options);
7856
- } else {
7857
- obj[key] = [options];
7858
- }
7859
- return obj;
7860
- }, {});
8491
+ const group = canMergeGraphics.reduce(
8492
+ (obj, options) => {
8493
+ const {
8494
+ fillColor,
8495
+ fillOpacity,
8496
+ strokeColor,
8497
+ strokeOpacity,
8498
+ height
8499
+ } = options;
8500
+ const key = `${fillColor}-${fillOpacity}-${strokeColor}-${strokeOpacity}-${height}`;
8501
+ if (obj[key]) {
8502
+ obj[key].push(options);
8503
+ } else {
8504
+ obj[key] = [options];
8505
+ }
8506
+ return obj;
8507
+ },
8508
+ {}
8509
+ );
7861
8510
  Object.values(group).forEach((options) => {
7862
- const mergeGeometries5 = new MergeGraphic(this.bmap.context, options);
8511
+ const mergeGeometries5 = new MergeGraphic(
8512
+ this.bmap.context,
8513
+ options
8514
+ );
7863
8515
  floor.mergeGraphicLayer.add(mergeGeometries5);
7864
8516
  });
7865
8517
  break;
7866
8518
  case "ground":
7867
8519
  transformGraphicData(layer.elements, center2);
7868
- const grounds = layer.elements.map((options) => new Graphic(this.bmap.context, options));
8520
+ const grounds = layer.elements.map(
8521
+ (options) => new Graphic(this.bmap.context, options)
8522
+ );
7869
8523
  floor.addGrounds(grounds);
7870
8524
  break;
7871
8525
  case "wall":
7872
8526
  transformGraphicData(layer.elements, center2);
7873
- const wallGroup = layer.elements.reduce((obj, options) => {
7874
- const { fillColor, fillOpacity, strokeColor, strokeOpacity, height } = options;
7875
- const key = `${fillColor}-${fillOpacity}-${strokeColor}-${strokeOpacity}-${height}`;
7876
- if (obj[key]) {
7877
- obj[key].push(options);
7878
- } else {
7879
- obj[key] = [options];
7880
- }
7881
- return obj;
7882
- }, {});
8527
+ const wallGroup = layer.elements.reduce(
8528
+ (obj, options) => {
8529
+ const {
8530
+ fillColor,
8531
+ fillOpacity,
8532
+ strokeColor,
8533
+ strokeOpacity,
8534
+ height
8535
+ } = options;
8536
+ const key = `${fillColor}-${fillOpacity}-${strokeColor}-${strokeOpacity}-${height}`;
8537
+ if (obj[key]) {
8538
+ obj[key].push(options);
8539
+ } else {
8540
+ obj[key] = [options];
8541
+ }
8542
+ return obj;
8543
+ },
8544
+ {}
8545
+ );
7883
8546
  Object.values(wallGroup).forEach((optionArray) => {
7884
8547
  const wall = new Wall(this.bmap.context, optionArray);
7885
8548
  floor.wallLayer.add(wall);
@@ -7887,16 +8550,19 @@ var AibeeLoader = class {
7887
8550
  break;
7888
8551
  case "lane":
7889
8552
  transformGraphicData(layer.elements, center2);
7890
- const laneGroup = layer.elements.reduce((obj, options) => {
7891
- const { fillColor, fillOpacity, strokeColor, strokeOpacity } = options;
7892
- const key = `${fillColor}-${fillOpacity}-${strokeColor}-${strokeOpacity}`;
7893
- if (obj[key]) {
7894
- obj[key].push(options);
7895
- } else {
7896
- obj[key] = [options];
7897
- }
7898
- return obj;
7899
- }, {});
8553
+ const laneGroup = layer.elements.reduce(
8554
+ (obj, options) => {
8555
+ const { fillColor, fillOpacity, strokeColor, strokeOpacity } = options;
8556
+ const key = `${fillColor}-${fillOpacity}-${strokeColor}-${strokeOpacity}`;
8557
+ if (obj[key]) {
8558
+ obj[key].push(options);
8559
+ } else {
8560
+ obj[key] = [options];
8561
+ }
8562
+ return obj;
8563
+ },
8564
+ {}
8565
+ );
7900
8566
  Object.values(laneGroup).forEach((optionArray) => {
7901
8567
  const lane = new Lane(this.bmap.context, optionArray);
7902
8568
  floor.laneLayer.add(lane);
@@ -7911,7 +8577,10 @@ var AibeeLoader = class {
7911
8577
  case "glb":
7912
8578
  transformGraphicData(layer.elements, center2);
7913
8579
  layer.elements.forEach((options) => {
7914
- const pos = translatePosToCenter([options.center_x, options.center_y], center2);
8580
+ const pos = translatePosToCenter(
8581
+ [options.center_x, options.center_y],
8582
+ center2
8583
+ );
7915
8584
  const model = new GlbModel(this.bmap.context, {
7916
8585
  ...options,
7917
8586
  url: options.secondUrl,
@@ -7926,17 +8595,21 @@ var AibeeLoader = class {
7926
8595
  case "store":
7927
8596
  transformGraphicData(layer.elements, center2);
7928
8597
  layer.elements.map((options) => {
7929
- const pos = translatePosToCenter([options.center_x, options.center_y], center2);
8598
+ const pos = translatePosToCenter(
8599
+ [options.center_x, options.center_y],
8600
+ center2
8601
+ );
7930
8602
  const graphic = floor.addGraphic(options);
7931
8603
  floor.userData.graphics.push(graphic);
7932
8604
  floor.userData.graphicMap.set(options.id, graphic);
7933
- const poi = floor.poiLayer.createPoi({
8605
+ const poi = new Poi2(this.bmap.context, {
7934
8606
  id: options.id,
7935
8607
  icon: options.poi_info.icon,
7936
- texts: [{ text: options.poi_info.showName || options.store_name || options.poi_info.text }],
7937
- position: { x: pos[0], y: pos[1], z: options.airHeight },
8608
+ text: options.poi_info.showName || options.store_name || options.poi_info.text,
8609
+ position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
7938
8610
  icon_size: [18, 18]
7939
8611
  });
8612
+ floor.poiLayer2.pushPoi(poi);
7940
8613
  if (poi) {
7941
8614
  poi.userData.type = "store";
7942
8615
  poi.userData.data = options;
@@ -7946,22 +8619,24 @@ var AibeeLoader = class {
7946
8619
  case "facility":
7947
8620
  transformGraphicData(layer.elements, center2);
7948
8621
  layer.elements.map((options) => {
7949
- const pos = translatePosToCenter(options.geometry.cds, center2);
8622
+ const pos = translatePosToCenter(
8623
+ options.geometry.cds,
8624
+ center2
8625
+ );
7950
8626
  const graphic = floor.addGraphic(options);
7951
8627
  floor.userData.graphics.push(graphic);
7952
8628
  floor.userData.graphicMap.set(options.id, graphic);
7953
8629
  if (options.poi_info) {
7954
- const poi = floor.poiLayer.createPoi({
8630
+ const poi = new Poi2(this.bmap.context, {
7955
8631
  id: options.id,
7956
8632
  icon: options.poi_info.icon,
7957
- texts: [{ text: options.poi_info.showName || options.store_name || options.poi_info.text }],
7958
- position: { x: pos[0], y: pos[1], z: options.airHeight },
8633
+ text: options.poi_info.showName || options.store_name || options.poi_info.text,
8634
+ position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
7959
8635
  icon_size: [18, 18]
7960
8636
  });
7961
- if (poi) {
7962
- poi.userData.type = "facility";
7963
- poi.userData.data = options;
7964
- }
8637
+ floor.poiLayer2.pushPoi(poi);
8638
+ poi.userData.type = "facility";
8639
+ poi.userData.data = options;
7965
8640
  }
7966
8641
  });
7967
8642
  break;
@@ -7973,17 +8648,25 @@ var AibeeLoader = class {
7973
8648
  const graphic = floor.addGraphic(options);
7974
8649
  parkingSpacesGraphics.push(graphic);
7975
8650
  parkingSpacesGraphicMap.set(options.id, graphic);
7976
- const pos = translatePosToCenter([options.center_x, options.center_y], center2);
8651
+ const pos = translatePosToCenter(
8652
+ [options.center_x, options.center_y],
8653
+ center2
8654
+ );
7977
8655
  if (options.texts[0]) {
7978
- const poi = floor.poiLayer.createPoi({
8656
+ const poi = new Poi2(this.bmap.context, {
7979
8657
  id: options.id,
7980
- texts: [{ text: options.texts[0] }],
7981
- position: { x: pos[0], y: pos[1], z: options.airHeight }
8658
+ text: options.texts[0],
8659
+ position: {
8660
+ x: pos[0],
8661
+ y: pos[1],
8662
+ z: options.airHeight + options.height
8663
+ }
7982
8664
  });
7983
8665
  if (poi) {
7984
8666
  poi.userData.type = "parkingSpace";
7985
8667
  poi.userData.data = options;
7986
8668
  }
8669
+ floor.poiLayer2.pushPoi(poi);
7987
8670
  }
7988
8671
  });
7989
8672
  floor.userData.parkingSpaces = parkingSpacesGraphics;
@@ -7994,6 +8677,8 @@ var AibeeLoader = class {
7994
8677
  floor.userData.center = center2;
7995
8678
  floor.userData.height = data.floorHeight;
7996
8679
  floor.name = data.floor;
8680
+ floor.userData.data = data;
8681
+ floor.updateBox();
7997
8682
  return floor;
7998
8683
  }
7999
8684
  clear() {
@@ -8028,7 +8713,9 @@ export {
8028
8713
  Overlay,
8029
8714
  PathDirection,
8030
8715
  Poi,
8716
+ Poi2,
8031
8717
  PoiLayer,
8718
+ PoiLayer2,
8032
8719
  RoadNetwork,
8033
8720
  RoadNetwork2,
8034
8721
  SelectBox,
@@ -8061,6 +8748,7 @@ export {
8061
8748
  disposeLoader,
8062
8749
  distancePointToSegment,
8063
8750
  generatorKeyByObj,
8751
+ getAngle,
8064
8752
  getCenter,
8065
8753
  getConfig,
8066
8754
  getDirectPath,
@@ -8068,6 +8756,7 @@ export {
8068
8756
  getLongestSideDir,
8069
8757
  getPathLength,
8070
8758
  getTextureByText,
8759
+ getTextureByUrl,
8071
8760
  hasChinese,
8072
8761
  initCamera,
8073
8762
  initCanvas,