@aibee/crc-bmap 0.1.2 → 0.1.4

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
@@ -838,6 +838,9 @@ function hexToRgb(hex, opacity) {
838
838
 
839
839
  // src/utils/os.ts
840
840
  var isMac = navigator.userAgent.toUpperCase().indexOf("MAC") >= 0;
841
+ var UA = (window.navigator.userAgent || "").toLocaleLowerCase();
842
+ var isIphone = /ios|iphone/i.test(UA);
843
+ var isAndroid = /android|adr|linux/gi.test(UA);
841
844
 
842
845
  // src/utils/keyboard.ts
843
846
  function isControl(key) {
@@ -1146,6 +1149,49 @@ function getDirectPath(points) {
1146
1149
  });
1147
1150
  return arr;
1148
1151
  }
1152
+ function getDistanceByPathPos(path, pos) {
1153
+ if (path.length < 2) {
1154
+ return -1;
1155
+ }
1156
+ let distance = 0;
1157
+ for (let i = 1; i < path.length; i++) {
1158
+ const prev = path[i - 1];
1159
+ const curr = path[i];
1160
+ const v1 = [pos[0] - prev[0], pos[1] - prev[1]];
1161
+ const v2 = [curr[0] - prev[0], curr[1] - prev[1]];
1162
+ const withinX = Math.min(curr[0], prev[0]) <= pos[0] && pos[0] <= Math.max(curr[0], prev[0]);
1163
+ const withinY = Math.min(curr[1], prev[1]) <= pos[1] && pos[1] <= Math.max(curr[1], prev[1]);
1164
+ console.log(withinX, withinY);
1165
+ if (withinX && withinY) {
1166
+ const crossProduct = v1[0] * v2[1] - v1[1] * v2[0];
1167
+ if (Math.abs(crossProduct) < 1e-6) {
1168
+ const segmentDistance = Math.sqrt((pos[0] - prev[0]) ** 2 + (pos[1] - prev[1]) ** 2);
1169
+ return distance + segmentDistance;
1170
+ }
1171
+ }
1172
+ distance += Math.sqrt((curr[0] - prev[0]) ** 2 + (curr[1] - prev[1]) ** 2);
1173
+ }
1174
+ return -1;
1175
+ }
1176
+ function getPosByPathDistance(path, distance) {
1177
+ if (path.length < 2) {
1178
+ return path[0] ?? null;
1179
+ }
1180
+ let accumulatedDistance = 0;
1181
+ for (let i = 1; i < path.length; i++) {
1182
+ const prev = path[i - 1];
1183
+ const curr = path[i];
1184
+ const segmentLength = Math.sqrt((curr[0] - prev[0]) ** 2 + (curr[1] - prev[1]) ** 2);
1185
+ accumulatedDistance += segmentLength;
1186
+ if (accumulatedDistance >= distance) {
1187
+ const ratio = (distance - (accumulatedDistance - segmentLength)) / segmentLength;
1188
+ const x = prev[0] + (curr[0] - prev[0]) * ratio;
1189
+ const y = prev[1] + (curr[1] - prev[1]) * ratio;
1190
+ return [x, y];
1191
+ }
1192
+ }
1193
+ return null;
1194
+ }
1149
1195
 
1150
1196
  // src/utils/road.ts
1151
1197
  var import_node_dijkstra = __toESM(require_Graph(), 1);
@@ -2119,7 +2165,7 @@ function toWebWorker(obj) {
2119
2165
  }
2120
2166
 
2121
2167
  // src/utils/create.ts
2122
- import { BufferGeometry, Line, LineBasicMaterial } from "three";
2168
+ import { BoxGeometry, BufferGeometry, Line, LineBasicMaterial, Mesh } from "three";
2123
2169
  function createThreeLine(points, color = 16711680) {
2124
2170
  const material = new LineBasicMaterial({
2125
2171
  color
@@ -2128,6 +2174,15 @@ function createThreeLine(points, color = 16711680) {
2128
2174
  const line = new Line(geometry, material);
2129
2175
  return line;
2130
2176
  }
2177
+ function createThreeBox(pos, color = 16711680) {
2178
+ const material = new LineBasicMaterial({
2179
+ color
2180
+ });
2181
+ const geometry = new BoxGeometry(1, 1, 1);
2182
+ const mesh = new Mesh(geometry, material);
2183
+ mesh.position.copy(pos);
2184
+ return mesh;
2185
+ }
2131
2186
 
2132
2187
  // src/utils/translate.ts
2133
2188
  function transformGraphicData(data, center2, baseIndex = 0) {
@@ -2165,6 +2220,51 @@ function translatePosToCenter(cds, center2) {
2165
2220
  return [cds[0] - center2[0], cds[1] - center2[1]];
2166
2221
  }
2167
2222
 
2223
+ // src/utils/tween.ts
2224
+ import { Group as Group2 } from "@tweenjs/tween.js";
2225
+ var TweenUtil = class {
2226
+ pauseTween = false;
2227
+ // 暂停动画
2228
+ tweenStore = /* @__PURE__ */ new Set();
2229
+ // 暂存的动画 在暂停的时候存入,在继续的时候清空
2230
+ group = new Group2();
2231
+ constructor() {
2232
+ }
2233
+ update() {
2234
+ this.group.update();
2235
+ }
2236
+ pause() {
2237
+ this.pauseTween = true;
2238
+ this.getAll().forEach((item) => {
2239
+ this.tweenStore.add(item);
2240
+ item.pause();
2241
+ });
2242
+ }
2243
+ continue() {
2244
+ if (!this.pauseTween) {
2245
+ return;
2246
+ }
2247
+ this.tweenStore.forEach((item) => {
2248
+ item.resume();
2249
+ });
2250
+ this.tweenStore.clear();
2251
+ this.pauseTween = false;
2252
+ }
2253
+ remove(tween) {
2254
+ this.group.remove(tween);
2255
+ }
2256
+ getAll() {
2257
+ return this.group.getAll();
2258
+ }
2259
+ clear() {
2260
+ this.getAll().forEach((item) => item.stop());
2261
+ this.group.removeAll();
2262
+ }
2263
+ dispose() {
2264
+ this.clear();
2265
+ }
2266
+ };
2267
+
2168
2268
  // src/context/context.ts
2169
2269
  import {
2170
2270
  EventDispatcher as EventDispatcher7,
@@ -2184,7 +2284,7 @@ import { EventDispatcher as EventDispatcher4 } from "three";
2184
2284
  import {
2185
2285
  Object3D,
2186
2286
  ExtrudeGeometry,
2187
- Mesh,
2287
+ Mesh as Mesh2,
2188
2288
  Box3,
2189
2289
  Vector3 as Vector34,
2190
2290
  BufferGeometry as BufferGeometry2,
@@ -2771,21 +2871,6 @@ var Graphic = class extends Object3D {
2771
2871
  this.material = [material, material1];
2772
2872
  return [material, material1];
2773
2873
  }
2774
- // createMesh(pos: Vector3, color = 0xff0000) {
2775
- // const geometry = new BoxGeometry(1, 1, 1)
2776
- // const material = new MeshBasicMaterial({ color })
2777
- // const mesh = new Mesh(geometry, material)
2778
- // mesh.position.copy(pos)
2779
- // this.context.scene.add(mesh)
2780
- // }
2781
- // createLine(points: Vector3[], color = 0xff0000) {
2782
- // const material = new LineBasicMaterial({
2783
- // color: color
2784
- // });
2785
- // const geometry = new BufferGeometry().setFromPoints(points);
2786
- // const line = new Line( geometry, material );
2787
- // this.context.scene.add(line)
2788
- // }
2789
2874
  getMaxAndMin(pos, dir) {
2790
2875
  const box = new Box3().setFromObject(this);
2791
2876
  const minOrigin = pos.clone().add(dir.clone().multiplyScalar(1e3));
@@ -2858,7 +2943,7 @@ var Graphic = class extends Object3D {
2858
2943
  if (this.mesh) {
2859
2944
  this.remove(this.mesh);
2860
2945
  }
2861
- this.mesh = new Mesh(this.geometry, this.material);
2946
+ this.mesh = new Mesh2(this.geometry, this.material);
2862
2947
  this.add(this.mesh);
2863
2948
  }
2864
2949
  getBorderPoints() {
@@ -2920,7 +3005,7 @@ var Graphic = class extends Object3D {
2920
3005
  import {
2921
3006
  Object3D as Object3D2,
2922
3007
  PlaneGeometry,
2923
- Mesh as Mesh2,
3008
+ Mesh as Mesh3,
2924
3009
  ShadowMaterial,
2925
3010
  Color as Color2,
2926
3011
  DoubleSide as DoubleSide2
@@ -2966,7 +3051,7 @@ var Shadow = class extends Object3D2 {
2966
3051
  opacity: 0,
2967
3052
  side: DoubleSide2
2968
3053
  });
2969
- const mesh = new Mesh2(geometry, material);
3054
+ const mesh = new Mesh3(geometry, material);
2970
3055
  mesh.receiveShadow = true;
2971
3056
  mesh.position.z = -10;
2972
3057
  this.add(mesh);
@@ -3572,7 +3657,7 @@ import {
3572
3657
  PlaneGeometry as PlaneGeometry2,
3573
3658
  Texture as Texture2,
3574
3659
  DoubleSide as DoubleSide3,
3575
- Mesh as Mesh3,
3660
+ Mesh as Mesh4,
3576
3661
  Matrix3 as Matrix32,
3577
3662
  Vector2 as Vector26
3578
3663
  } from "three";
@@ -3619,7 +3704,7 @@ var HeatmapElement = class extends Object3D5 {
3619
3704
  map: texture
3620
3705
  });
3621
3706
  material.needsUpdate = true;
3622
- this.plane = new Mesh3(geometry, material);
3707
+ this.plane = new Mesh4(geometry, material);
3623
3708
  this.add(this.plane);
3624
3709
  }
3625
3710
  getTransMatrix({ x, y }) {
@@ -4605,7 +4690,7 @@ import {
4605
4690
  Color as Color3,
4606
4691
  ExtrudeGeometry as ExtrudeGeometry2,
4607
4692
  LineSegments as LineSegments2,
4608
- Mesh as Mesh4,
4693
+ Mesh as Mesh5,
4609
4694
  Object3D as Object3D9,
4610
4695
  ShaderMaterial as ShaderMaterial3,
4611
4696
  Vector3 as Vector313
@@ -4761,7 +4846,7 @@ var Wall = class extends Object3D9 {
4761
4846
  init() {
4762
4847
  this.initGeometry();
4763
4848
  this.initMaterial();
4764
- const mesh = new Mesh4(this.geometry, this.material);
4849
+ const mesh = new Mesh5(this.geometry, this.material);
4765
4850
  this.add(mesh);
4766
4851
  if (this.options[0].strokeOpacity !== 0) {
4767
4852
  this.initLineMaterial();
@@ -4781,7 +4866,7 @@ var Wall = class extends Object3D9 {
4781
4866
  import {
4782
4867
  DoubleSide as DoubleSide4,
4783
4868
  Float32BufferAttribute,
4784
- Mesh as Mesh5,
4869
+ Mesh as Mesh6,
4785
4870
  MeshBasicMaterial as MeshBasicMaterial4,
4786
4871
  Object3D as Object3D10,
4787
4872
  ShapeGeometry
@@ -4839,7 +4924,7 @@ var GroundTexture = class extends Object3D10 {
4839
4924
  });
4840
4925
  return material;
4841
4926
  }));
4842
- const mesh = new Mesh5(geometry, materials);
4927
+ const mesh = new Mesh6(geometry, materials);
4843
4928
  this.mesh = mesh;
4844
4929
  this.position.z += 4e-3;
4845
4930
  this.add(mesh);
@@ -4852,7 +4937,7 @@ var GroundTexture = class extends Object3D10 {
4852
4937
  };
4853
4938
 
4854
4939
  // src/elements/glb-model.ts
4855
- import { Box3 as Box37, Mesh as Mesh6, Object3D as Object3D11, Vector3 as Vector314 } from "three";
4940
+ import { Box3 as Box37, Mesh as Mesh7, Object3D as Object3D11, Vector3 as Vector314 } from "three";
4856
4941
  var defaultGlbOptions = {
4857
4942
  url: "",
4858
4943
  geometry: { type: "polygon", cds: [], coords: [], curveCpt: [], curveIndex: [] },
@@ -4889,7 +4974,7 @@ var GlbModel = class extends Object3D11 {
4889
4974
  this.rotateZ(this.options.rotate);
4890
4975
  }
4891
4976
  meshSetMaterial(object) {
4892
- if (object instanceof Mesh6) {
4977
+ if (object instanceof Mesh7) {
4893
4978
  object.frustumCulled = false;
4894
4979
  object.castShadow = true;
4895
4980
  object.material.emissiveIntensity *= 0.95;
@@ -4908,7 +4993,7 @@ var GlbModel = class extends Object3D11 {
4908
4993
  };
4909
4994
 
4910
4995
  // src/elements/lane.ts
4911
- import { BufferGeometry as BufferGeometry4, LineSegments as LineSegments3, Mesh as Mesh7, Object3D as Object3D12, ShapeGeometry as ShapeGeometry2, Vector2 as Vector28, Vector3 as Vector315 } from "three";
4996
+ import { BufferGeometry as BufferGeometry4, LineSegments as LineSegments3, Mesh as Mesh8, Object3D as Object3D12, ShapeGeometry as ShapeGeometry2, Vector2 as Vector28, Vector3 as Vector315 } from "three";
4912
4997
  import { mergeGeometries as mergeGeometries3 } from "three/examples/jsm/utils/BufferGeometryUtils";
4913
4998
  import { Line2 as Line22 } from "three/examples/jsm/lines/Line2";
4914
4999
  import { LineGeometry } from "three/examples/jsm/lines/LineGeometry";
@@ -5029,7 +5114,7 @@ var Lane = class extends Object3D12 {
5029
5114
  init() {
5030
5115
  this.initGeometry();
5031
5116
  this.initMaterial();
5032
- const mesh = new Mesh7(this.geometry, this.material);
5117
+ const mesh = new Mesh8(this.geometry, this.material);
5033
5118
  this.add(mesh);
5034
5119
  if (this.options[0].strokeOpacity !== 0) {
5035
5120
  this.initLineMaterial();
@@ -5051,7 +5136,7 @@ var Lane = class extends Object3D12 {
5051
5136
  import {
5052
5137
  Object3D as Object3D13,
5053
5138
  ExtrudeGeometry as ExtrudeGeometry3,
5054
- Mesh as Mesh8,
5139
+ Mesh as Mesh9,
5055
5140
  Vector3 as Vector316,
5056
5141
  BufferGeometry as BufferGeometry5,
5057
5142
  LineSegments as LineSegments4,
@@ -5170,7 +5255,7 @@ var MergeGraphic = class extends Object3D13 {
5170
5255
  if (this.mesh) {
5171
5256
  this.remove(this.mesh);
5172
5257
  }
5173
- this.mesh = new Mesh8(this.geometry, this.material);
5258
+ this.mesh = new Mesh9(this.geometry, this.material);
5174
5259
  this.add(this.mesh);
5175
5260
  }
5176
5261
  getBorderPoints() {
@@ -5233,7 +5318,8 @@ var defaultOptions4 = {
5233
5318
  opacity: 1,
5234
5319
  id: "",
5235
5320
  position: { x: 0, y: 0, z: 0 },
5236
- text_font_size: 14
5321
+ text_font_size: 14,
5322
+ icon_rotate: 0
5237
5323
  };
5238
5324
  var Poi2 = class extends Object3D14 {
5239
5325
  constructor(context, options) {
@@ -5276,10 +5362,7 @@ var Poi2 = class extends Object3D14 {
5276
5362
  return this.options.text ? this.options.text_font_size : 0;
5277
5363
  }
5278
5364
  get deltaZ() {
5279
- const { offset, iconHeight, durIconAndText, textHeight } = this;
5280
- let dz = offset * (iconHeight + durIconAndText + textHeight) / this.context.camera.zoom;
5281
- dz += 0.1;
5282
- return dz;
5365
+ return 0.1;
5283
5366
  }
5284
5367
  get canSelect() {
5285
5368
  return this.visible && (this.spriteIcon ? this.spriteIcon.visible : true) && (this.spriteText ? this.spriteText.visible : true);
@@ -5304,6 +5387,11 @@ var Poi2 = class extends Object3D14 {
5304
5387
  this.initSize();
5305
5388
  this._initScale({ zoom: this.context.camera.zoom });
5306
5389
  });
5390
+ this.addEventListener("change-icon_rotate", ({ value }) => {
5391
+ if (this.spriteIcon) {
5392
+ this.spriteIcon.material.rotation = value / 180 * Math.PI;
5393
+ }
5394
+ });
5307
5395
  }
5308
5396
  unRegistryEvent() {
5309
5397
  this.context.removeEventListener("control-zoom-change", this._initScale);
@@ -5316,7 +5404,8 @@ var Poi2 = class extends Object3D14 {
5316
5404
  map: texture,
5317
5405
  transparent: true,
5318
5406
  alphaTest: 0.2,
5319
- depthTest: false
5407
+ depthTest: false,
5408
+ rotation: this.options.icon_rotate / 180 * Math.PI
5320
5409
  })
5321
5410
  );
5322
5411
  spriteIcon.visible = false;
@@ -5423,9 +5512,9 @@ var Poi2 = class extends Object3D14 {
5423
5512
  if (!this.boxHelper) {
5424
5513
  const div = document.createElement("div");
5425
5514
  div.style.position = "fixed";
5426
- this.boxHelper = div;
5427
5515
  div.style.border = "1px solid red";
5428
5516
  div.style.pointerEvents = "none";
5517
+ this.boxHelper = div;
5429
5518
  this.context.container.appendChild(div);
5430
5519
  }
5431
5520
  this.boxHelper.style.left = this.box.min.x + "px";
@@ -5455,7 +5544,7 @@ var Poi2 = class extends Object3D14 {
5455
5544
  import {
5456
5545
  DoubleSide as DoubleSide5,
5457
5546
  Matrix4 as Matrix42,
5458
- Mesh as Mesh9,
5547
+ Mesh as Mesh10,
5459
5548
  MeshBasicMaterial as MeshBasicMaterial6,
5460
5549
  Object3D as Object3D15,
5461
5550
  PlaneGeometry as PlaneGeometry3
@@ -5521,7 +5610,7 @@ var TextTexture = class extends Object3D15 {
5521
5610
  texture.needsUpdate = true;
5522
5611
  return material;
5523
5612
  });
5524
- const mesh = new Mesh9(geometry, materials);
5613
+ const mesh = new Mesh10(geometry, materials);
5525
5614
  this.mesh = mesh;
5526
5615
  this.position.z += 4e-3;
5527
5616
  this.add(mesh);
@@ -5998,7 +6087,7 @@ var CameraBound = class {
5998
6087
  // src/context/control.ts
5999
6088
  import { Vector3 as Vector320 } from "three";
6000
6089
  import { MapControls } from "three/examples/jsm/controls/MapControls";
6001
- import { Tween, Group as TweenGroup } from "@tweenjs/tween.js";
6090
+ import { Tween as Tween2, Group as TweenGroup } from "@tweenjs/tween.js";
6002
6091
  var Control = class extends MapControls {
6003
6092
  constructor(context, camera, domElement) {
6004
6093
  super(camera, domElement);
@@ -6051,7 +6140,7 @@ var Control = class extends MapControls {
6051
6140
  new Promise((resolve) => {
6052
6141
  const start = { polar: this.getPolarAngle() };
6053
6142
  const end = { polar };
6054
- const tween = new Tween(start, this.tweenGroup).to(end, duration).onUpdate(() => {
6143
+ const tween = new Tween2(start, this.tweenGroup).to(end, duration).onUpdate(() => {
6055
6144
  this.setPolarAngle(start.polar, force);
6056
6145
  }).onComplete(() => {
6057
6146
  this.enabled = true;
@@ -6090,7 +6179,7 @@ var Control = class extends MapControls {
6090
6179
  new Promise((resolve) => {
6091
6180
  const start = { azimuthal: this.getAzimuthalAngle() };
6092
6181
  const end = { azimuthal };
6093
- const tween = new Tween(start, this.tweenGroup).to(end, duration).onUpdate(() => {
6182
+ const tween = new Tween2(start, this.tweenGroup).to(end, duration).onUpdate(() => {
6094
6183
  this.setAzimuthalAngle(start.azimuthal, force);
6095
6184
  }).onComplete(() => {
6096
6185
  this.enabled = true;
@@ -6122,7 +6211,7 @@ var Control = class extends MapControls {
6122
6211
  }
6123
6212
  return timeoutPromise(
6124
6213
  new Promise((resolve) => {
6125
- const tween = new Tween(start, this.tweenGroup).to(newTarget, duration).onUpdate(() => {
6214
+ const tween = new Tween2(start, this.tweenGroup).to(newTarget, duration).onUpdate(() => {
6126
6215
  this.camera.position.copy(start.clone().sub(lookAtVector));
6127
6216
  this.target.copy(start.clone());
6128
6217
  this.update();
@@ -6166,7 +6255,7 @@ var Control = class extends MapControls {
6166
6255
  }
6167
6256
  return timeoutPromise(
6168
6257
  new Promise((resolve) => {
6169
- const tween = new Tween(start, this.tweenGroup).to(
6258
+ const tween = new Tween2(start, this.tweenGroup).to(
6170
6259
  {
6171
6260
  zoom,
6172
6261
  target: center2
@@ -7174,7 +7263,7 @@ var Equipment = class extends Plugin {
7174
7263
 
7175
7264
  // src/plugins/navigation/path.ts
7176
7265
  import {
7177
- Mesh as Mesh10,
7266
+ Mesh as Mesh11,
7178
7267
  Object3D as Object3D18,
7179
7268
  TextureLoader as TextureLoader2,
7180
7269
  Color as Color8,
@@ -7853,7 +7942,6 @@ var Path2 = class extends Object3D18 {
7853
7942
  texture = null;
7854
7943
  config = defaultConfig2;
7855
7944
  points = [];
7856
- pathDistance = 0;
7857
7945
  basicRepeat = 1;
7858
7946
  prevCameraZoom = 0;
7859
7947
  registryEvent() {
@@ -7862,6 +7950,7 @@ var Path2 = class extends Object3D18 {
7862
7950
  this.onControlChange
7863
7951
  );
7864
7952
  this.navigation.bmap.context.addEventListener("update", this.onUpdate);
7953
+ this.navigation.bmap.context.addEventListener("resize", this.onResize);
7865
7954
  }
7866
7955
  unRegistryEvent() {
7867
7956
  this.navigation.bmap.context.removeEventListener(
@@ -7869,6 +7958,7 @@ var Path2 = class extends Object3D18 {
7869
7958
  this.onControlChange
7870
7959
  );
7871
7960
  this.navigation.bmap.context.removeEventListener("update", this.onUpdate);
7961
+ this.navigation.bmap.context.removeEventListener("resize", this.onResize);
7872
7962
  }
7873
7963
  onControlChange = () => {
7874
7964
  const zoom = this.navigation.bmap.context.camera.zoom;
@@ -7882,6 +7972,12 @@ var Path2 = class extends Object3D18 {
7882
7972
  return;
7883
7973
  }
7884
7974
  };
7975
+ onResize = () => {
7976
+ if (this.material) {
7977
+ const { width, height } = this.navigation.bmap.context.clientSize;
7978
+ this.material.resolution.set(width, height);
7979
+ }
7980
+ };
7885
7981
  getRepeat() {
7886
7982
  const {
7887
7983
  points,
@@ -7921,18 +8017,16 @@ var Path2 = class extends Object3D18 {
7921
8017
  }
7922
8018
  updatePoints(points) {
7923
8019
  this.points = points;
7924
- this.pathDistance = getPathLength(points);
7925
8020
  this.changeRepeat();
7926
8021
  const _points = this.transformPoints(points);
7927
8022
  if (this.geometry) {
7928
8023
  this.geometry.setPoints(_points);
7929
8024
  }
7930
8025
  }
7931
- movePath(distance) {
7932
- if (!this.material || !this.pathDistance) {
8026
+ movePath(ratio) {
8027
+ if (!this.material) {
7933
8028
  return;
7934
8029
  }
7935
- const ratio = distance / this.pathDistance;
7936
8030
  this.material.thresholdRatio = ratio;
7937
8031
  }
7938
8032
  async create(points) {
@@ -7959,7 +8053,7 @@ var Path2 = class extends Object3D18 {
7959
8053
  blending: NormalBlending,
7960
8054
  repeat: new Vector213(this.getRepeat(), 1)
7961
8055
  });
7962
- const mesh = this.mesh = new Mesh10(lineGeometry, material);
8056
+ const mesh = this.mesh = new Mesh11(lineGeometry, material);
7963
8057
  mesh.renderOrder = 9;
7964
8058
  this.add(mesh);
7965
8059
  return mesh;
@@ -7974,25 +8068,36 @@ var Path2 = class extends Object3D18 {
7974
8068
  };
7975
8069
 
7976
8070
  // src/plugins/navigation/navigation.ts
7977
- import { Group as TweenGroup2, Tween as Tween2, Easing } from "@tweenjs/tween.js";
8071
+ import { Tween as Tween3, Easing } from "@tweenjs/tween.js";
7978
8072
  import { Vector3 as Vector325 } from "three";
7979
8073
  var defaultConfig3 = {
7980
8074
  path: {},
7981
- speed: 10,
7982
8075
  cheapMaximumDistance: 20,
7983
8076
  needStartPoi: false,
7984
8077
  startPoi: {},
7985
- offsetY: 150
8078
+ offsetY: 150,
8079
+ directionEmitThreshold: 5,
8080
+ disablePathAnimation: false
7986
8081
  };
7987
8082
  var Navigation = class extends Plugin {
7988
8083
  path = null;
7989
8084
  fetchRoadStatus = false;
7990
8085
  paths = [];
8086
+ // 原始坐标路线
8087
+ curPathIndex = 0;
8088
+ // 当前展示的路线所在的下标
8089
+ curFloorPath = null;
8090
+ // 当前楼层原始坐标路线
8091
+ translatePath = null;
8092
+ // 对原始坐标做完平移路线,只有当前楼层
8093
+ currentPathPosition = null;
8094
+ // 起点所在的当前位置,平移前坐标
7991
8095
  options;
7992
- pathTween = new TweenGroup2();
8096
+ pathTween = null;
7993
8097
  startPoi = null;
7994
8098
  movedDistance = 0;
7995
8099
  pathStart = [0, 0];
8100
+ tweenUtil = new TweenUtil();
7996
8101
  // 处理路线动画
7997
8102
  animationPathOptions = {
7998
8103
  cPathIndex: 0
@@ -8000,8 +8105,11 @@ var Navigation = class extends Plugin {
8000
8105
  };
8001
8106
  cPath = [];
8002
8107
  // 当前楼层的平滑后的路线
8003
- constructor(bmap, project, options = {}) {
8108
+ constructor(bmap, project = {}, options) {
8004
8109
  super(bmap);
8110
+ if (!options && typeof project === "object") {
8111
+ options = project;
8112
+ }
8005
8113
  this.options = Object.assign({}, defaultConfig3, options);
8006
8114
  const {
8007
8115
  apiDomain,
@@ -8010,6 +8118,12 @@ var Navigation = class extends Plugin {
8010
8118
  } = this.bmap.config;
8011
8119
  this.registryEvent();
8012
8120
  }
8121
+ get curFloorPathLength() {
8122
+ return this.curFloorPath?.distance ?? 0;
8123
+ }
8124
+ get curFloorPathPoints() {
8125
+ return this.curFloorPath?.points ?? [];
8126
+ }
8013
8127
  registryEvent() {
8014
8128
  this.bmap.context.addEventListener("update", this.onUpdate);
8015
8129
  this.bmap.addEventListener(
@@ -8017,6 +8131,12 @@ var Navigation = class extends Plugin {
8017
8131
  this.onSwitchFloor
8018
8132
  );
8019
8133
  }
8134
+ pauseAnimation() {
8135
+ this.tweenUtil.pause();
8136
+ }
8137
+ continueAnimation() {
8138
+ this.tweenUtil.continue();
8139
+ }
8020
8140
  unRegistryEvent() {
8021
8141
  this.bmap.context.removeEventListener("update", this.onUpdate);
8022
8142
  this.bmap.removeEventListener(
@@ -8025,26 +8145,44 @@ var Navigation = class extends Plugin {
8025
8145
  );
8026
8146
  }
8027
8147
  onUpdate = () => {
8028
- this.pathTween.update();
8148
+ this.tweenUtil.update();
8029
8149
  };
8030
8150
  clearPath() {
8031
8151
  if (this.path) {
8032
8152
  this.bmap.context.scene.remove(this.path);
8033
8153
  this.path.dispose();
8034
8154
  this.path = null;
8035
- this.pathTween.getAll().forEach((item) => item.stop());
8036
- this.pathTween.removeAll();
8155
+ this.tweenUtil.clear();
8037
8156
  }
8038
8157
  if (this.startPoi) {
8039
8158
  this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
8040
8159
  this.startPoi = null;
8041
8160
  }
8161
+ this.translatePath = null;
8162
+ }
8163
+ setCurFloorPath(path) {
8164
+ if (path === null) {
8165
+ this.curFloorPath = null;
8166
+ this.currentPathPosition = null;
8167
+ } else {
8168
+ this.curFloorPath = path;
8169
+ this.currentPathPosition = path.points[0];
8170
+ }
8171
+ this.movedDistance = 0;
8172
+ }
8173
+ setCurPathIndex(index) {
8174
+ this.curPathIndex = index;
8175
+ if (this.paths[index]?.floor === this.bmap.context.currentFloor?.name) {
8176
+ this.setCurFloorPath(this.paths[index]);
8177
+ this.renderPath(this.translatePoints(this.curFloorPathPoints));
8178
+ } else {
8179
+ this.clearPath();
8180
+ }
8042
8181
  }
8043
8182
  onSwitchFloor = ({ data: { curFloor } }) => {
8044
- if (this.paths.length) {
8045
- const curFloorPathData = this.paths.find(
8046
- (item) => item.floor === curFloor.name
8047
- );
8183
+ if (this.paths[this.curPathIndex]) {
8184
+ const curFloorPathData = this.paths[this.curPathIndex];
8185
+ this.setCurFloorPath(curFloorPathData ?? null);
8048
8186
  if (curFloorPathData) {
8049
8187
  this.renderPath(this.translatePoints(curFloorPathData.points));
8050
8188
  } else {
@@ -8054,11 +8192,13 @@ var Navigation = class extends Plugin {
8054
8192
  this.clearPath();
8055
8193
  }
8056
8194
  };
8057
- addPath(paths) {
8195
+ addPath(paths, routeIndex = 0) {
8058
8196
  this.paths = paths;
8197
+ this.curPathIndex = routeIndex;
8059
8198
  const floorName = this.bmap.context.currentFloor?.name;
8060
- const curFloorPath = paths.find((item) => item.floor === floorName);
8061
- if (curFloorPath) {
8199
+ const curFloorPath = paths[routeIndex];
8200
+ if (floorName && curFloorPath?.floor === floorName) {
8201
+ this.setCurFloorPath(curFloorPath);
8062
8202
  if (this.bmap.currentBuildGround) {
8063
8203
  this.renderPath(this.translatePoints(curFloorPath.points));
8064
8204
  } else {
@@ -8079,12 +8219,12 @@ var Navigation = class extends Plugin {
8079
8219
  });
8080
8220
  }
8081
8221
  renderPath(points) {
8222
+ this.translatePath = points;
8082
8223
  const cPath = this.catmullRomCurve3(points);
8083
8224
  this.cPath = cPath;
8084
8225
  this.animationPathOptions = {
8085
8226
  cPathIndex: 0
8086
8227
  };
8087
- this.movedDistance = 0;
8088
8228
  this.pathStart = cPath[0];
8089
8229
  if (this.path) {
8090
8230
  this.path.updatePoints(cPath);
@@ -8102,21 +8242,25 @@ var Navigation = class extends Plugin {
8102
8242
  this.startPoi = new Poi2(this.bmap.context, {
8103
8243
  ...this.options.startPoi,
8104
8244
  id: "navigation_start_poi",
8105
- position: { x: cPath[0][0], y: cPath[0][1], z: 1e-4 },
8245
+ position: { x: cPath[0][0], y: cPath[0][1], z: 0.51 },
8106
8246
  collision_enable: false
8107
8247
  }) || null;
8108
8248
  this.bmap.context.currentFloor?.poiLayer2.pushPoi(this.startPoi);
8109
8249
  }
8250
+ this.dispatchEvent({
8251
+ type: "render-path",
8252
+ path: this.path
8253
+ });
8110
8254
  }
8111
8255
  catmullRomCurve3(points) {
8112
- return simplifyPath(points, false, true, 0.1, 150, 2.5);
8256
+ return simplifyPath(points, false, true, 0.1, 170, 2.5);
8113
8257
  }
8114
8258
  /**
8115
8259
  * 按照指定速度移动到目标位置
8116
8260
  * @param point 目标位置
8117
8261
  * @param speed 移动速度 / 米/s
8118
8262
  */
8119
- async animationTo(point3, speed = this.options.speed) {
8263
+ async animationTo(point3, speed) {
8120
8264
  if (point3.floor !== this.bmap.context.currentFloor?.name || !this.path) {
8121
8265
  return;
8122
8266
  }
@@ -8171,14 +8315,13 @@ var Navigation = class extends Plugin {
8171
8315
  moveDistance = moveDistanceArray.reduce((sum, cur) => sum + cur, 0);
8172
8316
  }
8173
8317
  const timeSecond = moveDistance / speed;
8174
- this.pathTween.getAll().forEach((item) => item.stop());
8175
- this.pathTween.removeAll();
8318
+ this.tweenUtil.clear();
8176
8319
  const start = { distance: 0 };
8177
8320
  const prevCPathIndex = this.animationPathOptions.cPathIndex;
8178
8321
  let pastRouteLength = 0;
8179
8322
  let pastRouteIndex = 0;
8180
8323
  return new Promise((resolve) => {
8181
- const tween = new Tween2(start, this.pathTween).to({ distance: moveDistance }, timeSecond * 1e3).onUpdate(async () => {
8324
+ const tween = new Tween3(start, this.tweenUtil.group).to({ distance: moveDistance }, timeSecond * 1e3).onUpdate(async () => {
8182
8325
  let dis = start.distance - pastRouteLength;
8183
8326
  while (moveDistanceArray.length && dis > moveDistanceArray[0]) {
8184
8327
  pastRouteLength += moveDistanceArray.shift();
@@ -8203,7 +8346,7 @@ var Navigation = class extends Plugin {
8203
8346
  tween.resume();
8204
8347
  this.dispatchEvent({ type: "path-animation", pathIndex: this.animationPathOptions.cPathIndex });
8205
8348
  }).onComplete(() => {
8206
- this.pathTween.remove(tween);
8349
+ this.tweenUtil.remove(tween);
8207
8350
  this.dispatchEvent({ type: "path-animation-end" });
8208
8351
  this.movedDistance += moveDistance;
8209
8352
  resolve(true);
@@ -8212,25 +8355,22 @@ var Navigation = class extends Plugin {
8212
8355
  }
8213
8356
  // 计算路线的方向
8214
8357
  getPathDirection() {
8215
- const path = this.cPath.slice(this.animationPathOptions.cPathIndex);
8216
- if (path.length < 3) {
8358
+ if (!this.curFloorPath || !this.currentPathPosition) {
8217
8359
  return null;
8218
8360
  }
8219
- const p0 = path[0];
8220
- const p1 = path[1];
8221
- const p2 = path[2];
8222
- const angle = calc_angle(p0, p1, p2);
8223
- if (Math.abs(angle) >= 179.5 && Math.abs(angle) <= 180) {
8224
- const v1 = new Vector325(p2[0] - p1[0], p2[1] - p1[1], 0).normalize();
8225
- const v2 = new Vector325(0, 1, 0).normalize();
8226
- const angle2 = v1.angleTo(v2);
8227
- const cross = new Vector325().crossVectors(v2, v1);
8228
- const sign = Object.is(cross.y, 0) ? -1 : 1;
8229
- const finalAngle = sign * angle2;
8230
- return finalAngle;
8231
- } else {
8361
+ if (this.curFloorPathPoints.length < 2) {
8232
8362
  return null;
8233
8363
  }
8364
+ const index = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
8365
+ const l1 = this.curFloorPathPoints[index];
8366
+ const l2 = this.curFloorPathPoints[index + 1];
8367
+ const v1 = new Vector325(l2[0] - l1[0], l2[1] - l1[1], 0).normalize();
8368
+ const v2 = new Vector325(0, 1, 0).normalize();
8369
+ const angle = v1.angleTo(v2);
8370
+ const cross = new Vector325().crossVectors(v2, v1);
8371
+ const sign = Object.is(cross.y, 0) ? -1 : 1;
8372
+ const finalAngle = sign * angle;
8373
+ return finalAngle;
8234
8374
  }
8235
8375
  // 把相机旋转到路线的上方向
8236
8376
  async changeCameraToPathUp(duration = 100) {
@@ -8255,13 +8395,13 @@ var Navigation = class extends Plugin {
8255
8395
  return new Promise((resolve) => {
8256
8396
  const start = { azimuthal: control.getAzimuthalAngle() };
8257
8397
  const end = { azimuthal: angle };
8258
- const tween = new Tween2(start, this.pathTween).to(end, time).easing(Easing.Quadratic.InOut).onUpdate(async () => {
8398
+ const tween = new Tween3(start, this.tweenUtil.group).to(end, time).easing(Easing.Quadratic.InOut).onUpdate(async () => {
8259
8399
  control.target.copy(this.startPoi.position);
8260
8400
  control.setAzimuthalAngle(start.azimuthal, true);
8261
8401
  control.setTargetByOffset(this.options.offsetY);
8262
8402
  }).onComplete(() => {
8263
8403
  control.enabled = true;
8264
- this.pathTween.remove(tween);
8404
+ this.tweenUtil.remove(tween);
8265
8405
  resolve(true);
8266
8406
  }).onStart(() => {
8267
8407
  control.enabled = false;
@@ -8320,7 +8460,151 @@ var Navigation = class extends Plugin {
8320
8460
  duration
8321
8461
  );
8322
8462
  }
8463
+ async toPositionBySpeed(position, speed) {
8464
+ if (this.pathTween) {
8465
+ this.tweenUtil.clear();
8466
+ }
8467
+ const { currentPathPosition, curFloorPath, curFloorPathPoints } = this;
8468
+ if (!curFloorPath || !currentPathPosition) {
8469
+ return null;
8470
+ }
8471
+ const curDistance = this.movedDistance;
8472
+ const positionDistance = getDistanceByPathPos(curFloorPathPoints, position);
8473
+ console.log(curDistance, positionDistance);
8474
+ if (curDistance === -1 || positionDistance === -1) {
8475
+ return null;
8476
+ }
8477
+ if (positionDistance <= curDistance) {
8478
+ return null;
8479
+ }
8480
+ const distance = positionDistance - curDistance;
8481
+ if (!distance) {
8482
+ return;
8483
+ }
8484
+ const time = distance / speed;
8485
+ return new Promise((resolve) => {
8486
+ const tween = this.pathTween = new Tween3({ distance: 0 }, this.tweenUtil.group).to({ distance }, time * 1e3).onUpdate(async (v) => {
8487
+ this.movedDistance = v.distance + curDistance;
8488
+ this.path?.movePath(this.movedDistance / this.curFloorPathLength);
8489
+ const pos = getPosByPathDistance(curFloorPathPoints, this.movedDistance);
8490
+ if (pos === null) {
8491
+ this.tweenUtil.remove(tween);
8492
+ return;
8493
+ }
8494
+ this.currentPathPosition = pos;
8495
+ const translatePos = this.translatePoints([pos])[0];
8496
+ if (this.startPoi) {
8497
+ this.startPoi.position.setX(translatePos[0]).setY(translatePos[1]);
8498
+ if (!this.options.disablePathAnimation) {
8499
+ this.bmap.context.control.setTargetByOffset(this.options.offsetY, this.startPoi.position.clone());
8500
+ }
8501
+ }
8502
+ if (!this.options.disablePathAnimation) {
8503
+ tween.pause();
8504
+ await this.changeCameraToPathUp(500 / speed);
8505
+ tween.resume();
8506
+ }
8507
+ this.emitNavigationInfo();
8508
+ }).onComplete(() => {
8509
+ this.tweenUtil.remove(tween);
8510
+ resolve(true);
8511
+ }).start();
8512
+ });
8513
+ }
8514
+ // 吸附路线
8515
+ adsorb(floor, position) {
8516
+ if (!this.curFloorPathPoints.length) {
8517
+ return null;
8518
+ }
8519
+ let path = this.curFloorPathPoints;
8520
+ if (this.currentPathPosition) {
8521
+ const index2 = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
8522
+ path = path.slice(index2 + 1);
8523
+ path.unshift(this.currentPathPosition);
8524
+ }
8525
+ const paths = [
8526
+ { floor: this.curFloorPath?.floor, points: path },
8527
+ ...this.paths.slice(this.curPathIndex + 1)
8528
+ ].filter((item) => item.floor === floor);
8529
+ const { distance, closestPoint, index } = paths.reduce((obj, cur, index2) => {
8530
+ const { distance: distance2, closestPoint: closestPoint2 } = cur.points.reduce((obj2, cur2, index3, arr) => {
8531
+ if (!arr[index3 + 1]) {
8532
+ return obj2;
8533
+ }
8534
+ const { distance: distance3, closestPoint: closestPoint3 } = distancePointToSegment(position, cur2, arr[index3 + 1]);
8535
+ if (distance3 < obj2.distance) {
8536
+ return { distance: distance3, closestPoint: closestPoint3 };
8537
+ }
8538
+ return obj2;
8539
+ }, { distance: Infinity, closestPoint: path[0] });
8540
+ if (distance2 < obj.distance) {
8541
+ return { distance: distance2, closestPoint: closestPoint2, index: index2 };
8542
+ }
8543
+ return obj;
8544
+ }, { distance: Infinity, closestPoint: path[0], index: 0 });
8545
+ return { distance, closestPoint, index: index + this.curPathIndex };
8546
+ }
8547
+ // 计算剩余距离
8548
+ getRemainDistance() {
8549
+ const curPathRemainDistance = this.curFloorPathLength - this.movedDistance;
8550
+ const remainFloor = this.paths.slice(this.curPathIndex + 1);
8551
+ const remainFloorDistance = remainFloor.reduce((total, item) => total + item.distance, 0);
8552
+ return remainFloorDistance + curPathRemainDistance;
8553
+ }
8554
+ // 计算下一个拐弯点的方向和距离
8555
+ getNextDirDistance() {
8556
+ if (!this.currentPathPosition) {
8557
+ return null;
8558
+ }
8559
+ const index = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
8560
+ const p1 = this.curFloorPathPoints[index];
8561
+ const p2 = this.curFloorPathPoints[index + 1];
8562
+ const p3 = this.curFloorPathPoints[index + 2];
8563
+ if (!p1 || !p2) {
8564
+ return null;
8565
+ }
8566
+ const distance = getLength(this.currentPathPosition, p2);
8567
+ if (index === 0) {
8568
+ const l = getLength(p1, this.currentPathPosition);
8569
+ if (l < 5) {
8570
+ return { dir: "start" /* START */, distance };
8571
+ }
8572
+ }
8573
+ if (!p3) {
8574
+ return { dir: "end" /* END */, distance };
8575
+ }
8576
+ const dir = calc_direction(p1, p2, p3);
8577
+ return { dir, distance };
8578
+ }
8579
+ emitNavigationInfo() {
8580
+ const remainDistance = this.getRemainDistance();
8581
+ const nextDirInfo = this.getNextDirDistance();
8582
+ if (!nextDirInfo) {
8583
+ return null;
8584
+ }
8585
+ let { dir, distance } = nextDirInfo;
8586
+ if (dir === "end" /* END */ && distance > 15) {
8587
+ dir = "front" /* FRONT */;
8588
+ }
8589
+ if (dir !== "start" /* START */ && distance >= this.options.directionEmitThreshold) {
8590
+ dir = "front" /* FRONT */;
8591
+ }
8592
+ this.dispatchEvent({
8593
+ type: "navigation-info",
8594
+ dir,
8595
+ distance: remainDistance,
8596
+ nextDirDistance: distance
8597
+ });
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
+ }
8323
8606
  dispose() {
8607
+ this.tweenUtil.dispose();
8324
8608
  this.unRegistryEvent();
8325
8609
  this.path?.dispose();
8326
8610
  this.startPoi?.dispose();
@@ -8328,11 +8612,11 @@ var Navigation = class extends Plugin {
8328
8612
  };
8329
8613
 
8330
8614
  // src/plugins/mul-floors/mul-floors.ts
8331
- import { Group as Group3 } from "three";
8615
+ import { Group as Group4 } from "three";
8332
8616
  var MulFloors = class extends Plugin {
8333
8617
  poiLayer;
8334
8618
  floors = [];
8335
- group = new Group3();
8619
+ group = new Group4();
8336
8620
  constructor(bmap) {
8337
8621
  super(bmap);
8338
8622
  this.poiLayer = new PoiLayer(bmap.context);
@@ -8442,7 +8726,6 @@ var NavPath = class extends EventDispatcher10 {
8442
8726
  }
8443
8727
  });
8444
8728
  };
8445
- console.log(this.initRoadStatus);
8446
8729
  if (this.initRoadStatus) {
8447
8730
  _getPath();
8448
8731
  } else {
@@ -8465,6 +8748,284 @@ var NavPath = class extends EventDispatcher10 {
8465
8748
  }
8466
8749
  };
8467
8750
 
8751
+ // src/plugins/select/box-selection.ts
8752
+ import { Frustum as Frustum3 } from "three";
8753
+ var BoxSelection2 = class extends BaseSvg {
8754
+ startPoint;
8755
+ endPoint;
8756
+ rect;
8757
+ frustum = new Frustum3();
8758
+ constructor(context) {
8759
+ super(context);
8760
+ const { config: { selectBox: { fill, stroke } } } = context;
8761
+ this.rect = createRect(stroke, fill);
8762
+ this.svg.appendChild(this.rect);
8763
+ this.registryEvent();
8764
+ }
8765
+ setEnable(enable) {
8766
+ super.setEnable(enable);
8767
+ setRectPosition(this.rect, 0, 0, 0, 0);
8768
+ if (enable) {
8769
+ this.registryEvent();
8770
+ } else {
8771
+ this.startPoint = void 0;
8772
+ this.unRegistryEvent();
8773
+ }
8774
+ }
8775
+ onPointerDown = (e) => {
8776
+ if (!this.enable) {
8777
+ return;
8778
+ }
8779
+ const point3 = this.getIntersectByPointerEvent(e);
8780
+ if (point3) {
8781
+ this.startPoint = point3;
8782
+ }
8783
+ this.endPoint = void 0;
8784
+ };
8785
+ onPointerMove = (e) => {
8786
+ if (!this.enable || !this.startPoint) {
8787
+ return;
8788
+ }
8789
+ const point3 = this.getIntersectByPointerEvent(e);
8790
+ if (point3) {
8791
+ this.endPoint = point3;
8792
+ }
8793
+ };
8794
+ onPointerUp = (e) => {
8795
+ if (!this.enable) {
8796
+ return;
8797
+ }
8798
+ const point3 = this.getIntersectByPointerEvent(e);
8799
+ if (point3) {
8800
+ this.endPoint = point3;
8801
+ }
8802
+ this.doSelect();
8803
+ this.startPoint = void 0;
8804
+ };
8805
+ onUpdate = () => {
8806
+ if (this.startPoint) {
8807
+ const startPoint = this.getSvgCoordinate(this.startPoint);
8808
+ let endPoint = { ...startPoint };
8809
+ if (this.endPoint) {
8810
+ endPoint = this.getSvgCoordinate(this.endPoint);
8811
+ }
8812
+ const leftTop = { x: Math.min(startPoint.x, endPoint.x), y: Math.min(startPoint.y, endPoint.y) };
8813
+ const width = Math.abs(endPoint.x - startPoint.x);
8814
+ const height = Math.abs(endPoint.y - startPoint.y);
8815
+ setRectPosition(this.rect, leftTop.x, leftTop.y, width, height);
8816
+ } else {
8817
+ setRectPosition(this.rect, 0, 0, 0, 0);
8818
+ }
8819
+ };
8820
+ registryEvent() {
8821
+ this.context.container.addEventListener("pointerdown", this.onPointerDown);
8822
+ this.context.container.addEventListener("pointermove", this.onPointerMove);
8823
+ this.context.container.addEventListener("pointerup", this.onPointerUp);
8824
+ this.context.addEventListener("update", this.onUpdate);
8825
+ }
8826
+ unRegistryEvent() {
8827
+ this.context.container.removeEventListener("pointerdown", this.onPointerDown);
8828
+ this.context.container.removeEventListener("pointermove", this.onPointerMove);
8829
+ this.context.container.removeEventListener("pointerup", this.onPointerUp);
8830
+ this.context.removeEventListener("update", this.onUpdate);
8831
+ }
8832
+ doSelect() {
8833
+ if (this.startPoint && this.endPoint) {
8834
+ const dis = this.startPoint.distanceTo(this.endPoint);
8835
+ if (dis < 0.1) {
8836
+ return;
8837
+ }
8838
+ const { context: { camera, container: { clientWidth: w, clientHeight: h } } } = this;
8839
+ const startDevice = vector3ToDevice(this.startPoint, camera, w, h);
8840
+ const endDevice = vector3ToDevice(this.endPoint, camera, w, h);
8841
+ const leftTop = { x: Math.min(startDevice.x, endDevice.x), y: Math.min(startDevice.y, endDevice.y) };
8842
+ const rightBottom = { x: Math.max(startDevice.x, endDevice.x), y: Math.max(startDevice.y, endDevice.y) };
8843
+ const list = this.searchMapInFrustum(leftTop, rightBottom);
8844
+ this.dispatchEvent({ type: "selected", list });
8845
+ }
8846
+ }
8847
+ searchMapInFrustum(leftTop, rightBottom) {
8848
+ const { context } = this;
8849
+ return context.currentFloor?.graphicLayer.children.filter((item) => {
8850
+ return item instanceof Graphic && this.searchChildInFrustum(item, leftTop, rightBottom);
8851
+ }) || [];
8852
+ }
8853
+ searchChildInFrustum(object, leftTop, rightBottom) {
8854
+ const { context: { camera, container: { clientWidth: w, clientHeight: h } } } = this;
8855
+ if (!object) return false;
8856
+ if (!object.mesh) {
8857
+ const position = object.getPosition();
8858
+ if (position) {
8859
+ const position2d = vector3ToDevice(position, camera, w, h);
8860
+ return isContain(position2d, leftTop, rightBottom);
8861
+ }
8862
+ return false;
8863
+ }
8864
+ if (!object.mesh.geometry.boundingBox) {
8865
+ object.mesh.geometry.computeBoundingBox();
8866
+ }
8867
+ const box = object.mesh.geometry.boundingBox;
8868
+ if (!box) {
8869
+ return false;
8870
+ }
8871
+ const { min, max } = box;
8872
+ const minDevice = vector3ToDevice(min, camera, w, h);
8873
+ const maxDevice = vector3ToDevice(max, camera, w, h);
8874
+ if (!isContain(minDevice, leftTop, rightBottom)) {
8875
+ return false;
8876
+ }
8877
+ if (!isContain(maxDevice, leftTop, rightBottom)) {
8878
+ return false;
8879
+ }
8880
+ return true;
8881
+ }
8882
+ dispose() {
8883
+ this.unRegistryEvent();
8884
+ }
8885
+ };
8886
+
8887
+ // src/plugins/select/select.ts
8888
+ var bmapSelectDefaultOptions = {
8889
+ boxSelection: false,
8890
+ elements: ["graphic", "poi"]
8891
+ };
8892
+ var BMapSelect = class extends Plugin {
8893
+ options;
8894
+ _list = /* @__PURE__ */ new Set();
8895
+ _poiList = /* @__PURE__ */ new Set();
8896
+ boxSelection;
8897
+ prevPanStatus;
8898
+ prevRotateStatus;
8899
+ downPoint = null;
8900
+ isMultipleSelect = false;
8901
+ constructor(bmap, options = {}) {
8902
+ super(bmap);
8903
+ this.options = { ...bmapSelectDefaultOptions, ...options };
8904
+ this.boxSelection = new BoxSelection2(this.bmap.context);
8905
+ this.boxSelection.setEnable(false);
8906
+ this.registryEvent();
8907
+ }
8908
+ get list() {
8909
+ return this._list;
8910
+ }
8911
+ enableBoxSelection() {
8912
+ if (this.isMultipleSelect || !this.options.boxSelection) {
8913
+ return;
8914
+ }
8915
+ this.isMultipleSelect = true;
8916
+ this.boxSelection.setEnable(true);
8917
+ this.prevPanStatus = this.bmap.context.control.enablePan;
8918
+ this.prevRotateStatus = this.bmap.context.control.enableRotate;
8919
+ this.bmap.context.control.enablePan = false;
8920
+ this.bmap.context.control.enableRotate = false;
8921
+ }
8922
+ disableBoxSelection() {
8923
+ if (this.isMultipleSelect) {
8924
+ this.isMultipleSelect = false;
8925
+ this.boxSelection.setEnable(false);
8926
+ this.bmap.context.control.enablePan = !!this.prevPanStatus;
8927
+ this.bmap.context.control.enableRotate = !!this.prevRotateStatus;
8928
+ }
8929
+ }
8930
+ onPointerDown = (e) => {
8931
+ this.downPoint = { x: e.offsetX, y: e.offsetY };
8932
+ };
8933
+ onPointerUp = (e) => {
8934
+ if (!this.downPoint) {
8935
+ return;
8936
+ }
8937
+ const { offsetX, offsetY } = e;
8938
+ const { x, y } = this.downPoint;
8939
+ if (Math.sqrt((x - offsetX) ** 2 + (y - offsetY) ** 2) > 3) {
8940
+ return;
8941
+ }
8942
+ const set2 = /* @__PURE__ */ new Set();
8943
+ const selectGraphics = [];
8944
+ const selectPois = [];
8945
+ if (this.options.elements.includes("graphic")) {
8946
+ const { graphics } = this.bmap.context.getGraphicsByDeviceXy(offsetX, offsetY);
8947
+ graphics.map((item) => set2.add(item.options.id));
8948
+ selectGraphics.push(...graphics);
8949
+ }
8950
+ if (this.options.elements.includes("poi")) {
8951
+ const pois = this.bmap.context.getPoisByDeviceXy(offsetX, offsetY);
8952
+ selectPois.push(...pois);
8953
+ pois.forEach((item) => {
8954
+ if (!set2.has(item.options.id)) {
8955
+ const graphic = this.bmap.context.currentFloor?.graphicLayer.graphicMap.get(item.options.id) || null;
8956
+ if (graphic) {
8957
+ set2.add(item.options.id);
8958
+ selectGraphics.push(graphic);
8959
+ }
8960
+ }
8961
+ });
8962
+ }
8963
+ if (!this.options.boxSelection || !(isMac ? e.metaKey : e.ctrlKey)) {
8964
+ this._list.clear();
8965
+ this._poiList.clear();
8966
+ }
8967
+ selectGraphics.forEach((item) => this._list.add(item));
8968
+ selectPois.forEach((item) => this._poiList.add(item));
8969
+ this.selectEnd();
8970
+ this.downPoint = null;
8971
+ };
8972
+ onPointerOut = (e) => {
8973
+ this.disableBoxSelection();
8974
+ };
8975
+ onKeyDown = (e) => {
8976
+ if (isControl(e.key)) {
8977
+ this.enableBoxSelection();
8978
+ }
8979
+ };
8980
+ onKeyUp = (e) => {
8981
+ if (isControl(e.key)) {
8982
+ this.disableBoxSelection();
8983
+ }
8984
+ };
8985
+ onBoxSelected = ({ list }) => {
8986
+ this._list.clear();
8987
+ list.forEach((item) => {
8988
+ this._list.add(item);
8989
+ });
8990
+ this.selectEnd();
8991
+ };
8992
+ selectEnd() {
8993
+ this.dispatchEvent({
8994
+ type: "select",
8995
+ graphics: [...this._list],
8996
+ pois: [...this._poiList],
8997
+ isMultipleSelect: this.isMultipleSelect
8998
+ });
8999
+ }
9000
+ registryEvent() {
9001
+ this.bmap.context.container.addEventListener("pointerdown", this.onPointerDown);
9002
+ this.bmap.context.container.addEventListener("pointerup", this.onPointerUp);
9003
+ this.bmap.context.container.addEventListener("pointerout", this.onPointerOut);
9004
+ this.bmap.context.container.addEventListener("pointercancel", this.onPointerOut);
9005
+ window.addEventListener("keydown", this.onKeyDown);
9006
+ window.addEventListener("keyup", this.onKeyUp);
9007
+ this.boxSelection.addEventListener("selected", this.onBoxSelected);
9008
+ }
9009
+ unRegistryEvent() {
9010
+ this.bmap.context.container.removeEventListener("pointerdown", this.onPointerDown);
9011
+ this.bmap.context.container.removeEventListener("pointerup", this.onPointerUp);
9012
+ this.bmap.context.container.removeEventListener("pointerout", this.onPointerOut);
9013
+ this.bmap.context.container.removeEventListener("pointercancel", this.onPointerOut);
9014
+ window.removeEventListener("keydown", this.onKeyDown);
9015
+ window.removeEventListener("keyup", this.onKeyUp);
9016
+ this.boxSelection.removeEventListener("selected", this.onBoxSelected);
9017
+ }
9018
+ clear() {
9019
+ this._list.clear();
9020
+ }
9021
+ remove(graphic) {
9022
+ this._list.delete(graphic);
9023
+ }
9024
+ dispose() {
9025
+ this.unRegistryEvent();
9026
+ }
9027
+ };
9028
+
8468
9029
  // src/loader/CrLoader/api/floor.ts
8469
9030
  async function loadBuildingGround({ brand, project }, config) {
8470
9031
  const {
@@ -8860,17 +9421,21 @@ var AibeeLoader = class {
8860
9421
  const graphic = floor.addGraphic(options);
8861
9422
  floor.userData.graphics.push(graphic);
8862
9423
  floor.userData.graphicMap.set(options.id, graphic);
8863
- const poi = new Poi2(this.bmap.context, {
8864
- id: options.id,
8865
- icon: options.poi_info.icon,
8866
- text: options.poi_info.showName || options.store_name || options.poi_info.text,
8867
- position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
8868
- icon_size: [18, 18]
8869
- });
8870
- floor.poiLayer2.pushPoi(poi);
8871
- if (poi) {
8872
- poi.userData.type = "store";
8873
- 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);
8874
9439
  }
8875
9440
  });
8876
9441
  break;
@@ -8895,6 +9460,8 @@ var AibeeLoader = class {
8895
9460
  floor.poiLayer2.pushPoi(poi);
8896
9461
  poi.userData.type = "facility";
8897
9462
  poi.userData.data = options;
9463
+ } else {
9464
+ console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info", options);
8898
9465
  }
8899
9466
  });
8900
9467
  break;
@@ -9121,6 +9688,7 @@ var CrLoader = class {
9121
9688
  export {
9122
9689
  AibeeLoader,
9123
9690
  BMap,
9691
+ BMapSelect,
9124
9692
  BaseSvg,
9125
9693
  Context,
9126
9694
  CrLoader,
@@ -9157,6 +9725,8 @@ export {
9157
9725
  SvgPolygon,
9158
9726
  TextTexture,
9159
9727
  Timer,
9728
+ TweenUtil,
9729
+ UA,
9160
9730
  Wall,
9161
9731
  addAlphaToHexColor,
9162
9732
  calc_angle,
@@ -9167,6 +9737,7 @@ export {
9167
9737
  createRect,
9168
9738
  createSvg,
9169
9739
  createSvgElement,
9740
+ createThreeBox,
9170
9741
  createThreeLine,
9171
9742
  darkenColor,
9172
9743
  defaultAibeeLoaderOption,
@@ -9181,18 +9752,22 @@ export {
9181
9752
  getCenter,
9182
9753
  getConfig,
9183
9754
  getDirectPath,
9755
+ getDistanceByPathPos,
9184
9756
  getLength,
9185
9757
  getLongestSideDir,
9186
9758
  getMinEdgeSquare,
9187
9759
  getPathLength,
9188
9760
  getPointEdgeIndex,
9761
+ getPosByPathDistance,
9189
9762
  hasChinese,
9190
9763
  hexToRgb,
9191
9764
  initDirectionalLight,
9192
9765
  initLight,
9193
9766
  initShape,
9767
+ isAndroid,
9194
9768
  isContain,
9195
9769
  isControl,
9770
+ isIphone,
9196
9771
  isMac,
9197
9772
  isPointInPolygon,
9198
9773
  loadBuildingGround,