# ARCHITEKTUR-BRIEFING: Tauri + wgpu (Korrigiert) **Stand:** 2026-07-01 — **KORREKTUR** (vorherige Dokumente waren unvollständig) --- ## Die Entscheidung (FINAL) **Browser-CAD (alt) → Desktop Tauri-App mit Rust-Backend + wgpu-Rendering (neu)** | Aspekt | Alt | Neu | |---|---|---| | **App-Form** | Browser-Tab | Desktop Tauri-Window | | **Frontend** | React/Vite (TS) | React/Vite (TS) — UNVERÄNDERT | | **2D-Rendering** | SVG-Plan | SVG-Plan — UNVERÄNDERT | | **3D-Rendering** | three.js/WebGL | **wgpu** (Vulkan/Metal/DX12) | | **Rechenintensive Ops** | TS in Browser | **Rust im Backend** | | **Betriebssystem** | cross-platform browser | Windows/macOS/Linux Desktop App | --- ## Warum dieser Umstieg? **Problem mit three.js/WebGL:** - komplexe Möbel = 100k+ Polygone - mehrere parallele Ops (kernel2d, bool-Ops, DXF-Parser, SIA-Raumerkennung) - WebGL hat harte Limits (GPU VRAM, draw calls, single-threaded) - → Laggy, nicht skalierbar für Professional CAD **Lösung: Tauri + wgpu + Rust** - **wgpu** = low-level GPU API (direkt zu Vulkan/Metal/DX12, nicht WebGL) - **Rust** = rechenintensive Ops parallelisiert + native performance - **Desktop** = native App, nicht Browser (bessere Kontrolle, bessere Perf) - **React-Frontend bleibt** = UI/Sketching/Panels unverändert (wgpu nur für 3D-Display) --- ## Der neue Stack (FINAL) ``` ┌─────────────────────────────────────────────────────┐ │ Desktop Tauri-Window │ ├─────────────────────────────────────────────────────┤ │ │ │ React/Vite (UI-Shell, State, Panels) │ │ ├─ SVG 2D-Plan (Grundriss) │ │ └─ wgpu 3D-Viewport (3D-Ansicht + Rendering) │ │ │ │ ↓ invoke (IPC) ↓ │ │ │ │ Rust-Backend (src-tauri/) │ │ ├─ computeJoins() — Wand-Eckverbindungen │ │ ├─ kernel2d() — Offset/Trim/Extend/… │ │ ├─ parseShapeFromDwg() — Geometrie-Import │ │ ├─ detectRooms() — SIA-Raumerkennung │ │ └─ booleanOps() — Union/Differenz/Schnitt │ │ │ └─────────────────────────────────────────────────────┘ ``` **Nicht verändert:** - App.tsx, state/, commands/, panels/, model/types.ts - UI-Logik, Befehlssystem, Sketching-Tools **Neu/geändert:** - `src-tauri/` — Rust-Crate für Backend - `src/compute/index.ts` — Boundary (invoke + TS-Fallback) - Rendering-Engine: **three.js → wgpu** - Build: `npm run tauri:build` statt `npm run build` --- ## Die Aufgabe (vier Agents) **Siehe: `docs/design/tauri-migration-plan.md`** Vier parallele Agents: 1. **Agent: Tauri-Shell Setup** → `src-tauri/` + Cargo.toml + main.rs (Tauri window registrieren) 2. **Agent: Compute-Boundary (TS)** → `src/compute/index.ts` (invoke-Wrapper + TS-Fallbacks) 3. **Agent: Rust compute_joins Impl** → `src-tauri/src/geometry.rs` (erste Op, Proof-of-Concept) 4. **Agent: Vite/Package-Integration** → vite.config.ts + package.json (Tauri-Plugins, scripts) **Deliverable:** lauffähige Desktop-App, wand-Edit triggert Rust-Op, Output identisch TS-Version. --- ## Dev-Workflow (post-Tauri) ```bash # Dev: Terminal 1 (Vite) npm run dev # localhost:5173 # Dev: Terminal 2 (Tauri) npm run tauri:dev # öffnet Desktop-Window, zeigt auf localhost:5173 # Build npm run tauri:build # → Windows .exe / macOS .app / Linux .deb ``` --- ## Rendering: three.js → wgpu (Wichtig!) **3D-Viewport wird NEU implementiert in wgpu:** - Nicht: "drei.js mit Rust-Fallback" - **Ja:** wgpu als native GPU-Renderer (skaliert auf 100k+ Polygone) **2D-Plan bleibt SVG** (keine Änderung). **Timeline für wgpu-Impl:** - Milestone 1 (jetzt): Tauri-Shell + Rust-Compute-Ops - Milestone 2 (nächst): wgpu 3D-Viewport-Impl (ersetzt drei.js/WebGL) - Milestone 3: Live clipping/sectioning in wgpu --- ## Migration-Reihenfolge **Phase 1 (Tauri-Shell + Proof-of-Concept):** - [ ] `computeJoins` (Wand-Ecken) → Rust **Phase 2 (Rendering-Umbau):** - [ ] wgpu Viewport-Impl (ersetzt drei.js) - [ ] Instancing/LOD für Möbel-Geometrie **Phase 3 (weitere Ops):** - [ ] `kernel2d` (Offset/Trim) → Rust - [ ] DXF/DWG-Parser → Rust - [ ] detectRooms → Rust - [ ] booleanOps → Rust --- ## Was sich NICHT ändert - `src/App.tsx`, `src/state/`, `src/commands/` - UI-Panels, Zeichenwerkzeuge, Befehlssystem - Semantisches Modell (types.ts) - i18n, Styling ## Was ändert sich - **Engine:** three.js/WebGL → wgpu - **Backend:** TS-Only → Tauri + Rust - **Distribution:** Browser → Desktop App - **Build-Prozess:** `npm run build` → `npm run tauri:build` --- ## Fehlerquellen (zur Klarheit) ❌ **FALSCH:** "Wir bleiben bei three.js" ✅ **RICHTIG:** "three.js → wgpu, Rust-Compute + Desktop Tauri" ❌ **FALSCH:** "Tauri + three.js als Frontend-Engine" ✅ **RICHTIG:** "Tauri-Shell + React UI + wgpu 3D-Rendering + Rust-Compute" --- ## Nächste Schritte 1. **Lesen:** `docs/design/tauri-migration-plan.md` (technisch, konkret) 2. **Spawn:** vier Agents (parallel, unabhängig) 3. **Verifizieren:** `npm run tauri:dev` → App läuft, erste Op in Rust funktioniert 4. **Aktualisieren:** HANDOVER.md mit Milestone-1-Status --- ## Fragen? - **"Warum Desktop statt Browser?"** → Skalierbarkeit (native GPU + Rust-Compute) - **"Warum wgpu statt drei.js?"** → wgpu skaliert auf 100k+ Polygone, three.js/WebGL hat Limits - **"Bleibt React?"** → Ja, React/Vite UI bleibt, nur 3D-Engine wechselt - **"Wann ist wgpu-Impl fertig?"** → Milestone 2 (nach Tauri-Shell)