# ronaldo-dck/render3d architecture

> Architecture diagram of the GitHub repository ronaldo-dck/render3d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ronaldo-dck/render3d
- Repository: https://github.com/ronaldo-dck/render3d

## Overview

Render3D is a Pygame application for drawing 2D polylines and revolving them into editable 3D models. The main workflow is user input in the 2D scene, scene switching in the application loop, then mesh creation and 3D rendering. Separate components cover camera/projection, clipping, lighting, and matrix transforms. The shown excerpts establish the core scene, geometry, and math relationships; some 3D integrations are only visible as imports or in omitted code, so those links are not asserted.

Main entry points: [`Cena3D.py`](https://github.com/ronaldo-dck/render3d/blob/main/Cena3D.py) (3D scene), [`init.py`](https://github.com/ronaldo-dck/render3d/blob/main/init.py) (Scene controller), [`Objeto3d.py`](https://github.com/ronaldo-dck/render3d/blob/main/Objeto3d.py) (Revolved mesh), [`Cena2D.py`](https://github.com/ronaldo-dck/render3d/blob/main/Cena2D.py) (Polyline drawing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Scene workflow"]
  node_app["Scene controller<br/>[init.py]"]
  node_drawing["Polyline drawing<br/>[Cena2D.py]"]
end

subgraph group_render["3D rendering"]
  node_scene3d["3D scene<br/>[Cena3D.py]"]
  node_raster["Rasterization and buffers<br/>[Cena3D.py]"]
end

subgraph group_geometry["Geometry and transforms"]
  node_mesh["Revolved mesh<br/>[Objeto3d.py]"]
  node_face["Face visibility<br/>[Objeto3d.py]"]
  node_matrices["Matrix operations"]
end

subgraph group_view["View and clipping"]
  node_camera["Camera controls<br/>[camera.py]"]
  node_projection["Projection<br/>[camera.py]"]
  node_clipping["Polygon clipping<br/>[recorte2d.py]"]
end

subgraph group_shading["Lighting"]
  node_lighting["Phong lighting<br/>[luz.py]"]
end

node_user(("User"))

node_user -->|"starts"| node_app
node_app -->|"runs"| node_drawing
node_drawing -->|"returns polylines"| node_app
node_app -->|"creates with polylines"| node_scene3d
node_app -->|"runs scene"| node_scene3d
node_scene3d -->|"creates meshes"| node_mesh
node_scene3d -->|"rasterizes faces"| node_raster
node_scene3d -->|"calculates shading"| node_lighting
node_scene3d -.-> node_camera
node_scene3d -.-> node_clipping
node_mesh -->|"builds faces"| node_face
node_mesh -->|"transforms vertices"| node_matrices
node_camera -->|"normalizes vectors"| node_matrices

click node_app "https://github.com/ronaldo-dck/render3d/blob/main/init.py"
click node_drawing "https://github.com/ronaldo-dck/render3d/blob/main/Cena2D.py"
click node_scene3d "https://github.com/ronaldo-dck/render3d/blob/main/Cena3D.py"
click node_raster "https://github.com/ronaldo-dck/render3d/blob/main/Cena3D.py"
click node_mesh "https://github.com/ronaldo-dck/render3d/blob/main/Objeto3d.py"
click node_face "https://github.com/ronaldo-dck/render3d/blob/main/Objeto3d.py"
click node_matrices "https://github.com/ronaldo-dck/render3d/blob/main/matrix_functions.py"
click node_camera "https://github.com/ronaldo-dck/render3d/blob/main/camera.py"
click node_projection "https://github.com/ronaldo-dck/render3d/blob/main/camera.py"
click node_clipping "https://github.com/ronaldo-dck/render3d/blob/main/recorte2d.py"
click node_lighting "https://github.com/ronaldo-dck/render3d/blob/main/luz.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_drawing,node_user toneBlue
class node_scene3d,node_raster toneAmber
class node_mesh,node_face,node_matrices toneMint
class node_camera,node_projection,node_clipping toneRose
class node_lighting toneIndigo
```

## Components

### Scene workflow

- [Scene controller](https://github.com/ronaldo-dck/render3d/blob/main/init.py): `init.py`
- [Polyline drawing](https://github.com/ronaldo-dck/render3d/blob/main/Cena2D.py): `Cena2D.py`

### 3D rendering

- [3D scene](https://github.com/ronaldo-dck/render3d/blob/main/Cena3D.py): `Cena3D.py`
- [Rasterization and buffers](https://github.com/ronaldo-dck/render3d/blob/main/Cena3D.py): `Cena3D.py`

### Geometry and transforms

- [Revolved mesh](https://github.com/ronaldo-dck/render3d/blob/main/Objeto3d.py): `Objeto3d.py`
- [Face visibility](https://github.com/ronaldo-dck/render3d/blob/main/Objeto3d.py): `Objeto3d.py`
- [Matrix operations](https://github.com/ronaldo-dck/render3d/blob/main/matrix_functions.py): `matrix_functions.py`

### View and clipping

- [Camera controls](https://github.com/ronaldo-dck/render3d/blob/main/camera.py): `camera.py`
- [Projection](https://github.com/ronaldo-dck/render3d/blob/main/camera.py): `camera.py`
- [Polygon clipping](https://github.com/ronaldo-dck/render3d/blob/main/recorte2d.py): `recorte2d.py`

### Lighting

- [Phong lighting](https://github.com/ronaldo-dck/render3d/blob/main/luz.py): `luz.py`

### Other components

- **User**

## Connections

- User → Scene controller: starts (evidence: `README.md`)
- Scene controller → Polyline drawing: runs (evidence: `init.py`)
- Polyline drawing → Scene controller: returns polylines (evidence: `Cena2D.py`)
- Scene controller → 3D scene: creates with polylines (evidence: `init.py`)
- Scene controller → 3D scene: runs scene (evidence: `init.py`)
- 3D scene → Revolved mesh: creates meshes (evidence: `Cena3D.py`)
- 3D scene → Rasterization and buffers: rasterizes faces (evidence: `Cena3D.py`)
- 3D scene → Phong lighting: calculates shading (evidence: `Cena3D.py`)
- 3D scene → Camera controls (evidence: `Cena3D.py`)
- 3D scene → Polygon clipping (evidence: `Cena3D.py`)
- Revolved mesh → Face visibility: builds faces (evidence: `Objeto3d.py`)
- Revolved mesh → Matrix operations: transforms vertices (evidence: `Objeto3d.py`)
- Camera controls → Matrix operations: normalizes vectors (evidence: `camera.py`)
