@aibee/crc-bmap 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/bmap.esm.js CHANGED
@@ -8399,7 +8399,6 @@ var PositionNavigation = class extends EventDispatcher10 {
8399
8399
  onAddPaths = ({ paths }) => {
8400
8400
  this.paths = paths;
8401
8401
  this.resetStatus(paths);
8402
- this.emitNavigationStatus();
8403
8402
  };
8404
8403
  onUpdate = () => {
8405
8404
  this.tweenUtil.update();
@@ -8442,12 +8441,16 @@ var PositionNavigation = class extends EventDispatcher10 {
8442
8441
  ...allPath.slice(routeIndex + 1)
8443
8442
  ];
8444
8443
  const { distance, closestPoint, index, i } = paths.reduce((obj, cur, index2) => {
8444
+ console.log("cur", cur.floor, floor);
8445
8445
  if (cur.floor !== floor) {
8446
8446
  return obj;
8447
8447
  }
8448
8448
  const { distance: distance2, closestPoint: closestPoint2, index: i2 } = cur.points.reduce((obj2, cur2, index3, arr) => {
8449
8449
  if (!arr[index3 + 1]) {
8450
- return obj2;
8450
+ return {
8451
+ ...obj2,
8452
+ distance: obj2.distance === Infinity ? getLength(cur2, _position) : obj2.distance
8453
+ };
8451
8454
  }
8452
8455
  const { distance: distance3, closestPoint: closestPoint3 } = distancePointToSegment(_position, cur2, arr[index3 + 1]);
8453
8456
  if (distance3 < obj2.distance) {
@@ -8464,6 +8467,7 @@ var PositionNavigation = class extends EventDispatcher10 {
8464
8467
  }
8465
8468
  toPosition(floor, pos) {
8466
8469
  const adsorbData = this.adsorb(floor, pos);
8470
+ console.log("adsorbData", adsorbData);
8467
8471
  if (!adsorbData) {
8468
8472
  return;
8469
8473
  }
@@ -8481,6 +8485,7 @@ var PositionNavigation = class extends EventDispatcher10 {
8481
8485
  this.reset = false;
8482
8486
  if (this.resetTimer) {
8483
8487
  this.timer.clearTimeout(this.resetTimer);
8488
+ this.resetTimer = null;
8484
8489
  }
8485
8490
  }
8486
8491
  this.routeIndex = routeIndex;
@@ -8516,6 +8521,8 @@ var PositionNavigation = class extends EventDispatcher10 {
8516
8521
  }, 200);
8517
8522
  const tween = this.simulationTween = new Tween3({ distance: 0 }, this.tweenUtil.group).to({ distance }, time * 1e3).onUpdate(onUpdate).onComplete(() => {
8518
8523
  this.tweenUtil.remove(tween);
8524
+ onUpdate.flush();
8525
+ onUpdate.cancel();
8519
8526
  if (this.routeIndex + 1 < this.paths.length) {
8520
8527
  this.routeIndex++;
8521
8528
  this.position = this.paths[this.routeIndex].points[0];
@@ -8523,7 +8530,7 @@ var PositionNavigation = class extends EventDispatcher10 {
8523
8530
  resolve(this.startCurRouteSimulation());
8524
8531
  } else {
8525
8532
  resolve(true);
8526
- console.log(arr);
8533
+ console.log(arr, this.routeIndex, this.paths);
8527
8534
  }
8528
8535
  }).start();
8529
8536
  });
@@ -8560,7 +8567,7 @@ var PositionNavigation = class extends EventDispatcher10 {
8560
8567
  const p2 = curRoutePathPoints[pointIndex + 1];
8561
8568
  const p3 = curRoutePathPoints[pointIndex + 2];
8562
8569
  if (!p1 || !p2) {
8563
- return null;
8570
+ return { dir: "end" /* END */, distance: 0 };
8564
8571
  }
8565
8572
  const distance = getLength(position, p2);
8566
8573
  if (pointIndex === 0) {
@@ -8691,7 +8698,7 @@ var Navigation = class extends Plugin {
8691
8698
  if (!this.toPositionPromise) {
8692
8699
  this.toPositionPromise = this.toPositionBySpeed(info.pos, this.options.speed);
8693
8700
  } else {
8694
- this.toPositionPromise.then(() => {
8701
+ this.toPositionPromise.finally(() => {
8695
8702
  return this.toPositionBySpeed(info.pos, this.options.speed);
8696
8703
  });
8697
8704
  }
@@ -8742,7 +8749,7 @@ var Navigation = class extends Plugin {
8742
8749
  this.currentPathPosition = path.points[0];
8743
8750
  }
8744
8751
  this.movedDistance = 0;
8745
- this.toPositionPromise = null;
8752
+ this.clearTween();
8746
8753
  }
8747
8754
  setCurPathIndex(index) {
8748
8755
  this.curPathIndex = index;
@@ -8997,14 +9004,14 @@ var Navigation = class extends Plugin {
8997
9004
  if (this.pathTween) {
8998
9005
  this.clearTween();
8999
9006
  }
9000
- return new Promise((resolve) => {
9007
+ return timeoutPromise(new Promise((resolve) => {
9001
9008
  const tween = this.pathTween = new Tween4({ distance: 0 }, this.tweenUtil.group).to({ distance }, time * 1e3).onUpdate(async (v) => {
9002
9009
  this.moveDistance(v.distance + curDistance, tween);
9003
9010
  }).onComplete(() => {
9004
9011
  this.tweenUtil.remove(tween);
9005
9012
  resolve(true);
9006
9013
  }).start();
9007
- });
9014
+ }), time * 1e3 + 500);
9008
9015
  }
9009
9016
  async moveDistance(distance, tween) {
9010
9017
  this.movedDistance = distance;