# chenjian222/visualization architecture

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

- Interactive diagram: https://gitdiagram.com/chenjian222/visualization
- Repository: https://github.com/chenjian222/visualization

## Overview

- Data Conversion Module:
- Represented by the Python script (scripts/npzToPt.py) and the npz file (scripts/41_02_poses.npz).
- This module processes the npz data (pose/rotation data), converts it to JSON format (likely outputting something similar to visual/assets/data/quaternion.json), and discards unnecessary translation data.
- Web Visualization Frontend:
- Centered around visual/index.html that serves as the main entry point.
- This component uses three.js (visual/assets/script/three.js) and several loader scripts (FBXLoader.js, GLTFLoader.js, MTLLoader.js, OBJLoader.js, STLLoader.js) along with utilities like OrbitControls.js.
- Additionally, the 3D SMPL model is stored as a FBX asset (visual/assets/model/smallBody.fbx), and the associated bone manipulation is handled using the quaternion/rotation data.
- Assets and Resources:
- Visual assets such as the 3D model, additional scripts, and data files are key parts of the visualization and need to be depicted as supporting resources.
- (Optional) Development Environment Artifacts:
- The .vs folder indicates that Visual Studio was used as the IDE, which can be noted as part of the development environment if necessary, though it’s less critical to the runtime architecture.

##### Relationships and Data Flow
- That this component outputs a JSON file containing the rotation data.
- Next, the Web Visualization Frontend:
- That the frontend (via the index.html entry point) loads the 3D model using FBXLoader (and possibly other loaders) from the assets folder.
- A link from the index.html to the various three.js scripts, and clearly indicate the utilization of loader and controller scripts.
- Data/Data Flow Design:

##### Architectural Patterns and Key Design Principles
- Separation of Concerns:
- The design clearly separates the data conversion process (backend preprocessing) from the user-facing visualization (frontend rendering).
- This separation ensures that each component focuses on a single responsibility: data transformation vs. interactive visualization.
- Client-Side Rendering:
- That the web frontend relies on three.js and related libraries to load and render the 3D models directly in the web browser.
- Loose Coupling via Data Files:
- The use of JSON as an intermediary data format decouples the data generation from the visualization, making the system more modular and easier to maintain.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Conversion Module
    subgraph "Data Conversion Module"
        A["NPZ Data: 41_02_poses.npz"]
        B["Conversion Script: npzToPt.py"]
        C["Output JSON: quaternion.json"]
    end
    A --> B
    B --> C

    %% Web Visualization Frontend
    subgraph "Web Visualization Frontend"
        D["Main Entry: index.html"]
        subgraph "3D Rendering Engine"
            E["Rendering Engine: three.js"]
            subgraph "Loader Scripts"
                F["FBX Loader: FBXLoader.js"]
                G["GLTF Loader: GLTFLoader.js"]
                H["MTL Loader: MTLLoader.js"]
                I["OBJ Loader: OBJLoader.js"]
                J["STL Loader: STLLoader.js"]
                K["Orbit Controls: OrbitControls.js"]
            end
        end
        L["3D Model: smallBody.fbx"]
    end

    %% Data flows
    C -->|"providesData"| D
    L -->|"providesModel"| D
    D -->|"usesEngine"| E
    E -->|"usesLoader"| F
    E -->|"usesLoader"| G
    E -->|"usesLoader"| H
    E -->|"usesLoader"| I
    E -->|"usesLoader"| J
    E -->|"usesLoader"| K

    %% Click Events
    click A "https://github.com/chenjian222/visualization/blob/main/scripts/41_02_poses.npz"
    click B "https://github.com/chenjian222/visualization/blob/main/scripts/npzToPt.py"
    click C "https://github.com/chenjian222/visualization/blob/main/visual/assets/data/quaternion.json"
    click D "https://github.com/chenjian222/visualization/blob/main/visual/index.html"
    click E "https://github.com/chenjian222/visualization/blob/main/visual/assets/script/three.js"
    click F "https://github.com/chenjian222/visualization/blob/main/visual/assets/script/FBXLoader.js"
    click G "https://github.com/chenjian222/visualization/blob/main/visual/assets/script/GLTFLoader.js"
    click H "https://github.com/chenjian222/visualization/blob/main/visual/assets/script/MTLLoader.js"
    click I "https://github.com/chenjian222/visualization/blob/main/visual/assets/script/OBJLoader.js"
    click J "https://github.com/chenjian222/visualization/blob/main/visual/assets/script/STLLoader.js"
    click K "https://github.com/chenjian222/visualization/blob/main/visual/assets/script/OrbitControls.js"
    click L "https://github.com/chenjian222/visualization/blob/main/visual/assets/model/smallBody.fbx"

    %% Styles
    classDef data fill:#FFDDC1,stroke:#333,stroke-width:2px;
    classDef frontend fill:#C1FFD7,stroke:#333,stroke-width:2px;
    classDef engine fill:#C1E1FF,stroke:#333,stroke-width:2px;
    classDef loader fill:#FFC1C1,stroke:#333,stroke-width:2px;

    class A,B,C data
    class D,L frontend
    class E engine
    class F,G,H,I,J,K loader
```
