๐ Web Game Engines & Libraries
The technology that enables 2D and 3D graphics for the web is WebGL (opens in a new tab) (WebGL2 (opens in a new tab) for engines that support it).
WebGPU (opens in a new tab) is an upcoming more performant technology but is currently behind feature flags (opens in a new tab) (it may come in Chrome desktop (opens in a new tab) around May 2023!). Writing raw WebGL code would be very tedious, so there are libraries that abstract the complexity and do the heavy-lifting to provide more user-friendly APIs.
Engines and libraries
Much like any ecosystem of developer tools, there are 2 approaches: the monolithic batteries-included framework approach (those would be the engines), or the modular assemble-independent-libraries-together approach. The main engines and libraries for JavaScript game development are:
-
Three.js89k1M/w โ 3D library, WebGPU-ready
3D library, WebGPU-ready -
PixiJS39k93k/w โ 2D library (there is also Pixi3D (opens in a new tab))
2D library (there is also Pixi3D (opens in a new tab)) -
Phaser34k14k/w โ 2D engine
2D engine -
Babylon.js19k22k/w โ 3D engine, WebGPU-ready
3D engine, WebGPU-ready -
PlayCanvas8k โ 3D engine, freemium editor, WebGPU-ready
3D engine, freemium editor, WebGPU-ready -
OGL3k12k/w โ Minimal 3D library
Minimal 3D library -
Kaboom2k9k/w โ Simple 2D engine
Simple 2D engine -
Two.js8k3k/w โ 2D library
2D library
Show more
Compare on NPMTrends and Star History (requires a GH token)
About these numbers and colors
There is also Rogue Engine (opens in a new tab), an editor in alpha for Three.js games,
Ethereal Engine (opens in a new tab), a full-stack solution for metaverse experiences, and many more engines and libraries (opens in a new tab).
UI libraries wrappers
You can use any of the previous libraries and engines on their own, but some of them can also be combined with UI libraries wrappers for React, Svelte, Vue, or Angular. This might seem surprising at first, but using these makes your code more declarative and conveniently abstracts some boilerplate. The main wrapper libraries are:
Three.js
-
React Three Fiber21k127k/w
-
Threlte60020k/w
-
Svelte Cubed1k800/w2y years
-
TresJS
-
Trois3k1k/w1y year
-
Lunchbox200
-
Angular Three300140/w
Babylon.js
PixiJS
Phaser
Show more
OGL
For instance, React Three Fiber (R3F), lets you add objects to a scene and control them as React components:
Going native with JavaScript
Now hold on to your hats, because this is where things get wild. You can also use JavaScript (well, mostly React) to create native OpenGL ES games. Expo (opens in a new tab) is a framework for React Native (opens in a new tab) (it is basically the Next.js of React Native), and they created Expo GL (opens in a new tab) and expo-three (opens in a new tab) to provide a Three.js interface for native OpenGL ES. And it can be used declaratively with React Three Fiber (opens in a new tab). I have not tried it yet but that completely blows my mind ๐คฏ.
Babylon.js is working on a similar preview feature with Babylon Native (opens in a new tab) and Babylon React Native (opens in a new tab).