Skip to main content

A lightweight 3D rendering library for Python

Project description

3Dlib (tdlib) 🦆

A lightweight, hardware-accelerated 3D rendering library for Python built on ModernGL and Pygame.

Features

  • Fast Rendering: Uses ModernGL for low-level GPU access.
  • Universal Loading: Support for .obj, .stl, .glb, and more via trimesh.
  • Lighting: Built-in Phong shading (Ambient + Diffuse).
  • Textures: Easy PNG/JPG texture mapping.
  • Simple API: Designed to get you rendering in under 50 lines of code.

Code be like: import tdlib from pyrr import Matrix44 import pygame

1. Initialize the Engine

engine = tdlib.Renderer(width=800, height=600)

2. Load a 3D Model

Supports .obj, .glb, .stl

model = tdlib.load_resource(engine, "assets/duck.obj", texture_path="assets/duck_diffuse.png")

3. Main Render Loop

angle = 0 while True: engine.clear() # Clears the screen angle += 0.01

# Define Camera and Transformation
model_matrix = Matrix44.from_y_rotation(angle)
view_matrix = Matrix44.look_at((3, 3, 3), (0, 0, 0), (0, 1, 0))
proj_matrix = Matrix44.perspective_projection(45.0, 800/600, 0.1, 100.0)
mvp = proj_matrix * view_matrix * model_matrix

# Draw the object
engine.render_object(model, mvp, model_matrix, light_pos=[5, 5, 5])

pygame.display.flip()

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

tdlib3d-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

tdlib3d-1.0.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file tdlib3d-1.0.0.tar.gz.

File metadata

  • Download URL: tdlib3d-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for tdlib3d-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e89e1c71897b08e334bf645d316b1f82aed544c808ec9b794f22a7bd453a32de
MD5 aa7c7c98b6f7b78ace7be0c93bf9fbcb
BLAKE2b-256 ef1ba20c4f34b677e02e49fc830171cdf62b89d13e153b305288f2923571a9f4

See more details on using hashes here.

File details

Details for the file tdlib3d-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tdlib3d-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for tdlib3d-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9cd27c46ecb2b950f4d7aca26aa344f55f6a4eaf469e6d9e5ef9e607cf2b6cd
MD5 f5cec82f4d871b0a17879943810d3586
BLAKE2b-256 f6c79a5f767fae1cbc7b4df59119439c760e2cc0f3f046e7f78aad53f9b5ea3c

See more details on using hashes here.

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