The Ivy Pathfinding Algorithm Wrapped Accessible via Javascript
npm install ivy_pathfinding_algorithmbash
npm i ivy_pathfinding_algorithm
`
Usage
This algorithm takes two flattened arrays of three dimensional coordinates (x1,y1,z1,x2,y2,z2, ...) and produces an array of OutputMove objects if the run is successful.
`Typescript
import { ivy_pathfinding_algorithm, type OutputMove } from "./pkg/ivy_pathfinding_algorithm";
interface Block {
id: number;
position: [number, number, number];
}
const call_pathfinding_algorithm = (start_blocks: Block[], end_blocks: Block[]): OutputMove[] | undefined => {
const start_coords_raw: BigInt64Array = new BigInt64Array(3 * start_blocks.length);
for (const [index, coordinate] of start_blocks.entries()) {
const array_index = 3 * index;
start_coords_raw[array_index] = BigInt(coordinate.position[0]);
start_coords_raw[array_index + 1] = BigInt(coordinate.position[1]);
start_coords_raw[array_index + 2] = BigInt(coordinate.position[2]);
}
const end_coords_raw: BigInt64Array = new BigInt64Array(3 * end_blocks.length);
for (const [index, coordinate] of end_blocks.entries()) {
const array_index = 3 * index;
end_coords_raw[array_index] = BigInt(coordinate.position[0]);
end_coords_raw[array_index + 1] = BigInt(coordinate.position[1]);
end_coords_raw[array_index + 2] = BigInt(coordinate.position[2]);
}
return ivy_pathfinding_algorithm(start_coords_raw, end_coords_raw);
}
`
Publish
- ensure code works
- ensure version has been updated
`bash
wasm-pack build --target web
wasm-pack publish --target web
``