This is my GitHub repository pathfinding3d. I previously released three-pathfinding-3d, which fixed some algorithmic issues with three-pathfinding. The /pkg directory contains a pre-built wasm module that can be used directly as an es-module.
Performance comparison (WASM vs JavaScript)
This document compares the two implementations used in demo/src/main_wasm.ts: pathfinding3d (Rust / WASM) and three-pathfinding-3d (JavaScript).
Browser demo methodology
After level.nav.glb is loaded, a single click on the navmesh (without dragging) triggers pathfinding. The code runs 10 pathfinding calls for the same start / end pair and measures elapsed time:
| Section | Metric / Detail | Value | Notes |
|---|---|---|---|
| Browser Demo | API (WASM) | PathfindingWasm.prototype.find_path |
10 iterations |
| API (JS) | Pathfinding.prototype.findPath |
10 iterations | |
| Measurement | Elapsed time for 10 calls | Inspect console.table |
|
| Metrics | Total ms, Avg per call | console.time / console.timeEnd |
|
| Node Benchmark | Script | demo/scripts/bench-pathfinding.mjs |
Headless, reproducible |
| Mesh | level.nav.glb (Navmesh_Mesh) |
Vertices: 563, Indices: 1656 | |
| Endpoints | Start: (-3.5, 0.5, 5.5)End: (2, 0.5, -2) |
Player height aligned | |
| Iterations | 10 calls per implementation | No rendering overhead | |
| Pathfinding Performance | Run 1 | WASM: 0.8818 ms JS: 10.4133 ms |
Ratio: 11.81x |
| Run 2 | WASM: 0.7459 ms JS: 9.5605 ms |
Ratio: 12.82x | |
| Run 3 | WASM: 0.8342 ms JS: 10.4888 ms |
Ratio: 12.57x | |
| Summary | JS is ~11–13× slower than WASM | Varies by mesh complexity | |
| Zone Build Performance | Run 1 | WASM: 3.1529 ms JS: 4.9874 ms |
Single shot |
| Run 2 | WASM: 2.8102 ms JS: 5.7774 ms |
Single shot | |
| Run 3 | WASM: 2.8803 ms JS: 5.0330 ms |
Single shot | |
| Summary | Same order of magnitude | WASM sometimes slightly faster | |
| Environment | Date | 2026-05-11 | Recorded run |
| OS | Windows (win32) |
||
| Node.js | v22.22.0 |
On this asset, single-shot zone build is the same order of magnitude for WASM and JS; across these runs WASM was sometimes slightly faster.
Takeaways
-
Pathfinding: On the Node benchmark against
demo/public/level.nav.glb, WASM is on the order of one magnitude faster than JavaScript (here ~12×, seejs_vs_wasm_ratioin the table). In the browser, treatconsole.tableas the ground truth; absolute milliseconds vary with endpoints and load. -
Zone build: Strongly depends on mesh complexity; on this navmesh, single-shot WASM / JS builds are in the low single‑digit millisecond range.
-
Recommendation: Use the browser demo’s
console.tablefor interactive realism; usebench-pathfinding.mjsfor regression checks against the same glb shipped with the repo.
