# playcanvas/supersplat-viewer architecture

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

- Interactive diagram: https://gitdiagram.com/playcanvas/supersplat-viewer
- Repository: https://github.com/playcanvas/supersplat-viewer

## Overview

##### Main components
- Frontend Web Application – The project is entirely client-side. The entry point is the index.html that loads the index.js and index.css.
- Camera Modules – Multiple camera-related modules (anim-camera.js, fly-camera.js, orbit-camera.js) indicate specialized components for different viewing and animation behaviors.
- Data and Configuration – The system supports external data input via URL parameters for settings (settings.json) and scene files (scene.compressed.ply). The settings schema provided in the README (defining camera, background, and animation tracks) is central to configuring the viewer.
- Build/Deployment and Development Tools – Build configuration files (rollup.config.mjs), the npm package configuration (package.json, package-lock.json), and the eslint.config.mjs all hint at the build process, code standards, and deployment pipeline supported by GitHub Actions (in .github/workflows).

##### Relationships and interactions
- Data Setup – Indicate that configuration (from URL parameters and settings.json) flows into the application, influencing camera behavior and scene construction.

##### Architectural patterns and principles
- Component-based Structure – Although not using a formal framework, the clear separation of functionality (rendering, camera control, utilities) suggests a modular design.
- Static Asset Generation – Illustrate how the project is bundled using a tool like Rollup. The build process takes the source files and produces a self-contained static website.
- Separation of Concerns – Illustrate separation between user interface elements (HTML/CSS) and behavior (JavaScript modules) along with distinct responsibilities (input handling, rendering, animation).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser Environment
    subgraph "Browser Environment"
        A("Entry Point (index.html)"):::frontend
        B("App Bootstrap (index.js)"):::frontend
        C("Styles (index.css)"):::frontend
        A -->|"loads"| B
        A -->|"applies"| C

        subgraph "Camera Modules"
            D("Anim Camera"):::camera
            E("Fly Camera"):::camera
            F("Orbit Camera"):::camera
        end
        B -->|"initializes"| D
        B -->|"initializes"| E
        B -->|"initializes"| F
    end

    %% Utility Modules
    subgraph "Utility Modules"
        G("Math Utility"):::utility
        H("User Input Handler"):::utility
        I("Picker Utility"):::utility
        J("State Observation"):::utility
        K("Spline Utility"):::utility
        L("Pointer Device Utility"):::utility
        M("Data Migration Utility"):::utility
    end

    %% Configuration & Data
    subgraph "Configuration & Data"
        N("Settings/Scene Data (URL & settings.json)"):::data
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        O("Build Configuration (Rollup)"):::build
        P("Linting (ESLint)"):::build
        Q1("Package Configurations (package.json)"):::build
        Q2("Package Configurations (package-lock.json)"):::build
        R("CI/CD Workflows"):::build
    end

    %% Data and Control Flow
    B -->|"configures-from"| N
    B -->|"handles"| H
    H -->|"observes"| J
    H -->|"integrates"| L
    H -->|"migrates"| M
    H -->|"routes-selection-to"| I
    D -->|"animates-with"| K
    D -->|"calculates-using"| G
    E -->|"calculates-using"| G
    F -->|"calculates-using"| G

    %% Build Process Flow
    O -->|"bundles"| A
    O -->|"bundles"| B
    O -->|"bundles"| C
    R -->|"orchestrates"| O

    %% Styling Classes
    classDef frontend fill:#fce4d6,stroke:#d35400,stroke-width:2px;
    classDef camera fill:#d6eaf8,stroke:#2874a6,stroke-width:2px;
    classDef utility fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef data fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
    classDef build fill:#fdebd0,stroke:#e67e22,stroke-width:2px;

    %% Click Events
    click A "https://github.com/playcanvas/supersplat-viewer/blob/main/src/index.html"
    click B "https://github.com/playcanvas/supersplat-viewer/blob/main/src/index.js"
    click C "https://github.com/playcanvas/supersplat-viewer/blob/main/src/index.css"
    click D "https://github.com/playcanvas/supersplat-viewer/blob/main/src/anim-camera.js"
    click E "https://github.com/playcanvas/supersplat-viewer/blob/main/src/fly-camera.js"
    click F "https://github.com/playcanvas/supersplat-viewer/blob/main/src/orbit-camera.js"
    click G "https://github.com/playcanvas/supersplat-viewer/blob/main/src/math.js"
    click H "https://github.com/playcanvas/supersplat-viewer/blob/main/src/input.js"
    click I "https://github.com/playcanvas/supersplat-viewer/blob/main/src/picker.js"
    click J "https://github.com/playcanvas/supersplat-viewer/blob/main/src/observe.js"
    click K "https://github.com/playcanvas/supersplat-viewer/blob/main/src/spline.js"
    click L "https://github.com/playcanvas/supersplat-viewer/blob/main/src/pointer-device.js"
    click M "https://github.com/playcanvas/supersplat-viewer/blob/main/src/data-migrations.js"
    click O "https://github.com/playcanvas/supersplat-viewer/blob/main/rollup.config.mjs"
    click P "https://github.com/playcanvas/supersplat-viewer/blob/main/eslint.config.mjs"
    click Q1 "https://github.com/playcanvas/supersplat-viewer/blob/main/package.json"
    click Q2 "https://github.com/playcanvas/supersplat-viewer/blob/main/package-lock.json"
    click R "https://github.com/playcanvas/supersplat-viewer/blob/main/.github/workflows/ci.yml"
```
