microboard-temp 0.5.88 → 0.5.90
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 +34 -36
- package/dist/cjs/index.js +34 -36
- package/dist/cjs/node.js +34 -36
- package/dist/esm/browser.js +34 -36
- package/dist/esm/index.js +34 -36
- package/dist/esm/node.js +34 -36
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -36895,7 +36895,6 @@ function reducePoints(points) {
|
|
|
36895
36895
|
return result;
|
|
36896
36896
|
}
|
|
36897
36897
|
function getLines(pathPoints) {
|
|
36898
|
-
const lines = [];
|
|
36899
36898
|
if (pathPoints.length < 2) {
|
|
36900
36899
|
return [];
|
|
36901
36900
|
}
|
|
@@ -36903,24 +36902,15 @@ function getLines(pathPoints) {
|
|
|
36903
36902
|
if (reducedPoints.length < 2) {
|
|
36904
36903
|
return [];
|
|
36905
36904
|
}
|
|
36905
|
+
const lines = [];
|
|
36906
36906
|
let startPoint = reducedPoints[0];
|
|
36907
|
-
for (let i = 1;i < reducedPoints.length; i
|
|
36908
|
-
const
|
|
36909
|
-
const currPoint = reducedPoints[i];
|
|
36907
|
+
for (let i = 1;i < reducedPoints.length; i++) {
|
|
36908
|
+
const currentPoint = reducedPoints[i];
|
|
36910
36909
|
const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
|
|
36911
|
-
|
|
36912
|
-
|
|
36913
|
-
startPoint
|
|
36914
|
-
|
|
36915
|
-
}
|
|
36916
|
-
if (lines.length === 0 && reducedPoints.length > 1) {
|
|
36917
|
-
lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
|
|
36918
|
-
} else if (lines.length > 0) {
|
|
36919
|
-
const lastLine = lines[lines.length - 1];
|
|
36920
|
-
const lastPointInLines = lastLine.getEndPoint();
|
|
36921
|
-
const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
|
|
36922
|
-
if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
|
|
36923
|
-
lines.push(new Line(lastPointInLines, lastPointInReduced));
|
|
36910
|
+
const direction = getDirection(startPoint, currentPoint);
|
|
36911
|
+
if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
|
|
36912
|
+
lines.push(new Line(startPoint, currentPoint));
|
|
36913
|
+
startPoint = currentPoint;
|
|
36924
36914
|
}
|
|
36925
36915
|
}
|
|
36926
36916
|
return lines;
|
|
@@ -36934,39 +36924,45 @@ function reconstructPath(node2) {
|
|
|
36934
36924
|
}
|
|
36935
36925
|
return path2.reverse();
|
|
36936
36926
|
}
|
|
36937
|
-
function
|
|
36938
|
-
|
|
36939
|
-
}
|
|
36940
|
-
function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
|
|
36941
|
-
return firstMbr.right <= secondMbr.left - offset && secondMbr.right <= firstMbr.left - offset;
|
|
36942
|
-
}
|
|
36943
|
-
function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
|
|
36944
|
-
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
|
|
36927
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36928
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36945
36929
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36930
|
+
console.log("111");
|
|
36931
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36946
36932
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36947
36933
|
}
|
|
36948
|
-
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x
|
|
36934
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36949
36935
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36936
|
+
console.log("222");
|
|
36937
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36950
36938
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36951
36939
|
}
|
|
36952
|
-
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y
|
|
36940
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36953
36941
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36942
|
+
console.log("333");
|
|
36943
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36954
36944
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36955
36945
|
}
|
|
36956
|
-
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y
|
|
36946
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36957
36947
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36948
|
+
console.log("444");
|
|
36949
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36958
36950
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36959
36951
|
}
|
|
36960
36952
|
const dx = endPoint.x - startPoint.x;
|
|
36961
36953
|
const dy = endPoint.y - startPoint.y;
|
|
36962
|
-
const startConflictX =
|
|
36963
|
-
const startConflictY =
|
|
36964
|
-
const endConflictX =
|
|
36965
|
-
const endConflictY =
|
|
36954
|
+
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36955
|
+
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36956
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36957
|
+
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36966
36958
|
if (startConflictX || endConflictY) {
|
|
36959
|
+
console.log("555");
|
|
36960
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36967
36961
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36968
36962
|
}
|
|
36969
36963
|
if (startConflictY || endConflictX) {
|
|
36964
|
+
console.log("666");
|
|
36965
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36970
36966
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36971
36967
|
}
|
|
36972
36968
|
return [];
|
|
@@ -36977,12 +36973,14 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
|
36977
36973
|
const endPoint = newEnd || end;
|
|
36978
36974
|
const startDir = getPointerDirection(start);
|
|
36979
36975
|
const endDir = getPointerDirection(end);
|
|
36980
|
-
|
|
36981
|
-
if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
|
|
36982
|
-
hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
|
|
36983
|
-
}
|
|
36976
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36984
36977
|
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36985
36978
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36979
|
+
console.log("RESULT", {
|
|
36980
|
+
lines: getLines(pathPoints),
|
|
36981
|
+
newStart,
|
|
36982
|
+
newEnd
|
|
36983
|
+
});
|
|
36986
36984
|
return {
|
|
36987
36985
|
lines: getLines(pathPoints),
|
|
36988
36986
|
newStart,
|
package/dist/cjs/index.js
CHANGED
|
@@ -36895,7 +36895,6 @@ function reducePoints(points) {
|
|
|
36895
36895
|
return result;
|
|
36896
36896
|
}
|
|
36897
36897
|
function getLines(pathPoints) {
|
|
36898
|
-
const lines = [];
|
|
36899
36898
|
if (pathPoints.length < 2) {
|
|
36900
36899
|
return [];
|
|
36901
36900
|
}
|
|
@@ -36903,24 +36902,15 @@ function getLines(pathPoints) {
|
|
|
36903
36902
|
if (reducedPoints.length < 2) {
|
|
36904
36903
|
return [];
|
|
36905
36904
|
}
|
|
36905
|
+
const lines = [];
|
|
36906
36906
|
let startPoint = reducedPoints[0];
|
|
36907
|
-
for (let i = 1;i < reducedPoints.length; i
|
|
36908
|
-
const
|
|
36909
|
-
const currPoint = reducedPoints[i];
|
|
36907
|
+
for (let i = 1;i < reducedPoints.length; i++) {
|
|
36908
|
+
const currentPoint = reducedPoints[i];
|
|
36910
36909
|
const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
|
|
36911
|
-
|
|
36912
|
-
|
|
36913
|
-
startPoint
|
|
36914
|
-
|
|
36915
|
-
}
|
|
36916
|
-
if (lines.length === 0 && reducedPoints.length > 1) {
|
|
36917
|
-
lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
|
|
36918
|
-
} else if (lines.length > 0) {
|
|
36919
|
-
const lastLine = lines[lines.length - 1];
|
|
36920
|
-
const lastPointInLines = lastLine.getEndPoint();
|
|
36921
|
-
const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
|
|
36922
|
-
if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
|
|
36923
|
-
lines.push(new Line(lastPointInLines, lastPointInReduced));
|
|
36910
|
+
const direction = getDirection(startPoint, currentPoint);
|
|
36911
|
+
if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
|
|
36912
|
+
lines.push(new Line(startPoint, currentPoint));
|
|
36913
|
+
startPoint = currentPoint;
|
|
36924
36914
|
}
|
|
36925
36915
|
}
|
|
36926
36916
|
return lines;
|
|
@@ -36934,39 +36924,45 @@ function reconstructPath(node2) {
|
|
|
36934
36924
|
}
|
|
36935
36925
|
return path2.reverse();
|
|
36936
36926
|
}
|
|
36937
|
-
function
|
|
36938
|
-
|
|
36939
|
-
}
|
|
36940
|
-
function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
|
|
36941
|
-
return firstMbr.right <= secondMbr.left - offset && secondMbr.right <= firstMbr.left - offset;
|
|
36942
|
-
}
|
|
36943
|
-
function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
|
|
36944
|
-
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
|
|
36927
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36928
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36945
36929
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36930
|
+
console.log("111");
|
|
36931
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36946
36932
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36947
36933
|
}
|
|
36948
|
-
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x
|
|
36934
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36949
36935
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36936
|
+
console.log("222");
|
|
36937
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36950
36938
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36951
36939
|
}
|
|
36952
|
-
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y
|
|
36940
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36953
36941
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36942
|
+
console.log("333");
|
|
36943
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36954
36944
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36955
36945
|
}
|
|
36956
|
-
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y
|
|
36946
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36957
36947
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36948
|
+
console.log("444");
|
|
36949
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36958
36950
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36959
36951
|
}
|
|
36960
36952
|
const dx = endPoint.x - startPoint.x;
|
|
36961
36953
|
const dy = endPoint.y - startPoint.y;
|
|
36962
|
-
const startConflictX =
|
|
36963
|
-
const startConflictY =
|
|
36964
|
-
const endConflictX =
|
|
36965
|
-
const endConflictY =
|
|
36954
|
+
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36955
|
+
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36956
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36957
|
+
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36966
36958
|
if (startConflictX || endConflictY) {
|
|
36959
|
+
console.log("555");
|
|
36960
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36967
36961
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36968
36962
|
}
|
|
36969
36963
|
if (startConflictY || endConflictX) {
|
|
36964
|
+
console.log("666");
|
|
36965
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36970
36966
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36971
36967
|
}
|
|
36972
36968
|
return [];
|
|
@@ -36977,12 +36973,14 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
|
36977
36973
|
const endPoint = newEnd || end;
|
|
36978
36974
|
const startDir = getPointerDirection(start);
|
|
36979
36975
|
const endDir = getPointerDirection(end);
|
|
36980
|
-
|
|
36981
|
-
if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
|
|
36982
|
-
hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
|
|
36983
|
-
}
|
|
36976
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36984
36977
|
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36985
36978
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36979
|
+
console.log("RESULT", {
|
|
36980
|
+
lines: getLines(pathPoints),
|
|
36981
|
+
newStart,
|
|
36982
|
+
newEnd
|
|
36983
|
+
});
|
|
36986
36984
|
return {
|
|
36987
36985
|
lines: getLines(pathPoints),
|
|
36988
36986
|
newStart,
|
package/dist/cjs/node.js
CHANGED
|
@@ -39368,7 +39368,6 @@ function reducePoints(points) {
|
|
|
39368
39368
|
return result;
|
|
39369
39369
|
}
|
|
39370
39370
|
function getLines(pathPoints) {
|
|
39371
|
-
const lines = [];
|
|
39372
39371
|
if (pathPoints.length < 2) {
|
|
39373
39372
|
return [];
|
|
39374
39373
|
}
|
|
@@ -39376,24 +39375,15 @@ function getLines(pathPoints) {
|
|
|
39376
39375
|
if (reducedPoints.length < 2) {
|
|
39377
39376
|
return [];
|
|
39378
39377
|
}
|
|
39378
|
+
const lines = [];
|
|
39379
39379
|
let startPoint = reducedPoints[0];
|
|
39380
|
-
for (let i = 1;i < reducedPoints.length; i
|
|
39381
|
-
const
|
|
39382
|
-
const currPoint = reducedPoints[i];
|
|
39380
|
+
for (let i = 1;i < reducedPoints.length; i++) {
|
|
39381
|
+
const currentPoint = reducedPoints[i];
|
|
39383
39382
|
const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
|
|
39384
|
-
|
|
39385
|
-
|
|
39386
|
-
startPoint
|
|
39387
|
-
|
|
39388
|
-
}
|
|
39389
|
-
if (lines.length === 0 && reducedPoints.length > 1) {
|
|
39390
|
-
lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
|
|
39391
|
-
} else if (lines.length > 0) {
|
|
39392
|
-
const lastLine = lines[lines.length - 1];
|
|
39393
|
-
const lastPointInLines = lastLine.getEndPoint();
|
|
39394
|
-
const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
|
|
39395
|
-
if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
|
|
39396
|
-
lines.push(new Line(lastPointInLines, lastPointInReduced));
|
|
39383
|
+
const direction = getDirection(startPoint, currentPoint);
|
|
39384
|
+
if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
|
|
39385
|
+
lines.push(new Line(startPoint, currentPoint));
|
|
39386
|
+
startPoint = currentPoint;
|
|
39397
39387
|
}
|
|
39398
39388
|
}
|
|
39399
39389
|
return lines;
|
|
@@ -39407,39 +39397,45 @@ function reconstructPath(node2) {
|
|
|
39407
39397
|
}
|
|
39408
39398
|
return path2.reverse();
|
|
39409
39399
|
}
|
|
39410
|
-
function
|
|
39411
|
-
|
|
39412
|
-
}
|
|
39413
|
-
function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
|
|
39414
|
-
return firstMbr.right <= secondMbr.left - offset && secondMbr.right <= firstMbr.left - offset;
|
|
39415
|
-
}
|
|
39416
|
-
function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
|
|
39417
|
-
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
|
|
39400
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
39401
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
39418
39402
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39403
|
+
console.log("111");
|
|
39404
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
39419
39405
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39420
39406
|
}
|
|
39421
|
-
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x
|
|
39407
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
39422
39408
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39409
|
+
console.log("222");
|
|
39410
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
39423
39411
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39424
39412
|
}
|
|
39425
|
-
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y
|
|
39413
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
39426
39414
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39415
|
+
console.log("333");
|
|
39416
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
39427
39417
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39428
39418
|
}
|
|
39429
|
-
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y
|
|
39419
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
39430
39420
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39421
|
+
console.log("444");
|
|
39422
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
39431
39423
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39432
39424
|
}
|
|
39433
39425
|
const dx = endPoint.x - startPoint.x;
|
|
39434
39426
|
const dy = endPoint.y - startPoint.y;
|
|
39435
|
-
const startConflictX =
|
|
39436
|
-
const startConflictY =
|
|
39437
|
-
const endConflictX =
|
|
39438
|
-
const endConflictY =
|
|
39427
|
+
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
39428
|
+
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
39429
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
39430
|
+
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
39439
39431
|
if (startConflictX || endConflictY) {
|
|
39432
|
+
console.log("555");
|
|
39433
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
39440
39434
|
return [new Point(startPoint.x, endPoint.y)];
|
|
39441
39435
|
}
|
|
39442
39436
|
if (startConflictY || endConflictX) {
|
|
39437
|
+
console.log("666");
|
|
39438
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
39443
39439
|
return [new Point(endPoint.x, startPoint.y)];
|
|
39444
39440
|
}
|
|
39445
39441
|
return [];
|
|
@@ -39450,12 +39446,14 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
|
39450
39446
|
const endPoint = newEnd || end;
|
|
39451
39447
|
const startDir = getPointerDirection(start);
|
|
39452
39448
|
const endDir = getPointerDirection(end);
|
|
39453
|
-
|
|
39454
|
-
if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
|
|
39455
|
-
hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
|
|
39456
|
-
}
|
|
39449
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
39457
39450
|
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
39458
39451
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
39452
|
+
console.log("RESULT", {
|
|
39453
|
+
lines: getLines(pathPoints),
|
|
39454
|
+
newStart,
|
|
39455
|
+
newEnd
|
|
39456
|
+
});
|
|
39459
39457
|
return {
|
|
39460
39458
|
lines: getLines(pathPoints),
|
|
39461
39459
|
newStart,
|
package/dist/esm/browser.js
CHANGED
|
@@ -36740,7 +36740,6 @@ function reducePoints(points) {
|
|
|
36740
36740
|
return result;
|
|
36741
36741
|
}
|
|
36742
36742
|
function getLines(pathPoints) {
|
|
36743
|
-
const lines = [];
|
|
36744
36743
|
if (pathPoints.length < 2) {
|
|
36745
36744
|
return [];
|
|
36746
36745
|
}
|
|
@@ -36748,24 +36747,15 @@ function getLines(pathPoints) {
|
|
|
36748
36747
|
if (reducedPoints.length < 2) {
|
|
36749
36748
|
return [];
|
|
36750
36749
|
}
|
|
36750
|
+
const lines = [];
|
|
36751
36751
|
let startPoint = reducedPoints[0];
|
|
36752
|
-
for (let i = 1;i < reducedPoints.length; i
|
|
36753
|
-
const
|
|
36754
|
-
const currPoint = reducedPoints[i];
|
|
36752
|
+
for (let i = 1;i < reducedPoints.length; i++) {
|
|
36753
|
+
const currentPoint = reducedPoints[i];
|
|
36755
36754
|
const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
|
|
36756
|
-
|
|
36757
|
-
|
|
36758
|
-
startPoint
|
|
36759
|
-
|
|
36760
|
-
}
|
|
36761
|
-
if (lines.length === 0 && reducedPoints.length > 1) {
|
|
36762
|
-
lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
|
|
36763
|
-
} else if (lines.length > 0) {
|
|
36764
|
-
const lastLine = lines[lines.length - 1];
|
|
36765
|
-
const lastPointInLines = lastLine.getEndPoint();
|
|
36766
|
-
const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
|
|
36767
|
-
if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
|
|
36768
|
-
lines.push(new Line(lastPointInLines, lastPointInReduced));
|
|
36755
|
+
const direction = getDirection(startPoint, currentPoint);
|
|
36756
|
+
if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
|
|
36757
|
+
lines.push(new Line(startPoint, currentPoint));
|
|
36758
|
+
startPoint = currentPoint;
|
|
36769
36759
|
}
|
|
36770
36760
|
}
|
|
36771
36761
|
return lines;
|
|
@@ -36779,39 +36769,45 @@ function reconstructPath(node2) {
|
|
|
36779
36769
|
}
|
|
36780
36770
|
return path2.reverse();
|
|
36781
36771
|
}
|
|
36782
|
-
function
|
|
36783
|
-
|
|
36784
|
-
}
|
|
36785
|
-
function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
|
|
36786
|
-
return firstMbr.right <= secondMbr.left - offset && secondMbr.right <= firstMbr.left - offset;
|
|
36787
|
-
}
|
|
36788
|
-
function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
|
|
36789
|
-
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
|
|
36772
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36773
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36790
36774
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36775
|
+
console.log("111");
|
|
36776
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36791
36777
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36792
36778
|
}
|
|
36793
|
-
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x
|
|
36779
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36794
36780
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36781
|
+
console.log("222");
|
|
36782
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36795
36783
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36796
36784
|
}
|
|
36797
|
-
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y
|
|
36785
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36798
36786
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36787
|
+
console.log("333");
|
|
36788
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36799
36789
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36800
36790
|
}
|
|
36801
|
-
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y
|
|
36791
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36802
36792
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36793
|
+
console.log("444");
|
|
36794
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36803
36795
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36804
36796
|
}
|
|
36805
36797
|
const dx = endPoint.x - startPoint.x;
|
|
36806
36798
|
const dy = endPoint.y - startPoint.y;
|
|
36807
|
-
const startConflictX =
|
|
36808
|
-
const startConflictY =
|
|
36809
|
-
const endConflictX =
|
|
36810
|
-
const endConflictY =
|
|
36799
|
+
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36800
|
+
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36801
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36802
|
+
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36811
36803
|
if (startConflictX || endConflictY) {
|
|
36804
|
+
console.log("555");
|
|
36805
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36812
36806
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36813
36807
|
}
|
|
36814
36808
|
if (startConflictY || endConflictX) {
|
|
36809
|
+
console.log("666");
|
|
36810
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36815
36811
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36816
36812
|
}
|
|
36817
36813
|
return [];
|
|
@@ -36822,12 +36818,14 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
|
36822
36818
|
const endPoint = newEnd || end;
|
|
36823
36819
|
const startDir = getPointerDirection(start);
|
|
36824
36820
|
const endDir = getPointerDirection(end);
|
|
36825
|
-
|
|
36826
|
-
if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
|
|
36827
|
-
hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
|
|
36828
|
-
}
|
|
36821
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36829
36822
|
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36830
36823
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36824
|
+
console.log("RESULT", {
|
|
36825
|
+
lines: getLines(pathPoints),
|
|
36826
|
+
newStart,
|
|
36827
|
+
newEnd
|
|
36828
|
+
});
|
|
36831
36829
|
return {
|
|
36832
36830
|
lines: getLines(pathPoints),
|
|
36833
36831
|
newStart,
|
package/dist/esm/index.js
CHANGED
|
@@ -36733,7 +36733,6 @@ function reducePoints(points) {
|
|
|
36733
36733
|
return result;
|
|
36734
36734
|
}
|
|
36735
36735
|
function getLines(pathPoints) {
|
|
36736
|
-
const lines = [];
|
|
36737
36736
|
if (pathPoints.length < 2) {
|
|
36738
36737
|
return [];
|
|
36739
36738
|
}
|
|
@@ -36741,24 +36740,15 @@ function getLines(pathPoints) {
|
|
|
36741
36740
|
if (reducedPoints.length < 2) {
|
|
36742
36741
|
return [];
|
|
36743
36742
|
}
|
|
36743
|
+
const lines = [];
|
|
36744
36744
|
let startPoint = reducedPoints[0];
|
|
36745
|
-
for (let i = 1;i < reducedPoints.length; i
|
|
36746
|
-
const
|
|
36747
|
-
const currPoint = reducedPoints[i];
|
|
36745
|
+
for (let i = 1;i < reducedPoints.length; i++) {
|
|
36746
|
+
const currentPoint = reducedPoints[i];
|
|
36748
36747
|
const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
|
|
36749
|
-
|
|
36750
|
-
|
|
36751
|
-
startPoint
|
|
36752
|
-
|
|
36753
|
-
}
|
|
36754
|
-
if (lines.length === 0 && reducedPoints.length > 1) {
|
|
36755
|
-
lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
|
|
36756
|
-
} else if (lines.length > 0) {
|
|
36757
|
-
const lastLine = lines[lines.length - 1];
|
|
36758
|
-
const lastPointInLines = lastLine.getEndPoint();
|
|
36759
|
-
const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
|
|
36760
|
-
if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
|
|
36761
|
-
lines.push(new Line(lastPointInLines, lastPointInReduced));
|
|
36748
|
+
const direction = getDirection(startPoint, currentPoint);
|
|
36749
|
+
if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
|
|
36750
|
+
lines.push(new Line(startPoint, currentPoint));
|
|
36751
|
+
startPoint = currentPoint;
|
|
36762
36752
|
}
|
|
36763
36753
|
}
|
|
36764
36754
|
return lines;
|
|
@@ -36772,39 +36762,45 @@ function reconstructPath(node2) {
|
|
|
36772
36762
|
}
|
|
36773
36763
|
return path2.reverse();
|
|
36774
36764
|
}
|
|
36775
|
-
function
|
|
36776
|
-
|
|
36777
|
-
}
|
|
36778
|
-
function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
|
|
36779
|
-
return firstMbr.right <= secondMbr.left - offset && secondMbr.right <= firstMbr.left - offset;
|
|
36780
|
-
}
|
|
36781
|
-
function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
|
|
36782
|
-
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
|
|
36765
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36766
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36783
36767
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36768
|
+
console.log("111");
|
|
36769
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36784
36770
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36785
36771
|
}
|
|
36786
|
-
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x
|
|
36772
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36787
36773
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
36774
|
+
console.log("222");
|
|
36775
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
36788
36776
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36789
36777
|
}
|
|
36790
|
-
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y
|
|
36778
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36791
36779
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36780
|
+
console.log("333");
|
|
36781
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36792
36782
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36793
36783
|
}
|
|
36794
|
-
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y
|
|
36784
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36795
36785
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
36786
|
+
console.log("444");
|
|
36787
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
36796
36788
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36797
36789
|
}
|
|
36798
36790
|
const dx = endPoint.x - startPoint.x;
|
|
36799
36791
|
const dy = endPoint.y - startPoint.y;
|
|
36800
|
-
const startConflictX =
|
|
36801
|
-
const startConflictY =
|
|
36802
|
-
const endConflictX =
|
|
36803
|
-
const endConflictY =
|
|
36792
|
+
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36793
|
+
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36794
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36795
|
+
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36804
36796
|
if (startConflictX || endConflictY) {
|
|
36797
|
+
console.log("555");
|
|
36798
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36805
36799
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36806
36800
|
}
|
|
36807
36801
|
if (startConflictY || endConflictX) {
|
|
36802
|
+
console.log("666");
|
|
36803
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36808
36804
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36809
36805
|
}
|
|
36810
36806
|
return [];
|
|
@@ -36815,12 +36811,14 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
|
36815
36811
|
const endPoint = newEnd || end;
|
|
36816
36812
|
const startDir = getPointerDirection(start);
|
|
36817
36813
|
const endDir = getPointerDirection(end);
|
|
36818
|
-
|
|
36819
|
-
if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
|
|
36820
|
-
hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
|
|
36821
|
-
}
|
|
36814
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36822
36815
|
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
36823
36816
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36817
|
+
console.log("RESULT", {
|
|
36818
|
+
lines: getLines(pathPoints),
|
|
36819
|
+
newStart,
|
|
36820
|
+
newEnd
|
|
36821
|
+
});
|
|
36824
36822
|
return {
|
|
36825
36823
|
lines: getLines(pathPoints),
|
|
36826
36824
|
newStart,
|
package/dist/esm/node.js
CHANGED
|
@@ -39201,7 +39201,6 @@ function reducePoints(points) {
|
|
|
39201
39201
|
return result;
|
|
39202
39202
|
}
|
|
39203
39203
|
function getLines(pathPoints) {
|
|
39204
|
-
const lines = [];
|
|
39205
39204
|
if (pathPoints.length < 2) {
|
|
39206
39205
|
return [];
|
|
39207
39206
|
}
|
|
@@ -39209,24 +39208,15 @@ function getLines(pathPoints) {
|
|
|
39209
39208
|
if (reducedPoints.length < 2) {
|
|
39210
39209
|
return [];
|
|
39211
39210
|
}
|
|
39211
|
+
const lines = [];
|
|
39212
39212
|
let startPoint = reducedPoints[0];
|
|
39213
|
-
for (let i = 1;i < reducedPoints.length; i
|
|
39214
|
-
const
|
|
39215
|
-
const currPoint = reducedPoints[i];
|
|
39213
|
+
for (let i = 1;i < reducedPoints.length; i++) {
|
|
39214
|
+
const currentPoint = reducedPoints[i];
|
|
39216
39215
|
const nextPoint = i + 1 < reducedPoints.length ? reducedPoints[i + 1] : null;
|
|
39217
|
-
|
|
39218
|
-
|
|
39219
|
-
startPoint
|
|
39220
|
-
|
|
39221
|
-
}
|
|
39222
|
-
if (lines.length === 0 && reducedPoints.length > 1) {
|
|
39223
|
-
lines.push(new Line(reducedPoints[0], reducedPoints[reducedPoints.length - 1]));
|
|
39224
|
-
} else if (lines.length > 0) {
|
|
39225
|
-
const lastLine = lines[lines.length - 1];
|
|
39226
|
-
const lastPointInLines = lastLine.getEndPoint();
|
|
39227
|
-
const lastPointInReduced = reducedPoints[reducedPoints.length - 1];
|
|
39228
|
-
if (!lastPointInLines.barelyEqual(lastPointInReduced)) {
|
|
39229
|
-
lines.push(new Line(lastPointInLines, lastPointInReduced));
|
|
39216
|
+
const direction = getDirection(startPoint, currentPoint);
|
|
39217
|
+
if (!nextPoint || direction !== getDirection(currentPoint, nextPoint)) {
|
|
39218
|
+
lines.push(new Line(startPoint, currentPoint));
|
|
39219
|
+
startPoint = currentPoint;
|
|
39230
39220
|
}
|
|
39231
39221
|
}
|
|
39232
39222
|
return lines;
|
|
@@ -39240,39 +39230,45 @@ function reconstructPath(node2) {
|
|
|
39240
39230
|
}
|
|
39241
39231
|
return path2.reverse();
|
|
39242
39232
|
}
|
|
39243
|
-
function
|
|
39244
|
-
|
|
39245
|
-
}
|
|
39246
|
-
function haveHorizontalIntersection(firstMbr, secondMbr, offset = 0) {
|
|
39247
|
-
return firstMbr.right <= secondMbr.left - offset && secondMbr.right <= firstMbr.left - offset;
|
|
39248
|
-
}
|
|
39249
|
-
function createHookWaypoints(startPoint, endPoint, startItemMbr, endItemMbr, startDir, endDir) {
|
|
39250
|
-
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x && !haveVerticalIntersection(startItemMbr, endItemMbr, conf.CONNECTOR_ITEM_OFFSET * 2)) {
|
|
39233
|
+
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
39234
|
+
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
39251
39235
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39236
|
+
console.log("111");
|
|
39237
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
39252
39238
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39253
39239
|
}
|
|
39254
|
-
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x
|
|
39240
|
+
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
39255
39241
|
const midY = (startPoint.y + endPoint.y) / 2;
|
|
39242
|
+
console.log("222");
|
|
39243
|
+
console.log([new Point(startPoint.x, midY), new Point(endPoint.x, midY)]);
|
|
39256
39244
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39257
39245
|
}
|
|
39258
|
-
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y
|
|
39246
|
+
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
39259
39247
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39248
|
+
console.log("333");
|
|
39249
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
39260
39250
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39261
39251
|
}
|
|
39262
|
-
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y
|
|
39252
|
+
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
39263
39253
|
const midX = (startPoint.x + endPoint.x) / 2;
|
|
39254
|
+
console.log("444");
|
|
39255
|
+
console.log([new Point(midX, startPoint.y), new Point(midX, endPoint.y)]);
|
|
39264
39256
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39265
39257
|
}
|
|
39266
39258
|
const dx = endPoint.x - startPoint.x;
|
|
39267
39259
|
const dy = endPoint.y - startPoint.y;
|
|
39268
|
-
const startConflictX =
|
|
39269
|
-
const startConflictY =
|
|
39270
|
-
const endConflictX =
|
|
39271
|
-
const endConflictY =
|
|
39260
|
+
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
39261
|
+
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
39262
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
39263
|
+
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
39272
39264
|
if (startConflictX || endConflictY) {
|
|
39265
|
+
console.log("555");
|
|
39266
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
39273
39267
|
return [new Point(startPoint.x, endPoint.y)];
|
|
39274
39268
|
}
|
|
39275
39269
|
if (startConflictY || endConflictX) {
|
|
39270
|
+
console.log("666");
|
|
39271
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
39276
39272
|
return [new Point(endPoint.x, startPoint.y)];
|
|
39277
39273
|
}
|
|
39278
39274
|
return [];
|
|
@@ -39283,12 +39279,14 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
|
39283
39279
|
const endPoint = newEnd || end;
|
|
39284
39280
|
const startDir = getPointerDirection(start);
|
|
39285
39281
|
const endDir = getPointerDirection(end);
|
|
39286
|
-
|
|
39287
|
-
if (startPoint.pointType !== "Board" && endPoint.pointType !== "Board") {
|
|
39288
|
-
hookWaypoints = createHookWaypoints(startPoint, endPoint, startPoint.item.getMbr(), endPoint.item.getMbr(), startDir, endDir);
|
|
39289
|
-
}
|
|
39282
|
+
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
39290
39283
|
const points = [startPoint, ...hookWaypoints, ...toVisitPoints, endPoint];
|
|
39291
39284
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
39285
|
+
console.log("RESULT", {
|
|
39286
|
+
lines: getLines(pathPoints),
|
|
39287
|
+
newStart,
|
|
39288
|
+
newEnd
|
|
39289
|
+
});
|
|
39292
39290
|
return {
|
|
39293
39291
|
lines: getLines(pathPoints),
|
|
39294
39292
|
newStart,
|