@aibee/crc-bmap 0.8.45 → 0.8.46
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 +408 -401
- package/lib/bmap.esm.js +7310 -1296
- package/lib/bmap.esm.min.js +408 -401
- package/lib/bmap.min.js +408 -401
- package/lib/src/bmap.js +60 -54
- package/lib/src/context/OrbitControls.js +4 -1
- package/lib/src/context/context.js +54 -37
- package/lib/src/context/control.js +85 -85
- package/lib/src/elements/base-svg.js +5 -4
- package/lib/src/elements/floor.js +8 -0
- package/lib/src/elements/glb-model.js +14 -18
- package/lib/src/elements/graphic.js +18 -8
- package/lib/src/elements/ground-texture.js +41 -44
- package/lib/src/elements/heatmap.js +2 -1
- package/lib/src/elements/lane.js +5 -1
- package/lib/src/elements/merge-graphic.js +3 -28
- package/lib/src/elements/model.js +5 -9
- package/lib/src/elements/overlay.js +9 -7
- package/lib/src/elements/poi.js +55 -49
- package/lib/src/elements/poi2.js +52 -53
- package/lib/src/elements/shadow.js +3 -1
- package/lib/src/elements/svg-line.js +2 -0
- package/lib/src/elements/svg-polygon.js +1 -0
- package/lib/src/elements/text-texture.js +32 -36
- package/lib/src/elements/wall.js +3 -41
- package/lib/src/external/meshLine.js +17 -0
- package/lib/src/factory/img-texture.js +1 -0
- package/lib/src/factory/material.js +21 -51
- package/lib/src/factory/model.js +31 -33
- package/lib/src/factory/text-texture.js +17 -0
- package/lib/src/factory/unique-key.js +8 -0
- package/lib/src/layer/graphic-layer.js +1 -0
- package/lib/src/layer/parking-layer.d.ts +6 -0
- package/lib/src/layer/parking-layer.js +8 -0
- package/lib/src/layer/poi-layer.js +4 -1
- package/lib/src/layer/poi-layer2.js +2 -0
- package/lib/src/loader/AibeeLoader/index.js +230 -276
- package/lib/src/loader/AibeeLoader/layer.js +8 -6
- package/lib/src/loader/CrLoader/api/floor.js +45 -73
- package/lib/src/loader/CrLoader/index.js +88 -106
- package/lib/src/operations/hover/hover-helper.js +12 -2
- package/lib/src/operations/selection/selection.js +11 -1
- package/lib/src/plugins/car-inertial-position/car-inertial-position.js +9 -3
- package/lib/src/plugins/car-inertial-position/compass.js +20 -25
- package/lib/src/plugins/car-inertial-position/utils.js +3 -0
- package/lib/src/plugins/cr-nav-path/cr-nav-path.js +47 -55
- package/lib/src/plugins/cr-nav-path/cr-path.worker.js +4 -2
- package/lib/src/plugins/equipment/equipment.js +20 -22
- package/lib/src/plugins/mul-floor-navigation/mul-floor-navigation.js +63 -61
- package/lib/src/plugins/mul-floor-navigation/path.js +34 -30
- package/lib/src/plugins/mul-floor-navigation/start-model.js +2 -1
- package/lib/src/plugins/mul-floor-select/mul-floor-select.js +2 -1
- package/lib/src/plugins/mul-floors/mul-floors.js +1 -0
- package/lib/src/plugins/nav-path/nav-path.js +51 -59
- package/lib/src/plugins/nav-path/path.worker.js +4 -2
- package/lib/src/plugins/navigation/navigation.js +206 -214
- package/lib/src/plugins/navigation/path.js +34 -30
- package/lib/src/plugins/navigation/position-navigation.js +53 -53
- package/lib/src/plugins/navigation/start-rotate-helper-poi.js +18 -6
- package/lib/src/plugins/pdr-position/imu-position.js +13 -9
- package/lib/src/plugins/pdr-position/particle.js +4 -2
- package/lib/src/plugins/pdr-position/pdr.js +5 -4
- package/lib/src/plugins/pdr-position/position.js +5 -2
- package/lib/src/plugins/pdr-position/sensor.js +20 -25
- package/lib/src/plugins/select/select.js +11 -1
- package/lib/src/utils/camera-bound.js +3 -1
- package/lib/src/utils/color.js +8 -4
- package/lib/src/utils/coordinate.js +1 -0
- package/lib/src/utils/create.js +4 -2
- package/lib/src/utils/events.js +15 -4
- package/lib/src/utils/index-db.js +18 -11
- package/lib/src/utils/init-helper.js +7 -2
- package/lib/src/utils/obj-utils.js +3 -2
- package/lib/src/utils/os.js +1 -0
- package/lib/src/utils/path.js +15 -4
- package/lib/src/utils/promise.js +3 -1
- package/lib/src/utils/proxy.js +2 -1
- package/lib/src/utils/road.js +20 -14
- package/lib/src/utils/road2.js +60 -39
- package/lib/src/utils/rules.js +1 -0
- package/lib/src/utils/string.js +3 -1
- package/lib/src/utils/svg.js +12 -11
- package/lib/src/utils/taskQueue.js +29 -29
- package/lib/src/utils/timer.js +8 -0
- package/lib/src/utils/translate.js +3 -1
- package/lib/src/utils/tween.js +8 -0
- package/lib/src/utils/webworker.js +10 -9
- package/package.json +2 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import "core-js/modules/es.string.replace.js";
|
|
3
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
4
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
5
|
+
import "core-js/modules/es.promise.finally.js";
|
|
3
6
|
import { Plugin } from "../base";
|
|
4
7
|
import { Path } from "./path";
|
|
5
8
|
import { HooksName, vector3ToDevice, TweenUtil, getPointEdgeIndex, timeoutPromise } from "../../utils";
|
|
@@ -154,7 +157,8 @@ export class Navigation extends Plugin {
|
|
|
154
157
|
this.clearPath();
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
|
-
addPath(paths, routeIndex
|
|
160
|
+
addPath(paths, routeIndex) {
|
|
161
|
+
if (routeIndex === void 0) routeIndex = 0;
|
|
158
162
|
var _this_bmap_context_currentFloor;
|
|
159
163
|
this.paths = paths;
|
|
160
164
|
this.curPathIndex = routeIndex;
|
|
@@ -288,145 +292,137 @@ export class Navigation extends Plugin {
|
|
|
288
292
|
return (angle - 90 + 360) % 360;
|
|
289
293
|
}
|
|
290
294
|
// 把相机旋转到路线的上方向
|
|
291
|
-
changeCameraToPathUp(duration
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (
|
|
300
|
-
|
|
301
|
-
angle = Math.PI * 2 + angle;
|
|
302
|
-
} else {
|
|
303
|
-
angle = angle - Math.PI * 2;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
const diffAngle = Math.abs(angle - _this.bmap.context.control.getAzimuthalAngle());
|
|
307
|
-
if (diffAngle < 0.01) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const { control } = _this.bmap.context;
|
|
311
|
-
const time = duration / Math.PI * 6 * diffAngle;
|
|
312
|
-
return timeoutPromise(new Promise((resolve)=>{
|
|
313
|
-
const start = {
|
|
314
|
-
azimuthal: control.getAzimuthalAngle()
|
|
315
|
-
};
|
|
316
|
-
const end = {
|
|
317
|
-
azimuthal: angle
|
|
318
|
-
};
|
|
319
|
-
const polar = control.getPolarAngle();
|
|
320
|
-
const { maxPolarAngle, minPolarAngle } = control;
|
|
321
|
-
control.maxPolarAngle = polar;
|
|
322
|
-
control.minPolarAngle = polar;
|
|
323
|
-
const tween = new Tween(start, _this.tweenUtil.group).to(end, time).easing(Easing.Quadratic.InOut).onUpdate(/*#__PURE__*/ _async_to_generator(function*() {
|
|
324
|
-
if (_this.startPoi) {
|
|
325
|
-
control.target.copy(_this.startPoi.position);
|
|
326
|
-
}
|
|
327
|
-
control.setAzimuthalAngle(start.azimuthal, true);
|
|
328
|
-
control.setTargetByOffset(_this.options.offsetY);
|
|
329
|
-
})).onComplete(()=>{
|
|
330
|
-
control.enabled = true;
|
|
331
|
-
_this.tweenUtil.remove(tween);
|
|
332
|
-
control.maxPolarAngle = maxPolarAngle;
|
|
333
|
-
control.minPolarAngle = minPolarAngle;
|
|
334
|
-
resolve(true);
|
|
335
|
-
}).onStart(()=>{
|
|
336
|
-
control.enabled = false;
|
|
337
|
-
}).start();
|
|
338
|
-
}), time + 500).finally(()=>{
|
|
339
|
-
_this.bmap.context.control.enabled = true;
|
|
340
|
-
});
|
|
341
|
-
})();
|
|
342
|
-
}
|
|
343
|
-
initNavigationCamera(duration = 1000) {
|
|
344
|
-
var _this = this;
|
|
345
|
-
return _async_to_generator(function*() {
|
|
346
|
-
var _tasks_find;
|
|
347
|
-
const tasks = _this.taskQueue.getTasks();
|
|
348
|
-
const tid = (_tasks_find = tasks.find((item)=>item.meta.type === "initNavigationCamera")) == null ? void 0 : _tasks_find.tid;
|
|
349
|
-
const newTask = {
|
|
350
|
-
run: ()=>timeoutPromise(_async_to_generator(function*() {
|
|
351
|
-
yield _this.initCameraZoom(duration / 2);
|
|
352
|
-
yield _this.changeCameraToPathUp(duration / 4);
|
|
353
|
-
yield _this.translateCameraToStartPoi(duration / 4);
|
|
354
|
-
})(), duration + 500).finally(()=>{
|
|
355
|
-
_this.bmap.context.control.enabled = true;
|
|
356
|
-
}),
|
|
357
|
-
meta: {
|
|
358
|
-
type: "initNavigationCamera"
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
if (tid) {
|
|
362
|
-
_this.taskQueue.replace(tid, newTask);
|
|
295
|
+
async changeCameraToPathUp(duration) {
|
|
296
|
+
if (duration === void 0) duration = 100;
|
|
297
|
+
let angle = this.getPathDirection();
|
|
298
|
+
if (angle === null) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const currentAngle = this.bmap.context.control.getAzimuthalAngle();
|
|
302
|
+
if (Math.abs(currentAngle - angle) > Math.PI) {
|
|
303
|
+
if (currentAngle > 0) {
|
|
304
|
+
angle = Math.PI * 2 + angle;
|
|
363
305
|
} else {
|
|
364
|
-
|
|
306
|
+
angle = angle - Math.PI * 2;
|
|
365
307
|
}
|
|
366
|
-
}
|
|
308
|
+
}
|
|
309
|
+
const diffAngle = Math.abs(angle - this.bmap.context.control.getAzimuthalAngle());
|
|
310
|
+
if (diffAngle < 0.01) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const { control } = this.bmap.context;
|
|
314
|
+
const time = duration / Math.PI * 6 * diffAngle;
|
|
315
|
+
return timeoutPromise(new Promise((resolve)=>{
|
|
316
|
+
const start = {
|
|
317
|
+
azimuthal: control.getAzimuthalAngle()
|
|
318
|
+
};
|
|
319
|
+
const end = {
|
|
320
|
+
azimuthal: angle
|
|
321
|
+
};
|
|
322
|
+
const polar = control.getPolarAngle();
|
|
323
|
+
const { maxPolarAngle, minPolarAngle } = control;
|
|
324
|
+
control.maxPolarAngle = polar;
|
|
325
|
+
control.minPolarAngle = polar;
|
|
326
|
+
const tween = new Tween(start, this.tweenUtil.group).to(end, time).easing(Easing.Quadratic.InOut).onUpdate(async ()=>{
|
|
327
|
+
if (this.startPoi) {
|
|
328
|
+
control.target.copy(this.startPoi.position);
|
|
329
|
+
}
|
|
330
|
+
control.setAzimuthalAngle(start.azimuthal, true);
|
|
331
|
+
control.setTargetByOffset(this.options.offsetY);
|
|
332
|
+
}).onComplete(()=>{
|
|
333
|
+
control.enabled = true;
|
|
334
|
+
this.tweenUtil.remove(tween);
|
|
335
|
+
control.maxPolarAngle = maxPolarAngle;
|
|
336
|
+
control.minPolarAngle = minPolarAngle;
|
|
337
|
+
resolve(true);
|
|
338
|
+
}).onStart(()=>{
|
|
339
|
+
control.enabled = false;
|
|
340
|
+
}).start();
|
|
341
|
+
}), time + 500).finally(()=>{
|
|
342
|
+
this.bmap.context.control.enabled = true;
|
|
343
|
+
});
|
|
367
344
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
if (Math.abs(offsetX) >= 1) {
|
|
385
|
-
const xv3 = new Vector3();
|
|
386
|
-
xv3.setFromMatrixColumn(camera.matrix, 0);
|
|
387
|
-
xv3.normalize();
|
|
388
|
-
xv3.multiplyScalar(offsetX / camera.zoom);
|
|
389
|
-
target.add(new Vector3(xv3.x, xv3.y, 0));
|
|
390
|
-
}
|
|
391
|
-
if (Math.abs(offsetY) >= 1) {
|
|
392
|
-
const v3 = new Vector3();
|
|
393
|
-
v3.setFromMatrixColumn(camera.matrix, 1);
|
|
394
|
-
v3.normalize();
|
|
395
|
-
v3.multiplyScalar(offsetY / camera.zoom);
|
|
396
|
-
target.add(new Vector3(v3.x, v3.y, 0));
|
|
345
|
+
async initNavigationCamera(duration) {
|
|
346
|
+
if (duration === void 0) duration = 1000;
|
|
347
|
+
var _tasks_find;
|
|
348
|
+
const tasks = this.taskQueue.getTasks();
|
|
349
|
+
const tid = (_tasks_find = tasks.find((item)=>item.meta.type === "initNavigationCamera")) == null ? void 0 : _tasks_find.tid;
|
|
350
|
+
const newTask = {
|
|
351
|
+
run: ()=>timeoutPromise((async ()=>{
|
|
352
|
+
await this.initCameraZoom(duration / 2);
|
|
353
|
+
await this.changeCameraToPathUp(duration / 4);
|
|
354
|
+
await this.translateCameraToStartPoi(duration / 4);
|
|
355
|
+
})(), duration + 500).finally(()=>{
|
|
356
|
+
this.bmap.context.control.enabled = true;
|
|
357
|
+
}),
|
|
358
|
+
meta: {
|
|
359
|
+
type: "initNavigationCamera"
|
|
397
360
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
_this.bmap.context.control.setCameraPositionByTarget(target, 0);
|
|
405
|
-
_this.tweenUtil.remove(tween);
|
|
406
|
-
_this.bmap.context.control.enabled = true;
|
|
407
|
-
resolve(true);
|
|
408
|
-
}).onStart(()=>{
|
|
409
|
-
_this.bmap.context.control.enabled = false;
|
|
410
|
-
}).start();
|
|
411
|
-
}), duration + 500).then(()=>{
|
|
412
|
-
_this.bmap.context.control.enabled = true;
|
|
413
|
-
});
|
|
414
|
-
})();
|
|
361
|
+
};
|
|
362
|
+
if (tid) {
|
|
363
|
+
this.taskQueue.replace(tid, newTask);
|
|
364
|
+
} else {
|
|
365
|
+
this.taskQueue.add(newTask);
|
|
366
|
+
}
|
|
415
367
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
368
|
+
async translateCameraToStartPoi(duration) {
|
|
369
|
+
if (duration === void 0) duration = 100;
|
|
370
|
+
if (!this.startPoi) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const { clientSize: { width, height }, camera, control } = this.bmap.context;
|
|
374
|
+
const halfWidth = Math.round(width / 2);
|
|
375
|
+
const halfHeight = Math.round(height / 2);
|
|
376
|
+
const target = control.target.clone();
|
|
377
|
+
const device = vector3ToDevice(this.startPoi.position, camera, width, height);
|
|
378
|
+
const offsetX = device.x - halfWidth;
|
|
379
|
+
const offsetY = halfHeight - device.y + this.options.offsetY;
|
|
380
|
+
if (Math.abs(offsetX) <= 1 && Math.abs(offsetY) <= 1) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (Math.abs(offsetX) >= 1) {
|
|
384
|
+
const xv3 = new Vector3();
|
|
385
|
+
xv3.setFromMatrixColumn(camera.matrix, 0);
|
|
386
|
+
xv3.normalize();
|
|
387
|
+
xv3.multiplyScalar(offsetX / camera.zoom);
|
|
388
|
+
target.add(new Vector3(xv3.x, xv3.y, 0));
|
|
389
|
+
}
|
|
390
|
+
if (Math.abs(offsetY) >= 1) {
|
|
391
|
+
const v3 = new Vector3();
|
|
392
|
+
v3.setFromMatrixColumn(camera.matrix, 1);
|
|
393
|
+
v3.normalize();
|
|
394
|
+
v3.multiplyScalar(offsetY / camera.zoom);
|
|
395
|
+
target.add(new Vector3(v3.x, v3.y, 0));
|
|
396
|
+
}
|
|
397
|
+
return timeoutPromise(new Promise((resolve)=>{
|
|
398
|
+
const start = control.target.clone();
|
|
399
|
+
console.log(start, target, duration);
|
|
400
|
+
const tween = new Tween(start, this.tweenUtil.group).to(target, duration).onUpdate(()=>{
|
|
401
|
+
this.bmap.context.control.setCameraPositionByTarget(start, 0);
|
|
402
|
+
}).onComplete(()=>{
|
|
403
|
+
this.bmap.context.control.setCameraPositionByTarget(target, 0);
|
|
404
|
+
this.tweenUtil.remove(tween);
|
|
405
|
+
this.bmap.context.control.enabled = true;
|
|
406
|
+
resolve(true);
|
|
407
|
+
}).onStart(()=>{
|
|
408
|
+
this.bmap.context.control.enabled = false;
|
|
409
|
+
}).start();
|
|
410
|
+
}), duration + 500).then(()=>{
|
|
411
|
+
this.bmap.context.control.enabled = true;
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
async initCameraZoom(duration) {
|
|
415
|
+
if (duration === void 0) duration = 100;
|
|
416
|
+
if (!this.startPoi) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const { clientSize: { width, height }, currentFloor } = this.bmap.context;
|
|
420
|
+
const { max, min } = currentFloor.box;
|
|
421
|
+
const baseScale = Math.min(width / (max.x - min.x), height / (max.y - min.y));
|
|
422
|
+
const zoom = baseScale * (max.x - min.x) / 45;
|
|
423
|
+
return this.bmap.context.setZoom(zoom, this.startPoi.position, duration).finally(()=>{
|
|
424
|
+
this.bmap.context.control.enabled = true;
|
|
425
|
+
});
|
|
430
426
|
}
|
|
431
427
|
// 根据定位 实时导航
|
|
432
428
|
toPosition(floor, pos) {
|
|
@@ -440,83 +436,77 @@ export class Navigation extends Plugin {
|
|
|
440
436
|
setSimulationSpeed(speed) {
|
|
441
437
|
this.positionNavigation.changeSimulationSpeed(speed);
|
|
442
438
|
}
|
|
443
|
-
toPositionBySpeed(position, speed) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (_this.startPoi) {
|
|
505
|
-
_this.setStartPoiPosition(translatePos[0], translatePos[1]);
|
|
506
|
-
// this.startPoi.position.setX(translatePos[0]).setY(translatePos[1])
|
|
507
|
-
if (!_this.options.disablePathAnimation) {
|
|
508
|
-
_this.bmap.context.control.setTargetByOffset(_this.options.offsetY, _this.startPoi.position.clone());
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
if (!_this.options.disablePathAnimation) {
|
|
512
|
-
// 旋转方向
|
|
513
|
-
tween == null ? void 0 : tween.pause();
|
|
514
|
-
// this.positionNavigation.tweenUtil.pause()
|
|
515
|
-
yield _this.changeCameraToPathUp(500 / _this.options.speed);
|
|
516
|
-
// this.positionNavigation.tweenUtil.continue()
|
|
517
|
-
tween == null ? void 0 : tween.resume();
|
|
439
|
+
async toPositionBySpeed(position, speed) {
|
|
440
|
+
const { currentPathPosition, curFloorPath, curFloorPathPoints } = this;
|
|
441
|
+
if (!curFloorPath || !currentPathPosition) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
// 计算当前点在路线上的移动距离
|
|
445
|
+
const curDistance = this.movedDistance;
|
|
446
|
+
// 计算传入点在路线上的移动距离
|
|
447
|
+
const positionDistance = getDistanceByPathPos(curFloorPathPoints, position);
|
|
448
|
+
if (curDistance === -1 || positionDistance === -1) {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
// 传入点距离如果距离小于当前点距离就返回
|
|
452
|
+
if (positionDistance <= curDistance) {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
// 根据拐弯点切割路线
|
|
456
|
+
const distance = positionDistance - curDistance;
|
|
457
|
+
if (!distance) {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const time = Math.min(distance / speed, this.options.runAnimationMaxTime);
|
|
461
|
+
if (this.pathTween) {
|
|
462
|
+
this.clearTween();
|
|
463
|
+
}
|
|
464
|
+
// this.pathMoving = true;
|
|
465
|
+
// 根据移动的距离开始动画
|
|
466
|
+
return timeoutPromise(new Promise((resolve)=>{
|
|
467
|
+
const tween = this.pathTween = new Tween({
|
|
468
|
+
distance: 0
|
|
469
|
+
}, this.tweenUtil.group).to({
|
|
470
|
+
distance: distance
|
|
471
|
+
}, time * 1000).onUpdate(async (v)=>{
|
|
472
|
+
this.moveDistance(v.distance + curDistance, tween);
|
|
473
|
+
}).onComplete(()=>{
|
|
474
|
+
this.tweenUtil.remove(tween);
|
|
475
|
+
resolve(true);
|
|
476
|
+
}).start();
|
|
477
|
+
}), time * 1000 + 500).finally(()=>{
|
|
478
|
+
this.bmap.context.control.enabled = true;
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
async moveDistance(distance, tween) {
|
|
482
|
+
var _this_path;
|
|
483
|
+
this.movedDistance = distance;
|
|
484
|
+
(_this_path = this.path) == null ? void 0 : _this_path.movePath(this.movedDistance / this.curFloorPathLength);
|
|
485
|
+
// 获取移动后的位置
|
|
486
|
+
const pos = getPosByPathDistance(this.curFloorPathPoints, this.movedDistance);
|
|
487
|
+
if (pos === null) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
this.currentPathPosition = pos;
|
|
491
|
+
const translatePos = this.translatePoints([
|
|
492
|
+
pos
|
|
493
|
+
])[0];
|
|
494
|
+
// 平移相机
|
|
495
|
+
if (this.startPoi) {
|
|
496
|
+
this.setStartPoiPosition(translatePos[0], translatePos[1]);
|
|
497
|
+
// this.startPoi.position.setX(translatePos[0]).setY(translatePos[1])
|
|
498
|
+
if (!this.options.disablePathAnimation) {
|
|
499
|
+
this.bmap.context.control.setTargetByOffset(this.options.offsetY, this.startPoi.position.clone());
|
|
518
500
|
}
|
|
519
|
-
}
|
|
501
|
+
}
|
|
502
|
+
if (!this.options.disablePathAnimation) {
|
|
503
|
+
// 旋转方向
|
|
504
|
+
tween == null ? void 0 : tween.pause();
|
|
505
|
+
// this.positionNavigation.tweenUtil.pause()
|
|
506
|
+
await this.changeCameraToPathUp(500 / this.options.speed);
|
|
507
|
+
// this.positionNavigation.tweenUtil.continue()
|
|
508
|
+
tween == null ? void 0 : tween.resume();
|
|
509
|
+
}
|
|
520
510
|
}
|
|
521
511
|
setStartPoiRotate(rotate) {
|
|
522
512
|
this.startPoiRotate = rotate;
|
|
@@ -556,7 +546,8 @@ export class Navigation extends Plugin {
|
|
|
556
546
|
this.animationPathOptions = {
|
|
557
547
|
cPathIndex: 0
|
|
558
548
|
}, this.cPath = [] // 当前楼层的平滑后的路线
|
|
559
|
-
, this.onNavigationInfo = (
|
|
549
|
+
, this.onNavigationInfo = (param)=>{
|
|
550
|
+
let { info } = param;
|
|
560
551
|
this.dispatchEvent({
|
|
561
552
|
type: "navigation-info",
|
|
562
553
|
info
|
|
@@ -571,7 +562,8 @@ export class Navigation extends Plugin {
|
|
|
571
562
|
}
|
|
572
563
|
}, this.onUpdate = ()=>{
|
|
573
564
|
this.tweenUtil.update();
|
|
574
|
-
}, this.onSwitchFloor = (
|
|
565
|
+
}, this.onSwitchFloor = (param)=>{
|
|
566
|
+
let { data: { curFloor } } = param;
|
|
575
567
|
this.clearTween();
|
|
576
568
|
if (this.paths[this.curPathIndex]) {
|
|
577
569
|
const curFloorPathData = this.paths[this.curPathIndex];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
|
+
import "core-js/modules/es.array.push.js";
|
|
2
3
|
import { Mesh, Object3D, TextureLoader, Color, Vector2, Vector3, NormalBlending, RepeatWrapping } from "three";
|
|
3
4
|
// @ts-ignore
|
|
4
5
|
import { MeshLine, MeshLineMaterial } from "../../external/meshLine";
|
|
@@ -36,10 +37,16 @@ export class Path extends Object3D {
|
|
|
36
37
|
}
|
|
37
38
|
getRepeat() {
|
|
38
39
|
const { points, navigation: { bmap: { context: { camera, clientSize: { width, height } } } } } = this;
|
|
39
|
-
const screenPoints = points.map((
|
|
40
|
+
const screenPoints = points.map((param)=>{
|
|
41
|
+
let [x, y] = param;
|
|
42
|
+
return vector3ToDevice(new Vector3(x, y, 0), camera, width, height);
|
|
43
|
+
}).map((param)=>{
|
|
44
|
+
let { x, y } = param;
|
|
45
|
+
return [
|
|
40
46
|
x,
|
|
41
47
|
y
|
|
42
|
-
]
|
|
48
|
+
];
|
|
49
|
+
});
|
|
43
50
|
const pointLength = getPathLength(screenPoints);
|
|
44
51
|
return pointLength / 32;
|
|
45
52
|
}
|
|
@@ -77,33 +84,30 @@ export class Path extends Object3D {
|
|
|
77
84
|
}
|
|
78
85
|
this.material.thresholdRatio = ratio;
|
|
79
86
|
}
|
|
80
|
-
create(points) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
_this.add(mesh);
|
|
105
|
-
return mesh;
|
|
106
|
-
})();
|
|
87
|
+
async create(points) {
|
|
88
|
+
const lineGeometry = this.geometry = new MeshLine();
|
|
89
|
+
this.updatePoints(points);
|
|
90
|
+
if (!this.texture) {
|
|
91
|
+
const texture = this.texture = await this.loadTexture(this.config.texture_url);
|
|
92
|
+
texture.wrapS = texture.wrapT = RepeatWrapping;
|
|
93
|
+
}
|
|
94
|
+
const material = this.material = new MeshLineMaterial({
|
|
95
|
+
useMap: true,
|
|
96
|
+
color: new Color(this.config.color),
|
|
97
|
+
transparent: true,
|
|
98
|
+
resolution: new Vector2(this.navigation.bmap.context.clientSize.width, this.navigation.bmap.context.clientSize.height),
|
|
99
|
+
depthTest: this.depthTest,
|
|
100
|
+
sizeAttenuation: false,
|
|
101
|
+
lineWidth: this.config.lineWidth * 2,
|
|
102
|
+
map: this.texture,
|
|
103
|
+
blending: NormalBlending,
|
|
104
|
+
repeat: new Vector2(this.getRepeat(), 1)
|
|
105
|
+
});
|
|
106
|
+
// 生成模型
|
|
107
|
+
const mesh = this.mesh = new Mesh(lineGeometry, material);
|
|
108
|
+
mesh.renderOrder = 9;
|
|
109
|
+
this.add(mesh);
|
|
110
|
+
return mesh;
|
|
107
111
|
}
|
|
108
112
|
dispose() {
|
|
109
113
|
var _this_geometry, _this_material, _this_texture;
|