astar-wasm
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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);

Readme

Keywords

none

Package Sidebar

Install

npm i astar-wasm

Weekly Downloads

3

Version

0.1.0

License

none

Unpacked Size

95.6 kB

Total Files

5

Last publish

Collaborators

  • mutemoon