# brunosimon/my-room-in-3d architecture

> Architecture diagram of the GitHub repository brunosimon/my-room-in-3d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brunosimon/my-room-in-3d
- Repository: https://github.com/brunosimon/my-room-in-3d

## Overview

##### Main Components
- Bundler/Build System: Represent the webpack configuration files (webpack.common.js, webpack.dev.js, webpack.prod.js) and package.json. These files drive the build, dependency management, and environment configuration.
- Application Shell: The main HTML (src/index.html), script (src/script.js), and style (src/style.css) files serve as the entry point for the front-end.
- 3D Experience Core: Under src/Experience, you have multiple modules:
- Core Engine: "Experience.js" functions as the central controller that likely instantiates and manages sub-components.
- Rendering: "Renderer.js" and "World.js" that handle the actual 3D scene and render loop.
- Camera and Navigation: "Camera.js" and "Navigation.js" modules managing viewpoint and user interactions.
- Scene Elements: Specific components like "Baked.js", "BouncingLogo.js", "CoffeeSteam.js", "ElgatoLight.js", etc. Each likely corresponds to a particular visual or interactive element in the room.
- Assets and Resources: "Resources.js" and assets modules – shaders (in shaders/ folder) that define materials and visual effects.
- Utility Modules: Under Utils, modules such as "EventEmitter.js", "Loader.js", "Sizes.js", "Stats.js", and "Time.js" encapsulate cross-cutting concerns (e.g., event handling, asynchronous loading, performance stats).
- Static Assets: The “static” folder contains models, videos, and additional assets along with support libraries (basis, draco) for 3D model compression/decoding.

##### Relationships and Interactions
- The bundler and configuration layer feeds into building and serving the front-end assets.
- The entry point (HTML, script.js) initializes the “Experience” module, which in turn orchestrates the camera, renderer, world/environment, interaction components, and accessory animations (like CoffeeSteam or BouncingLogo).
- Utility modules support components by providing event handling, asset loading, time management, and statistics gathering.
- Static assets (3D models, shader files, videos) are loaded by components like Resources.js and passed to rendering engine modules to display the scene.

##### Architectural Patterns and Design Principles
- Modular Architecture: The clear separation of concerns between core experience logic, utility functions, and specific scene components suggests an emphasis on modularity and maintainability.
- Separation of Build Environment: The use of different webpack configurations for development and production emphasizes environment-specific setups.
- Component-based Rendering: Each “experience” component (Camera, Renderer, World, etc.) is likely designed to be fairly independent, enhancing reusability and flexibility.

##### Relevant Technologies and Frameworks
- Node.js/NPM for dependency management and development tooling.
- Webpack as the module bundler, with separate configurations for different environments.
- WebGL (or a library such as Three.js) is probable given the shader usage (.glsl files) and 3D models found in the static assets.
- Utility libraries for handling complex tasks (e.g., asset loading, event handling) are custom-built in this project.

##### Final Advice
- Essential architectural elements. Even if many components interact within the Experience module, break them out to emphasize their individual roles.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build System
    subgraph "Build System"
        BC1["webpack.common.js"]:::buildLayer
        BC2["webpack.dev.js"]:::buildLayer
        BC3["webpack.prod.js"]:::buildLayer
        pkg["package.json"]:::buildLayer
    end

    %% Application Shell
    subgraph "Application Shell"
        html["index.html"]:::appShell
        script["script.js"]:::appShell
        css["style.css"]:::appShell
    end

    %% 3D Experience Core
    subgraph "3D Experience Core"
        exp["Experience.js"]:::core
        subgraph "Rendering"
            renderer["Renderer.js"]:::core
            world["World.js"]:::core
        end
        subgraph "Camera and Navigation"
            camera["Camera.js"]:::core
            navigation["Navigation.js"]:::core
        end
        subgraph "Scene Elements"
            baked["Baked.js"]:::core
            bouncing["BouncingLogo.js"]:::core
            coffee["CoffeeSteam.js"]:::core
            elgato["ElgatoLight.js"]:::core
            google["GoogleLeds.js"]:::core
            loupedeck["LoupedeckButtons.js"]:::core
            screen["Screen.js"]:::core
            topChair["TopChair.js"]:::core
        end
        subgraph "Assets and Resources"
            resources["Resources.js"]:::core
            assets["assets.js"]:::core
            shaders["shaders (folder)"]:::core
        end
        subgraph "Utility Modules"
            emitter["EventEmitter.js"]:::utility
            loader["Loader.js"]:::utility
            sizes["Sizes.js"]:::utility
            stats["Stats.js"]:::utility
            time["Time.js"]:::utility
        end
    end

    %% Static Assets
    subgraph "Static Assets"
        staticFolder["static"]:::static
        basis["basis (folder)"]:::static
        draco["draco (folder)"]:::static
    end

    %% Connections
    pkg --> html
    pkg --> script
    pkg --> css

    html --> exp
    script --> exp

    exp --> renderer
    exp --> world
    exp --> camera
    exp --> navigation
    exp --> baked
    exp --> bouncing
    exp --> coffee
    exp --> elgato
    exp --> google
    exp --> loupedeck
    exp --> screen
    exp --> topChair
    exp --> resources
    exp --> assets
    exp --> shaders
    exp --> emitter
    exp --> loader
    exp --> sizes
    exp --> stats
    exp --> time

    resources -->|"loads"| staticFolder

    %% Click Events for Build System
    click BC1 "https://github.com/brunosimon/my-room-in-3d/blob/main/bundler/webpack.common.js"
    click BC2 "https://github.com/brunosimon/my-room-in-3d/blob/main/bundler/webpack.dev.js"
    click BC3 "https://github.com/brunosimon/my-room-in-3d/blob/main/bundler/webpack.prod.js"
    click pkg "https://github.com/brunosimon/my-room-in-3d/blob/main/package.json"

    %% Click Events for Application Shell
    click html "https://github.com/brunosimon/my-room-in-3d/blob/main/src/index.html"
    click script "https://github.com/brunosimon/my-room-in-3d/blob/main/src/script.js"
    click css "https://github.com/brunosimon/my-room-in-3d/blob/main/src/style.css"

    %% Click Event for Experience Core
    click exp "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Experience.js"

    %% Click Events for Rendering
    click renderer "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Renderer.js"
    click world "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/World.js"

    %% Click Events for Camera and Navigation
    click camera "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Camera.js"
    click navigation "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Navigation.js"

    %% Click Events for Scene Elements
    click baked "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Baked.js"
    click bouncing "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/BouncingLogo.js"
    click coffee "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/CoffeeSteam.js"
    click elgato "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/ElgatoLight.js"
    click google "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/GoogleLeds.js"
    click loupedeck "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/LoupedeckButtons.js"
    click screen "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Screen.js"
    click topChair "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/TopChair.js"

    %% Click Events for Assets and Resources
    click resources "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Resources.js"
    click assets "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/assets.js"
    click shaders "https://github.com/brunosimon/my-room-in-3d/tree/main/src/Experience/shaders"

    %% Click Events for Utility Modules
    click emitter "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Utils/EventEmitter.js"
    click loader "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Utils/Loader.js"
    click sizes "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Utils/Sizes.js"
    click stats "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Utils/Stats.js"
    click time "https://github.com/brunosimon/my-room-in-3d/blob/main/src/Experience/Utils/Time.js"

    %% Click Events for Static Assets
    click staticFolder "https://github.com/brunosimon/my-room-in-3d/tree/main/static"
    click basis "https://github.com/brunosimon/my-room-in-3d/tree/main/static/basis"
    click draco "https://github.com/brunosimon/my-room-in-3d/tree/main/static/draco"

    %% Styles
    classDef buildLayer fill:#F4A460,stroke:#333,stroke-width:2px;
    classDef appShell fill:#87CEEB,stroke:#333,stroke-width:2px;
    classDef core fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef utility fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef static fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
