# pong-lei/su7_imitate architecture

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

- Interactive diagram: https://gitdiagram.com/pong-lei/su7_imitate
- Repository: https://github.com/pong-lei/su7_imitate

## Overview

##### Project Type and Purpose
- This is a front-end single-page application built with Vue 3 and Vite.
- Purpose: an interactive 3D car-visualization tool with three modes (“wind resistance,” “body inspection,” “smart driving”), using WebGL/Three.js plus custom GLSL shaders and Draco-compressed 3D assets.

##### High-Level Architecture
- No backend/microservices: all logic runs in the browser.
- Core components:
- Build & Serve (Vite, package.json)
- Static Assets (public folder: Draco decoders, images)
- Application Code (src folder: Vue components, shaders, models)
- Rendering Engine (Three.js via imports, custom shaders)
- Deployment (static hosting on Vercel)

##### Main Components
a. Browser/Client
- Vue 3 SPA (App.vue → child components)
- Vite dev server/build pipeline
b. Rendering Engine
- Three.js scene graph
- Custom GLSL shaders (fragment.glsl, vertex.glsl)
- Draco decoder WASM + JS modules (public/draco)
c. Asset Store
- 3D models (.glb, .gltf, .blend backups, JSON outlines)
- Textures (.hdr, .mp3 audio)
d. User Interaction Layer
- Mode-switch UI in components/World/I_drivingMode
- Animation logic in components and Test/groundGlass
e. Deployment
- Vite output → static files
- Served via Vercel URL

##### Relationships & Data Flow
- User events → Vue components → update Three.js scene graph
- Vue components import shaders & models → pass to Three.js renderer
- Three.js + WebGL → GPU → Canvas in index.html
- Build step (Vite) bundles src, shaders, public assets → dist
- Dist deployed to Vercel → CDN → Browser

##### Architectural Patterns & Principles
- Component-based UI (Vue’s single-file components)
- Layered separation: UI layer ↔ Rendering layer ↔ Asset layer
- Static asset pipeline: Draco compression for model delivery
- Build-time configuration (vite.config.js) decoupled from runtime

##### Technologies & Frameworks
- Vue 3 (composition API via .vue files)
- Vite (ESM bundler, dev server)
- Three.js (3D engine)
- Draco (geometry compression, WASM)
- GLSL (custom shaders for glass, outlines, bloom, wind lines)
- Vercel (static hosting)

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Build & Serve Layer
  subgraph "Build & Serve"
    pkg["package.json"]:::build
    vcfg["vite.config.js"]:::build
    idxhtml["index.html"]:::build
    pkg --> Vite["Vite (Dev Server & Bundler)"]:::build
    vcfg --> Vite
    idxhtml --> Vite
  end

  %% Static Assets
  subgraph "Static Assets (public)" 
    draco_js["draco_decoder.js"]:::asset
    draco_wasm["draco_decoder.wasm"]:::asset
    draco_enc["draco_encoder.js"]:::asset
    draco_wrap["draco_wasm_wrapper.js"]:::asset
    gltf_public["gltf/*"]:::asset
    draco_js --> Vite
    draco_wasm --> Vite
    draco_enc --> Vite
    draco_wrap --> Vite
    gltf_public --> Vite
  end

  %% Application Code
  subgraph "Application Code (src)" 
    entry["main.js"]:::code
    appvue["App.vue"]:::code
    entry --> appvue
    subgraph "Vue SPA Components"
      world_vue["components/World/index.vue"]:::code
      world_js["components/World/World.js"]:::code
      appvue --> world_vue
      world_vue --> world_js
    end
    subgraph "Mode Switching"
      initBg["I_drivingMode/initBg.js"]:::code
      bodyMode["bodyMode.js"]:::code
      world_js --> initBg
      world_js --> bodyMode
    end
    subgraph "Shaders"
      v_glsl["vertex.glsl"]:::asset
      f_glsl["fragment.glsl"]:::asset
      f2_glsl["fragment2.glsl"]:::asset
      fl_glsl["fragment_line.glsl"]:::asset
      flr_glsl["fragment_line_red.glsl"]:::asset
      flw_glsl["fragment_line_wind.glsl"]:::asset
      vl_glsl["vertex_line.glsl"]:::asset
      world_js --> v_glsl
      world_js --> f_glsl
      world_js --> f2_glsl
      world_js --> fl_glsl
      world_js --> flr_glsl
      world_js --> flw_glsl
      world_js --> vl_glsl
    end
  end

  %% Test Glass Demo
  subgraph "Test/groundGlass"
    tg_vue["index.vue"]:::code
    tg_glass["GlassMesh.js"]:::code
    tg_v["shader/vertex.glsl"]:::asset
    tg_f["shader/fragment.glsl"]:::asset
    tg_f2["shader/fragment2.glsl"]:::asset
    tg_tex["textures/t_env_light.hdr"]:::asset
    tg_vue --> tg_glass
    tg_glass --> tg_v
    tg_glass --> tg_f
    tg_glass --> tg_f2
    tg_glass --> tg_tex
  end

  %% 3D Asset Store
  subgraph "3D Asset Store"
    model1["bodyPlan.glb"]:::asset
    model2["line.glb"]:::asset
    model3["stree.glb"]:::asset
    model4["merge.glb"]:::asset
    model5["merge.gltf"]:::asset
    model6["wind_line.glb"]:::asset
    model7["windlines/*.json"]:::asset
    model8["outlines/*.json"]:::asset
    tex_env["t_env_light.hdr"]:::asset
    audio["shengna.mp3"]:::asset
  end

  %% Runtime & Rendering
  Browser["User / Browser"]:::ext
  subgraph "Rendering Engine"
    three["Three.js"]:::ext
    draco_wasm_mod["Draco WASM Module"]:::ext
    webgl["WebGL / GPU"]:::ext
    canvas["Canvas (index.html)"]:::ext
    Browser --> entry
    appvue --> three
    world_js --> three
    model1 --> three
    model2 --> three
    model3 --> three
    model4 --> three
    model5 --> three
    model6 --> three
    model7 --> three
    model8 --> three
    v_glsl --> three
    f_glsl --> three
    f2_glsl --> three
    fl_glsl --> three
    draco_js --> draco_wasm_mod
    draco_wasm --> draco_wasm_mod
    draco_wrap --> draco_wasm_mod
    draco_wasm_mod --> three
    three --> webgl --> canvas
  end

  %% Deployment
  Vite --> dist["dist (Bundle)"]:::build
  dist --> Vercel["Vercel / CDN"]:::host
  Vercel --> Browser

  %% Click Events
  click pkg "https://github.com/pong-lei/su7_imitate/blob/master/package.json"
  click vcfg "https://github.com/pong-lei/su7_imitate/blob/master/vite.config.js"
  click idxhtml "https://github.com/pong-lei/su7_imitate/blob/master/index.html"
  click draco_js "https://github.com/pong-lei/su7_imitate/blob/master/public/draco/draco_decoder.js"
  click draco_wasm "https://github.com/pong-lei/su7_imitate/blob/master/public/draco/draco_decoder.wasm"
  click draco_enc "https://github.com/pong-lei/su7_imitate/blob/master/public/draco/draco_encoder.js"
  click draco_wrap "https://github.com/pong-lei/su7_imitate/blob/master/public/draco/draco_wasm_wrapper.js"
  click gltf_public "https://github.com/pong-lei/su7_imitate/tree/master/public/draco/gltf/*"
  click entry "https://github.com/pong-lei/su7_imitate/blob/master/src/main.js"
  click appvue "https://github.com/pong-lei/su7_imitate/blob/master/src/App.vue"
  click world_vue "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/index.vue"
  click world_js "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/World.js"
  click initBg "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/I_drivingMode/initBg.js"
  click bodyMode "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/bodyMode.js"
  click v_glsl "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/shader/vertex.glsl"
  click f_glsl "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/shader/fragment.glsl"
  click f2_glsl "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/shader/fragment2.glsl"
  click fl_glsl "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/shader/fragment_line.glsl"
  click flr_glsl "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/shader/fragment_line_red.glsl"
  click flw_glsl "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/shader/fragment_line_wind.glsl"
  click vl_glsl "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/shader/vertex_line.glsl"
  click tg_vue "https://github.com/pong-lei/su7_imitate/blob/master/src/Test/groundGlass/index.vue"
  click tg_glass "https://github.com/pong-lei/su7_imitate/blob/master/src/Test/groundGlass/GlassMesh.js"
  click tg_v "https://github.com/pong-lei/su7_imitate/blob/master/src/Test/groundGlass/shader/vertex.glsl"
  click tg_f "https://github.com/pong-lei/su7_imitate/blob/master/src/Test/groundGlass/shader/fragment.glsl"
  click tg_f2 "https://github.com/pong-lei/su7_imitate/blob/master/src/Test/groundGlass/shader/fragment2.glsl"
  click tg_tex "https://github.com/pong-lei/su7_imitate/blob/master/src/Test/groundGlass/textures/t_env_light.hdr"
  click model1 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/bodyPlan/bodyPlan.glb"
  click model2 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/line.glb"
  click model3 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/stree/stree.glb"
  click model4 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/su7blender/merge.glb"
  click model5 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/su7blender/merge.gltf"
  click model6 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/wind_line.glb"
  click model7 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/windlines/*.json"
  click model8 "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/model/outlines/*.json"
  click tex_env "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/textures/t_env_light.hdr"
  click audio "https://github.com/pong-lei/su7_imitate/blob/master/src/components/World/audio/shengna.mp3"
  click README "https://github.com/pong-lei/su7_imitate/blob/master/README.md"

  %% Styles
  classDef build fill:#FFA500,stroke:#333,stroke-width:1px;
  classDef code fill:#87CEFA,stroke:#333,stroke-width:1px;
  classDef asset fill:#98FB98,stroke:#333,stroke-width:1px;
  classDef ext fill:#DDA0DD,stroke:#333,stroke-width:1px;
  classDef host fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
