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