Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ZamaRig Logo

ZamaRig β€” AI-Powered Auto-Rigging

Upload a static 3D mesh. Get an animation-ready rigged model in seconds.

Features β€’ Architecture β€’ Pipeline β€’ Tech Stack β€’ Getting Started β€’ Project Structure β€’ API β€’ License


🎯 Overview

ZamaRig is a full-stack web application that automatically rigs 3D models using a combination of machine learning classification and procedural bone fitting. Users upload a static .obj or .fbx mesh through a modern web interface, and the system:

  1. Renders the model from multiple camera angles
  2. Classifies it as humanoid or quadruped using a trained CNN
  3. Generates and fits a skeleton template based on the model's anatomy
  4. Applies automatic weight painting (skinning)
  5. Returns the rigged model ready for animation

No manual bone placement. No weight painting by hand. Just upload and download.


✨ Features

  • AI Classification β€” EfficientNetB0-based CNN automatically determines model type (humanoid / quadruped)
  • Automatic Skeleton Generation β€” Procedural bone placement using bounding box analysis and anatomical proportions
  • Pose Detection β€” Detects whether humanoid models are in A-pose or T-pose for accurate fitting
  • Geodesic Skinning β€” Advanced weight painting using geodesic distance calculations for natural deformation
  • Interactive 3D Landing Page β€” Scroll-driven animations with dissolve effects, model transitions, and skeleton visualization using Three.js
  • Real-time 3D Preview β€” Preview uploaded and rigged models directly in the browser with React Three Fiber
  • Dark / Light Theme β€” Full theme support across UI and 3D viewport
  • Responsive Design β€” Optimized layouts for desktop, tablet, and mobile

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          CLIENT                                 β”‚
β”‚  React + TypeScript + Three.js/R3F + GSAP + Tailwind CSS        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚  Landing β”‚  β”‚   Rig    β”‚  β”‚  3D View β”‚  β”‚ Theme System β”‚     β”‚
β”‚  β”‚   Page   β”‚  β”‚   Page   β”‚  β”‚  (R3F)   β”‚  β”‚  (Context)   β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ REST API (multipart/form-data)
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        BACKEND                                  β”‚
β”‚  FastAPI + Uvicorn (Async Python)                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  API Router  β”‚  β”‚  ML Service  β”‚  β”‚  Blender Service     β”‚   β”‚
β”‚  β”‚  /api/v1/*   β”‚  β”‚  (TF/Keras)  β”‚  β”‚  (subprocess β†’ bpy)  β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚ subprocess call
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     BLENDER (Headless)                          β”‚
β”‚  Python bpy scripts β€” runs without GUI                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Renderer  β”‚  β”‚   Humanoid   β”‚  β”‚      Quadruped         β”‚   β”‚
β”‚  β”‚  (renders) β”‚  β”‚   Rigging    β”‚  β”‚      Rigging           β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”„ Rigging Pipeline

The auto-rigging pipeline follows 6 sequential stages:

Stage 1 β€” Upload & Preprocessing

The user uploads a .obj or .fbx file. The backend saves it temporarily and validates the format.

Stage 2 β€” Multi-Angle Rendering

Blender runs headlessly to import the model, center it, and render silhouette images from 4–6 camera angles (front, back, left, right, top). These renders serve as input to the classifier.

Stage 3 β€” AI Classification

The rendered images are fed into a pre-trained EfficientNetB0 model (transfer learning on ImageNet). The CNN outputs a category with a confidence score:

  • humanoid β€” bipedal characters (humans, robots, etc.)
  • quadruped β€” four-legged animals (dogs, horses, etc.)

Stage 4 β€” Template Selection & Skeleton Fitting

Based on the classification result, the corresponding skeleton template is loaded. The system:

  • Computes the mesh's bounding box dimensions
  • For humanoids: detects A-pose vs T-pose via arm angle analysis
  • Scales and positions each bone proportionally using anatomical heuristics
  • Handles special cases like finger joints, spine curvature, and tail bones

Stage 5 β€” Automatic Weight Painting (Skinning)

Vertices are assigned bone influence weights using:

  • Blender's built-in Auto Weights as a baseline
  • Geodesic distance-based skinning for improved deformation quality around joints

Stage 6 β€” Export & Download

The fully rigged model is exported as .glb (glTF Binary) and served to the frontend for preview and download.

πŸ“– For an in-depth technical deep-dive with mathematical foundations, bone hierarchies, and code-level explanations, see RIGGING_PIPELINE.md.


πŸ›  Tech Stack

Frontend

Technology Purpose
React 19 UI framework with hooks & context
TypeScript Type-safe development
Vite Build tool & dev server
React Three Fiber Declarative Three.js for 3D rendering
Three.js WebGL-based 3D engine
GSAP + ScrollTrigger Scroll-driven animations & transitions
Lenis Smooth scroll behavior
Tailwind CSS 4 Utility-first styling
React Router 7 Client-side routing

Backend

Technology Purpose
FastAPI Async Python API framework
Uvicorn ASGI server
TensorFlow / Keras ML model inference (EfficientNetB0)
Pillow Image preprocessing
NumPy Numerical operations
Pydantic Request/response validation

3D & ML

Technology Purpose
Blender 5.x (bpy) Headless 3D processing, rendering, rigging
EfficientNetB0 Image classification (transfer learning)
Geodesic Skinning Distance-based vertex weight calculation

Deployment

Technology Purpose
Vercel Frontend hosting (SPA with rewrites)
Bun JavaScript runtime & package manager

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ or Bun (recommended)
  • Python 3.10+
  • Blender 5.x (must be accessible from command line)

Frontend Setup

cd frontend
bun install        # or npm install
bun dev            # starts dev server at http://localhost:5173

Backend Setup

cd backend
python -m venv venv
source venv/bin/activate       # Windows: venv\Scripts\activate
pip install -r requirements.txt
python main.py                  # starts API at http://localhost:8000

Environment Variables

Create frontend/.env:

VITE_API_URL=http://localhost:8000

Production Build

cd frontend
bun run build      # outputs to dist/

πŸ“ Project Structure

auto-rigging/
β”œβ”€β”€ frontend/                    # React + TypeScript SPA
β”‚   β”œβ”€β”€ public/                  # Static assets (3D models, icons)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ landing/         # Landing page components
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ landing-canvas.tsx    # Three.js canvas wrapper
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ landing-model.tsx     # 3D model with scroll animations
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ dissolve-material.ts  # Custom dissolve shader
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ smooth-scroll.tsx     # Lenis smooth scroll + progress bar
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ loading-screen.tsx    # Loading overlay
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ footer.tsx            # Site footer
β”‚   β”‚   β”‚   β”‚   └── sections/            # Individual scroll sections
β”‚   β”‚   β”‚   β”œβ”€β”€ layout/          # Header, layout wrapper
β”‚   β”‚   β”‚   └── ui/              # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── scroll-anim-config.ts    # Responsive scroll animation values
β”‚   β”‚   β”œβ”€β”€ hooks/               # Custom React hooks (theme, etc.)
β”‚   β”‚   β”œβ”€β”€ pages/               # Route pages (Home, Rig)
β”‚   β”‚   β”œβ”€β”€ services/            # API client services
β”‚   β”‚   └── types/               # TypeScript type definitions
β”‚   β”œβ”€β”€ vercel.json              # Vercel SPA routing config
β”‚   └── package.json
β”‚
β”œβ”€β”€ backend/                     # FastAPI Python server
β”‚   β”œβ”€β”€ main.py                  # App entry point
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api/v1/
β”‚   β”‚   β”‚   └── endpoints/
β”‚   β”‚   β”‚       └── rigging.py   # POST /api/v1/rigging/process
β”‚   β”‚   β”œβ”€β”€ core/                # Settings, configuration
β”‚   β”‚   └── services/
β”‚   β”‚       β”œβ”€β”€ ml_service.py    # TensorFlow model inference
β”‚   β”‚       └── blender_service.py  # Blender subprocess orchestration
β”‚   β”œβ”€β”€ blender_scripts/
β”‚   β”‚   β”œβ”€β”€ common/              # Shared utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ blender_utils.py
β”‚   β”‚   β”‚   β”œβ”€β”€ fitting_utils.py
β”‚   β”‚   β”‚   β”œβ”€β”€ mesh_processing.py
β”‚   β”‚   β”‚   β”œβ”€β”€ mesh_utils.py
β”‚   β”‚   β”‚   └── profile_analysis.py
β”‚   β”‚   β”œβ”€β”€ humanoid/
β”‚   β”‚   β”‚   β”œβ”€β”€ analyzer.py      # Pose detection, proportion analysis
β”‚   β”‚   β”‚   └── rigging.py       # Humanoid skeleton generation & fitting
β”‚   β”‚   β”œβ”€β”€ quadruped/
β”‚   β”‚   β”‚   β”œβ”€β”€ analyzer.py      # Body segment analysis
β”‚   β”‚   β”‚   └── rigging.py       # Quadruped skeleton generation & fitting
β”‚   β”‚   └── tools/
β”‚   β”‚       β”œβ”€β”€ take_renders.py  # Multi-angle rendering script
β”‚   β”‚       β”œβ”€β”€ run_rigging.py   # Rigging orchestrator
β”‚   β”‚       β”œβ”€β”€ geodesic_skinning.py  # Advanced weight painting
β”‚   β”‚       └── inspect_rig.py   # Debug/inspection utility
β”‚   └── public/                  # Served static files (processed models)
β”‚
β”œβ”€β”€ blender/                     # Standalone Blender utilities
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”œβ”€β”€ render_dataset.py    # Batch render script for dataset creation
β”‚   β”‚   └── export_all.py        # Batch export utility
β”‚   └── add-ons/                 # Custom Blender add-ons
β”‚
β”œβ”€β”€ ml_pipeline/                 # Machine learning training
β”‚   β”œβ”€β”€ notebooks/
β”‚   β”‚   β”œβ”€β”€ model_train.ipynb    # EfficientNetB0 training notebook
β”‚   β”‚   └── test.ipynb           # Model evaluation & testing
β”‚   └── saved_models/            # Exported .keras model files
β”‚
β”œβ”€β”€ dataset/                     # Training data
β”‚   β”œβ”€β”€ models/                  # Raw 3D models (organized by class)
β”‚   β”œβ”€β”€ renders/                 # Multi-angle renders for training
β”‚   └── test_renders/            # Test set renders
β”‚
β”œβ”€β”€ RIGGING_PIPELINE.md          # In-depth technical documentation
β”œβ”€β”€ TODOS.md                     # Development roadmap & progress
└── README.md                    # ← You are here

πŸ“‘ API Reference

POST /api/v1/rigging/process

Accepts a 3D model file and returns a rigged version.

Request:

Content-Type: multipart/form-data

file: <.obj or .fbx file>

Response:

{
  "status": "success",
  "classification": "humanoid",
  "confidence": 0.97,
  "output_file": "/public/results/<id>/rigged_model.glb"
}

Pipeline Steps (server-side):

  1. Save uploaded file β†’ public/uploads/
  2. Render silhouettes via Blender subprocess
  3. Classify renders via TensorFlow
  4. Run appropriate rigging script via Blender subprocess
  5. Return rigged .glb path

GET /

Redirects to Swagger UI documentation at /docs.


🎨 Landing Page

The landing page features an interactive 3D experience built with React Three Fiber and GSAP:

  • Scroll-driven model animation β€” The 3D model moves, rotates, and scales based on scroll position with configurable breakpoint-specific values
  • Dissolve effect β€” Custom shader-based morph transition between humanoid and quadruped models in the Classification section
  • Skeleton visualization β€” 3D bone meshes rendered on top of the model in the Download section with emissive cyan material
  • Smooth scrolling β€” Lenis-powered buttery smooth scroll with GSAP ScrollTrigger integration
  • Responsive configs β€” Separate animation values for desktop (>1024px), tablet (768–1024px), and mobile (<768px)
  • Loading screen β€” Animated overlay that displays while 3D assets are loading

πŸ“„ License

This project is open source under the MIT License.


Built with ❀️ by zamazincode

About

Auto Rigging System for 3D Models

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages