# ohzinteractive/core architecture

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

- Interactive diagram: https://gitdiagram.com/ohzinteractive/core
- Repository: https://github.com/ohzinteractive/core

## Overview

##### Project Type and Purpose
- This is a core library (“OHZI Core”) for WebGL development.
- Its purpose is to provide building blocks that speed up the development of complex WebGL applications.
- It works in complementary fashion with existing libraries such as three.js and PIT.

##### Analyzing the File Structure
- The top-level directory contains configuration files (like package.json, rollup.config.mjs, and TypeScript declaration files) as well as the README, indicating a well-organized library.
- The “src” folder is the heart of the library. Inside, you have numerous subdirectories dedicated to various aspects of rendering:
– Base application and browser integration (e.g., BaseApplication.js, Browser.js).
– Camera handling with different camera types (PerspectiveCamera, OrthographicCamera) and camera management.
– Resource loading and asset management, found under “loaders”, “resource_loader”, and “assets_loader”.
– Rendering engine components such as RenderLoop, various render modes (in the “render_mode” folder) and shader/material definitions (in the “materials” and “shaders” folders).
– UI and view components (under “ui” and “view_components”) that manage user interface elements and transitions.
– Specialized functionality like GPU particle systems, static batchers, and action sequencers to handle animations or state transitions.
– Utility functions, helpers, and data textures, along with editor and debugging tools.
- The library is split into modules that separately handle input, graphics, resource management, and shader management, among others.

##### Key Components
a. Core Application & Initialization:
- BaseApplication.js, Initializer.js, and Browser.js define the core setup.
- They likely establish the rendering context and manage overall application life-cycle.
b. Rendering Engine:
- RenderLoop.js, RenderLayers, and the “render_mode” modules (NormalRender, DeferredRender, BloomRender, etc.) form the backbone of WebGL rendering.
- Materials and shaders (located in “materials” and “shaders”) implement various visual effects.
c. Scene and Camera Management:
- SceneManager.js and different camera modules (PerspectiveCamera, OrthographicCamera, CameraManager.js) handle different viewpoints and scene composition.
d. Asset and Resource Loaders:
- A set of loaders (in “loaders” and “resource_loader”) ensure asynchronous loading of textures, models, fonts, and sounds.
e. UI and View Components:
- UI.js, view_components, and the “editor” folder provide interactive elements for editing and scene transitions.
f. Specialized Modules:
- Action Sequencer (action_sequencer folder) for managing animations and events.
- GPU particles (gpu_particles) and static batcher for performance optimizations.
- Utilities across the project that support geometry, easing, and various common operations.

##### Architectural Relationships and Patterns
- The library is organized in a modular fashion. Each module (rendering, loading, UI, etc.) should be represented as a distinct component that interacts with the central application core.
- Many modules follow separation-of-concerns by isolating specific tasks: for instance, the rendering modules only handle graphics, while asset loaders deal with external resources.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Application & Initialization
    subgraph "Core Application & Initialization"
        BA["BaseApplication"]:::core
        BR["Browser"]:::core
        IN["Initializer"]:::core
    end

    %% Rendering Engine
    subgraph "Rendering Engine"
        RL["RenderLoop"]:::rendering
        RLA["RenderLayers"]:::rendering
        RM["Render Modes"]:::rendering
        MAT["Materials"]:::rendering
        SHA["Shaders"]:::rendering
    end

    %% Scene and Camera Management
    subgraph "Scene and Camera Management"
        SM["SceneManager"]:::scene
        CM["CameraManager"]:::scene
        PC["PerspectiveCamera"]:::scene
        OC["OrthographicCamera"]:::scene
    end

    %% Asset and Resource Loaders
    subgraph "Asset and Resource Loaders"
        LO["Loaders"]:::loaders
        AL["Asset Loaders"]:::loaders
        RE["Resource Loaders"]:::loaders
    end

    %% UI and View Components
    subgraph "UI and View Components"
        UI["UI"]:::ui
        VC["View Components"]:::ui
        ED["Editor"]:::ui
    end

    %% Specialized Modules
    subgraph "Specialized Modules"
        AS["Action Sequencer"]:::specialized
        GP["GPU Particle System"]:::specialized
        SB["Static Batcher"]:::specialized
    end

    %% Utility Functions & Helpers
    subgraph "Utility Functions & Helpers"
        UT["Utilities"]:::utilities
        DT["Data Textures"]:::utilities
        CD["Canvas Drawer"]:::utilities
        HU["HTML Utilities"]:::utilities
    end

    %% Relationships
    BA -->|"init"| RL
    BA -->|"init"| SM
    BA -->|"init"| CM
    BA -->|"init"| IN
    BA -->|"init"| BR

    RL -->|"manages"| RLA
    RL -->|"uses"| RM
    RL -->|"applies"| MAT
    RL -->|"applies"| SHA
    RL -->|"drives"| SM
    RL -->|"drives"| CM

    LO -->|"feeds"| SM
    AL -->|"feeds"| SM
    RE -->|"feeds"| SM

    UI -->|"triggers"| AS
    UI -->|"interfaces"| VC
    ED -->|"edits"| SM

    AS -->|"controls"| RL
    GP -->|"enhances"| RL
    SB -->|"optimizes"| RL

    UT -->|"assists"| SM
    UT -->|"assists"| CM
    CD -->|"renders"| UI
    HU -->|"animates"| UI

    %% Click Events for Core Application & Initialization
    click BA "https://github.com/ohzinteractive/core/blob/main/src/BaseApplication.js"
    click BR "https://github.com/ohzinteractive/core/blob/main/src/Browser.js"
    click IN "https://github.com/ohzinteractive/core/blob/main/src/Initializer.js"

    %% Click Events for Rendering Engine
    click RL "https://github.com/ohzinteractive/core/blob/main/src/RenderLoop.js"
    click RLA "https://github.com/ohzinteractive/core/blob/main/src/RenderLayers.js"
    click RM "https://github.com/ohzinteractive/core/tree/main/src/render_mode"
    click MAT "https://github.com/ohzinteractive/core/tree/main/src/materials"
    click SHA "https://github.com/ohzinteractive/core/tree/main/src/shaders"

    %% Click Events for Scene and Camera Management
    click SM "https://github.com/ohzinteractive/core/blob/main/src/SceneManager.js"
    click CM "https://github.com/ohzinteractive/core/blob/main/src/CameraManager.js"
    click PC "https://github.com/ohzinteractive/core/blob/main/src/PerspectiveCamera.js"
    click OC "https://github.com/ohzinteractive/core/blob/main/src/OrthographicCamera.js"

    %% Click Events for Asset and Resource Loaders
    click LO "https://github.com/ohzinteractive/core/tree/main/src/loaders"
    click AL "https://github.com/ohzinteractive/core/tree/main/src/loaders/assets_loader"
    click RE "https://github.com/ohzinteractive/core/tree/main/src/resource_loader"

    %% Click Events for UI and View Components
    click UI "https://github.com/ohzinteractive/core/blob/main/src/UI.js"
    click VC "https://github.com/ohzinteractive/core/tree/main/src/view_components"
    click ED "https://github.com/ohzinteractive/core/tree/main/src/editor"

    %% Click Events for Specialized Modules
    click AS "https://github.com/ohzinteractive/core/tree/main/src/action_sequencer"
    click GP "https://github.com/ohzinteractive/core/tree/main/src/gpu_particles"
    click SB "https://github.com/ohzinteractive/core/tree/main/src/static_batcher"

    %% Click Events for Utility Functions & Helpers
    click UT "https://github.com/ohzinteractive/core/tree/main/src/utilities"
    click DT "https://github.com/ohzinteractive/core/tree/main/src/data_textures"
    click CD "https://github.com/ohzinteractive/core/tree/main/src/canvas_drawer"
    click HU "https://github.com/ohzinteractive/core/tree/main/src/html_utilities"

    %% Styles
    classDef core fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef rendering fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef scene fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef loaders fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef ui fill:#87cefa,stroke:#333,stroke-width:2px;
    classDef specialized fill:#f08080,stroke:#333,stroke-width:2px;
    classDef utilities fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
