Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. recursiveIterationOfPoints: function(path, end) {
  2.             let current = path[path.length - 1];
  3.  
  4.             if (current.id === end.id) {
  5.                 console.log(path);
  6.                 path.push(path);
  7.                 return path;
  8.             }
  9.  
  10.             // Otherwise run run other ercursive iterations for the connected.
  11.             for (let i = 0; i < current.connected.length; i++) {
  12.                 let nextPoint = hallwayPoints[current.connected[i]];
  13.  
  14.                 let found = false;
  15.  
  16.                 path.forEach( function (point, index) {
  17.                     if (point.id === nextPoint.id) {
  18.                         found = true;
  19.                     }
  20.                 });
  21.  
  22.                 if (found)
  23.                     continue;
  24.  
  25.                 let newPath = path.slice();
  26.                 newPath.push(hallwayPoints[current.connected[i]]);
  27.  
  28.                 newPath = this.recursiveIterationOfPoints(newPath, end);
  29.  
  30.                 if (newPath !== undefined) {
  31.                     if (newPath[newPath.length - 1].id === end.id) {
  32.                         path.push(path);
  33.                         return path;
  34.                     }
  35.                 }
  36.             }
  37.  
  38.             return path;
  39.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement