Skip to main content

A library for 3D rendering in PyGame

Project description

Pygame 3D

Pygame3D is a cross-platform open-source python library for basic 3D rendering in PyGame. It has many features, from 3D rendering to camera control. It is extremely simple, with a streamlined creation process, and just like what its name suggests, it integrates perfectly into PyGame.

Results


Scene rendering:

Installation


To install Pygame3D, use the Python Package Manager and type:

pip install pygame3d

Once it is installed, you can start using it just like any other module!

Documentation


To learn more about this module, you can read its documentation here

Quickstart


Here is a sample code to render a 3D model in Pygame3D, as shown in the image above.

# Basic model loading and rendering

import pygame
import pygame3d
import sys

# Initialize the pygame library
pygame.init()

screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()

# Create a 3D surface
surface = pygame3d.Surface3D((800, 600))

# Configure background color
surface.background_color = (145, 216, 255) # Sky blue

# Loading a model
model = surface.load_mesh('assets/model.glb')
model.position = (0, 20, -2)

# Add a light
light = surface.add_light('point')
light.position = (20, 20, 20)

light2 = surface.add_light('ambient')
light2.color = (50, 50, 50)

# Main game loop
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    model.rotation += (1, 0, 0) # Rotate the model
    surface.render() # Render the surface to display the newest updates
    screen.blit(surface, (0, 0))

    pygame.display.update()
    clock.tick(60) # 60 FPS

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

pygame3d-0.1.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

pygame3d-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pygame3d-0.1.1.tar.gz.

File metadata

  • Download URL: pygame3d-0.1.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pygame3d-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9fa504b03d093be296f85361d74d8d008f2e10ab95095fbcfa9149f83bb4b9b6
MD5 c2f7de238f27a805610d56ac468a7625
BLAKE2b-256 e6c5184b248181c0051c72d6c40084202320106c7a765bd08b0fd509657bba47

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygame3d-0.1.1.tar.gz:

Publisher: publish.yml on Fr5ctal-Dev/pygame3d

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

File details

Details for the file pygame3d-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pygame3d-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pygame3d-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5130875060e106ac5014efd6c0e43e21a120f313e2d65fa04d92830aa2d7577e
MD5 56655d8b6facc65ab83d9bec12dd0411
BLAKE2b-256 2a54e4ac1d51ad98bb78a079dae6695e48a57b667244e6fdb8d368e653025617

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygame3d-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Fr5ctal-Dev/pygame3d

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