@aibee/crc-bmap 0.1.2 → 0.1.3
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.cjs.min.js +6 -6
- package/lib/bmap.cjs.min.js.map +4 -4
- package/lib/bmap.esm.js +631 -94
- package/lib/bmap.esm.js.map +4 -4
- package/lib/bmap.esm.min.js +3722 -7
- package/lib/bmap.esm.min.js.map +4 -4
- package/lib/bmap.min.js +3722 -7
- package/lib/bmap.min.js.map +4 -4
- package/lib/src/plugins/index.d.ts +1 -0
- package/lib/src/plugins/nav-path/nav-path.d.ts +2 -2
- package/lib/src/plugins/navigation/navigation.d.ts +40 -10
- package/lib/src/plugins/navigation/path.d.ts +1 -2
- package/lib/src/plugins/position/index.d.ts +2 -0
- package/lib/src/plugins/position/particle.d.ts +0 -0
- package/lib/src/plugins/position/pdr.d.ts +0 -0
- package/lib/src/plugins/position/position.d.ts +11 -0
- package/lib/src/plugins/position/sensor.d.ts +59 -0
- package/lib/src/plugins/select/box-selection.d.ts +39 -0
- package/lib/src/plugins/select/index.d.ts +1 -0
- package/lib/src/plugins/select/select.d.ts +47 -0
- package/lib/src/utils/create.d.ts +2 -1
- package/lib/src/utils/index.d.ts +1 -0
- package/lib/src/utils/os.d.ts +3 -0
- package/lib/src/utils/path.d.ts +2 -0
- package/lib/src/utils/tween.d.ts +16 -0
- package/package.json +1 -1
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
5258
|
+
this.mesh = new Mesh9(this.geometry, this.material);
|
|
5174
5259
|
this.add(this.mesh);
|
|
5175
5260
|
}
|
|
5176
5261
|
getBorderPoints() {
|
|
@@ -5276,10 +5361,7 @@ var Poi2 = class extends Object3D14 {
|
|
|
5276
5361
|
return this.options.text ? this.options.text_font_size : 0;
|
|
5277
5362
|
}
|
|
5278
5363
|
get deltaZ() {
|
|
5279
|
-
|
|
5280
|
-
let dz = offset * (iconHeight + durIconAndText + textHeight) / this.context.camera.zoom;
|
|
5281
|
-
dz += 0.1;
|
|
5282
|
-
return dz;
|
|
5364
|
+
return 0.1;
|
|
5283
5365
|
}
|
|
5284
5366
|
get canSelect() {
|
|
5285
5367
|
return this.visible && (this.spriteIcon ? this.spriteIcon.visible : true) && (this.spriteText ? this.spriteText.visible : true);
|
|
@@ -5423,9 +5505,9 @@ var Poi2 = class extends Object3D14 {
|
|
|
5423
5505
|
if (!this.boxHelper) {
|
|
5424
5506
|
const div = document.createElement("div");
|
|
5425
5507
|
div.style.position = "fixed";
|
|
5426
|
-
this.boxHelper = div;
|
|
5427
5508
|
div.style.border = "1px solid red";
|
|
5428
5509
|
div.style.pointerEvents = "none";
|
|
5510
|
+
this.boxHelper = div;
|
|
5429
5511
|
this.context.container.appendChild(div);
|
|
5430
5512
|
}
|
|
5431
5513
|
this.boxHelper.style.left = this.box.min.x + "px";
|
|
@@ -5455,7 +5537,7 @@ var Poi2 = class extends Object3D14 {
|
|
|
5455
5537
|
import {
|
|
5456
5538
|
DoubleSide as DoubleSide5,
|
|
5457
5539
|
Matrix4 as Matrix42,
|
|
5458
|
-
Mesh as
|
|
5540
|
+
Mesh as Mesh10,
|
|
5459
5541
|
MeshBasicMaterial as MeshBasicMaterial6,
|
|
5460
5542
|
Object3D as Object3D15,
|
|
5461
5543
|
PlaneGeometry as PlaneGeometry3
|
|
@@ -5521,7 +5603,7 @@ var TextTexture = class extends Object3D15 {
|
|
|
5521
5603
|
texture.needsUpdate = true;
|
|
5522
5604
|
return material;
|
|
5523
5605
|
});
|
|
5524
|
-
const mesh = new
|
|
5606
|
+
const mesh = new Mesh10(geometry, materials);
|
|
5525
5607
|
this.mesh = mesh;
|
|
5526
5608
|
this.position.z += 4e-3;
|
|
5527
5609
|
this.add(mesh);
|
|
@@ -5998,7 +6080,7 @@ var CameraBound = class {
|
|
|
5998
6080
|
// src/context/control.ts
|
|
5999
6081
|
import { Vector3 as Vector320 } from "three";
|
|
6000
6082
|
import { MapControls } from "three/examples/jsm/controls/MapControls";
|
|
6001
|
-
import { Tween, Group as TweenGroup } from "@tweenjs/tween.js";
|
|
6083
|
+
import { Tween as Tween2, Group as TweenGroup } from "@tweenjs/tween.js";
|
|
6002
6084
|
var Control = class extends MapControls {
|
|
6003
6085
|
constructor(context, camera, domElement) {
|
|
6004
6086
|
super(camera, domElement);
|
|
@@ -6051,7 +6133,7 @@ var Control = class extends MapControls {
|
|
|
6051
6133
|
new Promise((resolve) => {
|
|
6052
6134
|
const start = { polar: this.getPolarAngle() };
|
|
6053
6135
|
const end = { polar };
|
|
6054
|
-
const tween = new
|
|
6136
|
+
const tween = new Tween2(start, this.tweenGroup).to(end, duration).onUpdate(() => {
|
|
6055
6137
|
this.setPolarAngle(start.polar, force);
|
|
6056
6138
|
}).onComplete(() => {
|
|
6057
6139
|
this.enabled = true;
|
|
@@ -6090,7 +6172,7 @@ var Control = class extends MapControls {
|
|
|
6090
6172
|
new Promise((resolve) => {
|
|
6091
6173
|
const start = { azimuthal: this.getAzimuthalAngle() };
|
|
6092
6174
|
const end = { azimuthal };
|
|
6093
|
-
const tween = new
|
|
6175
|
+
const tween = new Tween2(start, this.tweenGroup).to(end, duration).onUpdate(() => {
|
|
6094
6176
|
this.setAzimuthalAngle(start.azimuthal, force);
|
|
6095
6177
|
}).onComplete(() => {
|
|
6096
6178
|
this.enabled = true;
|
|
@@ -6122,7 +6204,7 @@ var Control = class extends MapControls {
|
|
|
6122
6204
|
}
|
|
6123
6205
|
return timeoutPromise(
|
|
6124
6206
|
new Promise((resolve) => {
|
|
6125
|
-
const tween = new
|
|
6207
|
+
const tween = new Tween2(start, this.tweenGroup).to(newTarget, duration).onUpdate(() => {
|
|
6126
6208
|
this.camera.position.copy(start.clone().sub(lookAtVector));
|
|
6127
6209
|
this.target.copy(start.clone());
|
|
6128
6210
|
this.update();
|
|
@@ -6166,7 +6248,7 @@ var Control = class extends MapControls {
|
|
|
6166
6248
|
}
|
|
6167
6249
|
return timeoutPromise(
|
|
6168
6250
|
new Promise((resolve) => {
|
|
6169
|
-
const tween = new
|
|
6251
|
+
const tween = new Tween2(start, this.tweenGroup).to(
|
|
6170
6252
|
{
|
|
6171
6253
|
zoom,
|
|
6172
6254
|
target: center2
|
|
@@ -7174,7 +7256,7 @@ var Equipment = class extends Plugin {
|
|
|
7174
7256
|
|
|
7175
7257
|
// src/plugins/navigation/path.ts
|
|
7176
7258
|
import {
|
|
7177
|
-
Mesh as
|
|
7259
|
+
Mesh as Mesh11,
|
|
7178
7260
|
Object3D as Object3D18,
|
|
7179
7261
|
TextureLoader as TextureLoader2,
|
|
7180
7262
|
Color as Color8,
|
|
@@ -7853,7 +7935,6 @@ var Path2 = class extends Object3D18 {
|
|
|
7853
7935
|
texture = null;
|
|
7854
7936
|
config = defaultConfig2;
|
|
7855
7937
|
points = [];
|
|
7856
|
-
pathDistance = 0;
|
|
7857
7938
|
basicRepeat = 1;
|
|
7858
7939
|
prevCameraZoom = 0;
|
|
7859
7940
|
registryEvent() {
|
|
@@ -7921,18 +8002,16 @@ var Path2 = class extends Object3D18 {
|
|
|
7921
8002
|
}
|
|
7922
8003
|
updatePoints(points) {
|
|
7923
8004
|
this.points = points;
|
|
7924
|
-
this.pathDistance = getPathLength(points);
|
|
7925
8005
|
this.changeRepeat();
|
|
7926
8006
|
const _points = this.transformPoints(points);
|
|
7927
8007
|
if (this.geometry) {
|
|
7928
8008
|
this.geometry.setPoints(_points);
|
|
7929
8009
|
}
|
|
7930
8010
|
}
|
|
7931
|
-
movePath(
|
|
7932
|
-
if (!this.material
|
|
8011
|
+
movePath(ratio) {
|
|
8012
|
+
if (!this.material) {
|
|
7933
8013
|
return;
|
|
7934
8014
|
}
|
|
7935
|
-
const ratio = distance / this.pathDistance;
|
|
7936
8015
|
this.material.thresholdRatio = ratio;
|
|
7937
8016
|
}
|
|
7938
8017
|
async create(points) {
|
|
@@ -7959,7 +8038,7 @@ var Path2 = class extends Object3D18 {
|
|
|
7959
8038
|
blending: NormalBlending,
|
|
7960
8039
|
repeat: new Vector213(this.getRepeat(), 1)
|
|
7961
8040
|
});
|
|
7962
|
-
const mesh = this.mesh = new
|
|
8041
|
+
const mesh = this.mesh = new Mesh11(lineGeometry, material);
|
|
7963
8042
|
mesh.renderOrder = 9;
|
|
7964
8043
|
this.add(mesh);
|
|
7965
8044
|
return mesh;
|
|
@@ -7974,25 +8053,36 @@ var Path2 = class extends Object3D18 {
|
|
|
7974
8053
|
};
|
|
7975
8054
|
|
|
7976
8055
|
// src/plugins/navigation/navigation.ts
|
|
7977
|
-
import {
|
|
8056
|
+
import { Tween as Tween3, Easing } from "@tweenjs/tween.js";
|
|
7978
8057
|
import { Vector3 as Vector325 } from "three";
|
|
7979
8058
|
var defaultConfig3 = {
|
|
7980
8059
|
path: {},
|
|
7981
|
-
speed: 10,
|
|
7982
8060
|
cheapMaximumDistance: 20,
|
|
7983
8061
|
needStartPoi: false,
|
|
7984
8062
|
startPoi: {},
|
|
7985
|
-
offsetY: 150
|
|
8063
|
+
offsetY: 150,
|
|
8064
|
+
directionEmitThreshold: 5,
|
|
8065
|
+
disablePathAnimation: false
|
|
7986
8066
|
};
|
|
7987
8067
|
var Navigation = class extends Plugin {
|
|
7988
8068
|
path = null;
|
|
7989
8069
|
fetchRoadStatus = false;
|
|
7990
8070
|
paths = [];
|
|
8071
|
+
// 原始坐标路线
|
|
8072
|
+
curPathIndex = 0;
|
|
8073
|
+
// 当前展示的路线所在的下标
|
|
8074
|
+
curFloorPath = null;
|
|
8075
|
+
// 当前楼层原始坐标路线
|
|
8076
|
+
translatePath = null;
|
|
8077
|
+
// 对原始坐标做完平移路线,只有当前楼层
|
|
8078
|
+
currentPathPosition = null;
|
|
8079
|
+
// 起点所在的当前位置,平移前坐标
|
|
7991
8080
|
options;
|
|
7992
|
-
pathTween =
|
|
8081
|
+
pathTween = null;
|
|
7993
8082
|
startPoi = null;
|
|
7994
8083
|
movedDistance = 0;
|
|
7995
8084
|
pathStart = [0, 0];
|
|
8085
|
+
tweenUtil = new TweenUtil();
|
|
7996
8086
|
// 处理路线动画
|
|
7997
8087
|
animationPathOptions = {
|
|
7998
8088
|
cPathIndex: 0
|
|
@@ -8000,8 +8090,11 @@ var Navigation = class extends Plugin {
|
|
|
8000
8090
|
};
|
|
8001
8091
|
cPath = [];
|
|
8002
8092
|
// 当前楼层的平滑后的路线
|
|
8003
|
-
constructor(bmap, project
|
|
8093
|
+
constructor(bmap, project = {}, options) {
|
|
8004
8094
|
super(bmap);
|
|
8095
|
+
if (!options && typeof project === "object") {
|
|
8096
|
+
options = project;
|
|
8097
|
+
}
|
|
8005
8098
|
this.options = Object.assign({}, defaultConfig3, options);
|
|
8006
8099
|
const {
|
|
8007
8100
|
apiDomain,
|
|
@@ -8010,6 +8103,12 @@ var Navigation = class extends Plugin {
|
|
|
8010
8103
|
} = this.bmap.config;
|
|
8011
8104
|
this.registryEvent();
|
|
8012
8105
|
}
|
|
8106
|
+
get curFloorPathLength() {
|
|
8107
|
+
return this.curFloorPath?.distance ?? 0;
|
|
8108
|
+
}
|
|
8109
|
+
get curFloorPathPoints() {
|
|
8110
|
+
return this.curFloorPath?.points ?? [];
|
|
8111
|
+
}
|
|
8013
8112
|
registryEvent() {
|
|
8014
8113
|
this.bmap.context.addEventListener("update", this.onUpdate);
|
|
8015
8114
|
this.bmap.addEventListener(
|
|
@@ -8017,6 +8116,12 @@ var Navigation = class extends Plugin {
|
|
|
8017
8116
|
this.onSwitchFloor
|
|
8018
8117
|
);
|
|
8019
8118
|
}
|
|
8119
|
+
pauseAnimation() {
|
|
8120
|
+
this.tweenUtil.pause();
|
|
8121
|
+
}
|
|
8122
|
+
continueAnimation() {
|
|
8123
|
+
this.tweenUtil.continue();
|
|
8124
|
+
}
|
|
8020
8125
|
unRegistryEvent() {
|
|
8021
8126
|
this.bmap.context.removeEventListener("update", this.onUpdate);
|
|
8022
8127
|
this.bmap.removeEventListener(
|
|
@@ -8025,26 +8130,44 @@ var Navigation = class extends Plugin {
|
|
|
8025
8130
|
);
|
|
8026
8131
|
}
|
|
8027
8132
|
onUpdate = () => {
|
|
8028
|
-
this.
|
|
8133
|
+
this.tweenUtil.update();
|
|
8029
8134
|
};
|
|
8030
8135
|
clearPath() {
|
|
8031
8136
|
if (this.path) {
|
|
8032
8137
|
this.bmap.context.scene.remove(this.path);
|
|
8033
8138
|
this.path.dispose();
|
|
8034
8139
|
this.path = null;
|
|
8035
|
-
this.
|
|
8036
|
-
this.pathTween.removeAll();
|
|
8140
|
+
this.tweenUtil.clear();
|
|
8037
8141
|
}
|
|
8038
8142
|
if (this.startPoi) {
|
|
8039
8143
|
this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
|
|
8040
8144
|
this.startPoi = null;
|
|
8041
8145
|
}
|
|
8146
|
+
this.translatePath = null;
|
|
8147
|
+
}
|
|
8148
|
+
setCurFloorPath(path) {
|
|
8149
|
+
if (path === null) {
|
|
8150
|
+
this.curFloorPath = null;
|
|
8151
|
+
this.currentPathPosition = null;
|
|
8152
|
+
} else {
|
|
8153
|
+
this.curFloorPath = path;
|
|
8154
|
+
this.currentPathPosition = path.points[0];
|
|
8155
|
+
}
|
|
8156
|
+
this.movedDistance = 0;
|
|
8157
|
+
}
|
|
8158
|
+
setCurPathIndex(index) {
|
|
8159
|
+
this.curPathIndex = index;
|
|
8160
|
+
if (this.paths[index]?.floor === this.bmap.context.currentFloor?.name) {
|
|
8161
|
+
this.setCurFloorPath(this.paths[index]);
|
|
8162
|
+
this.renderPath(this.translatePoints(this.curFloorPathPoints));
|
|
8163
|
+
} else {
|
|
8164
|
+
this.clearPath();
|
|
8165
|
+
}
|
|
8042
8166
|
}
|
|
8043
8167
|
onSwitchFloor = ({ data: { curFloor } }) => {
|
|
8044
|
-
if (this.paths.
|
|
8045
|
-
const curFloorPathData = this.paths.
|
|
8046
|
-
|
|
8047
|
-
);
|
|
8168
|
+
if (this.paths[this.curPathIndex]) {
|
|
8169
|
+
const curFloorPathData = this.paths[this.curPathIndex];
|
|
8170
|
+
this.setCurFloorPath(curFloorPathData ?? null);
|
|
8048
8171
|
if (curFloorPathData) {
|
|
8049
8172
|
this.renderPath(this.translatePoints(curFloorPathData.points));
|
|
8050
8173
|
} else {
|
|
@@ -8054,11 +8177,13 @@ var Navigation = class extends Plugin {
|
|
|
8054
8177
|
this.clearPath();
|
|
8055
8178
|
}
|
|
8056
8179
|
};
|
|
8057
|
-
addPath(paths) {
|
|
8180
|
+
addPath(paths, routeIndex = 0) {
|
|
8058
8181
|
this.paths = paths;
|
|
8182
|
+
this.curPathIndex = routeIndex;
|
|
8059
8183
|
const floorName = this.bmap.context.currentFloor?.name;
|
|
8060
|
-
const curFloorPath = paths
|
|
8061
|
-
if (curFloorPath) {
|
|
8184
|
+
const curFloorPath = paths[routeIndex];
|
|
8185
|
+
if (floorName && curFloorPath?.floor === floorName) {
|
|
8186
|
+
this.setCurFloorPath(curFloorPath);
|
|
8062
8187
|
if (this.bmap.currentBuildGround) {
|
|
8063
8188
|
this.renderPath(this.translatePoints(curFloorPath.points));
|
|
8064
8189
|
} else {
|
|
@@ -8079,12 +8204,12 @@ var Navigation = class extends Plugin {
|
|
|
8079
8204
|
});
|
|
8080
8205
|
}
|
|
8081
8206
|
renderPath(points) {
|
|
8207
|
+
this.translatePath = points;
|
|
8082
8208
|
const cPath = this.catmullRomCurve3(points);
|
|
8083
8209
|
this.cPath = cPath;
|
|
8084
8210
|
this.animationPathOptions = {
|
|
8085
8211
|
cPathIndex: 0
|
|
8086
8212
|
};
|
|
8087
|
-
this.movedDistance = 0;
|
|
8088
8213
|
this.pathStart = cPath[0];
|
|
8089
8214
|
if (this.path) {
|
|
8090
8215
|
this.path.updatePoints(cPath);
|
|
@@ -8094,6 +8219,10 @@ var Navigation = class extends Plugin {
|
|
|
8094
8219
|
this.path.position.z = this.bmap.context.currentFloor.groundMaxHeight + 0.5;
|
|
8095
8220
|
this.bmap.context.scene.add(this.path);
|
|
8096
8221
|
}
|
|
8222
|
+
this.dispatchEvent({
|
|
8223
|
+
type: "render-path",
|
|
8224
|
+
path: this.path
|
|
8225
|
+
});
|
|
8097
8226
|
if (this.startPoi) {
|
|
8098
8227
|
this.bmap.context.currentFloor?.poiLayer2.removePoi(this.startPoi);
|
|
8099
8228
|
this.startPoi = null;
|
|
@@ -8102,21 +8231,21 @@ var Navigation = class extends Plugin {
|
|
|
8102
8231
|
this.startPoi = new Poi2(this.bmap.context, {
|
|
8103
8232
|
...this.options.startPoi,
|
|
8104
8233
|
id: "navigation_start_poi",
|
|
8105
|
-
position: { x: cPath[0][0], y: cPath[0][1], z:
|
|
8234
|
+
position: { x: cPath[0][0], y: cPath[0][1], z: 0.51 },
|
|
8106
8235
|
collision_enable: false
|
|
8107
8236
|
}) || null;
|
|
8108
8237
|
this.bmap.context.currentFloor?.poiLayer2.pushPoi(this.startPoi);
|
|
8109
8238
|
}
|
|
8110
8239
|
}
|
|
8111
8240
|
catmullRomCurve3(points) {
|
|
8112
|
-
return simplifyPath(points, false, true, 0.1,
|
|
8241
|
+
return simplifyPath(points, false, true, 0.1, 170, 2.5);
|
|
8113
8242
|
}
|
|
8114
8243
|
/**
|
|
8115
8244
|
* 按照指定速度移动到目标位置
|
|
8116
8245
|
* @param point 目标位置
|
|
8117
8246
|
* @param speed 移动速度 / 米/s
|
|
8118
8247
|
*/
|
|
8119
|
-
async animationTo(point3, speed
|
|
8248
|
+
async animationTo(point3, speed) {
|
|
8120
8249
|
if (point3.floor !== this.bmap.context.currentFloor?.name || !this.path) {
|
|
8121
8250
|
return;
|
|
8122
8251
|
}
|
|
@@ -8171,14 +8300,13 @@ var Navigation = class extends Plugin {
|
|
|
8171
8300
|
moveDistance = moveDistanceArray.reduce((sum, cur) => sum + cur, 0);
|
|
8172
8301
|
}
|
|
8173
8302
|
const timeSecond = moveDistance / speed;
|
|
8174
|
-
this.
|
|
8175
|
-
this.pathTween.removeAll();
|
|
8303
|
+
this.tweenUtil.clear();
|
|
8176
8304
|
const start = { distance: 0 };
|
|
8177
8305
|
const prevCPathIndex = this.animationPathOptions.cPathIndex;
|
|
8178
8306
|
let pastRouteLength = 0;
|
|
8179
8307
|
let pastRouteIndex = 0;
|
|
8180
8308
|
return new Promise((resolve) => {
|
|
8181
|
-
const tween = new
|
|
8309
|
+
const tween = new Tween3(start, this.tweenUtil.group).to({ distance: moveDistance }, timeSecond * 1e3).onUpdate(async () => {
|
|
8182
8310
|
let dis = start.distance - pastRouteLength;
|
|
8183
8311
|
while (moveDistanceArray.length && dis > moveDistanceArray[0]) {
|
|
8184
8312
|
pastRouteLength += moveDistanceArray.shift();
|
|
@@ -8203,7 +8331,7 @@ var Navigation = class extends Plugin {
|
|
|
8203
8331
|
tween.resume();
|
|
8204
8332
|
this.dispatchEvent({ type: "path-animation", pathIndex: this.animationPathOptions.cPathIndex });
|
|
8205
8333
|
}).onComplete(() => {
|
|
8206
|
-
this.
|
|
8334
|
+
this.tweenUtil.remove(tween);
|
|
8207
8335
|
this.dispatchEvent({ type: "path-animation-end" });
|
|
8208
8336
|
this.movedDistance += moveDistance;
|
|
8209
8337
|
resolve(true);
|
|
@@ -8212,25 +8340,22 @@ var Navigation = class extends Plugin {
|
|
|
8212
8340
|
}
|
|
8213
8341
|
// 计算路线的方向
|
|
8214
8342
|
getPathDirection() {
|
|
8215
|
-
|
|
8216
|
-
if (path.length < 3) {
|
|
8343
|
+
if (!this.curFloorPath || !this.currentPathPosition) {
|
|
8217
8344
|
return null;
|
|
8218
8345
|
}
|
|
8219
|
-
|
|
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 {
|
|
8346
|
+
if (this.curFloorPathPoints.length < 2) {
|
|
8232
8347
|
return null;
|
|
8233
8348
|
}
|
|
8349
|
+
const index = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
|
|
8350
|
+
const l1 = this.curFloorPathPoints[index];
|
|
8351
|
+
const l2 = this.curFloorPathPoints[index + 1];
|
|
8352
|
+
const v1 = new Vector325(l2[0] - l1[0], l2[1] - l1[1], 0).normalize();
|
|
8353
|
+
const v2 = new Vector325(0, 1, 0).normalize();
|
|
8354
|
+
const angle = v1.angleTo(v2);
|
|
8355
|
+
const cross = new Vector325().crossVectors(v2, v1);
|
|
8356
|
+
const sign = Object.is(cross.y, 0) ? -1 : 1;
|
|
8357
|
+
const finalAngle = sign * angle;
|
|
8358
|
+
return finalAngle;
|
|
8234
8359
|
}
|
|
8235
8360
|
// 把相机旋转到路线的上方向
|
|
8236
8361
|
async changeCameraToPathUp(duration = 100) {
|
|
@@ -8255,13 +8380,13 @@ var Navigation = class extends Plugin {
|
|
|
8255
8380
|
return new Promise((resolve) => {
|
|
8256
8381
|
const start = { azimuthal: control.getAzimuthalAngle() };
|
|
8257
8382
|
const end = { azimuthal: angle };
|
|
8258
|
-
const tween = new
|
|
8383
|
+
const tween = new Tween3(start, this.tweenUtil.group).to(end, time).easing(Easing.Quadratic.InOut).onUpdate(async () => {
|
|
8259
8384
|
control.target.copy(this.startPoi.position);
|
|
8260
8385
|
control.setAzimuthalAngle(start.azimuthal, true);
|
|
8261
8386
|
control.setTargetByOffset(this.options.offsetY);
|
|
8262
8387
|
}).onComplete(() => {
|
|
8263
8388
|
control.enabled = true;
|
|
8264
|
-
this.
|
|
8389
|
+
this.tweenUtil.remove(tween);
|
|
8265
8390
|
resolve(true);
|
|
8266
8391
|
}).onStart(() => {
|
|
8267
8392
|
control.enabled = false;
|
|
@@ -8320,7 +8445,134 @@ var Navigation = class extends Plugin {
|
|
|
8320
8445
|
duration
|
|
8321
8446
|
);
|
|
8322
8447
|
}
|
|
8448
|
+
async toPositionBySpeed(position, speed) {
|
|
8449
|
+
if (this.pathTween) {
|
|
8450
|
+
this.tweenUtil.clear();
|
|
8451
|
+
}
|
|
8452
|
+
const { currentPathPosition, curFloorPath, curFloorPathPoints } = this;
|
|
8453
|
+
if (!curFloorPath || !currentPathPosition) {
|
|
8454
|
+
return null;
|
|
8455
|
+
}
|
|
8456
|
+
const curDistance = this.movedDistance;
|
|
8457
|
+
const positionDistance = getDistanceByPathPos(curFloorPathPoints, position);
|
|
8458
|
+
console.log(curDistance, positionDistance);
|
|
8459
|
+
if (curDistance === -1 || positionDistance === -1) {
|
|
8460
|
+
return null;
|
|
8461
|
+
}
|
|
8462
|
+
if (positionDistance <= curDistance) {
|
|
8463
|
+
return null;
|
|
8464
|
+
}
|
|
8465
|
+
const distance = positionDistance - curDistance;
|
|
8466
|
+
if (!distance) {
|
|
8467
|
+
return;
|
|
8468
|
+
}
|
|
8469
|
+
const time = distance / speed;
|
|
8470
|
+
return new Promise((resolve) => {
|
|
8471
|
+
const tween = this.pathTween = new Tween3({ distance: 0 }, this.tweenUtil.group).to({ distance }, time * 1e3).onUpdate(async (v) => {
|
|
8472
|
+
this.movedDistance = v.distance + curDistance;
|
|
8473
|
+
this.path?.movePath(this.movedDistance / this.curFloorPathLength);
|
|
8474
|
+
const pos = getPosByPathDistance(curFloorPathPoints, this.movedDistance);
|
|
8475
|
+
if (pos === null) {
|
|
8476
|
+
this.tweenUtil.remove(tween);
|
|
8477
|
+
return;
|
|
8478
|
+
}
|
|
8479
|
+
this.currentPathPosition = pos;
|
|
8480
|
+
const translatePos = this.translatePoints([pos])[0];
|
|
8481
|
+
if (this.startPoi) {
|
|
8482
|
+
this.startPoi.position.setX(translatePos[0]).setY(translatePos[1]);
|
|
8483
|
+
if (!this.options.disablePathAnimation) {
|
|
8484
|
+
this.bmap.context.control.setTargetByOffset(this.options.offsetY, this.startPoi.position.clone());
|
|
8485
|
+
}
|
|
8486
|
+
}
|
|
8487
|
+
if (!this.options.disablePathAnimation) {
|
|
8488
|
+
tween.pause();
|
|
8489
|
+
await this.changeCameraToPathUp(500 / speed);
|
|
8490
|
+
tween.resume();
|
|
8491
|
+
}
|
|
8492
|
+
this.emitNavigationInfo();
|
|
8493
|
+
}).onComplete(() => {
|
|
8494
|
+
this.tweenUtil.remove(tween);
|
|
8495
|
+
resolve(true);
|
|
8496
|
+
}).start();
|
|
8497
|
+
});
|
|
8498
|
+
}
|
|
8499
|
+
// 吸附路线
|
|
8500
|
+
adsorb(position) {
|
|
8501
|
+
if (!this.curFloorPathPoints.length) {
|
|
8502
|
+
return null;
|
|
8503
|
+
}
|
|
8504
|
+
let path = this.curFloorPathPoints;
|
|
8505
|
+
if (this.currentPathPosition) {
|
|
8506
|
+
const index = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
|
|
8507
|
+
path = path.slice(index + 1);
|
|
8508
|
+
path.unshift(this.currentPathPosition);
|
|
8509
|
+
}
|
|
8510
|
+
const { distance, closestPoint } = path.reduce((obj, cur, index, arr) => {
|
|
8511
|
+
if (!arr[index + 1]) {
|
|
8512
|
+
return obj;
|
|
8513
|
+
}
|
|
8514
|
+
const { distance: distance2, closestPoint: closestPoint2 } = distancePointToSegment(position, cur, arr[index + 1]);
|
|
8515
|
+
if (distance2 < obj.distance) {
|
|
8516
|
+
return { distance: distance2, closestPoint: closestPoint2 };
|
|
8517
|
+
}
|
|
8518
|
+
return obj;
|
|
8519
|
+
}, { distance: Infinity, closestPoint: path[0] });
|
|
8520
|
+
return { distance, closestPoint };
|
|
8521
|
+
}
|
|
8522
|
+
// 计算剩余距离
|
|
8523
|
+
getRemainDistance() {
|
|
8524
|
+
const curPathRemainDistance = this.curFloorPathLength - this.movedDistance;
|
|
8525
|
+
const remainFloor = this.paths.slice(this.curPathIndex + 1);
|
|
8526
|
+
const remainFloorDistance = remainFloor.reduce((total, item) => total + item.distance, 0);
|
|
8527
|
+
return remainFloorDistance + curPathRemainDistance;
|
|
8528
|
+
}
|
|
8529
|
+
// 计算下一个拐弯点的方向和距离
|
|
8530
|
+
getNextDirDistance() {
|
|
8531
|
+
if (!this.currentPathPosition) {
|
|
8532
|
+
return null;
|
|
8533
|
+
}
|
|
8534
|
+
const index = getPointEdgeIndex(this.curFloorPathPoints, this.currentPathPosition);
|
|
8535
|
+
const p1 = this.curFloorPathPoints[index];
|
|
8536
|
+
const p2 = this.curFloorPathPoints[index + 1];
|
|
8537
|
+
const p3 = this.curFloorPathPoints[index + 2];
|
|
8538
|
+
if (!p1 || !p2) {
|
|
8539
|
+
return null;
|
|
8540
|
+
}
|
|
8541
|
+
const distance = getLength(this.currentPathPosition, p2);
|
|
8542
|
+
if (index === 0) {
|
|
8543
|
+
const l = getLength(p1, this.currentPathPosition);
|
|
8544
|
+
if (l < 5) {
|
|
8545
|
+
return { dir: "start" /* START */, distance };
|
|
8546
|
+
}
|
|
8547
|
+
}
|
|
8548
|
+
if (!p3) {
|
|
8549
|
+
return { dir: "end" /* END */, distance };
|
|
8550
|
+
}
|
|
8551
|
+
const dir = calc_direction(p1, p2, p3);
|
|
8552
|
+
return { dir, distance };
|
|
8553
|
+
}
|
|
8554
|
+
emitNavigationInfo() {
|
|
8555
|
+
const remainDistance = this.getRemainDistance();
|
|
8556
|
+
const nextDirInfo = this.getNextDirDistance();
|
|
8557
|
+
if (!nextDirInfo) {
|
|
8558
|
+
return null;
|
|
8559
|
+
}
|
|
8560
|
+
let { dir, distance } = nextDirInfo;
|
|
8561
|
+
if (dir === "end" /* END */ && distance > 15) {
|
|
8562
|
+
dir = "front" /* FRONT */;
|
|
8563
|
+
}
|
|
8564
|
+
if (dir !== "start" /* START */ && distance >= this.options.directionEmitThreshold) {
|
|
8565
|
+
dir = "front" /* FRONT */;
|
|
8566
|
+
}
|
|
8567
|
+
this.dispatchEvent({
|
|
8568
|
+
type: "navigation-info",
|
|
8569
|
+
dir,
|
|
8570
|
+
distance: remainDistance,
|
|
8571
|
+
nextDirDistance: distance
|
|
8572
|
+
});
|
|
8573
|
+
}
|
|
8323
8574
|
dispose() {
|
|
8575
|
+
this.tweenUtil.dispose();
|
|
8324
8576
|
this.unRegistryEvent();
|
|
8325
8577
|
this.path?.dispose();
|
|
8326
8578
|
this.startPoi?.dispose();
|
|
@@ -8328,11 +8580,11 @@ var Navigation = class extends Plugin {
|
|
|
8328
8580
|
};
|
|
8329
8581
|
|
|
8330
8582
|
// src/plugins/mul-floors/mul-floors.ts
|
|
8331
|
-
import { Group as
|
|
8583
|
+
import { Group as Group4 } from "three";
|
|
8332
8584
|
var MulFloors = class extends Plugin {
|
|
8333
8585
|
poiLayer;
|
|
8334
8586
|
floors = [];
|
|
8335
|
-
group = new
|
|
8587
|
+
group = new Group4();
|
|
8336
8588
|
constructor(bmap) {
|
|
8337
8589
|
super(bmap);
|
|
8338
8590
|
this.poiLayer = new PoiLayer(bmap.context);
|
|
@@ -8442,7 +8694,6 @@ var NavPath = class extends EventDispatcher10 {
|
|
|
8442
8694
|
}
|
|
8443
8695
|
});
|
|
8444
8696
|
};
|
|
8445
|
-
console.log(this.initRoadStatus);
|
|
8446
8697
|
if (this.initRoadStatus) {
|
|
8447
8698
|
_getPath();
|
|
8448
8699
|
} else {
|
|
@@ -8465,6 +8716,284 @@ var NavPath = class extends EventDispatcher10 {
|
|
|
8465
8716
|
}
|
|
8466
8717
|
};
|
|
8467
8718
|
|
|
8719
|
+
// src/plugins/select/box-selection.ts
|
|
8720
|
+
import { Frustum as Frustum3 } from "three";
|
|
8721
|
+
var BoxSelection2 = class extends BaseSvg {
|
|
8722
|
+
startPoint;
|
|
8723
|
+
endPoint;
|
|
8724
|
+
rect;
|
|
8725
|
+
frustum = new Frustum3();
|
|
8726
|
+
constructor(context) {
|
|
8727
|
+
super(context);
|
|
8728
|
+
const { config: { selectBox: { fill, stroke } } } = context;
|
|
8729
|
+
this.rect = createRect(stroke, fill);
|
|
8730
|
+
this.svg.appendChild(this.rect);
|
|
8731
|
+
this.registryEvent();
|
|
8732
|
+
}
|
|
8733
|
+
setEnable(enable) {
|
|
8734
|
+
super.setEnable(enable);
|
|
8735
|
+
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
8736
|
+
if (enable) {
|
|
8737
|
+
this.registryEvent();
|
|
8738
|
+
} else {
|
|
8739
|
+
this.startPoint = void 0;
|
|
8740
|
+
this.unRegistryEvent();
|
|
8741
|
+
}
|
|
8742
|
+
}
|
|
8743
|
+
onPointerDown = (e) => {
|
|
8744
|
+
if (!this.enable) {
|
|
8745
|
+
return;
|
|
8746
|
+
}
|
|
8747
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
8748
|
+
if (point3) {
|
|
8749
|
+
this.startPoint = point3;
|
|
8750
|
+
}
|
|
8751
|
+
this.endPoint = void 0;
|
|
8752
|
+
};
|
|
8753
|
+
onPointerMove = (e) => {
|
|
8754
|
+
if (!this.enable || !this.startPoint) {
|
|
8755
|
+
return;
|
|
8756
|
+
}
|
|
8757
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
8758
|
+
if (point3) {
|
|
8759
|
+
this.endPoint = point3;
|
|
8760
|
+
}
|
|
8761
|
+
};
|
|
8762
|
+
onPointerUp = (e) => {
|
|
8763
|
+
if (!this.enable) {
|
|
8764
|
+
return;
|
|
8765
|
+
}
|
|
8766
|
+
const point3 = this.getIntersectByPointerEvent(e);
|
|
8767
|
+
if (point3) {
|
|
8768
|
+
this.endPoint = point3;
|
|
8769
|
+
}
|
|
8770
|
+
this.doSelect();
|
|
8771
|
+
this.startPoint = void 0;
|
|
8772
|
+
};
|
|
8773
|
+
onUpdate = () => {
|
|
8774
|
+
if (this.startPoint) {
|
|
8775
|
+
const startPoint = this.getSvgCoordinate(this.startPoint);
|
|
8776
|
+
let endPoint = { ...startPoint };
|
|
8777
|
+
if (this.endPoint) {
|
|
8778
|
+
endPoint = this.getSvgCoordinate(this.endPoint);
|
|
8779
|
+
}
|
|
8780
|
+
const leftTop = { x: Math.min(startPoint.x, endPoint.x), y: Math.min(startPoint.y, endPoint.y) };
|
|
8781
|
+
const width = Math.abs(endPoint.x - startPoint.x);
|
|
8782
|
+
const height = Math.abs(endPoint.y - startPoint.y);
|
|
8783
|
+
setRectPosition(this.rect, leftTop.x, leftTop.y, width, height);
|
|
8784
|
+
} else {
|
|
8785
|
+
setRectPosition(this.rect, 0, 0, 0, 0);
|
|
8786
|
+
}
|
|
8787
|
+
};
|
|
8788
|
+
registryEvent() {
|
|
8789
|
+
this.context.container.addEventListener("pointerdown", this.onPointerDown);
|
|
8790
|
+
this.context.container.addEventListener("pointermove", this.onPointerMove);
|
|
8791
|
+
this.context.container.addEventListener("pointerup", this.onPointerUp);
|
|
8792
|
+
this.context.addEventListener("update", this.onUpdate);
|
|
8793
|
+
}
|
|
8794
|
+
unRegistryEvent() {
|
|
8795
|
+
this.context.container.removeEventListener("pointerdown", this.onPointerDown);
|
|
8796
|
+
this.context.container.removeEventListener("pointermove", this.onPointerMove);
|
|
8797
|
+
this.context.container.removeEventListener("pointerup", this.onPointerUp);
|
|
8798
|
+
this.context.removeEventListener("update", this.onUpdate);
|
|
8799
|
+
}
|
|
8800
|
+
doSelect() {
|
|
8801
|
+
if (this.startPoint && this.endPoint) {
|
|
8802
|
+
const dis = this.startPoint.distanceTo(this.endPoint);
|
|
8803
|
+
if (dis < 0.1) {
|
|
8804
|
+
return;
|
|
8805
|
+
}
|
|
8806
|
+
const { context: { camera, container: { clientWidth: w, clientHeight: h } } } = this;
|
|
8807
|
+
const startDevice = vector3ToDevice(this.startPoint, camera, w, h);
|
|
8808
|
+
const endDevice = vector3ToDevice(this.endPoint, camera, w, h);
|
|
8809
|
+
const leftTop = { x: Math.min(startDevice.x, endDevice.x), y: Math.min(startDevice.y, endDevice.y) };
|
|
8810
|
+
const rightBottom = { x: Math.max(startDevice.x, endDevice.x), y: Math.max(startDevice.y, endDevice.y) };
|
|
8811
|
+
const list = this.searchMapInFrustum(leftTop, rightBottom);
|
|
8812
|
+
this.dispatchEvent({ type: "selected", list });
|
|
8813
|
+
}
|
|
8814
|
+
}
|
|
8815
|
+
searchMapInFrustum(leftTop, rightBottom) {
|
|
8816
|
+
const { context } = this;
|
|
8817
|
+
return context.currentFloor?.graphicLayer.children.filter((item) => {
|
|
8818
|
+
return item instanceof Graphic && this.searchChildInFrustum(item, leftTop, rightBottom);
|
|
8819
|
+
}) || [];
|
|
8820
|
+
}
|
|
8821
|
+
searchChildInFrustum(object, leftTop, rightBottom) {
|
|
8822
|
+
const { context: { camera, container: { clientWidth: w, clientHeight: h } } } = this;
|
|
8823
|
+
if (!object) return false;
|
|
8824
|
+
if (!object.mesh) {
|
|
8825
|
+
const position = object.getPosition();
|
|
8826
|
+
if (position) {
|
|
8827
|
+
const position2d = vector3ToDevice(position, camera, w, h);
|
|
8828
|
+
return isContain(position2d, leftTop, rightBottom);
|
|
8829
|
+
}
|
|
8830
|
+
return false;
|
|
8831
|
+
}
|
|
8832
|
+
if (!object.mesh.geometry.boundingBox) {
|
|
8833
|
+
object.mesh.geometry.computeBoundingBox();
|
|
8834
|
+
}
|
|
8835
|
+
const box = object.mesh.geometry.boundingBox;
|
|
8836
|
+
if (!box) {
|
|
8837
|
+
return false;
|
|
8838
|
+
}
|
|
8839
|
+
const { min, max } = box;
|
|
8840
|
+
const minDevice = vector3ToDevice(min, camera, w, h);
|
|
8841
|
+
const maxDevice = vector3ToDevice(max, camera, w, h);
|
|
8842
|
+
if (!isContain(minDevice, leftTop, rightBottom)) {
|
|
8843
|
+
return false;
|
|
8844
|
+
}
|
|
8845
|
+
if (!isContain(maxDevice, leftTop, rightBottom)) {
|
|
8846
|
+
return false;
|
|
8847
|
+
}
|
|
8848
|
+
return true;
|
|
8849
|
+
}
|
|
8850
|
+
dispose() {
|
|
8851
|
+
this.unRegistryEvent();
|
|
8852
|
+
}
|
|
8853
|
+
};
|
|
8854
|
+
|
|
8855
|
+
// src/plugins/select/select.ts
|
|
8856
|
+
var bmapSelectDefaultOptions = {
|
|
8857
|
+
boxSelection: false,
|
|
8858
|
+
elements: ["graphic", "poi"]
|
|
8859
|
+
};
|
|
8860
|
+
var BMapSelect = class extends Plugin {
|
|
8861
|
+
options;
|
|
8862
|
+
_list = /* @__PURE__ */ new Set();
|
|
8863
|
+
_poiList = /* @__PURE__ */ new Set();
|
|
8864
|
+
boxSelection;
|
|
8865
|
+
prevPanStatus;
|
|
8866
|
+
prevRotateStatus;
|
|
8867
|
+
downPoint = null;
|
|
8868
|
+
isMultipleSelect = false;
|
|
8869
|
+
constructor(bmap, options = {}) {
|
|
8870
|
+
super(bmap);
|
|
8871
|
+
this.options = { ...bmapSelectDefaultOptions, ...options };
|
|
8872
|
+
this.boxSelection = new BoxSelection2(this.bmap.context);
|
|
8873
|
+
this.boxSelection.setEnable(false);
|
|
8874
|
+
this.registryEvent();
|
|
8875
|
+
}
|
|
8876
|
+
get list() {
|
|
8877
|
+
return this._list;
|
|
8878
|
+
}
|
|
8879
|
+
enableBoxSelection() {
|
|
8880
|
+
if (this.isMultipleSelect || !this.options.boxSelection) {
|
|
8881
|
+
return;
|
|
8882
|
+
}
|
|
8883
|
+
this.isMultipleSelect = true;
|
|
8884
|
+
this.boxSelection.setEnable(true);
|
|
8885
|
+
this.prevPanStatus = this.bmap.context.control.enablePan;
|
|
8886
|
+
this.prevRotateStatus = this.bmap.context.control.enableRotate;
|
|
8887
|
+
this.bmap.context.control.enablePan = false;
|
|
8888
|
+
this.bmap.context.control.enableRotate = false;
|
|
8889
|
+
}
|
|
8890
|
+
disableBoxSelection() {
|
|
8891
|
+
if (this.isMultipleSelect) {
|
|
8892
|
+
this.isMultipleSelect = false;
|
|
8893
|
+
this.boxSelection.setEnable(false);
|
|
8894
|
+
this.bmap.context.control.enablePan = !!this.prevPanStatus;
|
|
8895
|
+
this.bmap.context.control.enableRotate = !!this.prevRotateStatus;
|
|
8896
|
+
}
|
|
8897
|
+
}
|
|
8898
|
+
onPointerDown = (e) => {
|
|
8899
|
+
this.downPoint = { x: e.offsetX, y: e.offsetY };
|
|
8900
|
+
};
|
|
8901
|
+
onPointerUp = (e) => {
|
|
8902
|
+
if (!this.downPoint) {
|
|
8903
|
+
return;
|
|
8904
|
+
}
|
|
8905
|
+
const { offsetX, offsetY } = e;
|
|
8906
|
+
const { x, y } = this.downPoint;
|
|
8907
|
+
if (Math.sqrt((x - offsetX) ** 2 + (y - offsetY) ** 2) > 3) {
|
|
8908
|
+
return;
|
|
8909
|
+
}
|
|
8910
|
+
const set2 = /* @__PURE__ */ new Set();
|
|
8911
|
+
const selectGraphics = [];
|
|
8912
|
+
const selectPois = [];
|
|
8913
|
+
if (this.options.elements.includes("graphic")) {
|
|
8914
|
+
const { graphics } = this.bmap.context.getGraphicsByDeviceXy(offsetX, offsetY);
|
|
8915
|
+
graphics.map((item) => set2.add(item.options.id));
|
|
8916
|
+
selectGraphics.push(...graphics);
|
|
8917
|
+
}
|
|
8918
|
+
if (this.options.elements.includes("poi")) {
|
|
8919
|
+
const pois = this.bmap.context.getPoisByDeviceXy(offsetX, offsetY);
|
|
8920
|
+
selectPois.push(...pois);
|
|
8921
|
+
pois.forEach((item) => {
|
|
8922
|
+
if (!set2.has(item.options.id)) {
|
|
8923
|
+
const graphic = this.bmap.context.currentFloor?.graphicLayer.graphicMap.get(item.options.id) || null;
|
|
8924
|
+
if (graphic) {
|
|
8925
|
+
set2.add(item.options.id);
|
|
8926
|
+
selectGraphics.push(graphic);
|
|
8927
|
+
}
|
|
8928
|
+
}
|
|
8929
|
+
});
|
|
8930
|
+
}
|
|
8931
|
+
if (!this.options.boxSelection || !(isMac ? e.metaKey : e.ctrlKey)) {
|
|
8932
|
+
this._list.clear();
|
|
8933
|
+
this._poiList.clear();
|
|
8934
|
+
}
|
|
8935
|
+
selectGraphics.forEach((item) => this._list.add(item));
|
|
8936
|
+
selectPois.forEach((item) => this._poiList.add(item));
|
|
8937
|
+
this.selectEnd();
|
|
8938
|
+
this.downPoint = null;
|
|
8939
|
+
};
|
|
8940
|
+
onPointerOut = (e) => {
|
|
8941
|
+
this.disableBoxSelection();
|
|
8942
|
+
};
|
|
8943
|
+
onKeyDown = (e) => {
|
|
8944
|
+
if (isControl(e.key)) {
|
|
8945
|
+
this.enableBoxSelection();
|
|
8946
|
+
}
|
|
8947
|
+
};
|
|
8948
|
+
onKeyUp = (e) => {
|
|
8949
|
+
if (isControl(e.key)) {
|
|
8950
|
+
this.disableBoxSelection();
|
|
8951
|
+
}
|
|
8952
|
+
};
|
|
8953
|
+
onBoxSelected = ({ list }) => {
|
|
8954
|
+
this._list.clear();
|
|
8955
|
+
list.forEach((item) => {
|
|
8956
|
+
this._list.add(item);
|
|
8957
|
+
});
|
|
8958
|
+
this.selectEnd();
|
|
8959
|
+
};
|
|
8960
|
+
selectEnd() {
|
|
8961
|
+
this.dispatchEvent({
|
|
8962
|
+
type: "select",
|
|
8963
|
+
graphics: [...this._list],
|
|
8964
|
+
pois: [...this._poiList],
|
|
8965
|
+
isMultipleSelect: this.isMultipleSelect
|
|
8966
|
+
});
|
|
8967
|
+
}
|
|
8968
|
+
registryEvent() {
|
|
8969
|
+
this.bmap.context.container.addEventListener("pointerdown", this.onPointerDown);
|
|
8970
|
+
this.bmap.context.container.addEventListener("pointerup", this.onPointerUp);
|
|
8971
|
+
this.bmap.context.container.addEventListener("pointerout", this.onPointerOut);
|
|
8972
|
+
this.bmap.context.container.addEventListener("pointercancel", this.onPointerOut);
|
|
8973
|
+
window.addEventListener("keydown", this.onKeyDown);
|
|
8974
|
+
window.addEventListener("keyup", this.onKeyUp);
|
|
8975
|
+
this.boxSelection.addEventListener("selected", this.onBoxSelected);
|
|
8976
|
+
}
|
|
8977
|
+
unRegistryEvent() {
|
|
8978
|
+
this.bmap.context.container.removeEventListener("pointerdown", this.onPointerDown);
|
|
8979
|
+
this.bmap.context.container.removeEventListener("pointerup", this.onPointerUp);
|
|
8980
|
+
this.bmap.context.container.removeEventListener("pointerout", this.onPointerOut);
|
|
8981
|
+
this.bmap.context.container.removeEventListener("pointercancel", this.onPointerOut);
|
|
8982
|
+
window.removeEventListener("keydown", this.onKeyDown);
|
|
8983
|
+
window.removeEventListener("keyup", this.onKeyUp);
|
|
8984
|
+
this.boxSelection.removeEventListener("selected", this.onBoxSelected);
|
|
8985
|
+
}
|
|
8986
|
+
clear() {
|
|
8987
|
+
this._list.clear();
|
|
8988
|
+
}
|
|
8989
|
+
remove(graphic) {
|
|
8990
|
+
this._list.delete(graphic);
|
|
8991
|
+
}
|
|
8992
|
+
dispose() {
|
|
8993
|
+
this.unRegistryEvent();
|
|
8994
|
+
}
|
|
8995
|
+
};
|
|
8996
|
+
|
|
8468
8997
|
// src/loader/CrLoader/api/floor.ts
|
|
8469
8998
|
async function loadBuildingGround({ brand, project }, config) {
|
|
8470
8999
|
const {
|
|
@@ -9121,6 +9650,7 @@ var CrLoader = class {
|
|
|
9121
9650
|
export {
|
|
9122
9651
|
AibeeLoader,
|
|
9123
9652
|
BMap,
|
|
9653
|
+
BMapSelect,
|
|
9124
9654
|
BaseSvg,
|
|
9125
9655
|
Context,
|
|
9126
9656
|
CrLoader,
|
|
@@ -9157,6 +9687,8 @@ export {
|
|
|
9157
9687
|
SvgPolygon,
|
|
9158
9688
|
TextTexture,
|
|
9159
9689
|
Timer,
|
|
9690
|
+
TweenUtil,
|
|
9691
|
+
UA,
|
|
9160
9692
|
Wall,
|
|
9161
9693
|
addAlphaToHexColor,
|
|
9162
9694
|
calc_angle,
|
|
@@ -9167,6 +9699,7 @@ export {
|
|
|
9167
9699
|
createRect,
|
|
9168
9700
|
createSvg,
|
|
9169
9701
|
createSvgElement,
|
|
9702
|
+
createThreeBox,
|
|
9170
9703
|
createThreeLine,
|
|
9171
9704
|
darkenColor,
|
|
9172
9705
|
defaultAibeeLoaderOption,
|
|
@@ -9181,18 +9714,22 @@ export {
|
|
|
9181
9714
|
getCenter,
|
|
9182
9715
|
getConfig,
|
|
9183
9716
|
getDirectPath,
|
|
9717
|
+
getDistanceByPathPos,
|
|
9184
9718
|
getLength,
|
|
9185
9719
|
getLongestSideDir,
|
|
9186
9720
|
getMinEdgeSquare,
|
|
9187
9721
|
getPathLength,
|
|
9188
9722
|
getPointEdgeIndex,
|
|
9723
|
+
getPosByPathDistance,
|
|
9189
9724
|
hasChinese,
|
|
9190
9725
|
hexToRgb,
|
|
9191
9726
|
initDirectionalLight,
|
|
9192
9727
|
initLight,
|
|
9193
9728
|
initShape,
|
|
9729
|
+
isAndroid,
|
|
9194
9730
|
isContain,
|
|
9195
9731
|
isControl,
|
|
9732
|
+
isIphone,
|
|
9196
9733
|
isMac,
|
|
9197
9734
|
isPointInPolygon,
|
|
9198
9735
|
loadBuildingGround,
|