refactor: simplify upload rules and remove destination flow

This commit is contained in:
Tom Boullay
2026-04-24 16:23:02 +02:00
parent 61a0146545
commit 944959fc22
20 changed files with 2033 additions and 217 deletions
+14 -26
View File
@@ -1,6 +1,6 @@
# upload-GLTF
A secure web interface for uploading 3D assets (GLTF/GLB + textures) to two destinations:
A secure web interface for uploading 3D assets (GLTF/GLB + textures) with two outputs:
- **Nextcloud Drive** — Archives the original files with automatic versioning (VF/V1/V2...), so artists always have a history of past versions.
- **GitHub** — Delivers compressed models (Draco via Blender) to the dev team's repository, ready for integration.
@@ -87,10 +87,9 @@ The Docker image includes Blender headless (installed once at build time). On st
## How it works
1. The user enters their access key
2. They pick a **destination** (`farm`, `map`, `powergrid`, `workshop`, `general`, `environment`)
3. They select a folder containing:
- `model.glb` or `model.gltf` (**required**)
- Textures: `roughness`, `normal`, `metalness`, `color`, `displace` (`.png/.jpg/.webp`, **optional** — missing textures show a warning but don't block the upload)
2. They select a folder containing:
- `model.glb` (**required**)
- Any associated textures (`.png/.jpg/.jpeg/.webp`)
4. The model is displayed in a 3D preview
5. On clicking "Envoyer":
- The app checks the remote Git repo for existing files and computes diffs (textures by size, models always re-pushed)
@@ -111,7 +110,7 @@ The Drive uses a `VF` (version finale) / `Vx` (archived versions) structure:
Models/
VF/ ← latest version
coffeetest/
model.gltf
model.glb
color.jpg
V1/ ← first archive
coffeetest/
@@ -131,42 +130,32 @@ All changes are pushed in a **single commit** with a formatted message:
**New folder:**
```
update: upload-gltf add a new model -> farm/my-model
update: upload-gltf add a new model -> my-model
📦 Model
✅ model.gltf (compressed)
✅ model.glb (compressed)
🎨 Textures
✅ color.jpg
❌ metalness (manquant)
```
**Update (only metalness changed):**
**Update (only one texture changed):**
```
update: upload-gltf update -> general/coffeetest
update: upload-gltf update -> coffeetest
📦 Model
↔️ model.gltf (inchange)
↔️ model.glb (inchange)
🎨 Textures
🔄 metalness.jpg
🔄 color_tuyaux.jpg
```
Symbols: `✅` new — `🔄` modified — `↔️` unchanged (model always re-pushed) — `❌` missing or deleted
Symbols: `✅` new — `🔄` modified — `↔️` unchanged (model always re-pushed) — `❌` deleted
8. Orphan files (present on remote but not in the new upload) are deleted in the same commit
9. If Blender is unavailable, the original model is pushed as-is (graceful fallback)
## Destinations
Uploaded models are pushed to `public/models/<destination>/<folderName>/` in the target repo:
| Destination | Path |
|-------------|------|
| Farm | `public/models/farm/` |
| Map | `public/models/map/` |
| Powergrid | `public/models/powergrid/` |
| Workshop | `public/models/workshop/` |
| General | `public/models/general/` |
| Environment | `public/models/environment/` |
Uploaded models are pushed to `public/models/<folderName>/` in the target repo.
## Project Structure
@@ -185,7 +174,6 @@ components/
│ └── Modal.tsx # Shared modal wrapper + ModalActions
├── upload/
│ ├── SecretInput.tsx # Access key input
│ ├── DestinationPicker.tsx # Destination selector
│ ├── FolderDropzone.tsx # Folder drag & drop / picker
│ ├── FolderCard.tsx # Folder status card (Drive + Git)
│ ├── DriveStatusLine.tsx # Drive/Git status sub-line
@@ -202,7 +190,7 @@ hooks/
├── useFolderEntries.ts # Folder entries state management
└── useUploadOrchestrator.ts # Upload pipeline orchestration (Drive → Git)
lib/
├── constants.ts # Shared constants, destinations, extensions
├── constants.ts # Shared constants and extensions
├── types.ts # Server types (ParsedFile, FileDiff, etc.)
├── client-types.ts # Client types (FolderEntry, DriveStatus, etc.)
├── upload-api.ts # Client-side API helpers (check, uploadDrive, uploadGit)