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