Skip to main content

ManifoldX

PyPI version Python versions License Tests

A real-time 3D rendering engine built on pure wgpu with an Entity Component System (ECS) architecture. Written in Python with numpy for high-performance data handling.

⚠️ Beta / Academic Project — This is an experimental proof-of-concept exploring the extent to which Python can be used for high-performance graphics via wgpu. Not recommended for production use. Expect bugs, breaking changes, and missing features.

Motivation

Domain researchers need to run large-scale simulations (10⁴-10⁶ entities) and visualize results in 3D. Currently they can't do both in pure Python.

Tool Simulation Visualization Language
Matplotlib/Plotly ✅ 2D only, slow at scale Pure Python
VisPy ❌ OpenGL, steep curve Python + GLSL
PyGfx ❌ Excellent rendering Pure Python
Game engines (PyGame) ✅ 2D mostly Pure Python
Specialized (OpenMM, SUMO) ✅ Data export only Fortran/C++

The gap: No Python tool combines data-driven simulation with accessible 3D visualization in one package.

The Vision

ManifoldX gives researchers both:

  1. Simulation in pure NumPy — vectorized operations over entity arrays, no Python loops in the hot path
  2. 3D visualization without graphics knowledge — spawn entities with meshes/materials, the engine handles GPU rendering
# Write physics in pure numpy (data-driven, not OOP)
@engine.system
def nbody_physics(query, dt):
    # Magic happens here...
    forces = compute_gravity_all_pairs(query[Transform].pos.data)
    velocities += forces * dt
    query[Transform].pos += velocities * dt

# Engine handles GPU buffers, WGSL shaders, instanced draw calls
# You get 3D visualization of your simulation instantly

Target domains: Astrophysics (galaxy formation), molecular dynamics (protein folding), epidemiology (disease spread), crowd science (evacuation flows), traffic engineering (vehicle flow), weather (particle advection).

Works in: Jupyter notebooks, Quarto documents, Streamlit dashboards, standalone scripts.

⚠️ Spoiler: Python is surprisingly capable at real-time 3D. The N-body demo runs 500 bodies with N² gravity — 250,000 force pairs per frame in pure numpy.

Why Not PyGfx?

PyGfx is an excellent rendering engine and has been a key source of inspiration — we've learned a lot from its WGSL patterns, material system, and API design. However, it's fundamentally a scene graph engine (object-oriented hierarchy of transforms), not a data-driven ECS. For large-scale simulations with vectorized physics, the OOP overhead of traversing a scene graph becomes a bottleneck. ManifoldX uses a flat SoA data layout where simulation logic operates directly on numpy arrays.

Technically this is a game engine — the ECS + instanced rendering + PBR pipeline is exactly what you'd use for a game. But that's not the focus. The goal is making 3D visualization accessible to researchers who don't know anything about graphics.

Installation

pip install manifold-gfx           # Base (no rendering backends)
pip install manifold-gfx[desktop]  # + GLFW for desktop window
pip install manifold-gfx[offline]  # + imageio-ffmpeg for video
pip install manifold-gfx[all]      # Everything

# or with uv
uv add manifold-gfx
uv add manifold-gfx[desktop]       # Desktop rendering
uv add manifold-gfx[offline]      # Video rendering

Requirements:

  • Python 3.13+
  • GPU with WebGPU support (via wgpu backend)
    • Vulkan on Linux
    • Metal on macOS
    • D3D12 on Windows

Note: Install with [desktop] for interactive rendering, [offline] for video output, or [all] for both.

The guide

The documentation is a book in docs/ that follows one project, a small town plaza, from a first frame to a finished scene. Every code block in it runs against the library when the guide is built, so what it says is what this version does. Each chapter's finished program is in docs/examples/.

  1. A first frame: the engine, a camera, something to look at.
  2. People who walk: components, queries and systems.
  3. Reacting to the visitor: events, input and commands.
  4. Light and surface: materials, lights and shadows.
  5. Sky, water and textures: textures, water, atmosphere and image-based lighting.
  6. Modelling the buildings: meshes built in code: booleans, deformers, fields.
  7. Bodies and poses: humanoid figures, skinning and the id pass.
  8. Measuring the plaza: point clouds, labels, axes, charts and volumes.
  9. A control panel: widgets inside the window.
  10. Crowds on the GPU: compute kernels written in Python.
  11. Assets in and out: OBJ, glTF and streaming.
  12. A still worth printing: the path tracer.
  13. Working with an agent: hot reload, the dev channel and the web page.
  14. The plaza, end to end: everything together.

Build it locally with make docs (the site lands in docs/site/).

Examples and demos

Two kinds of runnable code: examples/ are focused — one feature, minimal code (documentation); demos/ are show-off — game-like / sim-like experiences combining many systems. See each folder's README.md.

examples/ — focused feature examples

Example Description
hello_world.py Minimal empty window
cube.py Rotating cube with Phong material
pbr.py 3×2 grid demonstrating PBR materials + 3 orbiting lights
shadows.py / spotlight.py Directional-sun and spot-light shadow mapping
ibl.py Image-based lighting (split-sum environment reflection)
textures.py Textured PBR: a UV-mapped teapot with an albedo map
spheres.py Many spheres with physics-like behavior
nbody.py / gas.py / boids.py Pure-numpy gravity / ideal-gas / flocking simulations
nbody_compute.py / gas_compute.py / point_cloud_compute.py Same, ported to GPU compute kernels
scatter_plot.py / point_cloud.py / axes.py Sci-viz manifoldx.viz primitives
volume.py Direct volume rendering of a 64³ Gaussian blob
gui.py Immediate-ish GUI widgets (panels, sliders, toggles)
fields.py / color_by.py Composable field algebra + per-vertex coloring (procedural terrain)
deformers.py / sculpt* / topology.py / booleans.py / ffd.py manifoldx.modeling operators
event_dolly.py / event_pulse.py Event bus (async dolly, sync spawn-on-event)
input_orbit.py / input_fly.py Drag-to-orbit and WASD fly-cam via the input layer

demos/ — end-to-end showcases

Demo Description
terrain_stream.py Infinite procedural-terrain flyby with shader fog; patches generated in a worker process and streamed into a recycled slot pool
labyrinth_fps.py First-person maze crawl with a shadow-casting flashlight
sun_earth_moon.py Textured Earth + Moon orbiting a sun (bundled NASA imagery)
smoke.py Volumetric Perlin-FBM smoke with camera motion

Run one:

python examples/nbody.py                 # interactive window
python demos/terrain_stream.py --render --duration 8 --output flyby.mp4

Contributing

Contributions are welcome. Open an issue first for anything beyond a small fix; the roadmap lives in the pinned vision issue. Agents working in this repository start from AGENTS.md.

git clone https://github.com/gia-uh/manifoldx.git
cd manifoldx
uv sync --extra offline --extra viz --extra svg --dev --group docs
make test        # the suite; render tests need a GPU adapter (lavapipe works)
make docs-check  # the guide: every block runs, examples match, every class covered

License

MIT License — See LICENSE file.

Credits

  • wgpu — Pure Python WebGPU bindings
  • PyGfx — Reference for WGSL shader patterns
  • rendercanvas — Window management

Metadata

Release files for manifold-gfx 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for manifold-gfx 0.10.0
File Size Uploaded Provenance Actions
manifold_gfx-0.10.0.tar.gz 6.2 MB Without provenance Details for manifold_gfx-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for manifold-gfx 0.10.0
File Interpreter ABI Platform Actions
manifold_gfx-0.10.0-py3-none-any.whl Python 3 none any Details for manifold_gfx-0.10.0-py3-none-any.whl

Total release size: 9.2 MB

Release files / manifold_gfx-0.10.0.tar.gz

Download URL manifold_gfx-0.10.0.tar.gz
Size 6.2 MB
Tags Source
SHA-256 checksum
How to use checksums
11d27efbf4e60d3b7fbfb88e849e693c18e8971e02cec2507a8d096505028ea1
BLAKE2b-256 checksum
How to use checksums
ba850cb7a6d45b6b7daba2f90f554f917955d77b0e8324181e912910adf77364
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / manifold_gfx-0.10.0-py3-none-any.whl

Download URL manifold_gfx-0.10.0-py3-none-any.whl
Size 3.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
738c392732ffc2b341c562b62e0c7952f3a917459c2d8fd9574e8cf9e040b9cc
BLAKE2b-256 checksum
How to use checksums
004696bb0498ce6dd0bd919d0de8dd821c370f2961251ea4a9ffd6191a851a85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for manifold-gfx 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page