Basic setup
Three.js requires manual rendering driven by Helios instead of usingrequestAnimationFrame.
React Three Fiber integration
For React applications, use@react-three/fiber with Helios controlling the frame loop.
Scene component
Critical patterns
Disable automatic rendering
Three.js and React Three Fiber both have built-in render loops. You must disable them:- Vanilla Three.js: Don’t call
requestAnimationFrameorrenderer.setAnimationLoop() - React Three Fiber: Set
frameloop="never"on the<Canvas>component
Use Helios time, not system time
Always calculate animations fromstate.currentFrame / fps instead of Date.now() or performance.now():
Handle resize properly
Update camera aspect ratio and renderer size on window resize:Performance considerations
WebGL context limits
Browsers limit the number of WebGL contexts. Destroy renderers when unmounting:Scene complexity
Three.js performance depends on:- Polygon count: Keep meshes under 100k triangles for smooth rendering
- Draw calls: Merge geometries to reduce draw calls
- Texture size: Use power-of-2 textures (512x512, 1024x1024) for GPU efficiency
- Lighting: Limit real-time shadows and use baked lighting where possible
Rendering resolution
Match the renderer size to your target export resolution:Frame rate vs quality
Lower FPS reduces total render time but may affect motion smoothness:- 30 fps: Standard for most content, good balance
- 60 fps: Smooth motion, doubles render time
- 24 fps: Cinematic feel, fastest render