Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- recursiveIterationOfPoints: function(path, end) {
- let current = path[path.length - 1];
- if (current.id === end.id) {
- console.log(path);
- path.push(path);
- return path;
- }
- // Otherwise run run other ercursive iterations for the connected.
- for (let i = 0; i < current.connected.length; i++) {
- let nextPoint = hallwayPoints[current.connected[i]];
- let found = false;
- path.forEach( function (point, index) {
- if (point.id === nextPoint.id) {
- found = true;
- }
- });
- if (found)
- continue;
- let newPath = path.slice();
- newPath.push(hallwayPoints[current.connected[i]]);
- newPath = this.recursiveIterationOfPoints(newPath, end);
- if (newPath !== undefined) {
- if (newPath[newPath.length - 1].id === end.id) {
- path.push(path);
- return path;
- }
- }
- }
- return path;
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement