Skip to main content

A small software 3D renderer for pygame surfaces.

Project description

MiniPy3DR

MiniPy3DR is a tiny software 3D renderer for Pygame surfaces. It is designed for lessons, prototypes, and small games where students can see the basics of cameras, meshes, lights, flat shading, and z-buffer rendering.

Install

Recommended for Windows classroom PCs:

python -m pip install minipy3dr

This installs the matching prebuilt Windows wheel from PyPI for 64-bit Python 3.10, 3.11, 3.12, or 3.13. Students do not need Visual Studio Build Tools.

To pin a specific version for a class:

python -m pip install "minipy3dr==0.4.1"

Check that the native renderer is available:

python -c "from minipy3dr.render import is_native_available; print(is_native_available())"

With uv:

uv pip install minipy3dr

Installing from GitHub source is useful for teachers and development, but it is not the recommended classroom default because pip builds the C++ extension on the local PC:

python -m pip install "git+https://github.com/andogensi/MiniPy3DR.git"

With uv:

uv pip install "git+https://github.com/andogensi/MiniPy3DR.git"

From a specific branch or tag:

python -m pip install "git+https://github.com/andogensi/MiniPy3DR.git@main"
python -m pip install "git+https://github.com/andogensi/MiniPy3DR.git@v0.4.1"

From this repository:

python -m pip install .

For classroom development, use editable install:

python -m pip install -e .

or with uv:

uv pip install -e .

After that, student files can simply import the beginner API:

from minipy3dr import App

Quick Start

from minipy3dr import App

app = App(title="MiniPy3DR")
cube = app.cube(position=(0, 0, -5), size=2, color=(220, 120, 80), ambient=0.22)
app.light(direction=(-0.4, -0.8, -0.6))


def update(app, delta):
    app.rotate(cube, y=delta)


app.run(update=update)

Load OBJ Meshes

from minipy3dr import App

app = App(title="OBJ demo")
model = app.obj("assets/model.obj", position=(0, 0, -6), color=(160, 210, 255))
app.light(direction=(-0.4, -0.8, -0.6))


def update(app, delta):
    app.rotate(model, y=delta)


app.run(update=update)

For lower-level code, use load_obj(path) to get a Mesh:

from minipy3dr import load_obj

mesh = load_obj("assets/model.obj")

Run the Demo

python -m minipy3dr

or, after installation:

minipy3dr-demo

Renderer Benchmark

Compare the current renderer modes before changing the rasterizer:

python -m minipy3dr.benchmark

or, after installation:

minipy3dr-benchmark

The default benchmark runs these cases at 640x480 and 1280x720:

  • cube_100
  • cube_500
  • sphere_obj_1

You can also run the heavier example scene with --cases doom_like_shooter.

It measures solid, solid_numpy, and solid_native. solid_native uses the C++ extension when it is built; otherwise it is reported as skipped.

From source, install or rebuild the project to compile the native extension:

python -m pip install -e .

For a quick smoke run:

python -m minipy3dr.benchmark --frames 1 --warmup 0 --cases sphere_obj_1 --resolutions 640x480

Beginner Lessons

  • docs/beginner_api.md
  • docs/classroom_setup.md
  • examples/beginner_01_cube.py
  • examples/beginner_02_keyboard.py
  • examples/beginner_03_collect_game.py

Build

python -m pip install -e ".[dev]"
python -m build

With uv:

uv pip install -e ".[dev]"
uv run python -m build

The wheel and source archive will be written to dist/.

Publish to PyPI

Windows wheels are built by GitHub Actions and published to PyPI on version tags. Before the first release, configure a PyPI trusted publisher or pending publisher for repository andogensi/MiniPy3DR, workflow wheels.yml, and environment pypi.

To publish a new version, update the version in pyproject.toml and minipy3dr/__init__.py, then push a tag:

git tag v0.4.1
git push origin main
git push origin v0.4.1

The Build and publish package workflow uploads cp310, cp311, cp312, and cp313 Windows win_amd64 wheels plus the source distribution to PyPI. Those wheels include the C++ native renderer, so students can use pip install minipy3dr without Visual Studio Build Tools.

The workflow uses PyPI trusted publishing with the pypi GitHub Environment. It sets MINIPY3DR_REQUIRE_NATIVE=1, so PyPI wheels fail to build if the native extension is missing. Source installs keep the extension optional and fall back to the Python/NumPy renderer when no compiler is available.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minipy3dr-0.4.1.tar.gz (40.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

minipy3dr-0.4.1-cp313-cp313-win_amd64.whl (242.2 kB view details)

Uploaded CPython 3.13Windows x86-64

minipy3dr-0.4.1-cp312-cp312-win_amd64.whl (242.3 kB view details)

Uploaded CPython 3.12Windows x86-64

minipy3dr-0.4.1-cp311-cp311-win_amd64.whl (242.3 kB view details)

Uploaded CPython 3.11Windows x86-64

minipy3dr-0.4.1-cp310-cp310-win_amd64.whl (242.3 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file minipy3dr-0.4.1.tar.gz.

File metadata

  • Download URL: minipy3dr-0.4.1.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.4.1.tar.gz
Algorithm Hash digest
SHA256 7216ca0af2c4044aa7333539e59f8e341ecbfe7611f1c30a2623f2e6ca6c7b01
MD5 b703edb7af3ff1181c6299d30abe4383
BLAKE2b-256 d981dcfe366018b16c63fddfce24638aa7e0bce7030442c69fb7c893da8b4c55

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.1.tar.gz:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.4.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 242.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.4.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c145c67939f5555f1aa462765a39687a2d3e1a69ed7a8002b4c03a3ba527b52c
MD5 6246a65dbe023bd2f0fb7b50d05ae131
BLAKE2b-256 6dba7dd7c205ab1ed5bf91c95a2db72400368c63af603bf9e379f1c3e00edbe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.1-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.4.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 242.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d1e0e61a7dafc4f6609f71d3e5af44468ee9bbd77e6543f2fcfa163038e87dd2
MD5 e3195fbbc932732098eb7e04d6f64ec3
BLAKE2b-256 4e22df88ec45d7a76c0e1103590321db6c5086b64d441ee9bb76e800b8943d70

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.1-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.4.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 242.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8033404fae39df9a092a53e703786a6613466c814274800793f1dcd73887e333
MD5 db790419af38526ed35eb3545ec232a0
BLAKE2b-256 8502ce54368dd5e39dc563638ab61f7e7ffd2ace6d9034dd1295021b77cecd80

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.1-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.4.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 242.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 07a7fc09fa38c44c63d19e39280dc1e95844db76fe125a98edc5e43dbf1615c3
MD5 8741c03344fdb598247dd0d58bcedd42
BLAKE2b-256 eedfb270bed4691301f742d848cd0f96819734d29b666d8c9dae37ba41a7f198

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.1-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page