3D Animation System Test
🎬 Animation Playback System
This page demonstrates the new animation controls for GLB files with embedded animations. The animation panel appears automatically when a model contains animations.
Features
- Animation List - Clickable buttons for each animation in the model
- Playback Controls - Play, Pause, Resume, and Stop buttons
- Speed Control - Slider to adjust playback speed (0.25x to 2.0x)
- Loop Modes - Once, Loop (repeat), or Ping-Pong (back-and-forth)
- Visual Feedback - Active animation highlighted in gold/blue
Test Model: Chibiko with Animations
Load a GLB file with embedded animations. The animation controls will appear automatically in the control panel if animations are detected.
modelPath="/models/chibiko-anim2.glb" | controlTier="advanced" | Animation controls auto-shown
Usage Instructions
- Open Control Panel - Click the gear icon in the top-right corner
- Find Animations Section - Scroll down to see the "Animations" section (only appears if animations exist)
- Select Animation - Click any animation name button to start playback
- Adjust Speed - Use the slider to speed up (2.0x) or slow down (0.25x) playback
- Change Loop Mode - Choose Once (play once), Loop (repeat forever), or Ping-Pong (reverse at end)
- Pause/Resume - Use the Pause button to stop temporarily, Resume to continue
- Stop Animation - Click Stop to reset the animation to the beginning
How to Add Animations
1. Export from Blender
When exporting GLB from Blender, ensure:
- ✓ Format:
GLB Binary - ✓ Include:
Animationschecked - ✓ Animation:
Export All Actionsor select specific animations - ✓ Bake Animation: Checked (if using constraints/drivers)
2. Place in Public Directory
Copy your GLB file to public/models/
3. Use in ModelViewer
<ModelViewer
client:load
modelPath="/models/your-model.glb"
preset="studio"
controlTier="advanced"
/> Animation controls will appear automatically if the GLB contains animations!
Technical Details
- Hook:
useAnimationsfrom @react-three/drei - State Management: AnimationState interface with names[], current, isPlaying, speed, loop
- Control Methods:
playAnimation(name)- Start playing a specific animationstopAnimation()- Stop and reset to beginningpauseAnimation()- Pause without resettingresumeAnimation()- Resume from paused statesetAnimationSpeed(speed)- Change playback speedsetAnimationLoop(loop)- Change loop modegetAnimationState()- Get current animation state
- Loop Modes:
once- Play once and stop (LoopOnce)repeat- Loop forever (LoopRepeat)pingpong- Reverse at end, back and forth (LoopPingPong)
- Speed Range: 0.25x (slow motion) to 2.0x (double speed)
✅ Expected Behavior
- ✅ Animation section only appears if model has animations
- ✅ Active animation button highlighted in gold (light) or blue (dark)
- ✅ Speed slider updates in real-time during playback
- ✅ Loop mode changes apply to current animation
- ✅ Pause/Resume preserves playback position
- ✅ Stop resets animation to frame 0
- ✅ Animation names match those exported from Blender
⚠️ Troubleshooting
No animations showing?
- Check that your GLB was exported with animations enabled in Blender
- Open the GLB in a 3D viewer (e.g., Windows 3D Viewer) to verify animations exist
- Ensure animation names are not empty in Blender
- Try re-exporting with "Export All Actions" checked
Animation not playing smoothly?
- Try reducing animation speed if it appears choppy
- Check browser console for Three.js warnings
- Ensure your model isn't too high-poly (affects framerate)
Implementation Files
src/components/react/3d/scene/ModelScene.tsx- Animation state and control methodssrc/components/react/3d/controls/AnimationControls.tsx- UI componentsrc/components/react/3d/scene/ModelViewer.tsx- Integration and callbacks