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.2"

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.2"

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.2
git push origin main
git push origin v0.4.2

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.2.tar.gz (40.9 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.2-cp313-cp313-win_amd64.whl (243.3 kB view details)

Uploaded CPython 3.13Windows x86-64

minipy3dr-0.4.2-cp312-cp312-win_amd64.whl (243.3 kB view details)

Uploaded CPython 3.12Windows x86-64

minipy3dr-0.4.2-cp311-cp311-win_amd64.whl (243.4 kB view details)

Uploaded CPython 3.11Windows x86-64

minipy3dr-0.4.2-cp310-cp310-win_amd64.whl (243.4 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

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

File metadata

  • Download URL: minipy3dr-0.4.2.tar.gz
  • Upload date:
  • Size: 40.9 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.2.tar.gz
Algorithm Hash digest
SHA256 28dba2c75b77c851334c59d6eb005ed5c32285c6c46af42a63aad084b3efc1f0
MD5 143b07a339ae613122b31c530dd607ac
BLAKE2b-256 06f5386e4a90220ee09a1bcfc5f490986176a40828efabb4470c03c271b2f1fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.2.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.2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 243.3 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ead67cb1adaf846a82ce4a1192b821d08d64338c701814204755ec4b09e3e945
MD5 d2413696074f5b312015a1e9f9d45452
BLAKE2b-256 43ec87942a38d81a39c271e2b8c7e01d575ca67c51c3039d9478b61b7c47d893

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.2-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.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 243.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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3039fe8524ef1c1427fced69894190b631d01ad28e75ab57e18db2c466196cc0
MD5 0c953138029a9ad94c67bcb35f98b520
BLAKE2b-256 1e6eb1d70773ae362852288517c6d256d357d69e09e66b0dfb94201b128b67c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.2-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.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 243.4 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3f9b86cd7b5a63d19eb767d009ee442ba9ebac71811b74ae48f672a77120bde4
MD5 e313b4ca6633301cc2664e4fc8cf3454
BLAKE2b-256 352c9b59c253f73daf2de3917c08b50467529da4e7e3dd6d2b3c3e1b5cc92bf1

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.2-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.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.4.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 243.4 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.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e594595006abc1f90d9816c36309ce42bed1da0bd825aa4c5e42c9805bed4ee9
MD5 39c0b2a65f270f0fab397ab1788af382
BLAKE2b-256 ac7763f135dcd8250b4715b73797dbf60d5b1a5dcdffaa284886e8a623e4af59

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.4.2-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