Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WebAssembly

All library crates compile to wasm32-unknown-unknown. CI verifies this on every commit.

Building for WASM

# Build specific crates for WASM
cargo build --target wasm32-unknown-unknown -p landmark -p waymark

# Build all library crates
cargo build --target wasm32-unknown-unknown \
    -p landmark-common -p landmark -p waymark \
    -p waymark-crowd -p waymark-tilecache -p waymark-dynamic

The landmark-cli crate does not compile to WASM (it uses file I/O and clap).

Feature Compatibility

FeatureNativeWASMNotes
Mesh generationYesYesFull support
PathfindingYesYesFull support
Crowd simulationYesYesFull support
Dynamic obstaclesYesYesFull support
Async operationsYesYesRuntime-agnostic via async-lock
File I/OYesNoDisable std feature
SerializationYesYesIn-memory only on WASM

Crate-Specific Notes

landmark-common

Disable the std feature to remove file I/O dependencies:

[dependencies]
landmark-common = { version = "0.1", default-features = false }

This removes:

  • TriMesh::from_obj() (use TriMesh::from_obj_str() instead)
  • MeshError::Io variant

waymark

Serialization works on WASM using in-memory buffers. File-based save/load methods require native targets.

waymark-tilecache

Uses lz4_flex (pure Rust) instead of system LZ4. No C dependencies, works on WASM without configuration.

waymark-dynamic

Async operations use async-lock and futures-lite by default. These are runtime-agnostic and work on WASM without tokio.

The tokio feature flag enables tokio integration but is not WASM-compatible:

# Native only - do not use with WASM
waymark-dynamic = { version = "0.1", features = ["tokio"] }

Timing

The landmark crate uses web-time instead of std::time::Instant. This provides WASM-compatible timing via performance.now() on web targets.

Dependency Summary

WASM-incompatible features are isolated behind feature flags:

FeatureCrateWASM-compatible
stdlandmark-commonNo (file I/O)
tokiowaymark-dynamicNo (tokio runtime)
serializationwaymark, waymark-tilecacheYes (in-memory)