Show distance labels for points placed by pathfinding
This commit is contained in:
@@ -166,13 +166,17 @@ export function measure(destination, options={}) {
|
||||
}
|
||||
|
||||
// Remove waypoints generated by pathfinding
|
||||
this.waypoints.filter(waypoint => waypoint.isPathfinding).forEach(_ => this.labels.removeChild(this.labels.children.pop()));
|
||||
this.waypoints = this.waypoints.filter(waypoint => !waypoint.isPathfinding);
|
||||
|
||||
if (isToken && options.pathfinding) {
|
||||
let path = findPath(getGridPositionFromPixelsObj(this.waypoints[this.waypoints.length - 1]), getGridPositionFromPixelsObj(destination));
|
||||
if (path) {
|
||||
path = path.map(point => getCenterFromGridPositionObj(point));
|
||||
path.forEach(point => point.isPathfinding = true);
|
||||
for (const point of path) {
|
||||
point.isPathfinding = true;
|
||||
this.labels.addChild(new PreciseText("", CONFIG.canvasTextStyle));
|
||||
}
|
||||
this.waypoints = this.waypoints.concat(path);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user