Show HN: Intertia, Physics in a Terminal

aclfe1 pts0 comments

Inertia - a physics sandbox in your terminal

Rust · rapier3d · renders to braille

A physics sandbox in your terminal.

Inertia simulates rigid bodies, orbital gravity, cloth, fluid, and heat in full<br>3D, then draws the whole scene with Unicode braille. No GPU, no window server.<br>The same engine now compiles to WebAssembly, so it runs in your browser too.

Launch the demo &rarr;<br>View source

$cargo install inertia-tui

Copy

Rust<br>WebAssembly<br>60 fps<br>No GPU<br>MIT / Apache-2.0

inertia

Real physics, drawn in text.

Inertia is a real-time playground that lives entirely inside a terminal.<br>Every solid, particle, and spring is simulated in three dimensions and<br>rasterized with braille glyphs, so each character cell doubles as a 2&times;4<br>block of pixels. The result is a smooth, shaded 3D scene made of nothing but<br>text.

Rigid-body dynamics run on rapier3d; the n-body gravity, mass-spring<br>cloth, smoothed-particle fluid, and the temperature field on top of it are<br>built from scratch. You orbit the camera, spawn and throw objects, pour water,<br>heat things up, and watch it all settle, sixty times a second.

Because the engine is plain Rust, it also compiles to WebAssembly and renders<br>to a canvas through ratzilla. Every demo below is the exact terminal<br>program, running in the browser.

At a glance

LanguageRust

Rigid bodiesrapier3d

Rendererbraille / ratatui

In the browserratzilla / wasm

LicenseMIT / Apache-2.0

&rarr; Source on GitHub

&rarr; inertia-tui on crates.io

&rarr; Read the README

The simulations

Six sandboxes, one engine.

Five open on a preset scene; the sixth starts empty. Launch any of them in the<br>browser, then take the controls: orbit the camera, spawn objects, and push the<br>parameters around.

Rigid bodies

rapier3d

A ball is launched into a pyramid of boxes. Friction, restitution, and<br>stacking, solved in real time.

N-body gravity

brute-force / Barnes-Hut

Three stars trace a figure-eight in mutual gravitation, leaving orbital<br>trails behind them.

Cloth

mass-spring

A hammock of springs stretches and swings as two balls drop into it. Pin it<br>up, blow wind through it.

Fluid

SPH

Thousands of smoothed particles splash and settle into a tank, buoying the<br>debris that lands in them.

Thermal convection

heat transfer

A hot floor warms the water above it. Buoyant plumes rise and cool, shaded by<br>temperature.

Blank sandbox

build your own

Start from nothing. Drop boxes and spheres, switch gravity to n-body, add<br>cloth and water, and mix the systems however you like.

Get it running

In the browser, or in your shell.

Install from crates.io

Needs a recent Rust toolchain. The crate is published as inertia-tui; the installed command is inertia.

$ cargo install inertia-tui<br>$ inertia

Build the browser demo

The web build uses trunk and the<br>wasm32-unknown-unknown target. Point trunk at this site's<br>demo/ folder and the Launch buttons light up.

$ rustup target add wasm32-unknown-unknown<br>$ trunk build --release --dist site/demo

Controls

Arrow keysOrbit the camera

Shift + arrowsPan across the scene

+ / -Zoom in and out

Left dragGrab an object and throw it

b &middot; s &middot; nSpawn a box, sphere, or star

dCycle tool: place, grab, pour, heat, build

SpacePause, then m to step one frame

1 – 6Switch between the sandboxes

? &middot; qFull help, and quit

inertia terminal middot browser demo build

Related Articles