Skip to content
← All articles
Project introduction

Dimension: connecting Rust mathematics to a renderer

Listen to the audio story

From Rust math to pixels · 2:20 · AI-written script, synthetic voices

Transcript

Ava: What does it take to turn a few numbers in a matrix into a cube spinning on your screen? Antoine's Rust project Dimension answers that, one layer at a time.

Andrew: Okay, so where does a project like that start?

Ava: With the math library, called mathlib. It stores matrices in dense form and in sparse formats, and gives you vectors, views and submatrices. On top of that it offers classic numerical tools: LU, Cholesky and SVD decompositions, root finding and numerical integration.

Andrew: That sounds like a linear algebra textbook.

Ava: A bit, yes, and that's the point. The renderer reuses those same pieces on the CPU for transforms and camera math. So the math isn't a separate experiment, it feeds the drawing.

Andrew: How does the drawing part work?

Ava: Picture a flow: geometry goes into CPU transforms, then into a scene with cameras, then into a renderer built on wgpu. That renderer can show the result in a native window or in a web canvas through WebAssembly.

Andrew: What's in the scene?

Ava: A world of entities, each with a transform, plus cameras and render targets. The scene is a tree of parents and children. Think of a hand holding a cup: move the hand, and the cup moves with it, because the cup's position is described relative to the hand.

Andrew: That's neat. And keeping native and web separate?

Ava: Platform code lives in its own layer, apart from the scene and the numerical code, so both targets share the same building blocks. There's also optional serialization through the serde feature, and optional GPU functionality behind a feature flag.

Andrew: Is it only math and rendering?

Ava: The workspace is wider. Antoine's manifest lists crates for geometry, collision, kinematics, physics, networking, parsing and neural work next to mathlib. He reads the manifest and module entry points to see how it all fits together.

Andrew: So the takeaway is a clean path from matrices to pixels.

Ava: Yes: storage, transforms, scene, renderer. And you don't have to take it on faith: the page runs the demos right in your browser. Press start and you get the render demo, the geometry meshes, the math library and the embeddings, all compiled to WebAssembly. The full write-up has the architecture diagram and links to each source file.

Table of contents

Dimension is my Rust workspace for mathematics and graphics experiments. The useful starting point is mathlib: it exposes matrix storage, numerical solvers and the transformations that the rendering crate uses on the CPU.

Project architecture

Project architecture overview. Open the image to inspect the details.

1. Architecture

flowchart LR
  Geometry["Geometry"] --> Math["CPU transforms<br/>mathlib"]
  Math --> Scene["Scene and cameras"]
  Scene --> Render["wgpu renderer"]
  Render --> Native["Native window"]
  Render --> Web["Web canvas"]

The application supplies geometry and transforms. The scene layer organizes entities and cameras; the rendering layer prepares the GPU work for a native window or web canvas. This is the rendering path, not a claim that every numerical operation runs on the GPU.

Open the component-by-component code walkthrough.

2. Try it in the browser

The same crates compile to WebAssembly, and the repository publishes each demo as a static page. Pick one below and press start: it runs in your browser, with nothing to install.

Live demo

Dimension running in your browser

A cube, a tetrahedron and a cylinder drawn by the wgpu renderer, with a transform gizmo and object picking.

Loads from antoinebou12.github.io only when you press start. WebAssembly; the 3D demos need a browser with WebGPU.

Open in a new tab

The repository also publishes a kinematics demo[1] (a three-joint arm solved with inverse kinematics) and a physics demo[2] (rigid bodies with XPBD). Both need a browser with WebGPU and open in their own tab.

3. Start with the storage

mathlib/src/lib.rs[3] exports dense storage alongside sparse formats such as CRS and CCS. The public API also includes matrix and vector types, matrix views and submatrices. Those choices matter before a renderer draws anything: they determine how a caller represents and passes its data.

The same entry point exposes LU, Cholesky and SVD decompositions, plus root finding and numerical integration. Optional GPU functionality sits behind a feature flag. The presence of an executor abstraction is a design choice, not a measured speedup; I have not included performance comparisons here.

4. Follow a transform into the scene

render/src/lib.rs[4] describes a wgpu renderer that uses mathlib for CPU transforms and camera mathematics. Its exports include World, EntityId, Transform, cameras and render targets.

The scene represents parent-child relationships with a tree. A local transform therefore belongs to a hierarchy: moving a parent changes the context in which its children are rendered. Serialization is optional and enabled through the serde feature.

The platform layer supports native windows and WebAssembly canvas targets. Keeping platform code apart from scene and numerical code gives those targets shared building blocks, although it does not prove identical behavior on every GPU or browser.

5. Read the workspace, not only the README

The root Cargo.toml[5] lists crates for rendering, geometry, collision, kinematics, physics, networking, parsing and neural work alongside mathlib. The README still focuses on the mathematics crate. I use the manifest and module entry points to understand the current structure.

This is exploratory code. Performance comparisons would need a reproducible benchmark with its input size and target hardware.

Browse Dimension on GitHub[6].

References

  1. kinematics demo. (). [Web page] antoinebou12.github.io.
  2. physics demo. (). [Web page] antoinebou12.github.io.
  3. antoinebou12. (). mathlib/src/lib.rs. [Source file or documentation] github.com.
  4. antoinebou12. (). render/src/lib.rs. [Source file or documentation] github.com.
  5. antoinebou12. (). Cargo.toml. [Source file or documentation] github.com.
  6. antoinebou12. (). Dimension. [Software repository] github.com.

References use this article’s publication date.