astar-wasm
v0.1.0
Published
This is a WASM implementation of the A\* algorithm for pathfinding in flow. The algorithm is implemented in Rust and compiled to WASM using the `wasm-pack` tool.
Downloads
1
Readme
A* Algorithm in WASM
This is a WASM implementation of the A* algorithm for pathfinding in flow. The algorithm is implemented in Rust and compiled to WASM using the wasm-pack
tool.
Type
export declare function auto_route(
paths: {
start: { x: number; y: number };
end: { x: number; y: number };
source: number;
target: number;
}[],
rects: { x: number; y: number; weight: number; height: number }[],
offset: { x: number; y: number }
): { x: number; y: number }[][];
Usage
Browser:
import init, { auto_route } from "astar-wasm";
await init();
const paths = [
{
start: { x: 110, y: 50 },
end: { x: 150, y: 210 },
source: 0,
target: 1
}
]
const rects = [
{ x: 0, y: 0, weight: 100, height: 100 },
{ x: 100, y: 100, weight: 100, height: 100 }
]
const offset = { x: 10, y: 10 };
const pathPoints = auto_route(paths, rects, offset);
console.log(pathPoints);