microboard-temp 0.5.89 → 0.5.91
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 +33 -6
- package/dist/cjs/index.js +33 -6
- package/dist/cjs/node.js +33 -6
- package/dist/esm/browser.js +33 -6
- package/dist/esm/index.js +33 -6
- package/dist/esm/node.js +33 -6
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -36927,43 +36927,70 @@ function reconstructPath(node2) {
|
|
|
36927
36927
|
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36928
36928
|
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36929
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)]);
|
|
36930
36932
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36931
36933
|
}
|
|
36932
36934
|
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36933
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)]);
|
|
36934
36938
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36935
36939
|
}
|
|
36936
36940
|
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36937
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)]);
|
|
36938
36944
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36939
36945
|
}
|
|
36940
36946
|
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36941
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)]);
|
|
36942
36950
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36943
36951
|
}
|
|
36944
36952
|
const dx = endPoint.x - startPoint.x;
|
|
36945
36953
|
const dy = endPoint.y - startPoint.y;
|
|
36946
36954
|
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36947
36955
|
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36948
|
-
const endConflictX = endDir === "right" && dx
|
|
36956
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36949
36957
|
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36950
36958
|
if (startConflictX || endConflictY) {
|
|
36959
|
+
console.log("555");
|
|
36960
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36951
36961
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36952
36962
|
}
|
|
36953
36963
|
if (startConflictY || endConflictX) {
|
|
36964
|
+
console.log("666");
|
|
36965
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36954
36966
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36955
36967
|
}
|
|
36956
36968
|
return [];
|
|
36957
36969
|
}
|
|
36958
36970
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36959
|
-
const
|
|
36960
|
-
const startPoint = newStart || start;
|
|
36961
|
-
const endPoint = newEnd || end;
|
|
36971
|
+
const tempGridInfo = createGrid(start, end);
|
|
36972
|
+
const startPoint = tempGridInfo.newStart || start;
|
|
36973
|
+
const endPoint = tempGridInfo.newEnd || end;
|
|
36962
36974
|
const startDir = getPointerDirection(start);
|
|
36963
36975
|
const endDir = getPointerDirection(end);
|
|
36964
36976
|
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36965
|
-
const
|
|
36966
|
-
const
|
|
36977
|
+
const allWaypoints = [...hookWaypoints, ...toVisitPoints];
|
|
36978
|
+
const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
|
|
36979
|
+
const finalStart = newStart || start;
|
|
36980
|
+
const finalEnd = newEnd || end;
|
|
36981
|
+
const points = [finalStart, ...allWaypoints, finalEnd];
|
|
36982
|
+
const uniquePoints = points.reduce((acc, p3) => {
|
|
36983
|
+
if (!acc.some((existing) => existing.barelyEqual(p3))) {
|
|
36984
|
+
acc.push(p3);
|
|
36985
|
+
}
|
|
36986
|
+
return acc;
|
|
36987
|
+
}, []);
|
|
36988
|
+
const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
|
|
36989
|
+
console.log("RESULT", {
|
|
36990
|
+
lines: getLines(pathPoints),
|
|
36991
|
+
newStart,
|
|
36992
|
+
newEnd
|
|
36993
|
+
});
|
|
36967
36994
|
return {
|
|
36968
36995
|
lines: getLines(pathPoints),
|
|
36969
36996
|
newStart,
|
package/dist/cjs/index.js
CHANGED
|
@@ -36927,43 +36927,70 @@ function reconstructPath(node2) {
|
|
|
36927
36927
|
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36928
36928
|
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36929
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)]);
|
|
36930
36932
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36931
36933
|
}
|
|
36932
36934
|
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36933
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)]);
|
|
36934
36938
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36935
36939
|
}
|
|
36936
36940
|
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36937
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)]);
|
|
36938
36944
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36939
36945
|
}
|
|
36940
36946
|
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36941
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)]);
|
|
36942
36950
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36943
36951
|
}
|
|
36944
36952
|
const dx = endPoint.x - startPoint.x;
|
|
36945
36953
|
const dy = endPoint.y - startPoint.y;
|
|
36946
36954
|
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36947
36955
|
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36948
|
-
const endConflictX = endDir === "right" && dx
|
|
36956
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36949
36957
|
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36950
36958
|
if (startConflictX || endConflictY) {
|
|
36959
|
+
console.log("555");
|
|
36960
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36951
36961
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36952
36962
|
}
|
|
36953
36963
|
if (startConflictY || endConflictX) {
|
|
36964
|
+
console.log("666");
|
|
36965
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36954
36966
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36955
36967
|
}
|
|
36956
36968
|
return [];
|
|
36957
36969
|
}
|
|
36958
36970
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36959
|
-
const
|
|
36960
|
-
const startPoint = newStart || start;
|
|
36961
|
-
const endPoint = newEnd || end;
|
|
36971
|
+
const tempGridInfo = createGrid(start, end);
|
|
36972
|
+
const startPoint = tempGridInfo.newStart || start;
|
|
36973
|
+
const endPoint = tempGridInfo.newEnd || end;
|
|
36962
36974
|
const startDir = getPointerDirection(start);
|
|
36963
36975
|
const endDir = getPointerDirection(end);
|
|
36964
36976
|
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36965
|
-
const
|
|
36966
|
-
const
|
|
36977
|
+
const allWaypoints = [...hookWaypoints, ...toVisitPoints];
|
|
36978
|
+
const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
|
|
36979
|
+
const finalStart = newStart || start;
|
|
36980
|
+
const finalEnd = newEnd || end;
|
|
36981
|
+
const points = [finalStart, ...allWaypoints, finalEnd];
|
|
36982
|
+
const uniquePoints = points.reduce((acc, p3) => {
|
|
36983
|
+
if (!acc.some((existing) => existing.barelyEqual(p3))) {
|
|
36984
|
+
acc.push(p3);
|
|
36985
|
+
}
|
|
36986
|
+
return acc;
|
|
36987
|
+
}, []);
|
|
36988
|
+
const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
|
|
36989
|
+
console.log("RESULT", {
|
|
36990
|
+
lines: getLines(pathPoints),
|
|
36991
|
+
newStart,
|
|
36992
|
+
newEnd
|
|
36993
|
+
});
|
|
36967
36994
|
return {
|
|
36968
36995
|
lines: getLines(pathPoints),
|
|
36969
36996
|
newStart,
|
package/dist/cjs/node.js
CHANGED
|
@@ -39400,43 +39400,70 @@ function reconstructPath(node2) {
|
|
|
39400
39400
|
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
39401
39401
|
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
39402
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)]);
|
|
39403
39405
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39404
39406
|
}
|
|
39405
39407
|
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
39406
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)]);
|
|
39407
39411
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39408
39412
|
}
|
|
39409
39413
|
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
39410
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)]);
|
|
39411
39417
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39412
39418
|
}
|
|
39413
39419
|
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
39414
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)]);
|
|
39415
39423
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39416
39424
|
}
|
|
39417
39425
|
const dx = endPoint.x - startPoint.x;
|
|
39418
39426
|
const dy = endPoint.y - startPoint.y;
|
|
39419
39427
|
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
39420
39428
|
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
39421
|
-
const endConflictX = endDir === "right" && dx
|
|
39429
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
39422
39430
|
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
39423
39431
|
if (startConflictX || endConflictY) {
|
|
39432
|
+
console.log("555");
|
|
39433
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
39424
39434
|
return [new Point(startPoint.x, endPoint.y)];
|
|
39425
39435
|
}
|
|
39426
39436
|
if (startConflictY || endConflictX) {
|
|
39437
|
+
console.log("666");
|
|
39438
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
39427
39439
|
return [new Point(endPoint.x, startPoint.y)];
|
|
39428
39440
|
}
|
|
39429
39441
|
return [];
|
|
39430
39442
|
}
|
|
39431
39443
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
39432
|
-
const
|
|
39433
|
-
const startPoint = newStart || start;
|
|
39434
|
-
const endPoint = newEnd || end;
|
|
39444
|
+
const tempGridInfo = createGrid(start, end);
|
|
39445
|
+
const startPoint = tempGridInfo.newStart || start;
|
|
39446
|
+
const endPoint = tempGridInfo.newEnd || end;
|
|
39435
39447
|
const startDir = getPointerDirection(start);
|
|
39436
39448
|
const endDir = getPointerDirection(end);
|
|
39437
39449
|
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
39438
|
-
const
|
|
39439
|
-
const
|
|
39450
|
+
const allWaypoints = [...hookWaypoints, ...toVisitPoints];
|
|
39451
|
+
const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
|
|
39452
|
+
const finalStart = newStart || start;
|
|
39453
|
+
const finalEnd = newEnd || end;
|
|
39454
|
+
const points = [finalStart, ...allWaypoints, finalEnd];
|
|
39455
|
+
const uniquePoints = points.reduce((acc, p3) => {
|
|
39456
|
+
if (!acc.some((existing) => existing.barelyEqual(p3))) {
|
|
39457
|
+
acc.push(p3);
|
|
39458
|
+
}
|
|
39459
|
+
return acc;
|
|
39460
|
+
}, []);
|
|
39461
|
+
const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
|
|
39462
|
+
console.log("RESULT", {
|
|
39463
|
+
lines: getLines(pathPoints),
|
|
39464
|
+
newStart,
|
|
39465
|
+
newEnd
|
|
39466
|
+
});
|
|
39440
39467
|
return {
|
|
39441
39468
|
lines: getLines(pathPoints),
|
|
39442
39469
|
newStart,
|
package/dist/esm/browser.js
CHANGED
|
@@ -36772,43 +36772,70 @@ function reconstructPath(node2) {
|
|
|
36772
36772
|
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36773
36773
|
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36774
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)]);
|
|
36775
36777
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36776
36778
|
}
|
|
36777
36779
|
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36778
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)]);
|
|
36779
36783
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36780
36784
|
}
|
|
36781
36785
|
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36782
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)]);
|
|
36783
36789
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36784
36790
|
}
|
|
36785
36791
|
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36786
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)]);
|
|
36787
36795
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36788
36796
|
}
|
|
36789
36797
|
const dx = endPoint.x - startPoint.x;
|
|
36790
36798
|
const dy = endPoint.y - startPoint.y;
|
|
36791
36799
|
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36792
36800
|
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36793
|
-
const endConflictX = endDir === "right" && dx
|
|
36801
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36794
36802
|
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36795
36803
|
if (startConflictX || endConflictY) {
|
|
36804
|
+
console.log("555");
|
|
36805
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36796
36806
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36797
36807
|
}
|
|
36798
36808
|
if (startConflictY || endConflictX) {
|
|
36809
|
+
console.log("666");
|
|
36810
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36799
36811
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36800
36812
|
}
|
|
36801
36813
|
return [];
|
|
36802
36814
|
}
|
|
36803
36815
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36804
|
-
const
|
|
36805
|
-
const startPoint = newStart || start;
|
|
36806
|
-
const endPoint = newEnd || end;
|
|
36816
|
+
const tempGridInfo = createGrid(start, end);
|
|
36817
|
+
const startPoint = tempGridInfo.newStart || start;
|
|
36818
|
+
const endPoint = tempGridInfo.newEnd || end;
|
|
36807
36819
|
const startDir = getPointerDirection(start);
|
|
36808
36820
|
const endDir = getPointerDirection(end);
|
|
36809
36821
|
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36810
|
-
const
|
|
36811
|
-
const
|
|
36822
|
+
const allWaypoints = [...hookWaypoints, ...toVisitPoints];
|
|
36823
|
+
const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
|
|
36824
|
+
const finalStart = newStart || start;
|
|
36825
|
+
const finalEnd = newEnd || end;
|
|
36826
|
+
const points = [finalStart, ...allWaypoints, finalEnd];
|
|
36827
|
+
const uniquePoints = points.reduce((acc, p3) => {
|
|
36828
|
+
if (!acc.some((existing) => existing.barelyEqual(p3))) {
|
|
36829
|
+
acc.push(p3);
|
|
36830
|
+
}
|
|
36831
|
+
return acc;
|
|
36832
|
+
}, []);
|
|
36833
|
+
const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
|
|
36834
|
+
console.log("RESULT", {
|
|
36835
|
+
lines: getLines(pathPoints),
|
|
36836
|
+
newStart,
|
|
36837
|
+
newEnd
|
|
36838
|
+
});
|
|
36812
36839
|
return {
|
|
36813
36840
|
lines: getLines(pathPoints),
|
|
36814
36841
|
newStart,
|
package/dist/esm/index.js
CHANGED
|
@@ -36765,43 +36765,70 @@ function reconstructPath(node2) {
|
|
|
36765
36765
|
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
36766
36766
|
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
36767
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)]);
|
|
36768
36770
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36769
36771
|
}
|
|
36770
36772
|
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
36771
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)]);
|
|
36772
36776
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
36773
36777
|
}
|
|
36774
36778
|
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
36775
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)]);
|
|
36776
36782
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36777
36783
|
}
|
|
36778
36784
|
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
36779
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)]);
|
|
36780
36788
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
36781
36789
|
}
|
|
36782
36790
|
const dx = endPoint.x - startPoint.x;
|
|
36783
36791
|
const dy = endPoint.y - startPoint.y;
|
|
36784
36792
|
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
36785
36793
|
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
36786
|
-
const endConflictX = endDir === "right" && dx
|
|
36794
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
36787
36795
|
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
36788
36796
|
if (startConflictX || endConflictY) {
|
|
36797
|
+
console.log("555");
|
|
36798
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
36789
36799
|
return [new Point(startPoint.x, endPoint.y)];
|
|
36790
36800
|
}
|
|
36791
36801
|
if (startConflictY || endConflictX) {
|
|
36802
|
+
console.log("666");
|
|
36803
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
36792
36804
|
return [new Point(endPoint.x, startPoint.y)];
|
|
36793
36805
|
}
|
|
36794
36806
|
return [];
|
|
36795
36807
|
}
|
|
36796
36808
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36797
|
-
const
|
|
36798
|
-
const startPoint = newStart || start;
|
|
36799
|
-
const endPoint = newEnd || end;
|
|
36809
|
+
const tempGridInfo = createGrid(start, end);
|
|
36810
|
+
const startPoint = tempGridInfo.newStart || start;
|
|
36811
|
+
const endPoint = tempGridInfo.newEnd || end;
|
|
36800
36812
|
const startDir = getPointerDirection(start);
|
|
36801
36813
|
const endDir = getPointerDirection(end);
|
|
36802
36814
|
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
36803
|
-
const
|
|
36804
|
-
const
|
|
36815
|
+
const allWaypoints = [...hookWaypoints, ...toVisitPoints];
|
|
36816
|
+
const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
|
|
36817
|
+
const finalStart = newStart || start;
|
|
36818
|
+
const finalEnd = newEnd || end;
|
|
36819
|
+
const points = [finalStart, ...allWaypoints, finalEnd];
|
|
36820
|
+
const uniquePoints = points.reduce((acc, p3) => {
|
|
36821
|
+
if (!acc.some((existing) => existing.barelyEqual(p3))) {
|
|
36822
|
+
acc.push(p3);
|
|
36823
|
+
}
|
|
36824
|
+
return acc;
|
|
36825
|
+
}, []);
|
|
36826
|
+
const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
|
|
36827
|
+
console.log("RESULT", {
|
|
36828
|
+
lines: getLines(pathPoints),
|
|
36829
|
+
newStart,
|
|
36830
|
+
newEnd
|
|
36831
|
+
});
|
|
36805
36832
|
return {
|
|
36806
36833
|
lines: getLines(pathPoints),
|
|
36807
36834
|
newStart,
|
package/dist/esm/node.js
CHANGED
|
@@ -39233,43 +39233,70 @@ function reconstructPath(node2) {
|
|
|
39233
39233
|
function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
|
|
39234
39234
|
if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
|
|
39235
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)]);
|
|
39236
39238
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39237
39239
|
}
|
|
39238
39240
|
if (startDir === "left" && endDir === "right" && startPoint.x < endPoint.x) {
|
|
39239
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)]);
|
|
39240
39244
|
return [new Point(startPoint.x, midY), new Point(endPoint.x, midY)];
|
|
39241
39245
|
}
|
|
39242
39246
|
if (startDir === "bottom" && endDir === "top" && startPoint.y > endPoint.y) {
|
|
39243
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)]);
|
|
39244
39250
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39245
39251
|
}
|
|
39246
39252
|
if (startDir === "top" && endDir === "bottom" && startPoint.y < endPoint.y) {
|
|
39247
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)]);
|
|
39248
39256
|
return [new Point(midX, startPoint.y), new Point(midX, endPoint.y)];
|
|
39249
39257
|
}
|
|
39250
39258
|
const dx = endPoint.x - startPoint.x;
|
|
39251
39259
|
const dy = endPoint.y - startPoint.y;
|
|
39252
39260
|
const startConflictX = startDir === "right" && dx < 0 || startDir === "left" && dx > 0;
|
|
39253
39261
|
const startConflictY = startDir === "bottom" && dy < 0 || startDir === "top" && dy > 0;
|
|
39254
|
-
const endConflictX = endDir === "right" && dx
|
|
39262
|
+
const endConflictX = endDir === "right" && dx > 0 || endDir === "left" && dx < 0;
|
|
39255
39263
|
const endConflictY = endDir === "bottom" && dy < 0 || endDir === "top" && dy > 0;
|
|
39256
39264
|
if (startConflictX || endConflictY) {
|
|
39265
|
+
console.log("555");
|
|
39266
|
+
console.log([new Point(startPoint.x, endPoint.y)]);
|
|
39257
39267
|
return [new Point(startPoint.x, endPoint.y)];
|
|
39258
39268
|
}
|
|
39259
39269
|
if (startConflictY || endConflictX) {
|
|
39270
|
+
console.log("666");
|
|
39271
|
+
console.log([new Point(endPoint.x, startPoint.y)]);
|
|
39260
39272
|
return [new Point(endPoint.x, startPoint.y)];
|
|
39261
39273
|
}
|
|
39262
39274
|
return [];
|
|
39263
39275
|
}
|
|
39264
39276
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
39265
|
-
const
|
|
39266
|
-
const startPoint = newStart || start;
|
|
39267
|
-
const endPoint = newEnd || end;
|
|
39277
|
+
const tempGridInfo = createGrid(start, end);
|
|
39278
|
+
const startPoint = tempGridInfo.newStart || start;
|
|
39279
|
+
const endPoint = tempGridInfo.newEnd || end;
|
|
39268
39280
|
const startDir = getPointerDirection(start);
|
|
39269
39281
|
const endDir = getPointerDirection(end);
|
|
39270
39282
|
const hookWaypoints = createHookWaypoints(startPoint, endPoint, startDir, endDir);
|
|
39271
|
-
const
|
|
39272
|
-
const
|
|
39283
|
+
const allWaypoints = [...hookWaypoints, ...toVisitPoints];
|
|
39284
|
+
const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
|
|
39285
|
+
const finalStart = newStart || start;
|
|
39286
|
+
const finalEnd = newEnd || end;
|
|
39287
|
+
const points = [finalStart, ...allWaypoints, finalEnd];
|
|
39288
|
+
const uniquePoints = points.reduce((acc, p3) => {
|
|
39289
|
+
if (!acc.some((existing) => existing.barelyEqual(p3))) {
|
|
39290
|
+
acc.push(p3);
|
|
39291
|
+
}
|
|
39292
|
+
return acc;
|
|
39293
|
+
}, []);
|
|
39294
|
+
const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
|
|
39295
|
+
console.log("RESULT", {
|
|
39296
|
+
lines: getLines(pathPoints),
|
|
39297
|
+
newStart,
|
|
39298
|
+
newEnd
|
|
39299
|
+
});
|
|
39273
39300
|
return {
|
|
39274
39301
|
lines: getLines(pathPoints),
|
|
39275
39302
|
newStart,
|