A minimal WebGL 2 and WebGPU graphics library providing a lightweight alternative to three.js.
Four is a minimal 3D graphics library for JavaScript and TypeScript that serves as a lightweight alternative to three.js. It provides a streamlined API for creating and rendering 3D scenes using either WebGL 2 or WebGPU, focusing on performance and modern GPU features like instancing and compute shaders. The library handles core graphics tasks such as scene management, geometry, materials, and cameras while keeping the codebase small and efficient.
Web developers and graphics programmers building 3D applications, visualizations, or experiments who want a minimal, performant alternative to larger frameworks like three.js. It's ideal for those who need fine-grained control over WebGL 2 or WebGPU pipelines.
Developers choose Four for its minimal footprint, dual WebGL/WebGPU support, and modern API design that reduces boilerplate. Its focus on instancing and compute shaders out-of-the-box makes it particularly suited for performance-critical and GPU-driven applications compared to more heavyweight alternatives.
💎 Minimal three.js alternative.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports both WebGLRenderer and WebGPURenderer with a shared API, allowing flexible pipeline selection based on performance or compatibility needs, as shown in the separate WebGL and WebGPU examples.
Defaults to instanced rendering and includes compute shader support, optimizing for modern GPU workflows and high-performance applications like simulations, evident in the instancing and compute sections.
Acts as a lightweight alternative to three.js with a streamlined API, reducing overhead and keeping the codebase small, which is highlighted in its philosophy and gzip size badge.
Integrates GLSL for WebGL and WGSL for WebGPU, enabling custom visual behavior and compute operations with up-to-date shader languages, as detailed in the Material examples.
Lacks out-of-the-box utilities for common tasks like model loading, advanced lighting, or physics, requiring more manual implementation compared to larger libraries with richer ecosystems.
The README explicitly notes issues with Vite due to WebGPU's reliance on top-level await, necessitating additional plugins like vite-plugin-top-level-await, which adds setup complexity.
Requires proficiency in shader programming (GLSL/WGSL) and low-level graphics concepts, as users must write custom vertex and fragment shaders even for basic scenes, with minimal abstraction.
Four is an open-source alternative to the following products: