# annulusgames/litmotion architecture

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

- Interactive diagram: https://gitdiagram.com/annulusgames/litmotion
- Repository: https://github.com/annulusgames/litmotion

## Overview

##### Main Components
– Motion/Tween creation APIs (LMotion.Create, LMotion.Punch, etc.)
– Runtime execution and scheduling (e.g. MotionScheduler, UpdateRunner, MotionManager)
– Internal helper utilities (collections, easing functions, interpolation, update loops)
- Editor Integration Module – This contains all editor-specific code:
– Editor scripts and custom inspectors (e.g. MotionDebuggerWindow, EditorMotionScheduler)
– Tools for displaying and managing motions inside the Unity Editor
- Extensions/Adapters Module – This part provides support for additional functionalities and external integrations:
– Extensions for Unity components (e.g. Transform, TextMeshPro, UI, Renderer)
– Integration/adapters for external libraries like UniTask (async/await support), UniRx (Observable support), and R3.
- Animation Package (LitMotion.Animation) – A specialized submodule that hooks into the main library:
– Contains its own runtime and editor folders.
– Provides functionality to build animations directly from the Inspector.
- Documentation & Samples – Though not part of the runtime, the docs and sample directories are crucial:
– Docs folder with articles, usage guides, and DocFX configuration.
– Samples directory that holds demo Unity projects showing practical usage of the library.

##### Relationships and Data Flow
- The application (Unity game or scene) uses the LitMotion API to create motions (tweens).
- Inside the Core Tween Engine, motions are scheduled via modules like MotionScheduler and executed based on Unity’s update loop. The engine is designed for zero allocation with a focus on performance.
– Illustrate data flow from “Tween Creation API” → “MotionQueue/Scheduler” → “Update / Player Loop”
- The Editor Integration module interacts back with the core engine for debug displays and configuration:
- The Extensions/Adapters module wraps around core functionality to provide additional binding for various Unity components and support third-party integrations.
- The Animation Package module (LitMotion.Animation) bridges between the Inspector (Unity Editor) and the core tween engine:

##### Architectural Patterns and Design Principles
- Zero Allocation / Performance-Optimized – Indicate that the core engine uses a struct-based, DOTS-inflected design that minimizes allocations.
- Integration Points – Emphasize adapters and extension points (IMotionAdapter, IMotionOptions) thus making the library extensible.
- Separation of concerns – Runtime code is separated from editor code and sample/demo projects.

##### Relevant Technologies and Dependencies
- Unity (runtime, editor environment, scene components)
- Burst Compiler, Collections, Mathematics packages (as prerequisites)
- External libraries: UniTask, UniRx, and R3. Show links from Extensions/Adapters to these libraries.
- DocFX in the docs folder for generating documentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top level: Client code initiating tween creation
    A["Client Code/Unity Scene"]:::client

    %% Runtime Layer
    subgraph "Runtime Layer"
        B["Tween Creation API"]
        C["MotionScheduler/Update Loop"]
        D["Core Tween Engine Module\n(Zero Allocation, High Performance)"]:::runtime
        B -->|"schedules"| C
        C -->|"executes"| D
    end

    %% Editor Layer
    subgraph "Editor Layer"
        E["Editor Integration Module"]:::editor
        F["Animation Package (LitMotion.Animation)"]:::editor
    end

    %% Extensions/Adapters Layer
    subgraph "Extensions/Adapters Layer"
        G["Adapters"]:::extensions
        H["Extensions"]:::extensions
        I["External Integration"]:::extensions
    end

    %% External Libraries
    subgraph "External Libraries"
        J["UniTask"]:::external
        K["UniRx"]:::external
        L["R3"]:::external
    end

    %% Documentation & Samples
    subgraph "Auxiliary Resources"
        M["Documentation"]:::docs
        N["Samples/Demo Projects"]:::docs
    end

    %% Relationships between layers
    A -->|"motionRequest"| B
    E -->|"controlDebug"| D
    F -->|"bridges"| D
    F -->|"bridges"| E
    G -->|"enhances"| D
    H -->|"enhances"| D
    I -->|"enhances"| D
    I -->|"integrates"| J
    I -->|"integrates"| K
    I -->|"integrates"| L

    %% Documentation and Samples usage advisory (optional connection)
    M ---|"guides"| A
    N ---|"demonstrates"| A

    %% Click Events
    click D "https://github.com/annulusgames/litmotion/tree/main/src/LitMotion/Assets/LitMotion/Runtime"
    click E "https://github.com/annulusgames/litmotion/tree/main/src/LitMotion/Assets/LitMotion/Editor"
    click G "https://github.com/annulusgames/litmotion/tree/main/src/LitMotion/Assets/LitMotion/Runtime/Adapters"
    click H "https://github.com/annulusgames/litmotion/tree/main/src/LitMotion/Assets/LitMotion/Runtime/Extensions"
    click I "https://github.com/annulusgames/litmotion/tree/main/src/LitMotion/Assets/LitMotion/Runtime/External"
    click F "https://github.com/annulusgames/litmotion/blob/main/src/LitMotion/Assets/LitMotion.Animation"
    click M "https://github.com/annulusgames/litmotion/tree/main/docs"
    click N "https://github.com/annulusgames/litmotion/tree/main/samples"

    %% Styles
    classDef client fill:#dfe,stroke:#333,stroke-width:2px;
    classDef runtime fill:#f9c,stroke:#333,stroke-width:2px;
    classDef editor fill:#c9f,stroke:#333,stroke-width:2px;
    classDef extensions fill:#cfc,stroke:#333,stroke-width:2px;
    classDef external fill:#fc9,stroke:#333,stroke-width:2px;
    classDef docs fill:#cff,stroke:#333,stroke-width:2px;
```
