Spaces:
Sleeping
Sleeping
File size: 2,581 Bytes
346b70f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# Project Structure
Mesh Palettizer - Web application for 3D model texture simplification
## Stack
- Runtime: Python 3.10+
- 3D Processing: Trimesh
- Image Processing: Pillow, NumPy, OpenCV
- ML/Clustering: Scikit-learn
- Spatial Indexing: SciPy
- Web Interface: Gradio
## Commands
- Web interface: `uv run python app.py`
- Install: `uv sync`
- Lint: `uv run ruff check .`
- Format: `uv run black src/`
## Layout
```
conversion/
βββ CLAUDE.md # Global context (Tier 0)
βββ app.py # Web interface with Gradio
βββ README.md # Public documentation
βββ pyproject.toml # Dependencies
βββ context.md # Project context (Tier 2)
βββ src/ # Core tool - reusable texture palettizer
β βββ context.md # Module context (Tier 2)
β βββ __init__.py # Main API: convert_meshes()
β βββ preprocessing/ # Texture detail removal
β β βββ __init__.py
β β βββ simplifier.py # Bilateral filter for artifact removal
β βββ extraction/ # Color extraction from meshes
β β βββ __init__.py
β β βββ sampler.py # Face sampling with area weighting
β β βββ reader.py # Texture/material color reading
β βββ palette/ # Palette generation and mapping
β β βββ __init__.py
β β βββ quantizer.py # K-means clustering in LAB space
β β βββ mapper.py # Nearest color mapping via KD-tree
β β βββ color_space.py # RGB/LAB conversion
β βββ atlas/ # Texture atlas generation
β β βββ __init__.py
β β βββ builder.py # Atlas construction with UV mapping
β βββ mesh/ # Mesh transformation
β βββ __init__.py
β βββ uvmapper.py # UV remapping to atlas
βββ layers/
βββ structure.md # This file (Tier 1)
```
## Architecture
GLB processing with K-means color quantization and configurable palette sizes
- **Pattern**: Direct transformation pipeline
- **Flow**: Load meshes β Simplify textures β Sample colors β Quantize to palette β Create atlas β Apply β Export
- **Palette sizes**: Powers of 2 (8Γ8=64 colors, 16Γ16=256, 32Γ32=1024, etc.)
- **State**: None - pure transformation
- **Optimization**: Random sampling, vectorized operations, LAB color space
## Entry Points
`app.py` - Gradio web interface with configurable detail removal sensitivity
`src.convert_meshes()` - Core API with palette generation and detail control |