microboard-temp 0.5.92 → 0.5.93

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.
@@ -36924,20 +36924,6 @@ function reconstructPath(node2) {
36924
36924
  }
36925
36925
  return path2.reverse();
36926
36926
  }
36927
- function findClosestPointInGrid(point5, grid) {
36928
- let closestPoint = grid[0][0];
36929
- let minDistance = Infinity;
36930
- for (const row2 of grid) {
36931
- for (const gridPoint of row2) {
36932
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36933
- if (distance < minDistance) {
36934
- minDistance = distance;
36935
- closestPoint = gridPoint;
36936
- }
36937
- }
36938
- }
36939
- return closestPoint;
36940
- }
36941
36927
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36942
36928
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36943
36929
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36981,6 +36967,37 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36981
36967
  }
36982
36968
  return [];
36983
36969
  }
36970
+ function findClosestPointInGrid(point5, grid) {
36971
+ let closestPoint = grid[0][0];
36972
+ let minDistance = Infinity;
36973
+ for (const row2 of grid) {
36974
+ for (const gridPoint of row2) {
36975
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36976
+ if (distance < minDistance) {
36977
+ minDistance = distance;
36978
+ closestPoint = gridPoint;
36979
+ }
36980
+ }
36981
+ }
36982
+ return closestPoint;
36983
+ }
36984
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36985
+ let closestPoint = null;
36986
+ let minDistance = Infinity;
36987
+ for (const row2 of grid) {
36988
+ for (const gridPoint of row2) {
36989
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36990
+ if (isPointValid) {
36991
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36992
+ if (distance < minDistance) {
36993
+ minDistance = distance;
36994
+ closestPoint = gridPoint;
36995
+ }
36996
+ }
36997
+ }
36998
+ }
36999
+ return closestPoint;
37000
+ }
36984
37001
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36985
37002
  const tempGridInfo = createGrid(start, end);
36986
37003
  const startPoint = tempGridInfo.newStart || start;
@@ -36992,15 +37009,17 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36992
37009
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36993
37010
  const finalStart = newStart || start;
36994
37011
  const finalEnd = newEnd || end;
36995
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36996
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
37012
+ const snappedStart = findClosestPointInGrid(finalStart, grid);
37013
+ const snappedEnd = findClosestPointInGrid(finalEnd, grid);
37014
+ const snappedWaypoints = allWaypoints.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
37015
+ const points = [snappedStart, ...snappedWaypoints, snappedEnd];
37016
+ const uniquePoints = points.reduce((acc, p3) => {
36997
37017
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36998
37018
  acc.push(p3);
36999
37019
  }
37000
37020
  return acc;
37001
37021
  }, []);
37002
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
37003
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
37022
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
37004
37023
  return {
37005
37024
  lines: getLines(pathPoints),
37006
37025
  newStart,
package/dist/cjs/index.js CHANGED
@@ -36924,20 +36924,6 @@ function reconstructPath(node2) {
36924
36924
  }
36925
36925
  return path2.reverse();
36926
36926
  }
36927
- function findClosestPointInGrid(point5, grid) {
36928
- let closestPoint = grid[0][0];
36929
- let minDistance = Infinity;
36930
- for (const row2 of grid) {
36931
- for (const gridPoint of row2) {
36932
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36933
- if (distance < minDistance) {
36934
- minDistance = distance;
36935
- closestPoint = gridPoint;
36936
- }
36937
- }
36938
- }
36939
- return closestPoint;
36940
- }
36941
36927
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36942
36928
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36943
36929
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36981,6 +36967,37 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36981
36967
  }
36982
36968
  return [];
36983
36969
  }
36970
+ function findClosestPointInGrid(point5, grid) {
36971
+ let closestPoint = grid[0][0];
36972
+ let minDistance = Infinity;
36973
+ for (const row2 of grid) {
36974
+ for (const gridPoint of row2) {
36975
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36976
+ if (distance < minDistance) {
36977
+ minDistance = distance;
36978
+ closestPoint = gridPoint;
36979
+ }
36980
+ }
36981
+ }
36982
+ return closestPoint;
36983
+ }
36984
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36985
+ let closestPoint = null;
36986
+ let minDistance = Infinity;
36987
+ for (const row2 of grid) {
36988
+ for (const gridPoint of row2) {
36989
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36990
+ if (isPointValid) {
36991
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36992
+ if (distance < minDistance) {
36993
+ minDistance = distance;
36994
+ closestPoint = gridPoint;
36995
+ }
36996
+ }
36997
+ }
36998
+ }
36999
+ return closestPoint;
37000
+ }
36984
37001
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36985
37002
  const tempGridInfo = createGrid(start, end);
36986
37003
  const startPoint = tempGridInfo.newStart || start;
@@ -36992,15 +37009,17 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36992
37009
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36993
37010
  const finalStart = newStart || start;
36994
37011
  const finalEnd = newEnd || end;
36995
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36996
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
37012
+ const snappedStart = findClosestPointInGrid(finalStart, grid);
37013
+ const snappedEnd = findClosestPointInGrid(finalEnd, grid);
37014
+ const snappedWaypoints = allWaypoints.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
37015
+ const points = [snappedStart, ...snappedWaypoints, snappedEnd];
37016
+ const uniquePoints = points.reduce((acc, p3) => {
36997
37017
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36998
37018
  acc.push(p3);
36999
37019
  }
37000
37020
  return acc;
37001
37021
  }, []);
37002
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
37003
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
37022
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
37004
37023
  return {
37005
37024
  lines: getLines(pathPoints),
37006
37025
  newStart,
package/dist/cjs/node.js CHANGED
@@ -39397,20 +39397,6 @@ function reconstructPath(node2) {
39397
39397
  }
39398
39398
  return path2.reverse();
39399
39399
  }
39400
- function findClosestPointInGrid(point5, grid) {
39401
- let closestPoint = grid[0][0];
39402
- let minDistance = Infinity;
39403
- for (const row2 of grid) {
39404
- for (const gridPoint of row2) {
39405
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39406
- if (distance < minDistance) {
39407
- minDistance = distance;
39408
- closestPoint = gridPoint;
39409
- }
39410
- }
39411
- }
39412
- return closestPoint;
39413
- }
39414
39400
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39415
39401
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39416
39402
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -39454,6 +39440,37 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39454
39440
  }
39455
39441
  return [];
39456
39442
  }
39443
+ function findClosestPointInGrid(point5, grid) {
39444
+ let closestPoint = grid[0][0];
39445
+ let minDistance = Infinity;
39446
+ for (const row2 of grid) {
39447
+ for (const gridPoint of row2) {
39448
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39449
+ if (distance < minDistance) {
39450
+ minDistance = distance;
39451
+ closestPoint = gridPoint;
39452
+ }
39453
+ }
39454
+ }
39455
+ return closestPoint;
39456
+ }
39457
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
39458
+ let closestPoint = null;
39459
+ let minDistance = Infinity;
39460
+ for (const row2 of grid) {
39461
+ for (const gridPoint of row2) {
39462
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
39463
+ if (isPointValid) {
39464
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39465
+ if (distance < minDistance) {
39466
+ minDistance = distance;
39467
+ closestPoint = gridPoint;
39468
+ }
39469
+ }
39470
+ }
39471
+ }
39472
+ return closestPoint;
39473
+ }
39457
39474
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39458
39475
  const tempGridInfo = createGrid(start, end);
39459
39476
  const startPoint = tempGridInfo.newStart || start;
@@ -39465,15 +39482,17 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39465
39482
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
39466
39483
  const finalStart = newStart || start;
39467
39484
  const finalEnd = newEnd || end;
39468
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
39469
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
39485
+ const snappedStart = findClosestPointInGrid(finalStart, grid);
39486
+ const snappedEnd = findClosestPointInGrid(finalEnd, grid);
39487
+ const snappedWaypoints = allWaypoints.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
39488
+ const points = [snappedStart, ...snappedWaypoints, snappedEnd];
39489
+ const uniquePoints = points.reduce((acc, p3) => {
39470
39490
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
39471
39491
  acc.push(p3);
39472
39492
  }
39473
39493
  return acc;
39474
39494
  }, []);
39475
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
39476
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
39495
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
39477
39496
  return {
39478
39497
  lines: getLines(pathPoints),
39479
39498
  newStart,
@@ -36769,20 +36769,6 @@ function reconstructPath(node2) {
36769
36769
  }
36770
36770
  return path2.reverse();
36771
36771
  }
36772
- function findClosestPointInGrid(point5, grid) {
36773
- let closestPoint = grid[0][0];
36774
- let minDistance = Infinity;
36775
- for (const row2 of grid) {
36776
- for (const gridPoint of row2) {
36777
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36778
- if (distance < minDistance) {
36779
- minDistance = distance;
36780
- closestPoint = gridPoint;
36781
- }
36782
- }
36783
- }
36784
- return closestPoint;
36785
- }
36786
36772
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36787
36773
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36788
36774
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36826,6 +36812,37 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36826
36812
  }
36827
36813
  return [];
36828
36814
  }
36815
+ function findClosestPointInGrid(point5, grid) {
36816
+ let closestPoint = grid[0][0];
36817
+ let minDistance = Infinity;
36818
+ for (const row2 of grid) {
36819
+ for (const gridPoint of row2) {
36820
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36821
+ if (distance < minDistance) {
36822
+ minDistance = distance;
36823
+ closestPoint = gridPoint;
36824
+ }
36825
+ }
36826
+ }
36827
+ return closestPoint;
36828
+ }
36829
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36830
+ let closestPoint = null;
36831
+ let minDistance = Infinity;
36832
+ for (const row2 of grid) {
36833
+ for (const gridPoint of row2) {
36834
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36835
+ if (isPointValid) {
36836
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36837
+ if (distance < minDistance) {
36838
+ minDistance = distance;
36839
+ closestPoint = gridPoint;
36840
+ }
36841
+ }
36842
+ }
36843
+ }
36844
+ return closestPoint;
36845
+ }
36829
36846
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36830
36847
  const tempGridInfo = createGrid(start, end);
36831
36848
  const startPoint = tempGridInfo.newStart || start;
@@ -36837,15 +36854,17 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36837
36854
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36838
36855
  const finalStart = newStart || start;
36839
36856
  const finalEnd = newEnd || end;
36840
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36841
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
36857
+ const snappedStart = findClosestPointInGrid(finalStart, grid);
36858
+ const snappedEnd = findClosestPointInGrid(finalEnd, grid);
36859
+ const snappedWaypoints = allWaypoints.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
36860
+ const points = [snappedStart, ...snappedWaypoints, snappedEnd];
36861
+ const uniquePoints = points.reduce((acc, p3) => {
36842
36862
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36843
36863
  acc.push(p3);
36844
36864
  }
36845
36865
  return acc;
36846
36866
  }, []);
36847
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
36848
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
36867
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
36849
36868
  return {
36850
36869
  lines: getLines(pathPoints),
36851
36870
  newStart,
package/dist/esm/index.js CHANGED
@@ -36762,20 +36762,6 @@ function reconstructPath(node2) {
36762
36762
  }
36763
36763
  return path2.reverse();
36764
36764
  }
36765
- function findClosestPointInGrid(point5, grid) {
36766
- let closestPoint = grid[0][0];
36767
- let minDistance = Infinity;
36768
- for (const row2 of grid) {
36769
- for (const gridPoint of row2) {
36770
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36771
- if (distance < minDistance) {
36772
- minDistance = distance;
36773
- closestPoint = gridPoint;
36774
- }
36775
- }
36776
- }
36777
- return closestPoint;
36778
- }
36779
36765
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36780
36766
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
36781
36767
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -36819,6 +36805,37 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
36819
36805
  }
36820
36806
  return [];
36821
36807
  }
36808
+ function findClosestPointInGrid(point5, grid) {
36809
+ let closestPoint = grid[0][0];
36810
+ let minDistance = Infinity;
36811
+ for (const row2 of grid) {
36812
+ for (const gridPoint of row2) {
36813
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36814
+ if (distance < minDistance) {
36815
+ minDistance = distance;
36816
+ closestPoint = gridPoint;
36817
+ }
36818
+ }
36819
+ }
36820
+ return closestPoint;
36821
+ }
36822
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
36823
+ let closestPoint = null;
36824
+ let minDistance = Infinity;
36825
+ for (const row2 of grid) {
36826
+ for (const gridPoint of row2) {
36827
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
36828
+ if (isPointValid) {
36829
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
36830
+ if (distance < minDistance) {
36831
+ minDistance = distance;
36832
+ closestPoint = gridPoint;
36833
+ }
36834
+ }
36835
+ }
36836
+ }
36837
+ return closestPoint;
36838
+ }
36822
36839
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36823
36840
  const tempGridInfo = createGrid(start, end);
36824
36841
  const startPoint = tempGridInfo.newStart || start;
@@ -36830,15 +36847,17 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
36830
36847
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
36831
36848
  const finalStart = newStart || start;
36832
36849
  const finalEnd = newEnd || end;
36833
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
36834
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
36850
+ const snappedStart = findClosestPointInGrid(finalStart, grid);
36851
+ const snappedEnd = findClosestPointInGrid(finalEnd, grid);
36852
+ const snappedWaypoints = allWaypoints.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
36853
+ const points = [snappedStart, ...snappedWaypoints, snappedEnd];
36854
+ const uniquePoints = points.reduce((acc, p3) => {
36835
36855
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
36836
36856
  acc.push(p3);
36837
36857
  }
36838
36858
  return acc;
36839
36859
  }, []);
36840
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
36841
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
36860
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
36842
36861
  return {
36843
36862
  lines: getLines(pathPoints),
36844
36863
  newStart,
package/dist/esm/node.js CHANGED
@@ -39230,20 +39230,6 @@ function reconstructPath(node2) {
39230
39230
  }
39231
39231
  return path2.reverse();
39232
39232
  }
39233
- function findClosestPointInGrid(point5, grid) {
39234
- let closestPoint = grid[0][0];
39235
- let minDistance = Infinity;
39236
- for (const row2 of grid) {
39237
- for (const gridPoint of row2) {
39238
- const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39239
- if (distance < minDistance) {
39240
- minDistance = distance;
39241
- closestPoint = gridPoint;
39242
- }
39243
- }
39244
- }
39245
- return closestPoint;
39246
- }
39247
39233
  function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39248
39234
  if (startDir === "right" && endDir === "left" && startPoint.x > endPoint.x) {
39249
39235
  const midY = (startPoint.y + endPoint.y) / 2;
@@ -39287,6 +39273,37 @@ function createHookWaypoints(startPoint, endPoint, startDir, endDir) {
39287
39273
  }
39288
39274
  return [];
39289
39275
  }
39276
+ function findClosestPointInGrid(point5, grid) {
39277
+ let closestPoint = grid[0][0];
39278
+ let minDistance = Infinity;
39279
+ for (const row2 of grid) {
39280
+ for (const gridPoint of row2) {
39281
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39282
+ if (distance < minDistance) {
39283
+ minDistance = distance;
39284
+ closestPoint = gridPoint;
39285
+ }
39286
+ }
39287
+ }
39288
+ return closestPoint;
39289
+ }
39290
+ function findClosestValidPointInGrid(point5, grid, obstacles) {
39291
+ let closestPoint = null;
39292
+ let minDistance = Infinity;
39293
+ for (const row2 of grid) {
39294
+ for (const gridPoint of row2) {
39295
+ const isPointValid = !obstacles.some((obstacle) => obstacle.isAlmostInside(gridPoint, conf.CONNECTOR_ITEM_OFFSET - 1));
39296
+ if (isPointValid) {
39297
+ const distance = Math.abs(point5.x - gridPoint.x) + Math.abs(point5.y - gridPoint.y);
39298
+ if (distance < minDistance) {
39299
+ minDistance = distance;
39300
+ closestPoint = gridPoint;
39301
+ }
39302
+ }
39303
+ }
39304
+ }
39305
+ return closestPoint;
39306
+ }
39290
39307
  function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39291
39308
  const tempGridInfo = createGrid(start, end);
39292
39309
  const startPoint = tempGridInfo.newStart || start;
@@ -39298,15 +39315,17 @@ function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
39298
39315
  const { grid, newStart, newEnd } = createGrid(start, end, allWaypoints);
39299
39316
  const finalStart = newStart || start;
39300
39317
  const finalEnd = newEnd || end;
39301
- const pointsToVisit = [finalStart, ...allWaypoints, finalEnd];
39302
- const uniquePoints = pointsToVisit.reduce((acc, p3) => {
39318
+ const snappedStart = findClosestPointInGrid(finalStart, grid);
39319
+ const snappedEnd = findClosestPointInGrid(finalEnd, grid);
39320
+ const snappedWaypoints = allWaypoints.map((p3) => findClosestValidPointInGrid(p3, grid, obstacles)).filter((p3) => p3 !== null);
39321
+ const points = [snappedStart, ...snappedWaypoints, snappedEnd];
39322
+ const uniquePoints = points.reduce((acc, p3) => {
39303
39323
  if (!acc.some((existing) => existing.barelyEqual(p3))) {
39304
39324
  acc.push(p3);
39305
39325
  }
39306
39326
  return acc;
39307
39327
  }, []);
39308
- const snappedPoints = uniquePoints.map((p3) => findClosestPointInGrid(p3, grid));
39309
- const pathPoints = findPathPoints(snappedPoints, grid, obstacles, newStart, newEnd);
39328
+ const pathPoints = findPathPoints(uniquePoints, grid, obstacles, newStart, newEnd);
39310
39329
  return {
39311
39330
  lines: getLines(pathPoints),
39312
39331
  newStart,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.92",
3
+ "version": "0.5.93",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",