DFTZ Experiments

Small tests of web 3D, Rust compiled to WebAssembly, and WebXR. Each is one page that runs in a desktop browser or on a Quest, with its numbers on screen.

JavaScript vs WebAssembly in 3D

three.js · Rust → WebAssembly · WebXR

A fountain of up to 40,000 colliding balls. The same physics is written twice, in JavaScript and in Rust, and three.js draws both. Switch between them and watch the physics time.

First result, in Chrome on an M-series Mac: Rust was about 1.2× faster at every size. The Rust module is 20 KB and ready in a few milliseconds.

Minimal Rust 3D app

Rust → WebAssembly · WebGL2 · no framework

A page that is almost nothing but a reference to a WebAssembly binary. The Rust builds the page itself, handles the button, and draws 9,216 cubes with the browser's own WebGL2 in one draw call. View the source.

55 KB of WebAssembly (26 KB gzipped). It reports how long it took to draw its first frame.