# kirilbt/bike-demo-threejs architecture

> Architecture diagram of the GitHub repository kirilbt/bike-demo-threejs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kirilbt/bike-demo-threejs
- Repository: https://github.com/kirilbt/bike-demo-threejs

## Overview

##### Project type and purpose
- This is a single‐page front‐end demonstration built with Three.js, GSAP, ASScroll, and Vite.
- Its goal is to showcase a 3D bike scene with interactive scroll and animation effects.

##### File structure
- Top level:
- index.html – the HTML entry point
- style.css – global styles
- main.js – bootstraps the application
- package.json / package-lock.json – dependencies and scripts
- public/ – static assets served by Vite
- Source code is under Experience/:
- Experience.js – core class that initializes renderer, scene, camera, controls, preloader, time & size utilities
- World/ – defines scene objects (Bike, Environment, Floor, World container)
- Utils/ – helper modules (Debug, Resources, Sizes, Time, asset lists)
- Static assets:
- public/draco/ – Draco decoder scripts & WASM for glTF compression
- public/models – .glb bike model
- public/textures & fonts & videos

##### README for additional insights
- Confirms use of Three.js for rendering, GSAP for animation, ASScroll for scroll-driven animations, Vite as bundler/dev server.
- No backend or API layer—purely client-side.

##### Main components
a. User’s Browser/Client
b. Static Asset Server (Vercel/Vite Dev Server)
c. Application Entry (index.html + style.css)
d. main.js & Experience Manager
e. Three.js Engine (Renderer, Scene, Camera)
f. Controls & Scroll Manager (ASScroll + OrbitControls)
g. Animation Engine (GSAP)
h. Resource Loader (Three.js GLTFLoader + DracoLoader)
i. World Components (Bike, Environment, Floor)
j. Utilities (Sizes, Time, Debug overlay)
k. Static Assets (models, textures, fonts, videos)

##### Relationships and interactions
- Browser → fetch index.html + CSS + main.js
- main.js instantiates Experience
- Experience sets up Renderer → Scene → Camera → Controls
- Preloader & Resources utility load assets (using Draco decoder)
- Once loaded, World module adds Bike, Environment, Floor to Scene
- ASScroll feeds scroll events into Experience → triggers GSAP animations on scene objects & camera
- Render loop (Time utility) advances frame by frame
- Debug util overlays stats if in debug mode

##### Architectural patterns & design principles
- Modular single‐page architecture: Experience as orchestrator, clear separation of concerns (World vs. Utils)
- Dependency injection: Resources passed into World components
- Event‐driven update loop: Time tick events drive render + animations
- Code splitting: Visitor code organized by feature rather than all in one file

##### Final checklist
- Components clearly labeled
- Callouts for key technologies (Three.js, GSAP, ASScroll, Draco)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client and Server
    Browser["User Browser/Client"]:::client
    Server[(Static Asset Server)]:::server

    %% Entry Point
    subgraph "Entry Point"
        HTML["index.html"]:::module
        CSS["style.css"]:::module
    end

    %% Bootstrap & Core
    subgraph "Bootstrap & Experience Manager"
        Main["main.js"]:::module
        Exp["Experience.js"]:::module
    end

    %% Three.js Engine Core
    subgraph "Three.js Engine"
        Renderer["Renderer.js"]:::threejs
        Camera["Camera.js"]:::threejs
    end

    %% Controls & Scroll Manager
    Controls["Controls.js"]:::threejs

    %% Preloader Module
    Preloader["Preloader.js"]:::module

    %% Animation Engine
    GSAP["GSAP"]:::threejs

    %% World Components
    subgraph "World Components"
        World["World.js"]:::module
        Bike["Bike.js"]:::module
        Env["Environment.js"]:::module
        Floor["Floor.js"]:::module
    end

    %% Resource Loader & Asset Utilities
    subgraph "Resource Loader & Assets"
        Resources["Resources.js"]:::module
        AssetsUtil["assets.js"]:::module
    end

    %% Utilities
    subgraph "Utilities"
        Time["Time.js"]:::module
        Sizes["Sizes.js"]:::module
        Debug["Debug.js"]:::module
        Theme["Theme.js"]:::module
        DOMHelper["convertDivsToSpans.js"]:::module
    end

    %% Static Assets
    subgraph "Static Assets"
        GLB["bike-model.glb"]:::assets
        Draco["public/draco/"]:::assets
        Textures["public/textures/"]:::assets
        Fonts["public/fonts/"]:::assets
        Images["public/images/"]:::assets
    end

    %% Connections
    Browser -->|HTTP GET| Server
    Server -->|serves files| Browser
    Browser --> HTML
    Browser --> CSS
    Browser --> Main
    HTML --> Main
    CSS --> Main
    Main --> Exp
    Exp --> Renderer
    Exp --> Camera
    Exp --> Controls
    Exp --> Preloader
    Exp --> Resources
    Exp --> Time
    Exp --> Sizes
    Exp --> Debug
    Exp --> Theme
    Exp --> DOMHelper
    Exp --> World
    Preloader --> Resources
    Resources --> AssetsUtil
    Resources --> GLB
    Resources --> Draco
    Resources --> Textures
    Resources --> Fonts
    Resources --> Images
    Controls --> GSAP
    Time --> Exp
    GSAP --> Bike
    GSAP --> Env
    GSAP --> Floor
    AssetsUtil --> World

    %% Click Events
    click HTML "https://github.com/kirilbt/bike-demo-threejs/blob/main/index.html"
    click CSS "https://github.com/kirilbt/bike-demo-threejs/blob/main/style.css"
    click Main "https://github.com/kirilbt/bike-demo-threejs/blob/main/main.js"
    click Exp "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Experience.js"
    click Renderer "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Renderer.js"
    click Camera "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Camera.js"
    click Controls "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Controls.js"
    click Preloader "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Preloader.js"
    click World "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/World/World.js"
    click Bike "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/World/Bike.js"
    click Env "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/World/Environment.js"
    click Floor "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/World/Floor.js"
    click Resources "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Utils/Resources.js"
    click AssetsUtil "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Utils/assets.js"
    click Time "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Utils/Time.js"
    click Sizes "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Utils/Sizes.js"
    click Debug "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Utils/Debug.js"
    click Theme "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Theme.js"
    click DOMHelper "https://github.com/kirilbt/bike-demo-threejs/blob/main/Experience/Utils/convertDivsToSpans.js"
    click GLB "https://github.com/kirilbt/bike-demo-threejs/blob/main/public/models/bike-model.glb"
    click Draco "https://github.com/kirilbt/bike-demo-threejs/tree/main/public/draco/"
    click Textures "https://github.com/kirilbt/bike-demo-threejs/tree/main/public/textures/"
    click Fonts "https://github.com/kirilbt/bike-demo-threejs/tree/main/public/fonts/"
    click Images "https://github.com/kirilbt/bike-demo-threejs/tree/main/public/images/"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef server fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef module fill:#8FBC8F,stroke:#000,stroke-width:1px
    classDef threejs fill:#FFA500,stroke:#000,stroke-width:1px
    classDef assets fill:#9370DB,stroke:#000,stroke-width:1px
```
