Architecture

Atrion is a Rust-native physics engine compiled to WASM. The TypeScript package is a thin SDK wrapper.

The Stack

Rs

Rust Core

atrion-core crate

  • • SIMD-optimized physics calculations
  • • Zero-allocation hot path
  • • 586M ops/sec, 2.11ns latency
W

WASM Binary

wasm32-unknown-unknown target

  • • Compiled with wasm-bindgen
  • • ~50KB gzipped
  • • Auto-loaded when available
TS

TypeScript SDK

npm install atrion

  • • Thin wrapper over WASM core
  • • TypeScript types & DX
  • • Pure-JS fallback if WASM unavailable

Why Rust?

Determinism

No GC pauses. Physics calculations are bit-reproducible across runs.

Performance

SIMD vectorization. Zero-copy data paths. Sub-3ns decision latency.

Safety

Memory safety without runtime overhead. No undefined behavior.

Portability

Single crate compiles to native, WASM, and embedded targets.

Fallback Behavior

The SDK automatically detects WASM availability:

initialization
// The SDK handles this automatically:
const atrion = new Atrion()
// Check which engine is active
console.log(atrion.engine)
// → 'wasm' or 'js'
// Force specific engine (testing)
const jsOnly = new Atrion({ engine: 'js' })

Note: The pure-JS fallback is ~10x slower but produces identical results. Use WASM in production.

Source Code