# foxelfox/voxel-octree architecture

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

- Interactive diagram: https://gitdiagram.com/foxelfox/voxel-octree
- Repository: https://github.com/foxelfox/voxel-octree

## Overview

##### Main Components Identification

a. Core Systems:
- Octree Management System
- Rendering Pipeline System
- Generator System
- Worker System

**[Client Browser]**
- ↓
**[Application Core]**
- Generator System
- Octree System
- Workers
- Render System
- Pipeline Versions

##### Component Details

a. Octree System (Blue Components):
- To Worker subsystem:
- Block Generator Worker
- Mesh Generator Worker
- Node Worker

b. Render System (Green Components):
- Create two parallel pipeline versions (v1 and v2)
- Shared nodes:
- Denoiser
- Edit Node
- Output Node
- Pipeline-specific nodes:
- Chunk Node
- RT Light Node
- RT Chunk Node

c. Generator System (Yellow Components):
- Start scene generator to the octree system

##### Technical Details

Annotations for:
- WebGL as the rendering technology
- Web Workers for parallel processing
- GLSL shader implementation points
- Real-time ray tracing capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    title[Voxel Octree Engine Architecture]
    
    subgraph Core
        AppEntry["Application Entry"]:::core
        click AppEntry "https://github.com/FoxelFox/voxel-octree/blob/master/src/index.ts"
    end
    
    subgraph OctreeSystem["Octree Management System"]
        OctreeCore["Octree Core"]:::octree
        click OctreeCore "https://github.com/FoxelFox/voxel-octree/tree/master/src/octree/"
        OctreeChunk["Chunk Manager"]:::octree
        click OctreeChunk "https://github.com/FoxelFox/voxel-octree/blob/master/src/octree/chunk.ts"
        OctreeGrid["Grid Manager"]:::octree
        click OctreeGrid "https://github.com/FoxelFox/voxel-octree/blob/master/src/octree/grid.ts"
        OctreeUtil["Utility Functions"]:::octree
        click OctreeUtil "https://github.com/FoxelFox/voxel-octree/blob/master/src/octree/util.ts"
    end
    
    subgraph WorkerSystem["Worker System"]
        BlockGen["Block Generator Worker"]:::worker
        click BlockGen "https://github.com/FoxelFox/voxel-octree/blob/master/src/octree/worker/block-generator.ts"
        MeshGen["Mesh Generator Worker"]:::worker
        click MeshGen "https://github.com/FoxelFox/voxel-octree/blob/master/src/octree/worker/mesh-generator.ts"
        NodeWorker["Node Worker"]:::worker
        click NodeWorker "https://github.com/FoxelFox/voxel-octree/blob/master/src/octree/worker/node.ts"
    end
    
    subgraph RenderSystem["Render System"]
        RenderContext["Render Context"]:::render
        click RenderContext "https://github.com/FoxelFox/voxel-octree/blob/master/src/render/context.ts"
        Camera["Camera Manager"]:::render
        click Camera "https://github.com/FoxelFox/voxel-octree/blob/master/src/render/camera.ts"
        RenderLoop["Render Loop"]:::render
        click RenderLoop "https://github.com/FoxelFox/voxel-octree/blob/master/src/render/loop.ts"
        
        subgraph PipelineV1["Pipeline V1"]
            PipeV1["Pipeline V1 Core"]:::pipeline
            click PipeV1 "https://github.com/FoxelFox/voxel-octree/blob/master/src/render/pipeline/v1/pipeline-v1.ts"
            ChunkNode["Chunk Node"]:::pipeline
            click ChunkNode "https://github.com/FoxelFox/voxel-octree/tree/master/src/render/pipeline/v1/node/chunk-node/"
            RTLightNode["RT Light Node"]:::pipeline
            click RTLightNode "https://github.com/FoxelFox/voxel-octree/tree/master/src/render/pipeline/v1/node/rt-light/"
        end
        
        subgraph PipelineV2["Pipeline V2"]
            PipeV2["Pipeline V2 Core"]:::pipeline
            click PipeV2 "https://github.com/FoxelFox/voxel-octree/blob/master/src/render/pipeline/v2/pipeline-v2.ts"
            RTChunkNode["RT Chunk Node"]:::pipeline
            click RTChunkNode "https://github.com/FoxelFox/voxel-octree/tree/master/src/render/pipeline/v2/node/rt-chunk-node/"
        end
        
        subgraph SharedNodes["Shared Pipeline Nodes"]
            Denoiser["Denoiser Node"]:::shared
            click Denoiser "https://github.com/FoxelFox/voxel-octree/tree/master/src/render/pipeline/shared-node/denoiser/"
            EditNode["Edit Node"]:::shared
            click EditNode "https://github.com/FoxelFox/voxel-octree/tree/master/src/render/pipeline/shared-node/edit/"
            OutputNode["Output Node"]:::shared
            click OutputNode "https://github.com/FoxelFox/voxel-octree/tree/master/src/render/pipeline/shared-node/output/"
        end
    end
    
    subgraph GeneratorSystem["Generator System"]
        StartScene["Start Scene Generator"]:::generator
        click StartScene "https://github.com/FoxelFox/voxel-octree/blob/master/src/generator/start-scene.ts"
    end
    
    %% Connections
    AppEntry --> OctreeCore
    AppEntry --> RenderContext
    AppEntry --> StartScene
    
    OctreeCore --> OctreeChunk
    OctreeCore --> OctreeGrid
    OctreeCore --> OctreeUtil
    
    OctreeCore -.-> BlockGen
    OctreeCore -.-> MeshGen
    OctreeCore -.-> NodeWorker
    
    RenderContext --> Camera
    RenderContext --> RenderLoop
    RenderContext --> PipeV1
    RenderContext --> PipeV2
    
    PipeV1 --> ChunkNode
    PipeV1 --> RTLightNode
    PipeV2 --> RTChunkNode
    
    ChunkNode --> Denoiser
    RTChunkNode --> Denoiser
    Denoiser --> EditNode
    EditNode --> OutputNode
    
    StartScene --> OctreeCore
    
    %% Styles
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef octree fill:#9cf,stroke:#333,stroke-width:2px
    classDef worker fill:#c9f,stroke:#333,stroke-width:2px
    classDef render fill:#9fc,stroke:#333,stroke-width:2px
    classDef pipeline fill:#fc9,stroke:#333,stroke-width:2px
    classDef shared fill:#ff9,stroke:#333,stroke-width:2px
    classDef generator fill:#f90,stroke:#333,stroke-width:2px
    
    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Octree Component"]:::octree
        L3["Worker Component"]:::worker
        L4["Render Component"]:::render
        L5["Pipeline Component"]:::pipeline
        L6["Shared Node"]:::shared
        L7["Generator"]:::generator
    end
```
