A high-performance 3D model library management system built with Go and modular JavaScript.
- 3D Preview - Interactive THREE.js previews for STL, OBJ, and 3MF files
- Image Support - Display PNG/JPG preview images
- Smart Preview Selection - Auto-selects best preview (images preferred, then 3D models)
- Lazy Loading - Load 3D previews on scroll (files <10MB) or on-demand (files >10MB)
- Single WebGL Context - Shared renderer eliminates context limit issues
- ZIP Upload - Extract and organize models from ZIP files
- Slicer Integration - Open models directly in PrusaSlicer, Bambu Studio, OrcaSlicer, Cura
- Background Jobs - Async library scanning with Redis + Asynq
- REST API - 27 endpoints for complete library management
web/static/js/
├── app.js # Main entry point
├── three-loader.js # THREE.js loader
└── modules/
├── config.js # Configuration constants
├── api.js # API client
├── renderer-pool.js # Shared WebGL renderer
├── three-utils.js # THREE.js utilities
├── model-viewer.js # 3D preview logic
└── ui.js # UI components
cmd/
├── web/main.go # HTTP server
└── worker/main.go # Background worker
internal/
├── config/ # Configuration management
├── database/ # Database connection
├── models/ # Data models
├── handlers/ # HTTP handlers
├── jobs/ # Background jobs
└── scanner/ # File scanner
- Go 1.23+
- PostgreSQL 14+
- Redis
- Setup
cd /root/3d-library
cp .env.example .env- Database
sudo -u postgres psql -c "CREATE DATABASE library3d;"
sudo -u postgres psql -c "CREATE USER library3d WITH PASSWORD dev123;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE library3d TO library3d;"
sudo -u postgres psql -d library3d -c "ALTER TABLE models ADD COLUMN IF NOT EXISTS preview_file_id INTEGER REFERENCES model_files(id) ON DELETE SET NULL;"- Run
# Start web server
go run cmd/web/main.go
# Start worker (in another terminal)
go run cmd/worker/main.go- Access Open http://192.168.3.26:3000
GET /api/models- List all modelsPOST /api/models- Create modelGET /api/models/{id}- Get modelDELETE /api/models/{id}- Delete modelGET /api/models/{id}/files- Get model filesPOST /api/models/{id}/preview- Set preview filePOST /api/models/{id}/tags- Add tagGET /api/models/{id}/tags- Get tags
GET /api/libraries- List librariesPOST /api/libraries- Create libraryGET /api/libraries/{id}- Get libraryDELETE /api/libraries/{id}- Delete libraryPOST /api/libraries/{id}/scan- Scan libraryPOST /api/libraries/{id}/upload- Upload files
GET /api/files/{id}- Get file infoGET /api/files/{id}/download- Download fileDELETE /api/files/{id}- Delete file
- Automatically selects preview when uploading or scanning
- Priority: Images (PNG/JPG) > 3D models (STL/OBJ/3MF)
- Manual override available via "Set as Preview" button
- Single WebGL Context - One shared renderer for all previews
- Lazy Loading - 3D files load on scroll (IntersectionObserver)
- Size-Based Loading - Files >10MB require manual click
- Image Auto-Load - Lightweight images load immediately
- Loading Indicators - Animated spinner during 3D file loading
- Interactive OrbitControls (rotate, pan, zoom)
- Grid floor with axes
- Consistent lighting and materials
- Supports STL, OBJ, and 3MF formats
- 100x faster file scanning vs Rails
- 16x less memory usage
- No WebGL context limits - Single shared renderer
- Instant page loads - Lazy loading prevents blocking
ES6 modules with no build step. Changes reflect immediately after browser refresh.
go run cmd/web/main.gohttps://github.com/billsbdb3/Go3D
MIT