# danieledapo/r3d architecture

> Architecture diagram of the GitHub repository danieledapo/r3d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danieledapo/r3d
- Repository: https://github.com/danieledapo/r3d

## Overview

1. Buzz – a ray tracer capable of rendering basic geometric primitives (spheres, cubes, planes), triangle meshes, as well as some Constructive Solid Geometry (CSG) operations.
##### Ivo – an isometric voxel renderer that produces isometric views of voxel-based 3D scenes.

Additionally, there are core libraries such as “geo” (for managing 3D geometry, meshes, primitives, spatial indexing, etc.) and “sketch-utils” (which likely provides auxiliary functionality). The overall project is structured as a multi-crate workspace where each renderer is contained in its own subdirectory with examples, while shared functionality is implemented in other crates.

##### And Represent the Main Components
- Buzz (Ray Tracer)
- L (Line Renderer)
- Ivo (Isometric Voxel Renderer)
- Geo Library (Core geometry computations, primitives, meshes, spatial indexing)
- Sketch Utils (Helper functions/utilities)
- Data Assets (STL and OBJ models in the “data” directory; images used for demos)

##### Detail Internal Components of Each Renderer
- Camera module (“buzz/src/camera.rs”)
- Material module (“buzz/src/material.rs”)
- Object handling (with submodules such as “object”, “object/simple_object.rs”, and “objectgeo” for handling CSG operations and geometric constructs)
- Renderer module (“buzz/src/renderer.rs”)
- Examples that demonstrate various rendering techniques (listed in the buzz/examples folder)
- For L (line renderer):
- Components such as the camera, object handling (cube, sdf, grid, etc. in “l/src/object”), and the renderer (“l/src/renderer.rs”)
- Examples like “trex.rs”, “skyscrapers.rs”, and “fun.rs”
- For Ivo (voxel renderer):
- Renderer modules (found in “ivo/src/renderer”), the scene setup and object parsing components (like “ivo/src/renderer/scene.rs” and “ivo/src/renderer/obj.rs”), and its limited spatial indexing setup (“ivo/src/spatial_index.rs”)
- Example demos within “ivo/examples”

##### Interactions and Dependencies
- That data flows from input assets (the “data” directory and maybe images from “images”) into the renderers.

##### Architectural Patterns and Design Principles
- Separation of Concerns: each renderer (ray tracing, line rendering, voxel rendering) is isolated as its own crate with a clear internal module hierarchy.
- Point out the use of a layered design – for instance, the rendering engines use lower-level modules (like camera, material, objects) which in turn leverage core geometry computations from the Geo Library.
- Since the project features “examples” subdirectories in each renderer crate, consider noting that these serve as demonstration entry points or test cases rather than the main library API.
- The use of configuration files (like Cargo.toml for dependency management and GitHub workflows for CI) might be noted externally as part of the development pipeline, though they aren’t part of the runtime architecture.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Workspace / Project Core
    WC["Workspace Coordination (Cargo.toml & Cargo.lock)"]:::workspace

    %% Buzz (Ray Tracer)
    subgraph "Buzz (Ray Tracer)"
        B_camera["Camera Module"]:::module
        B_material["Material Module"]:::module
        B_obj_basic["Object Handling (Basic)"]:::module
        B_obj_csg["Object Handling (CSG)"]:::module
        B_renderer["Renderer Module"]:::module
        B_examples["Examples"]:::module
    end

    %% L (Line Renderer)
    subgraph "L (Line Renderer)"
        L_camera["Camera Module"]:::module
        L_object["Object Handling"]:::module
        L_renderer["Renderer Module"]:::module
        L_examples["Examples"]:::module
    end

    %% Ivo (Isometric Voxel Renderer)
    subgraph "Ivo (Isometric Voxel Renderer)"
        Ivo_renderer["Renderer Modules"]:::module
        Ivo_spatial["Spatial Indexing Setup"]:::module
        Ivo_examples["Examples"]:::module
    end

    %% Geo Library
    subgraph "Geo Library"
        Geo_core["Core Library"]:::library
        Geo_mesh["Mesh Processing"]:::library
        Geo_primitive["Primitive Computations"]:::library
        Geo_sdf["SDF"]:::library
        Geo_spatial["Spatial Indexing"]:::library
        Geo_util["Utility Functions"]:::library
    end

    %% Sketch Utils
    subgraph "Sketch Utils"
        Sketch_core["Core Library"]:::library
        Sketch_opener["Additional Utilities"]:::library
    end

    %% Data Assets
    subgraph "Data Assets"
        Data_models["3D Model Files"]:::data
        Data_images["Image Assets"]:::data
    end

    %% Internal Connections for Buzz
    B_camera -->|"feeds"| B_renderer
    B_material -->|"supplies"| B_renderer
    B_obj_basic -->|"provides objects"| B_renderer
    B_obj_csg -->|"provides CSG"| B_renderer
    B_renderer -->|"demonstrates"| B_examples

    %% Internal Connections for L
    L_camera -->|"feeds"| L_renderer
    L_object -->|"supplies objects"| L_renderer
    L_renderer -->|"demonstrates"| L_examples

    %% Internal Connections for Ivo
    Ivo_spatial -->|"indexes"| Ivo_renderer
    Ivo_renderer -->|"demonstrates"| Ivo_examples

    %% Workspace connections
    WC -->|"manages"| B_renderer
    WC -->|"manages"| L_renderer
    WC -->|"manages"| Ivo_renderer

    %% Renderers depending on Geo Library
    B_renderer -->|"uses_geo"| Geo_core
    L_renderer -->|"uses_geo"| Geo_core
    Ivo_renderer -->|"uses_geo"| Geo_core

    %% Renderers depending on Sketch Utils
    B_renderer -->|"uses_utils"| Sketch_core
    L_renderer -->|"uses_utils"| Sketch_core
    Ivo_renderer -->|"uses_utils"| Sketch_core

    %% Data Assets connections to Renderers
    Data_models -->|"input_models"| B_renderer
    Data_images -->|"input_images"| B_renderer
    Data_models -->|"input_models"| L_renderer
    Data_images -->|"input_images"| L_renderer
    Data_models -->|"input_models"| Ivo_renderer
    Data_images -->|"input_images"| Ivo_renderer

    %% Click Events for Buzz Components
    click B_camera "https://github.com/danieledapo/r3d/blob/master/buzz/src/camera.rs"
    click B_material "https://github.com/danieledapo/r3d/blob/master/buzz/src/material.rs"
    click B_obj_basic "https://github.com/danieledapo/r3d/tree/master/buzz/src/object"
    click B_obj_csg "https://github.com/danieledapo/r3d/tree/master/buzz/src/objectgeo"
    click B_renderer "https://github.com/danieledapo/r3d/blob/master/buzz/src/renderer.rs"
    click B_examples "https://github.com/danieledapo/r3d/tree/master/buzz/examples"

    %% Click Events for L Components
    click L_camera "https://github.com/danieledapo/r3d/blob/master/l/src/camera.rs"
    click L_object "https://github.com/danieledapo/r3d/tree/master/l/src/object"
    click L_renderer "https://github.com/danieledapo/r3d/blob/master/l/src/renderer.rs"
    click L_examples "https://github.com/danieledapo/r3d/tree/master/l/examples"

    %% Click Events for Ivo Components
    click Ivo_renderer "https://github.com/danieledapo/r3d/tree/master/ivo/src/renderer"
    click Ivo_spatial "https://github.com/danieledapo/r3d/blob/master/ivo/src/spatial_index.rs"
    click Ivo_examples "https://github.com/danieledapo/r3d/tree/master/ivo/examples"

    %% Click Events for Geo Library Components
    click Geo_core "https://github.com/danieledapo/r3d/blob/master/geo/src/lib.rs"
    click Geo_mesh "https://github.com/danieledapo/r3d/tree/master/geo/src/mesh"
    click Geo_primitive "https://github.com/danieledapo/r3d/tree/master/geo/src/primitive"
    click Geo_sdf "https://github.com/danieledapo/r3d/tree/master/geo/src/sdf"
    click Geo_spatial "https://github.com/danieledapo/r3d/tree/master/geo/src/spatial_index"
    click Geo_util "https://github.com/danieledapo/r3d/tree/master/geo/src/util"

    %% Click Events for Sketch Utils Components
    click Sketch_core "https://github.com/danieledapo/r3d/blob/master/sketch-utils/src/lib.rs"
    click Sketch_opener "https://github.com/danieledapo/r3d/blob/master/sketch-utils/src/opener.rs"

    %% Click Events for Data Assets
    click Data_models "https://github.com/danieledapo/r3d/tree/master/data"
    click Data_images "https://github.com/danieledapo/r3d/tree/master/images"

    %% Class Definitions for Styling
    classDef module fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef library fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef data fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef workspace fill:#D3D3D3,stroke:#696969,stroke-width:2px;
```
