Specimen Report · Python

blender-py-animate-threejs

phiat/blender-py-animate-threejs

procedural rigged characters in blender python → three.js - walk cycles, jumps, animation blending

Stars
★ 0
Forks
⑂ 0
Language
Python
Size
63 kB
Last Push
3mo ago
Forged
5mo ago
3danimationblenderprocedural-generationpythonthreejs
# Blender Python Animation + Three.js A complete workflow for creating animated 3D characters in Blender using Python and rendering them in the browser with Three.js. ## Features - **Procedural Character Generation** - Python script creates a fully rigged character with skeleton - **Multiple Walk Animations** - 3 walk styles (Natural, Bouncy, March) with customizable parameters - **Jump Animation** - 4-phase jump (anticipation, launch, airborne, landing) - **WASD Movement** - Full character controller with smooth rotation - **Animation Blending** - Smooth crossfade transitions between animations - **GLTF Export** - Automatic export to GLB format for web use ## Quick Start ### 1. Generate the Character Model ```bash blender --background --python create_character.py ``` This creates `character.glb` with: - Rigged mesh with 20 bones - Idle animation (3 seconds) - 3 walk animations (Natural, Bouncy, March) - Jump animation (0.8 seconds) ### 2. Run the Web Viewer ```bash python -m http.server 8000 ``` Open http://localhost:8000 in your browser. ### 3. Controls | Key | Action | |-----|--------| | W | Move forward | | A | Move left | | S | Move backward | | D | Move right | | Space | Jump | | Mouse | Orbit camera | ## Project Structure ``` ├── create_character.py # Blender Python script ├── index.html # Web page with UI ├── main.js # Three.js application ├── character.glb # Exported model (generated) └── README.md ``` ## Character Rig The skeleton includes: - Root (hip) - Spine chain (Spine1, Spine2, Spine3) - Neck & Head - Arms (Shoulder, UpperArm, LowerArm, Hand) x2 - Legs (UpperLeg, LowerLeg, Foot) x2 ## Animations ### Idle Subtle breathing motion with: - Spine movement - Head sway - Arm drift ### Walk Variations | Style | Speed | Knee Bend | Foot Lift | Character | |-------|-------|-----------|-----------|-----------| | Natural | 1.0s | 1.0 | 0.4 | Casual walk | | Bouncy | 0.8s | 1.2 | 0.5 | Energetic | | March | 0.9s | 1.4 | 0.6 | Military style | ### Jump 4-phase animation: 1. **Anticipation** - Crouch, arms back 2. **Launch** - Extend legs, arms up 3. **Airborne** - Legs tuck, arms out 4. **Landing** - Absorb impact ## Customization ### Adding New Walk Styles Edit `create_character.py` and add new parameters: ```python my_walk_params = { 'duration': 1.0, # Cycle duration in seconds 'hip_swing': 0.5, # Leg swing amplitude 'knee_bend': 1.0, # Knee bend amount 'foot_lift': 0.4, # Foot lift during swing 'bob': 0.04, # Vertical bounce 'arm_swing': 0.4, # Arm swing amplitude 'hip_sway': 0.05 # Hip side-to-side sway } create_walk_animation("MyWalk", my_walk_params) ``` ### Changing Character Appearance Modify the mesh creation section in `create_character.py`: - Adjust primitive dimensions - Change material color - Add more body parts ## Requirements - [Blender 4.0+](https://www.blender.org/) (tested with 5.0) - Modern web browser with WebGL support - Python 3.x (for local server) ## Tech Stack - **Blender** - 3D modeling and animation - **Three.js** - WebGL rendering - **GLTF/GLB** - Model format with animations ## License MIT
↗ GitHub