microboard-temp 0.5.82 → 0.5.84
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/dist/cjs/browser.js +40 -73
- package/dist/cjs/index.js +40 -73
- package/dist/cjs/node.js +40 -73
- package/dist/esm/browser.js +40 -73
- package/dist/esm/index.js +40 -73
- package/dist/esm/node.js +40 -73
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -36934,85 +36934,52 @@ function reconstructPath(node2) {
|
|
|
36934
36934
|
}
|
|
36935
36935
|
return path2.reverse();
|
|
36936
36936
|
}
|
|
36937
|
-
function
|
|
36938
|
-
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
let startPoint = start;
|
|
36942
|
-
let endPoint = end;
|
|
36943
|
-
const stemWaypoints = [];
|
|
36944
|
-
const allWaypoints = [];
|
|
36945
|
-
const processPoint = (point5, dir2) => {
|
|
36946
|
-
if (point5.pointType === "Board") {
|
|
36947
|
-
return point5;
|
|
36948
|
-
}
|
|
36949
|
-
const offsetMap = {
|
|
36950
|
-
top: { x: 0, y: -offset },
|
|
36951
|
-
bottom: { x: 0, y: offset },
|
|
36952
|
-
right: { x: offset, y: 0 },
|
|
36953
|
-
left: { x: -offset, y: 0 }
|
|
36954
|
-
};
|
|
36955
|
-
const itemMbr = point5.item.getMbr();
|
|
36956
|
-
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36957
|
-
const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36958
|
-
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36959
|
-
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36960
|
-
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36961
|
-
return newPoint;
|
|
36962
|
-
};
|
|
36963
|
-
if (start.pointType !== "Board" && startDir) {
|
|
36964
|
-
startPoint = processPoint(start, startDir);
|
|
36937
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36938
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36939
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36940
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36965
36941
|
}
|
|
36966
|
-
if (
|
|
36967
|
-
|
|
36968
|
-
|
|
36969
|
-
|
|
36970
|
-
|
|
36971
|
-
|
|
36972
|
-
|
|
36973
|
-
|
|
36974
|
-
|
|
36975
|
-
|
|
36976
|
-
|
|
36977
|
-
|
|
36978
|
-
|
|
36979
|
-
|
|
36980
|
-
|
|
36981
|
-
|
|
36982
|
-
|
|
36983
|
-
|
|
36984
|
-
|
|
36985
|
-
stem = new Point(endPoint.x + offset, endPoint.y);
|
|
36986
|
-
else if (endDir === "left")
|
|
36987
|
-
stem = new Point(endPoint.x - offset, endPoint.y);
|
|
36988
|
-
else if (endDir === "bottom")
|
|
36989
|
-
stem = new Point(endPoint.x, endPoint.y + offset);
|
|
36990
|
-
else
|
|
36991
|
-
stem = new Point(endPoint.x, endPoint.y - offset);
|
|
36992
|
-
stemWaypoints.push(stem);
|
|
36993
|
-
allWaypoints.push(stem);
|
|
36942
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36943
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36944
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36945
|
+
}
|
|
36946
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36947
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36948
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36949
|
+
}
|
|
36950
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36951
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36952
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36953
|
+
}
|
|
36954
|
+
const dx = endPoint.x - startPoint.x;
|
|
36955
|
+
const dy = endPoint.y - startPoint.y;
|
|
36956
|
+
if (startDir === "right" && dx < 0) {
|
|
36957
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36958
|
+
}
|
|
36959
|
+
if (startDir === "left" && dx > 0) {
|
|
36960
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36994
36961
|
}
|
|
36995
|
-
|
|
36962
|
+
if (startDir === "bottom" && dy < 0) {
|
|
36963
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36964
|
+
}
|
|
36965
|
+
if (startDir === "top" && dy > 0) {
|
|
36966
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36967
|
+
}
|
|
36968
|
+
return [];
|
|
36996
36969
|
}
|
|
36997
36970
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36998
|
-
const {
|
|
36999
|
-
const
|
|
37000
|
-
const
|
|
37001
|
-
|
|
37002
|
-
|
|
37003
|
-
|
|
37004
|
-
|
|
37005
|
-
|
|
37006
|
-
if (stemWaypoints.length > 1) {
|
|
37007
|
-
finalWaypoints.push(stemWaypoints[1]);
|
|
37008
|
-
}
|
|
37009
|
-
finalWaypoints.push(endPoint);
|
|
37010
|
-
const uniqueWaypoints = finalWaypoints.filter((point5, index2, self2) => index2 === 0 || !point5.barelyEqual(self2[index2 - 1]));
|
|
37011
|
-
const pathPoints = findPathPoints(uniqueWaypoints, grid, obstacles, newStart, newEnd);
|
|
36971
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36972
|
+
const startPoint = newStart || start;
|
|
36973
|
+
const endPoint = newEnd || end;
|
|
36974
|
+
const startDir = getPointerDirection(start);
|
|
36975
|
+
const endDir = getPointerDirection(end);
|
|
36976
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36977
|
+
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36978
|
+
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
37012
36979
|
return {
|
|
37013
36980
|
lines: getLines(pathPoints),
|
|
37014
|
-
newStart
|
|
37015
|
-
newEnd
|
|
36981
|
+
newStart,
|
|
36982
|
+
newEnd
|
|
37016
36983
|
};
|
|
37017
36984
|
}
|
|
37018
36985
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -36934,85 +36934,52 @@ function reconstructPath(node2) {
|
|
|
36934
36934
|
}
|
|
36935
36935
|
return path2.reverse();
|
|
36936
36936
|
}
|
|
36937
|
-
function
|
|
36938
|
-
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
let startPoint = start;
|
|
36942
|
-
let endPoint = end;
|
|
36943
|
-
const stemWaypoints = [];
|
|
36944
|
-
const allWaypoints = [];
|
|
36945
|
-
const processPoint = (point5, dir2) => {
|
|
36946
|
-
if (point5.pointType === "Board") {
|
|
36947
|
-
return point5;
|
|
36948
|
-
}
|
|
36949
|
-
const offsetMap = {
|
|
36950
|
-
top: { x: 0, y: -offset },
|
|
36951
|
-
bottom: { x: 0, y: offset },
|
|
36952
|
-
right: { x: offset, y: 0 },
|
|
36953
|
-
left: { x: -offset, y: 0 }
|
|
36954
|
-
};
|
|
36955
|
-
const itemMbr = point5.item.getMbr();
|
|
36956
|
-
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36957
|
-
const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36958
|
-
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36959
|
-
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36960
|
-
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36961
|
-
return newPoint;
|
|
36962
|
-
};
|
|
36963
|
-
if (start.pointType !== "Board" && startDir) {
|
|
36964
|
-
startPoint = processPoint(start, startDir);
|
|
36937
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36938
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36939
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36940
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36965
36941
|
}
|
|
36966
|
-
if (
|
|
36967
|
-
|
|
36968
|
-
|
|
36969
|
-
|
|
36970
|
-
|
|
36971
|
-
|
|
36972
|
-
|
|
36973
|
-
|
|
36974
|
-
|
|
36975
|
-
|
|
36976
|
-
|
|
36977
|
-
|
|
36978
|
-
|
|
36979
|
-
|
|
36980
|
-
|
|
36981
|
-
|
|
36982
|
-
|
|
36983
|
-
|
|
36984
|
-
|
|
36985
|
-
stem = new Point(endPoint.x + offset, endPoint.y);
|
|
36986
|
-
else if (endDir === "left")
|
|
36987
|
-
stem = new Point(endPoint.x - offset, endPoint.y);
|
|
36988
|
-
else if (endDir === "bottom")
|
|
36989
|
-
stem = new Point(endPoint.x, endPoint.y + offset);
|
|
36990
|
-
else
|
|
36991
|
-
stem = new Point(endPoint.x, endPoint.y - offset);
|
|
36992
|
-
stemWaypoints.push(stem);
|
|
36993
|
-
allWaypoints.push(stem);
|
|
36942
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36943
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36944
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36945
|
+
}
|
|
36946
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36947
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36948
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36949
|
+
}
|
|
36950
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36951
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36952
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36953
|
+
}
|
|
36954
|
+
const dx = endPoint.x - startPoint.x;
|
|
36955
|
+
const dy = endPoint.y - startPoint.y;
|
|
36956
|
+
if (startDir === "right" && dx < 0) {
|
|
36957
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36958
|
+
}
|
|
36959
|
+
if (startDir === "left" && dx > 0) {
|
|
36960
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36994
36961
|
}
|
|
36995
|
-
|
|
36962
|
+
if (startDir === "bottom" && dy < 0) {
|
|
36963
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36964
|
+
}
|
|
36965
|
+
if (startDir === "top" && dy > 0) {
|
|
36966
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36967
|
+
}
|
|
36968
|
+
return [];
|
|
36996
36969
|
}
|
|
36997
36970
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36998
|
-
const {
|
|
36999
|
-
const
|
|
37000
|
-
const
|
|
37001
|
-
|
|
37002
|
-
|
|
37003
|
-
|
|
37004
|
-
|
|
37005
|
-
|
|
37006
|
-
if (stemWaypoints.length > 1) {
|
|
37007
|
-
finalWaypoints.push(stemWaypoints[1]);
|
|
37008
|
-
}
|
|
37009
|
-
finalWaypoints.push(endPoint);
|
|
37010
|
-
const uniqueWaypoints = finalWaypoints.filter((point5, index2, self2) => index2 === 0 || !point5.barelyEqual(self2[index2 - 1]));
|
|
37011
|
-
const pathPoints = findPathPoints(uniqueWaypoints, grid, obstacles, newStart, newEnd);
|
|
36971
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36972
|
+
const startPoint = newStart || start;
|
|
36973
|
+
const endPoint = newEnd || end;
|
|
36974
|
+
const startDir = getPointerDirection(start);
|
|
36975
|
+
const endDir = getPointerDirection(end);
|
|
36976
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36977
|
+
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36978
|
+
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
37012
36979
|
return {
|
|
37013
36980
|
lines: getLines(pathPoints),
|
|
37014
|
-
newStart
|
|
37015
|
-
newEnd
|
|
36981
|
+
newStart,
|
|
36982
|
+
newEnd
|
|
37016
36983
|
};
|
|
37017
36984
|
}
|
|
37018
36985
|
|
package/dist/cjs/node.js
CHANGED
|
@@ -39407,85 +39407,52 @@ function reconstructPath(node2) {
|
|
|
39407
39407
|
}
|
|
39408
39408
|
return path2.reverse();
|
|
39409
39409
|
}
|
|
39410
|
-
function
|
|
39411
|
-
|
|
39412
|
-
|
|
39413
|
-
|
|
39414
|
-
let startPoint = start;
|
|
39415
|
-
let endPoint = end;
|
|
39416
|
-
const stemWaypoints = [];
|
|
39417
|
-
const allWaypoints = [];
|
|
39418
|
-
const processPoint = (point5, dir2) => {
|
|
39419
|
-
if (point5.pointType === "Board") {
|
|
39420
|
-
return point5;
|
|
39421
|
-
}
|
|
39422
|
-
const offsetMap = {
|
|
39423
|
-
top: { x: 0, y: -offset },
|
|
39424
|
-
bottom: { x: 0, y: offset },
|
|
39425
|
-
right: { x: offset, y: 0 },
|
|
39426
|
-
left: { x: -offset, y: 0 }
|
|
39427
|
-
};
|
|
39428
|
-
const itemMbr = point5.item.getMbr();
|
|
39429
|
-
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
39430
|
-
const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
39431
|
-
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
39432
|
-
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
39433
|
-
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
39434
|
-
return newPoint;
|
|
39435
|
-
};
|
|
39436
|
-
if (start.pointType !== "Board" && startDir) {
|
|
39437
|
-
startPoint = processPoint(start, startDir);
|
|
39410
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
39411
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
39412
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39413
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39438
39414
|
}
|
|
39439
|
-
if (
|
|
39440
|
-
|
|
39441
|
-
|
|
39442
|
-
|
|
39443
|
-
|
|
39444
|
-
|
|
39445
|
-
|
|
39446
|
-
|
|
39447
|
-
|
|
39448
|
-
|
|
39449
|
-
|
|
39450
|
-
|
|
39451
|
-
|
|
39452
|
-
|
|
39453
|
-
|
|
39454
|
-
|
|
39455
|
-
|
|
39456
|
-
|
|
39457
|
-
|
|
39458
|
-
stem = new Point(endPoint.x + offset, endPoint.y);
|
|
39459
|
-
else if (endDir === "left")
|
|
39460
|
-
stem = new Point(endPoint.x - offset, endPoint.y);
|
|
39461
|
-
else if (endDir === "bottom")
|
|
39462
|
-
stem = new Point(endPoint.x, endPoint.y + offset);
|
|
39463
|
-
else
|
|
39464
|
-
stem = new Point(endPoint.x, endPoint.y - offset);
|
|
39465
|
-
stemWaypoints.push(stem);
|
|
39466
|
-
allWaypoints.push(stem);
|
|
39415
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
39416
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39417
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39418
|
+
}
|
|
39419
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
39420
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39421
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39422
|
+
}
|
|
39423
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
39424
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39425
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39426
|
+
}
|
|
39427
|
+
const dx = endPoint.x - startPoint.x;
|
|
39428
|
+
const dy = endPoint.y - startPoint.y;
|
|
39429
|
+
if (startDir === "right" && dx < 0) {
|
|
39430
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
39431
|
+
}
|
|
39432
|
+
if (startDir === "left" && dx > 0) {
|
|
39433
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
39467
39434
|
}
|
|
39468
|
-
|
|
39435
|
+
if (startDir === "bottom" && dy < 0) {
|
|
39436
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
39437
|
+
}
|
|
39438
|
+
if (startDir === "top" && dy > 0) {
|
|
39439
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
39440
|
+
}
|
|
39441
|
+
return [];
|
|
39469
39442
|
}
|
|
39470
39443
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
39471
|
-
const {
|
|
39472
|
-
const
|
|
39473
|
-
const
|
|
39474
|
-
|
|
39475
|
-
|
|
39476
|
-
|
|
39477
|
-
|
|
39478
|
-
|
|
39479
|
-
if (stemWaypoints.length > 1) {
|
|
39480
|
-
finalWaypoints.push(stemWaypoints[1]);
|
|
39481
|
-
}
|
|
39482
|
-
finalWaypoints.push(endPoint);
|
|
39483
|
-
const uniqueWaypoints = finalWaypoints.filter((point5, index2, self2) => index2 === 0 || !point5.barelyEqual(self2[index2 - 1]));
|
|
39484
|
-
const pathPoints = findPathPoints(uniqueWaypoints, grid, obstacles, newStart, newEnd);
|
|
39444
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
39445
|
+
const startPoint = newStart || start;
|
|
39446
|
+
const endPoint = newEnd || end;
|
|
39447
|
+
const startDir = getPointerDirection(start);
|
|
39448
|
+
const endDir = getPointerDirection(end);
|
|
39449
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
39450
|
+
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
39451
|
+
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
39485
39452
|
return {
|
|
39486
39453
|
lines: getLines(pathPoints),
|
|
39487
|
-
newStart
|
|
39488
|
-
newEnd
|
|
39454
|
+
newStart,
|
|
39455
|
+
newEnd
|
|
39489
39456
|
};
|
|
39490
39457
|
}
|
|
39491
39458
|
|
package/dist/esm/browser.js
CHANGED
|
@@ -36779,85 +36779,52 @@ function reconstructPath(node2) {
|
|
|
36779
36779
|
}
|
|
36780
36780
|
return path2.reverse();
|
|
36781
36781
|
}
|
|
36782
|
-
function
|
|
36783
|
-
|
|
36784
|
-
|
|
36785
|
-
|
|
36786
|
-
let startPoint = start;
|
|
36787
|
-
let endPoint = end;
|
|
36788
|
-
const stemWaypoints = [];
|
|
36789
|
-
const allWaypoints = [];
|
|
36790
|
-
const processPoint = (point5, dir2) => {
|
|
36791
|
-
if (point5.pointType === "Board") {
|
|
36792
|
-
return point5;
|
|
36793
|
-
}
|
|
36794
|
-
const offsetMap = {
|
|
36795
|
-
top: { x: 0, y: -offset },
|
|
36796
|
-
bottom: { x: 0, y: offset },
|
|
36797
|
-
right: { x: offset, y: 0 },
|
|
36798
|
-
left: { x: -offset, y: 0 }
|
|
36799
|
-
};
|
|
36800
|
-
const itemMbr = point5.item.getMbr();
|
|
36801
|
-
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36802
|
-
const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36803
|
-
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36804
|
-
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36805
|
-
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36806
|
-
return newPoint;
|
|
36807
|
-
};
|
|
36808
|
-
if (start.pointType !== "Board" && startDir) {
|
|
36809
|
-
startPoint = processPoint(start, startDir);
|
|
36782
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36783
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36784
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36785
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36810
36786
|
}
|
|
36811
|
-
if (
|
|
36812
|
-
|
|
36813
|
-
|
|
36814
|
-
|
|
36815
|
-
|
|
36816
|
-
|
|
36817
|
-
|
|
36818
|
-
|
|
36819
|
-
|
|
36820
|
-
|
|
36821
|
-
|
|
36822
|
-
|
|
36823
|
-
|
|
36824
|
-
|
|
36825
|
-
|
|
36826
|
-
|
|
36827
|
-
|
|
36828
|
-
|
|
36829
|
-
|
|
36830
|
-
stem = new Point(endPoint.x + offset, endPoint.y);
|
|
36831
|
-
else if (endDir === "left")
|
|
36832
|
-
stem = new Point(endPoint.x - offset, endPoint.y);
|
|
36833
|
-
else if (endDir === "bottom")
|
|
36834
|
-
stem = new Point(endPoint.x, endPoint.y + offset);
|
|
36835
|
-
else
|
|
36836
|
-
stem = new Point(endPoint.x, endPoint.y - offset);
|
|
36837
|
-
stemWaypoints.push(stem);
|
|
36838
|
-
allWaypoints.push(stem);
|
|
36787
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36788
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36789
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36790
|
+
}
|
|
36791
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36792
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36793
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36794
|
+
}
|
|
36795
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36796
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36797
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36798
|
+
}
|
|
36799
|
+
const dx = endPoint.x - startPoint.x;
|
|
36800
|
+
const dy = endPoint.y - startPoint.y;
|
|
36801
|
+
if (startDir === "right" && dx < 0) {
|
|
36802
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36803
|
+
}
|
|
36804
|
+
if (startDir === "left" && dx > 0) {
|
|
36805
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36839
36806
|
}
|
|
36840
|
-
|
|
36807
|
+
if (startDir === "bottom" && dy < 0) {
|
|
36808
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36809
|
+
}
|
|
36810
|
+
if (startDir === "top" && dy > 0) {
|
|
36811
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36812
|
+
}
|
|
36813
|
+
return [];
|
|
36841
36814
|
}
|
|
36842
36815
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36843
|
-
const {
|
|
36844
|
-
const
|
|
36845
|
-
const
|
|
36846
|
-
|
|
36847
|
-
|
|
36848
|
-
|
|
36849
|
-
|
|
36850
|
-
|
|
36851
|
-
if (stemWaypoints.length > 1) {
|
|
36852
|
-
finalWaypoints.push(stemWaypoints[1]);
|
|
36853
|
-
}
|
|
36854
|
-
finalWaypoints.push(endPoint);
|
|
36855
|
-
const uniqueWaypoints = finalWaypoints.filter((point5, index2, self2) => index2 === 0 || !point5.barelyEqual(self2[index2 - 1]));
|
|
36856
|
-
const pathPoints = findPathPoints(uniqueWaypoints, grid, obstacles, newStart, newEnd);
|
|
36816
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36817
|
+
const startPoint = newStart || start;
|
|
36818
|
+
const endPoint = newEnd || end;
|
|
36819
|
+
const startDir = getPointerDirection(start);
|
|
36820
|
+
const endDir = getPointerDirection(end);
|
|
36821
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36822
|
+
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36823
|
+
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36857
36824
|
return {
|
|
36858
36825
|
lines: getLines(pathPoints),
|
|
36859
|
-
newStart
|
|
36860
|
-
newEnd
|
|
36826
|
+
newStart,
|
|
36827
|
+
newEnd
|
|
36861
36828
|
};
|
|
36862
36829
|
}
|
|
36863
36830
|
|
package/dist/esm/index.js
CHANGED
|
@@ -36772,85 +36772,52 @@ function reconstructPath(node2) {
|
|
|
36772
36772
|
}
|
|
36773
36773
|
return path2.reverse();
|
|
36774
36774
|
}
|
|
36775
|
-
function
|
|
36776
|
-
|
|
36777
|
-
|
|
36778
|
-
|
|
36779
|
-
let startPoint = start;
|
|
36780
|
-
let endPoint = end;
|
|
36781
|
-
const stemWaypoints = [];
|
|
36782
|
-
const allWaypoints = [];
|
|
36783
|
-
const processPoint = (point5, dir2) => {
|
|
36784
|
-
if (point5.pointType === "Board") {
|
|
36785
|
-
return point5;
|
|
36786
|
-
}
|
|
36787
|
-
const offsetMap = {
|
|
36788
|
-
top: { x: 0, y: -offset },
|
|
36789
|
-
bottom: { x: 0, y: offset },
|
|
36790
|
-
right: { x: offset, y: 0 },
|
|
36791
|
-
left: { x: -offset, y: 0 }
|
|
36792
|
-
};
|
|
36793
|
-
const itemMbr = point5.item.getMbr();
|
|
36794
|
-
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36795
|
-
const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36796
|
-
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36797
|
-
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36798
|
-
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36799
|
-
return newPoint;
|
|
36800
|
-
};
|
|
36801
|
-
if (start.pointType !== "Board" && startDir) {
|
|
36802
|
-
startPoint = processPoint(start, startDir);
|
|
36775
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36776
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36777
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36778
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36803
36779
|
}
|
|
36804
|
-
if (
|
|
36805
|
-
|
|
36806
|
-
|
|
36807
|
-
|
|
36808
|
-
|
|
36809
|
-
|
|
36810
|
-
|
|
36811
|
-
|
|
36812
|
-
|
|
36813
|
-
|
|
36814
|
-
|
|
36815
|
-
|
|
36816
|
-
|
|
36817
|
-
|
|
36818
|
-
|
|
36819
|
-
|
|
36820
|
-
|
|
36821
|
-
|
|
36822
|
-
|
|
36823
|
-
stem = new Point(endPoint.x + offset, endPoint.y);
|
|
36824
|
-
else if (endDir === "left")
|
|
36825
|
-
stem = new Point(endPoint.x - offset, endPoint.y);
|
|
36826
|
-
else if (endDir === "bottom")
|
|
36827
|
-
stem = new Point(endPoint.x, endPoint.y + offset);
|
|
36828
|
-
else
|
|
36829
|
-
stem = new Point(endPoint.x, endPoint.y - offset);
|
|
36830
|
-
stemWaypoints.push(stem);
|
|
36831
|
-
allWaypoints.push(stem);
|
|
36780
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36781
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36782
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36783
|
+
}
|
|
36784
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36785
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36786
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36787
|
+
}
|
|
36788
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36789
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36790
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36791
|
+
}
|
|
36792
|
+
const dx = endPoint.x - startPoint.x;
|
|
36793
|
+
const dy = endPoint.y - startPoint.y;
|
|
36794
|
+
if (startDir === "right" && dx < 0) {
|
|
36795
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36796
|
+
}
|
|
36797
|
+
if (startDir === "left" && dx > 0) {
|
|
36798
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
36832
36799
|
}
|
|
36833
|
-
|
|
36800
|
+
if (startDir === "bottom" && dy < 0) {
|
|
36801
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36802
|
+
}
|
|
36803
|
+
if (startDir === "top" && dy > 0) {
|
|
36804
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
36805
|
+
}
|
|
36806
|
+
return [];
|
|
36834
36807
|
}
|
|
36835
36808
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36836
|
-
const {
|
|
36837
|
-
const
|
|
36838
|
-
const
|
|
36839
|
-
|
|
36840
|
-
|
|
36841
|
-
|
|
36842
|
-
|
|
36843
|
-
|
|
36844
|
-
if (stemWaypoints.length > 1) {
|
|
36845
|
-
finalWaypoints.push(stemWaypoints[1]);
|
|
36846
|
-
}
|
|
36847
|
-
finalWaypoints.push(endPoint);
|
|
36848
|
-
const uniqueWaypoints = finalWaypoints.filter((point5, index2, self2) => index2 === 0 || !point5.barelyEqual(self2[index2 - 1]));
|
|
36849
|
-
const pathPoints = findPathPoints(uniqueWaypoints, grid, obstacles, newStart, newEnd);
|
|
36809
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36810
|
+
const startPoint = newStart || start;
|
|
36811
|
+
const endPoint = newEnd || end;
|
|
36812
|
+
const startDir = getPointerDirection(start);
|
|
36813
|
+
const endDir = getPointerDirection(end);
|
|
36814
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36815
|
+
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36816
|
+
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36850
36817
|
return {
|
|
36851
36818
|
lines: getLines(pathPoints),
|
|
36852
|
-
newStart
|
|
36853
|
-
newEnd
|
|
36819
|
+
newStart,
|
|
36820
|
+
newEnd
|
|
36854
36821
|
};
|
|
36855
36822
|
}
|
|
36856
36823
|
|
package/dist/esm/node.js
CHANGED
|
@@ -39240,85 +39240,52 @@ function reconstructPath(node2) {
|
|
|
39240
39240
|
}
|
|
39241
39241
|
return path2.reverse();
|
|
39242
39242
|
}
|
|
39243
|
-
function
|
|
39244
|
-
|
|
39245
|
-
|
|
39246
|
-
|
|
39247
|
-
let startPoint = start;
|
|
39248
|
-
let endPoint = end;
|
|
39249
|
-
const stemWaypoints = [];
|
|
39250
|
-
const allWaypoints = [];
|
|
39251
|
-
const processPoint = (point5, dir2) => {
|
|
39252
|
-
if (point5.pointType === "Board") {
|
|
39253
|
-
return point5;
|
|
39254
|
-
}
|
|
39255
|
-
const offsetMap = {
|
|
39256
|
-
top: { x: 0, y: -offset },
|
|
39257
|
-
bottom: { x: 0, y: offset },
|
|
39258
|
-
right: { x: offset, y: 0 },
|
|
39259
|
-
left: { x: -offset, y: 0 }
|
|
39260
|
-
};
|
|
39261
|
-
const itemMbr = point5.item.getMbr();
|
|
39262
|
-
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
39263
|
-
const pointOnMbr = itemMbr.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
39264
|
-
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
39265
|
-
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
39266
|
-
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
39267
|
-
return newPoint;
|
|
39268
|
-
};
|
|
39269
|
-
if (start.pointType !== "Board" && startDir) {
|
|
39270
|
-
startPoint = processPoint(start, startDir);
|
|
39243
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
39244
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
39245
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39246
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39271
39247
|
}
|
|
39272
|
-
if (
|
|
39273
|
-
|
|
39274
|
-
|
|
39275
|
-
|
|
39276
|
-
|
|
39277
|
-
|
|
39278
|
-
|
|
39279
|
-
|
|
39280
|
-
|
|
39281
|
-
|
|
39282
|
-
|
|
39283
|
-
|
|
39284
|
-
|
|
39285
|
-
|
|
39286
|
-
|
|
39287
|
-
|
|
39288
|
-
|
|
39289
|
-
|
|
39290
|
-
|
|
39291
|
-
stem = new Point(endPoint.x + offset, endPoint.y);
|
|
39292
|
-
else if (endDir === "left")
|
|
39293
|
-
stem = new Point(endPoint.x - offset, endPoint.y);
|
|
39294
|
-
else if (endDir === "bottom")
|
|
39295
|
-
stem = new Point(endPoint.x, endPoint.y + offset);
|
|
39296
|
-
else
|
|
39297
|
-
stem = new Point(endPoint.x, endPoint.y - offset);
|
|
39298
|
-
stemWaypoints.push(stem);
|
|
39299
|
-
allWaypoints.push(stem);
|
|
39248
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
39249
|
+
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39250
|
+
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39251
|
+
}
|
|
39252
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
39253
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39254
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39255
|
+
}
|
|
39256
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
39257
|
+
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39258
|
+
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39259
|
+
}
|
|
39260
|
+
const dx = endPoint.x - startPoint.x;
|
|
39261
|
+
const dy = endPoint.y - startPoint.y;
|
|
39262
|
+
if (startDir === "right" && dx < 0) {
|
|
39263
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
39264
|
+
}
|
|
39265
|
+
if (startDir === "left" && dx > 0) {
|
|
39266
|
+
return [new Point(startPoint.x, endPoint.y)];
|
|
39300
39267
|
}
|
|
39301
|
-
|
|
39268
|
+
if (startDir === "bottom" && dy < 0) {
|
|
39269
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
39270
|
+
}
|
|
39271
|
+
if (startDir === "top" && dy > 0) {
|
|
39272
|
+
return [new Point(endPoint.x, startPoint.y)];
|
|
39273
|
+
}
|
|
39274
|
+
return [];
|
|
39302
39275
|
}
|
|
39303
39276
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
39304
|
-
const {
|
|
39305
|
-
const
|
|
39306
|
-
const
|
|
39307
|
-
|
|
39308
|
-
|
|
39309
|
-
|
|
39310
|
-
|
|
39311
|
-
|
|
39312
|
-
if (stemWaypoints.length > 1) {
|
|
39313
|
-
finalWaypoints.push(stemWaypoints[1]);
|
|
39314
|
-
}
|
|
39315
|
-
finalWaypoints.push(endPoint);
|
|
39316
|
-
const uniqueWaypoints = finalWaypoints.filter((point5, index2, self2) => index2 === 0 || !point5.barelyEqual(self2[index2 - 1]));
|
|
39317
|
-
const pathPoints = findPathPoints(uniqueWaypoints, grid, obstacles, newStart, newEnd);
|
|
39277
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
39278
|
+
const startPoint = newStart || start;
|
|
39279
|
+
const endPoint = newEnd || end;
|
|
39280
|
+
const startDir = getPointerDirection(start);
|
|
39281
|
+
const endDir = getPointerDirection(end);
|
|
39282
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
39283
|
+
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
39284
|
+
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
39318
39285
|
return {
|
|
39319
39286
|
lines: getLines(pathPoints),
|
|
39320
|
-
newStart
|
|
39321
|
-
newEnd
|
|
39287
|
+
newStart,
|
|
39288
|
+
newEnd
|
|
39322
39289
|
};
|
|
39323
39290
|
}
|
|
39324
39291
|
|