@aibee/crc-bmap 0.0.106 → 0.0.108
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 +5 -5
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +240 -35
- package/lib/bmap.esm.js.map +3 -3
- package/lib/bmap.esm.min.js +5 -5
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +5 -5
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/context.d.ts +1 -1
- package/lib/src/operations/hover/hover-helper.d.ts +1 -0
- package/lib/src/plugins/navigation/navigation.d.ts +33 -3
- package/lib/src/plugins/navigation/path.d.ts +2 -2
- package/lib/src/utils/path.d.ts +34 -8
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -2791,9 +2791,18 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2791
2791
|
}
|
|
2792
2792
|
};
|
|
2793
2793
|
onPointerLevel = () => {
|
|
2794
|
+
console.log("level");
|
|
2794
2795
|
this.curGraphics.clear();
|
|
2795
2796
|
this.handleHoverGraphicsChange();
|
|
2796
2797
|
};
|
|
2798
|
+
onBodyPointerMove = (e) => {
|
|
2799
|
+
if (this.curGraphics.size) {
|
|
2800
|
+
const rect = this.context.container.getBoundingClientRect();
|
|
2801
|
+
if (e.clientX < rect.left || e.clientX > rect.right || e.clientY < rect.top || e.clientY > rect.bottom) {
|
|
2802
|
+
this.onPointerLevel();
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2797
2806
|
handleHoverGraphicsChange(graphics = this.curGraphics) {
|
|
2798
2807
|
this.dispatchEvent({ type: "hover-change", graphics: Array.from(graphics) });
|
|
2799
2808
|
}
|
|
@@ -2801,11 +2810,13 @@ var HoverHelper = class extends EventDispatcher5 {
|
|
|
2801
2810
|
this.context.addEventListener("pointer-over", this.onPointerMove);
|
|
2802
2811
|
this.context.addEventListener("pointer-move", this.onPointerMove);
|
|
2803
2812
|
this.context.addEventListener("pointer-level", this.onPointerLevel);
|
|
2813
|
+
document.body.addEventListener("pointermove", this.onBodyPointerMove);
|
|
2804
2814
|
}
|
|
2805
2815
|
unRegistryEvent() {
|
|
2806
2816
|
this.context.removeEventListener("pointer-over", this.onPointerMove);
|
|
2807
2817
|
this.context.removeEventListener("pointer-move", this.onPointerMove);
|
|
2808
2818
|
this.context.removeEventListener("pointer-level", this.onPointerLevel);
|
|
2819
|
+
document.body.removeEventListener("pointermove", this.onBodyPointerMove);
|
|
2809
2820
|
}
|
|
2810
2821
|
dispose() {
|
|
2811
2822
|
this.unRegistryEvent();
|
|
@@ -3219,7 +3230,8 @@ var Context = class extends EventDispatcher6 {
|
|
|
3219
3230
|
const pois = this.getPoisByDeviceXy(e.offsetX, e.offsetY);
|
|
3220
3231
|
this.dispatchEvent({ type: "pointer-move", e, graphics, pois, position });
|
|
3221
3232
|
};
|
|
3222
|
-
onPointerleave = () => {
|
|
3233
|
+
onPointerleave = (e) => {
|
|
3234
|
+
console.log(e.type);
|
|
3223
3235
|
this.dispatchEvent({ type: "pointer-level" });
|
|
3224
3236
|
};
|
|
3225
3237
|
onSelectionSelect = ({ graphics, isMultipleSelect }) => {
|
|
@@ -3234,6 +3246,8 @@ var Context = class extends EventDispatcher6 {
|
|
|
3234
3246
|
this.container.addEventListener("pointerover", this.onPointerover);
|
|
3235
3247
|
this.container.addEventListener("pointermove", this.onPointermove);
|
|
3236
3248
|
this.container.addEventListener("pointerleave", this.onPointerleave);
|
|
3249
|
+
this.container.addEventListener("pointercancel", this.onPointerleave);
|
|
3250
|
+
this.container.addEventListener("pointerout", this.onPointerleave);
|
|
3237
3251
|
this.selection.addEventListener("select", this.onSelectionSelect);
|
|
3238
3252
|
this.hoverHelper.addEventListener("hover-change", this.onHoverChange);
|
|
3239
3253
|
}
|
|
@@ -3243,6 +3257,8 @@ var Context = class extends EventDispatcher6 {
|
|
|
3243
3257
|
this.container.removeEventListener("pointerover", this.onPointerover);
|
|
3244
3258
|
this.container.removeEventListener("pointermove", this.onPointermove);
|
|
3245
3259
|
this.container.removeEventListener("pointerleave", this.onPointerleave);
|
|
3260
|
+
this.container.removeEventListener("pointercancel", this.onPointerleave);
|
|
3261
|
+
this.container.removeEventListener("pointerout", this.onPointerleave);
|
|
3246
3262
|
this.selection.removeEventListener("select", this.onSelectionSelect);
|
|
3247
3263
|
this.hoverHelper.removeEventListener("hover-change", this.onHoverChange);
|
|
3248
3264
|
}
|
|
@@ -3285,12 +3301,21 @@ var Context = class extends EventDispatcher6 {
|
|
|
3285
3301
|
* @param azimuthal 弧度
|
|
3286
3302
|
*/
|
|
3287
3303
|
setAzimuthalAngle(azimuthal, duration = 500) {
|
|
3304
|
+
const { maxAzimuthAngle, minAzimuthAngle } = this.control;
|
|
3305
|
+
const disable = maxAzimuthAngle === minAzimuthAngle;
|
|
3306
|
+
if (!disable) {
|
|
3307
|
+
if (azimuthal > maxAzimuthAngle && azimuthal < minAzimuthAngle) {
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3288
3311
|
if (duration === 0) {
|
|
3289
3312
|
this.control.maxAzimuthAngle = azimuthal;
|
|
3290
3313
|
this.control.minAzimuthAngle = azimuthal;
|
|
3291
3314
|
this.control.update();
|
|
3292
|
-
|
|
3293
|
-
|
|
3315
|
+
if (!disable) {
|
|
3316
|
+
this.control.maxAzimuthAngle = maxAzimuthAngle;
|
|
3317
|
+
this.control.minAzimuthAngle = minAzimuthAngle;
|
|
3318
|
+
}
|
|
3294
3319
|
return;
|
|
3295
3320
|
}
|
|
3296
3321
|
return timeoutPromise(
|
|
@@ -3303,8 +3328,10 @@ var Context = class extends EventDispatcher6 {
|
|
|
3303
3328
|
this.control.update();
|
|
3304
3329
|
}).onComplete(() => {
|
|
3305
3330
|
this.control.enabled = true;
|
|
3306
|
-
|
|
3307
|
-
|
|
3331
|
+
if (!disable) {
|
|
3332
|
+
this.control.maxAzimuthAngle = maxAzimuthAngle;
|
|
3333
|
+
this.control.minAzimuthAngle = minAzimuthAngle;
|
|
3334
|
+
}
|
|
3308
3335
|
this.tweenGroup.remove(tween);
|
|
3309
3336
|
resolve(true);
|
|
3310
3337
|
}).onStart(() => {
|
|
@@ -4047,9 +4074,7 @@ var BMap = class extends EventDispatcher7 {
|
|
|
4047
4074
|
}
|
|
4048
4075
|
rotateMap(radius = 0.1) {
|
|
4049
4076
|
const azimuthal = this.context.control.getAzimuthalAngle();
|
|
4050
|
-
this.context.
|
|
4051
|
-
this.context.control.minAzimuthAngle = azimuthal + radius;
|
|
4052
|
-
this.context.control.update();
|
|
4077
|
+
this.context.setAzimuthalAngle(azimuthal + radius, 500);
|
|
4053
4078
|
}
|
|
4054
4079
|
/**
|
|
4055
4080
|
* 测量距离
|
|
@@ -4944,7 +4969,7 @@ var arrow_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAMAA
|
|
|
4944
4969
|
// src/plugins/navigation/path.ts
|
|
4945
4970
|
var defaultConfig2 = {
|
|
4946
4971
|
texture_url: arrow_default,
|
|
4947
|
-
lineWidth:
|
|
4972
|
+
lineWidth: 8,
|
|
4948
4973
|
color: 16777215
|
|
4949
4974
|
};
|
|
4950
4975
|
var Path2 = class extends Object3D11 {
|
|
@@ -5047,7 +5072,7 @@ var Path2 = class extends Object3D11 {
|
|
|
5047
5072
|
),
|
|
5048
5073
|
depthTest: true,
|
|
5049
5074
|
sizeAttenuation: false,
|
|
5050
|
-
lineWidth: this.config.lineWidth,
|
|
5075
|
+
lineWidth: this.config.lineWidth * 2,
|
|
5051
5076
|
map: this.texture,
|
|
5052
5077
|
blending: NormalBlending,
|
|
5053
5078
|
repeat: new Vector25(this.getRepeat(), 1)
|
|
@@ -5142,48 +5167,107 @@ function simplifyPath(path, ignoreFirst = false, smoothingOptimization = true, s
|
|
|
5142
5167
|
const halfMidTailDist = tail.distanceTo(mid) / 2;
|
|
5143
5168
|
const curveHead = mid.clone();
|
|
5144
5169
|
const curveTail = mid.clone();
|
|
5145
|
-
curveHead.add(
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5170
|
+
curveHead.add(
|
|
5171
|
+
head.clone().sub(mid).normalize().multiplyScalar(
|
|
5172
|
+
halfHeadMidDist > smoothingDistance ? smoothingDistance / 2 : halfHeadMidDist
|
|
5173
|
+
)
|
|
5174
|
+
);
|
|
5175
|
+
curveTail.add(
|
|
5176
|
+
tail.clone().sub(mid).normalize().multiplyScalar(
|
|
5177
|
+
halfMidTailDist > smoothingDistance ? smoothingDistance / 2 : halfMidTailDist
|
|
5178
|
+
)
|
|
5179
|
+
);
|
|
5151
5180
|
const curveToSmooth = [
|
|
5152
5181
|
[curveHead.x, curveHead.y],
|
|
5153
5182
|
[mid.x, mid.y],
|
|
5154
5183
|
[curveTail.x, curveTail.y]
|
|
5155
5184
|
];
|
|
5156
|
-
simplifiedPath.push(
|
|
5157
|
-
...smoothPath(
|
|
5158
|
-
curveToSmooth,
|
|
5159
|
-
smoothingDistance / 25
|
|
5160
|
-
)
|
|
5161
|
-
);
|
|
5185
|
+
simplifiedPath.push(...smoothPath(curveToSmooth, smoothingDistance / 25));
|
|
5162
5186
|
}
|
|
5163
5187
|
simplifiedPath.push(joints[joints.length - 1]);
|
|
5188
|
+
return removeWeightPath(simplifiedPath);
|
|
5189
|
+
}
|
|
5190
|
+
function removeWeightPath(points) {
|
|
5191
|
+
if (points.length <= 1) {
|
|
5192
|
+
return points;
|
|
5193
|
+
}
|
|
5164
5194
|
const checkedPath = [];
|
|
5165
5195
|
let lastCheckedPoint;
|
|
5166
|
-
|
|
5196
|
+
points.forEach(([x, y]) => {
|
|
5167
5197
|
if (!lastCheckedPoint) {
|
|
5168
5198
|
lastCheckedPoint = [x, y];
|
|
5169
5199
|
checkedPath.push([x, y]);
|
|
5170
|
-
} else if (!(x === lastCheckedPoint[0] && y === lastCheckedPoint[
|
|
5200
|
+
} else if (!(x === lastCheckedPoint[0] && y === lastCheckedPoint[1])) {
|
|
5171
5201
|
lastCheckedPoint = [x, y];
|
|
5172
5202
|
checkedPath.push([x, y]);
|
|
5173
5203
|
}
|
|
5174
5204
|
});
|
|
5175
5205
|
return checkedPath;
|
|
5176
5206
|
}
|
|
5207
|
+
function distancePointToSegment(point3, start, end) {
|
|
5208
|
+
const segmentLength = Math.sqrt(
|
|
5209
|
+
(end[0] - start[0]) ** 2 + (end[1] - start[1]) ** 2
|
|
5210
|
+
);
|
|
5211
|
+
if (segmentLength === 0) {
|
|
5212
|
+
return {
|
|
5213
|
+
distance: Math.sqrt((point3[0] - start[0]) ** 2 + (point3[1] - start[1]) ** 2),
|
|
5214
|
+
closestPoint: start.slice(0)
|
|
5215
|
+
};
|
|
5216
|
+
}
|
|
5217
|
+
const t = Math.max(
|
|
5218
|
+
0,
|
|
5219
|
+
Math.min(
|
|
5220
|
+
1,
|
|
5221
|
+
((point3[0] - start[0]) * (end[0] - start[0]) + (point3[1] - start[1]) * (end[1] - start[1])) / segmentLength ** 2
|
|
5222
|
+
)
|
|
5223
|
+
);
|
|
5224
|
+
const closestPoint = [
|
|
5225
|
+
start[0] + t * (end[0] - start[0]),
|
|
5226
|
+
start[1] + t * (end[1] - start[1])
|
|
5227
|
+
];
|
|
5228
|
+
const distance = Math.sqrt(
|
|
5229
|
+
(point3[0] - closestPoint[0]) ** 2 + (point3[1] - closestPoint[1]) ** 2
|
|
5230
|
+
);
|
|
5231
|
+
return { distance, closestPoint };
|
|
5232
|
+
}
|
|
5233
|
+
function moveOnRoute(startPoint, endPoint, distance) {
|
|
5234
|
+
const [startX, startY] = startPoint;
|
|
5235
|
+
const [endX, endY] = endPoint;
|
|
5236
|
+
const routeLength = Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));
|
|
5237
|
+
const ratio = distance / routeLength;
|
|
5238
|
+
const newX = startX + (endX - startX) * ratio;
|
|
5239
|
+
const newY = startY + (endY - startY) * ratio;
|
|
5240
|
+
return [newX, newY];
|
|
5241
|
+
}
|
|
5177
5242
|
|
|
5178
5243
|
// src/plugins/navigation/navigation.ts
|
|
5244
|
+
import { Group as TweenGroup2, Tween as Tween2 } from "@tweenjs/tween.js";
|
|
5245
|
+
var defaultConfig3 = {
|
|
5246
|
+
path: {},
|
|
5247
|
+
speed: 10,
|
|
5248
|
+
cheapMaximumDistance: 20,
|
|
5249
|
+
needStartPoi: false,
|
|
5250
|
+
startPoi: {}
|
|
5251
|
+
};
|
|
5179
5252
|
var Navigation = class extends Plugin {
|
|
5180
5253
|
path = null;
|
|
5181
5254
|
worker = Worker2();
|
|
5182
5255
|
fetchRoadStatus = false;
|
|
5183
5256
|
uniqueKey = new UniqueKey();
|
|
5184
5257
|
paths = [];
|
|
5185
|
-
|
|
5258
|
+
options;
|
|
5259
|
+
pathTween = new TweenGroup2();
|
|
5260
|
+
startPoi = null;
|
|
5261
|
+
// 处理路线动画
|
|
5262
|
+
animationPathOptions = {
|
|
5263
|
+
cPathIndex: 0
|
|
5264
|
+
// 在平滑路线中的下标(平滑但是未做插值的数据,是做路线渲染的)
|
|
5265
|
+
};
|
|
5266
|
+
cPath = [];
|
|
5267
|
+
// 当前楼层的平滑后的路线
|
|
5268
|
+
constructor(bmap, project, options = {}) {
|
|
5186
5269
|
super(bmap);
|
|
5270
|
+
this.options = Object.assign({}, defaultConfig3, options);
|
|
5187
5271
|
const {
|
|
5188
5272
|
apiDomain,
|
|
5189
5273
|
apiPath: { roadNetwork },
|
|
@@ -5201,18 +5285,35 @@ var Navigation = class extends Plugin {
|
|
|
5201
5285
|
this.dispatchEvent({ type: "fetch-road-status", status: true });
|
|
5202
5286
|
}
|
|
5203
5287
|
});
|
|
5288
|
+
this.registryEvent();
|
|
5289
|
+
}
|
|
5290
|
+
registryEvent() {
|
|
5291
|
+
this.bmap.context.addEventListener("update", this.onUpdate);
|
|
5204
5292
|
this.bmap.addEventListener(
|
|
5205
5293
|
"switch_floor_after" /* SWITCH_FLOOR_AFTER */,
|
|
5206
5294
|
this.onSwitchFloor
|
|
5207
5295
|
);
|
|
5208
5296
|
}
|
|
5297
|
+
unRegistryEvent() {
|
|
5298
|
+
this.bmap.context.removeEventListener("update", this.onUpdate);
|
|
5299
|
+
this.bmap.removeEventListener(
|
|
5300
|
+
"switch_floor_after" /* SWITCH_FLOOR_AFTER */,
|
|
5301
|
+
this.onSwitchFloor
|
|
5302
|
+
);
|
|
5303
|
+
}
|
|
5304
|
+
onUpdate = () => {
|
|
5305
|
+
this.pathTween.update();
|
|
5306
|
+
};
|
|
5209
5307
|
triggerWorker(type, data) {
|
|
5210
5308
|
this.worker.postMessage({ type, data });
|
|
5211
5309
|
}
|
|
5212
5310
|
clearPath() {
|
|
5213
5311
|
if (this.path) {
|
|
5214
5312
|
this.bmap.context.scene.remove(this.path);
|
|
5313
|
+
this.path.dispose();
|
|
5215
5314
|
this.path = null;
|
|
5315
|
+
this.pathTween.getAll().forEach((item) => item.stop());
|
|
5316
|
+
this.pathTween.removeAll();
|
|
5216
5317
|
}
|
|
5217
5318
|
}
|
|
5218
5319
|
onSwitchFloor = ({ data: { curFloor } }) => {
|
|
@@ -5304,30 +5405,134 @@ var Navigation = class extends Plugin {
|
|
|
5304
5405
|
});
|
|
5305
5406
|
}
|
|
5306
5407
|
renderPath(points) {
|
|
5307
|
-
const cPath = this.catmullRomCurve3(points)
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5408
|
+
const cPath = this.catmullRomCurve3(points);
|
|
5409
|
+
this.cPath = cPath;
|
|
5410
|
+
this.animationPathOptions = {
|
|
5411
|
+
cPathIndex: 0
|
|
5412
|
+
};
|
|
5311
5413
|
if (this.path) {
|
|
5312
5414
|
this.path.updatePoints(cPath);
|
|
5313
5415
|
} else {
|
|
5314
|
-
this.path = new Path2(this,
|
|
5416
|
+
this.path = new Path2(this, this.options.path);
|
|
5315
5417
|
this.path.create(cPath);
|
|
5316
5418
|
this.path.position.z = this.bmap.context.currentFloor.groundMaxHeight + 0.1;
|
|
5317
5419
|
this.bmap.context.scene.add(this.path);
|
|
5318
5420
|
}
|
|
5421
|
+
if (this.startPoi) {
|
|
5422
|
+
this.startPoi.dispose();
|
|
5423
|
+
this.startPoi = null;
|
|
5424
|
+
}
|
|
5425
|
+
if (this.options.needStartPoi) {
|
|
5426
|
+
this.startPoi = this.bmap.context.currentFloor?.addPoi({
|
|
5427
|
+
...this.options.startPoi,
|
|
5428
|
+
position: { x: cPath[0][0], y: cPath[0][1], z: 1e-4 },
|
|
5429
|
+
collision_enable: false
|
|
5430
|
+
}) || null;
|
|
5431
|
+
}
|
|
5319
5432
|
}
|
|
5320
5433
|
catmullRomCurve3(points) {
|
|
5321
|
-
return simplifyPath(points,
|
|
5434
|
+
return simplifyPath(points, false, true, 0.1, 150, 2.5);
|
|
5435
|
+
}
|
|
5436
|
+
/**
|
|
5437
|
+
* 按照指定速度移动到目标位置
|
|
5438
|
+
* @param point 目标位置
|
|
5439
|
+
* @param speed 移动速度
|
|
5440
|
+
*/
|
|
5441
|
+
async animationTo(point3, speed = this.options.speed) {
|
|
5442
|
+
if (point3.floor !== this.bmap.context.currentFloor?.name || !this.path) {
|
|
5443
|
+
return;
|
|
5444
|
+
}
|
|
5445
|
+
const {
|
|
5446
|
+
animationPathOptions: { cPathIndex }
|
|
5447
|
+
} = this;
|
|
5448
|
+
const currentPath = [
|
|
5449
|
+
this.path.points[0],
|
|
5450
|
+
...this.cPath.slice(cPathIndex + 1)
|
|
5451
|
+
];
|
|
5452
|
+
const translatedPos = this.translatePoints([point3.pos])[0];
|
|
5453
|
+
const { distance, pos, index } = currentPath.reduce(
|
|
5454
|
+
(res, cur, index2, arr) => {
|
|
5455
|
+
if (index2 === arr.length - 1) {
|
|
5456
|
+
return res;
|
|
5457
|
+
}
|
|
5458
|
+
const { distance: distance2, closestPoint } = distancePointToSegment(
|
|
5459
|
+
translatedPos,
|
|
5460
|
+
cur,
|
|
5461
|
+
arr[index2 + 1]
|
|
5462
|
+
);
|
|
5463
|
+
if (distance2 < res.distance) {
|
|
5464
|
+
res.distance = distance2;
|
|
5465
|
+
res.pos = closestPoint;
|
|
5466
|
+
res.index = index2;
|
|
5467
|
+
}
|
|
5468
|
+
return res;
|
|
5469
|
+
},
|
|
5470
|
+
{
|
|
5471
|
+
distance: Number.MAX_SAFE_INTEGER,
|
|
5472
|
+
pos: point3.pos,
|
|
5473
|
+
index: 0
|
|
5474
|
+
}
|
|
5475
|
+
);
|
|
5476
|
+
if (distance > this.options.cheapMaximumDistance) {
|
|
5477
|
+
return;
|
|
5478
|
+
}
|
|
5479
|
+
if (this.path.points[0][0] === pos[0] && this.path.points[0][1] === pos[1]) {
|
|
5480
|
+
return;
|
|
5481
|
+
}
|
|
5482
|
+
let moveDistance = 0;
|
|
5483
|
+
let moveDistanceArray = [];
|
|
5484
|
+
if (index === 0) {
|
|
5485
|
+
moveDistance = getLength(currentPath[0], pos);
|
|
5486
|
+
moveDistanceArray = [moveDistance];
|
|
5487
|
+
} else {
|
|
5488
|
+
moveDistanceArray = [getLength(currentPath[0], currentPath[1])];
|
|
5489
|
+
for (let i = 1; i < index; i++) {
|
|
5490
|
+
moveDistanceArray.push(getLength(currentPath[i], currentPath[i + 1]));
|
|
5491
|
+
}
|
|
5492
|
+
moveDistanceArray.push(getLength(currentPath[index], pos));
|
|
5493
|
+
moveDistance = moveDistanceArray.reduce((sum, cur) => sum + cur, 0);
|
|
5494
|
+
}
|
|
5495
|
+
const speedSecond = this.kmPerHourToMetersPerSecond(speed);
|
|
5496
|
+
const timeSecond = moveDistance / speedSecond;
|
|
5497
|
+
this.pathTween.getAll().forEach((item) => item.stop());
|
|
5498
|
+
this.pathTween.removeAll();
|
|
5499
|
+
const start = { distance: 0 };
|
|
5500
|
+
return new Promise((resolve) => {
|
|
5501
|
+
const tween = new Tween2(start, this.pathTween).to({ distance: moveDistance }, timeSecond * 1e3).onUpdate(() => {
|
|
5502
|
+
for (let i = 0; i < moveDistanceArray.length; i++) {
|
|
5503
|
+
const sumDistance = moveDistanceArray.slice(0, i + 1).reduce((sum, cur) => sum + cur, 0);
|
|
5504
|
+
if (sumDistance >= start.distance) {
|
|
5505
|
+
const prevDistance = sumDistance - moveDistanceArray[i];
|
|
5506
|
+
const needDistance = start.distance - prevDistance;
|
|
5507
|
+
const startPoint = currentPath[i];
|
|
5508
|
+
const nextPoint = currentPath[i + 1];
|
|
5509
|
+
const pos2 = moveOnRoute(startPoint, nextPoint, needDistance);
|
|
5510
|
+
this.path?.updatePoints([pos2, ...currentPath.slice(i + 1)]);
|
|
5511
|
+
this.animationPathOptions.cPathIndex += i;
|
|
5512
|
+
if (this.startPoi) {
|
|
5513
|
+
this.startPoi.position.setX(pos2[0]).setY(pos2[1]);
|
|
5514
|
+
}
|
|
5515
|
+
this.dispatchEvent({ type: "path-animation" });
|
|
5516
|
+
return;
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
5519
|
+
}).onComplete(() => {
|
|
5520
|
+
this.pathTween.remove(tween);
|
|
5521
|
+
this.dispatchEvent({ type: "path-animation-end" });
|
|
5522
|
+
resolve(true);
|
|
5523
|
+
}).start();
|
|
5524
|
+
});
|
|
5525
|
+
}
|
|
5526
|
+
kmPerHourToMetersPerSecond(speedInKmPerHour) {
|
|
5527
|
+
const speedInMetersPerSecond = speedInKmPerHour * 1e3 / 3600;
|
|
5528
|
+
return speedInMetersPerSecond;
|
|
5322
5529
|
}
|
|
5323
5530
|
dispose() {
|
|
5324
5531
|
this.worker.terminate();
|
|
5325
|
-
this.
|
|
5326
|
-
"switch_floor_after" /* SWITCH_FLOOR_AFTER */,
|
|
5327
|
-
this.onSwitchFloor
|
|
5328
|
-
);
|
|
5532
|
+
this.unRegistryEvent();
|
|
5329
5533
|
this.path?.dispose();
|
|
5330
5534
|
this.uniqueKey.dispose();
|
|
5535
|
+
this.startPoi?.dispose();
|
|
5331
5536
|
}
|
|
5332
5537
|
};
|
|
5333
5538
|
|