# butzyung/systemanimatoronline architecture

> Architecture diagram of the GitHub repository butzyung/systemanimatoronline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/butzyung/systemanimatoronline
- Repository: https://github.com/butzyung/systemanimatoronline

## Overview

##### Main Components Overview
The system should be divided into these key components:

a. Input Layer
- Webcam/Media Input Handler
- Motion Capture System (MediaPipe/TensorFlow.js integration)
- File Input Handler (for MMD/VRM models, motion files)

b. Processing Layer
- Motion Tracking Engine
- Face tracking (52 blendshapes)
- Body tracking
- Hand tracking
- Physics Engine (Ammo.js)
- Animation Processing
- Motion format converters (VMD/BVH/glTF)
- Motion recording system

c. Rendering Layer
- Three.js 3D Engine
- WebGL Renderer
- AR System (WebXR integration)
- Background Effects Processor

d. Output Layer
- Output
- VMC Protocol Interface (Electron mode)
- Motion Export System

##### Architectural Patterns

a. Modular Architecture
- Separate core components (js/_SA.js, js/_SA2.js)
- Plugin system (js_filters/)
- Model loaders (three.js/loaders/)

b. Multi-threading Architecture
- Web Workers for motion processing
- OffscreenCanvas for rendering
- Background task management

##### Integration Points
Connections between:

- MediaPipe/TensorFlow.js and motion capture system
- Three.js and WebGL rendering pipeline
- AR system and device camera
- VMC protocol and external applications

##### Data Flow
Flow:

Input → Motion Processing → 3D Model Animation → Rendering → Output

##### Specific Implementation Details

a. Core Systems
- System Animator core (js/_SA*.js)
- Animation helper (three.js/animation/)
- Motion capture modules (js/@mediapipe/)

b. File Handling
- Model loaders (MMD/VRM)
- Motion format converters
- Asset management system

##### Environment-Specific Features

- Web browser implementation
- Electron native features
- Mobile AR capabilities
- Performance optimization paths

This system design should reflect both the real-time nature of the application and its extensible architecture, showing how it can support multiple platforms and use cases while maintaining performance.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        A[Regular Component]
        B[(Database Component)]
        C{{Processing Unit}}
        D[/API or Interface/]
        style A fill:#AEC6CF
        style B fill:#77DD77
        style C fill:#FFB347
        style D fill:#B19CD9
    end

    subgraph InputLayer["Input Layer"]
        WebcamInput[Media Input Handler]:::input
        FileInput[File Input Handler]:::input
        MotionCapture[Motion Capture System]:::input
    end

    subgraph ProcessingLayer["Processing Layer"]
        subgraph MotionTrackingEngine["Motion Tracking Engine"]
            FaceTrack[Face Tracking]:::processing
            BodyTrack[Body Tracking]:::processing
            HandTrack[Hand Tracking]:::processing
        end

        subgraph AnimationProcessing["Animation Processing"]
            MotionConverter{{Format Converters}}:::processing
            MotionRecorder{{Recording System}}:::processing
        end

        Physics{{Physics Engine}}:::processing
    end

    subgraph RenderingLayer["Rendering Layer"]
        ThreeJS[Three.js Engine]:::rendering
        WebGL[WebGL Renderer]:::rendering
        AR[AR System]:::rendering
        Effects[Background Effects]:::rendering
    end

    subgraph OutputLayer["Output Layer"]
        Display[Display Output]:::output
        VMC[VMC Protocol Interface]:::output
        Export[Motion Export System]:::output
    end

    %% Connections
    WebcamInput --> MotionCapture
    FileInput --> AnimationProcessing
    MotionCapture --> MotionTrackingEngine
    MotionTrackingEngine --> AnimationProcessing
    AnimationProcessing --> ThreeJS
    Physics --> ThreeJS
    ThreeJS --> WebGL
    WebGL --> Display
    AR --> WebGL
    Effects --> WebGL
    AnimationProcessing --> Export
    AnimationProcessing --> VMC

    %% Styles
    classDef input fill:#77DD77
    classDef processing fill:#FFB347
    classDef rendering fill:#AEC6CF
    classDef output fill:#B19CD9

    %% Click Events
    click WebcamInput "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/js/SA_media_control.js"
    click FileInput "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/js/file_io.js"
    click MotionCapture "https://github.com/ButzYung/SystemAnimatorOnline/tree/master/js/@mediapipe/holistic/"
    click FaceTrack "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/js/@mediapipe/tasks/face_landmarker.task"
    click BodyTrack "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/js/@mediapipe/tasks/pose_landmarker_full.task"
    click HandTrack "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/js/@mediapipe/tasks/hand_landmarker.task"
    click Physics "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/jThree/MMDplugin/ammo.js"
    click AnimationProcessing "https://github.com/ButzYung/SystemAnimatorOnline/tree/master/three.js/animation/"
    click ThreeJS "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/three.js/three.module.js"
    click Export "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/js/VMD_filewriter.js"
    click AR "https://github.com/ButzYung/SystemAnimatorOnline/blob/master/js/headtracker_ar.js"
    click Effects "https://github.com/ButzYung/SystemAnimatorOnline/tree/master/three.js/postprocessing/"
```
