RendererFactory API Reference
TheRendererFactory provides a centralized API for creating and managing Three.js WebGPU renderers in Hyperscape.
Location: packages/shared/src/utils/rendering/RendererFactory.ts
Overview
As of commit47782ed (2026-02-27), Hyperscape only supports WebGPU. All WebGL fallback code has been removed.
Breaking Changes
UniversalRenderertype removed (alwaysWebGPURenderer)RendererBackendtype now only accepts"webgpu"- All WebGL detection methods removed
- WebGL fallback flags ignored
API
createRenderer
Creates a WebGPU renderer instance.canvas- HTMLCanvasElement to render tooptions- Optional renderer configurationantialias- Enable antialiasing (default:true)alpha- Enable alpha channel (default:false)powerPreference- GPU power preference (default:'high-performance')
WebGPURenderer instance
Throws: Error if WebGPU is not available
Example:
getBackend
Returns the current renderer backend (always"webgpu").
"webgpu" (string literal)
Example:
Error Handling
WebGPU Not Available
If WebGPU is not available,createRenderer throws an error:
Recommended Error Handling
Migration from WebGL
Before (WebGL Fallback)
After (WebGPU Only)
Type Definitions
Related Documentation
- docs/migration/webgpu-only.md - WebGPU migration guide
- CLAUDE.md - WebGPU requirements and troubleshooting
- AGENTS.md - AI assistant WebGPU guidelines
Browser Compatibility
| Browser | Minimum Version | WebGPU Support | Notes |
|---|---|---|---|
| Chrome | 113+ | ✅ Full | Recommended |
| Edge | 113+ | ✅ Full | Chromium-based |
| Safari | 18+ | ✅ Full | Requires macOS 15+ |
| Firefox | Nightly | ⚠️ Partial | Behind flag, not recommended |
| Opera | 99+ | ✅ Full | Chromium-based |
| Brave | 1.52+ | ✅ Full | Chromium-based |
Performance Considerations
GPU Selection
WebGPU automatically selects the best available GPU:Memory Management
WebGPU uses GPU memory more efficiently than WebGL:- Shared buffers: Geometry and textures shared across instances
- Automatic cleanup: GPU resources freed when renderer is destroyed
- Memory limits: Respects GPU memory limits (no overallocation)
Render Pipeline
WebGPU uses a modern render pipeline:- Compute shaders: For particle systems, grass, terrain
- Storage buffers: For large datasets (vegetation, NPCs)
- Indirect rendering: For instanced meshes (trees, rocks)