# meta-quest/webxr-showcases architecture

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

- Interactive diagram: https://gitdiagram.com/meta-quest/webxr-showcases
- Repository: https://github.com/meta-quest/webxr-showcases

## Overview

##### Project type and purpose
- Type: Single-page WebXR front-end application.
- Purpose: Allow users to view, customize, and interact with 3D sneaker models in a Mixed Reality environment directly in their browser.

##### File structure (key directories/files)
- `src/`
- HTML entry point: `index.html`
- JS modules under `src/` (e.g., `index.js`, `scene.js`, `player.js`, `sneaker.js`, `configUI.js`, etc.)
- Styles: `styles/index.css`
- Assets: `assets/gltf/`, `assets/audio/`, `assets/*.glb`, `assets/*.exr`
- `content/`
- Raw 3D source files (Blender) and pre-compressed glTF binaries.
- Build config: `webpack.config.cjs`
- Packaging: `package.json`

##### Main components
a. Static Web Server / CDN
- Hosts the bundled application (HTML, JS, CSS, assets) – e.g., GitHub Pages or any static-site host.
b. Client Browser (WebXR-enabled)
- Loads the page via HTTP(S).
- WebAssembly/JavaScript runtime executes the bundle.
c. WebXR & Rendering Layer
- WebXR API (device/session management)
- WebGL renderer (likely Three.js under the hood)
d. Application Modules
- Entry Point (`index.js`)
- Scene Manager (`scene.js`)
- Interaction & Input (`player.js`, `pointer.js`, `grab.js`, `follow.js`)
- Sneaker Model Loader & Controller (`sneaker.js`, `configUI.js`, `size.js`)
- UI / Audio Manager (`audio.js`, `constants.js`)
e. Asset Pipeline
- glTF/GLB models, textures (KTX2), HDR environment maps (EXR), audio files
f. Browser APIs & External Services
- WebXR Device API
- WebGL / Three.js (rendering)
- (Optional) Analytics or telemetry if added

##### Relationships and data flow
- User → Browser UI → WebXR session start
- Browser (entry HTML/JS) → Loads application bundle from static host
- Application modules request assets → HTTP GET to host → Asset cache
- Scene Manager passes glTF data to renderer → Display in headset
- Input modules capture controller poses → Update scene & UI modules
- UI & Audio modules respond to interactions → Play sounds, update overlays

##### Architectural patterns and design principles
- Modular JavaScript: each feature in its own module
- Bundle & build via Webpack: single-page app
- Separation of concerns: rendering vs. input vs. UI vs. asset loading
- Client-only architecture: no backend or database

## Diagram (Mermaid)

```mermaid
graph TD

    subgraph "Infrastructure Layer"
        CDN["Static Host/CDN"]:::infra
        Content["Raw/Pre-compressed 3D Sources"]:::infra
    end

    subgraph "Browser Runtime"
        XR["WebXR API"]:::runtime
        RENDER["Renderer (WebGL/Three.js)"]:::runtime
        ASSET["Asset Loader"]:::runtime
    end

    subgraph "Application Modules"
        HTML["index.html"]:::app
        Entry["index.js (Entry)"]:::app
        Scene["scene.js (Scene Manager)"]:::app
        Landing["landing.js (WebXR Session Launcher)"]:::app
        Welcome["welcome.js (Welcome/UI Overlay)"]:::app

        subgraph "Input & Interaction"
            Player["player.js"]:::app
            Pointer["pointer.js"]:::app
            Grab["grab.js"]:::app
            Follow["follow.js"]:::app
        end

        subgraph "Sneaker Model Controller"
            Sneaker["sneaker.js"]:::app
            Config["configUI.js"]:::app
            Size["size.js"]:::app
        end

        subgraph "UI & Audio"
            Audio["audio.js"]:::app
            Const["constants.js"]:::app
            Global["global.js"]:::app
        end
    end

    subgraph "Assets & Styles"
        CSS["index.css"]:::app
        Assets["src/assets"]:::runtime
    end

    subgraph "Build & Package"
        Webpack["webpack.config.cjs"]:::build
        Package["package.json"]:::build
    end

    %% Data Flows
    CDN -->|"HTTP GET bundle"| HTML
    HTML -->|"loads via script"| Entry
    HTML -->|"loads style"| CSS

    Entry -->|"initializes"| XR
    Entry -->|"initializes"| RENDER
    Entry -->|"calls"| ASSET
    Entry -->|"uses constants"| Const
    Entry -->|"uses helpers"| Global

    Landing -->|"starts XR session"| XR
    Welcome -->|"UI overlay"| XR

    XR -->|"XRFrame callback"| Scene
    Pointer -->|"controller pose event"| Scene
    Player -->|"controller pose event"| Scene
    Grab -->|"interaction event"| Scene
    Follow -->|"interaction event"| Scene

    Scene -->|"provides glTF to"| RENDER
    ASSET -->|"GET glTF/EXR/audio"| CDN

    Assets -->|"host assets"| CDN
    Config -->|"modifies model"| Sneaker
    Size -->|"adjusts scale"| Sneaker
    Sneaker -->|"updates scene"| Scene

    Audio -->|"plays sounds"| RENDER

    Package -->|"defines deps"| Webpack
    Webpack -->|"builds bundle"| CDN

    %% Click Events
    click CDN "https://github.com/meta-quest/webxr-showcases/tree/main/sneaker-builder/"
    click Content "https://github.com/meta-quest/webxr-showcases/tree/main/sneaker-builder/content/"
    click HTML "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/index.html"
    click Entry "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/index.js"
    click Scene "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/scene.js"
    click Landing "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/landing.js"
    click Welcome "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/welcome.js"
    click Player "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/player.js"
    click Pointer "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/pointer.js"
    click Grab "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/grab.js"
    click Follow "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/follow.js"
    click Sneaker "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/sneaker.js"
    click Config "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/configUI.js"
    click Size "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/size.js"
    click Audio "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/audio.js"
    click Const "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/constants.js"
    click Global "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/global.js"
    click CSS "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/src/styles/index.css"
    click Assets "https://github.com/meta-quest/webxr-showcases/tree/main/sneaker-builder/src/assets/"
    click Webpack "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/webpack.config.cjs"
    click Package "https://github.com/meta-quest/webxr-showcases/blob/main/sneaker-builder/package.json"

    %% Styles
    classDef infra fill:#f9f,stroke:#333,stroke-width:2px
    classDef runtime fill:#bbf,stroke:#333,stroke-width:2px
    classDef app fill:#bfb,stroke:#333,stroke-width:2px
    classDef build fill:#ffb,stroke:#333,stroke-width:2px
```
