From Websites to Games: The Future of React Three Fiber

Rate this content
Bookmark

Web developers learn a lot of programming techniques in the pursuit of their career but often don't realize the depth of their own skill. React Three Fiber became a sensation among thousands of developers because it demonstrated that the knowledge they possess can be harnessed to create interactive 3D graphics. However, React Three Fiber has been stuck in the mindset of websites while the future of web increasingly moves toward immersive 3D experiences.

In this presentation, we will explore the new generation of React Three Fiber and the changes being made to evolve it into a framework capable of supporting complex real time apps, such as live simulations and video games. Our goal is to give web developers a new moment of recognition where they look at a video game programmed with React and think, "I can do this"

This talk has been presented at React Summit 2024, check out the latest edition of this React Conference.

FAQ

React 3 Fiber (R3F) is a library for React that allows developers to render 3D graphics declaratively, similar to a browser API. It serves as a React renderer for the open-source 3D engine Three.js.

Notable adopters of React 3 Fiber include companies like Vercel, Zillow, and Ready Player Me.

The three design principles of React 3 Fiber are to keep the API simple, pragmatic, and stable.

Poimandris is an open-source collective started by Paul Henschel in 2017. It focuses on knowledge sharing and enabling creativity for developers. It maintains libraries like React 3 Fiber, React Spring, and others.

The main challenge in using React for immersive 3D apps is that React is render-oriented, while 3D worlds and simulations are data-oriented. This means React's top-to-bottom state flow isn't well-suited for the real-time updates required by 3D simulations.

The frame loop in React 3 Fiber is a mechanism that allows real-time apps to update every frame without causing React to re-render every frame. It runs independently from React's own loop and allows for v-synced code execution.

The new scheduler library 'directed' is designed to schedule update functions based on their dependencies, ensuring they execute in the correct order. It uses a directed acyclic graph (DAG) to achieve this and works with both Vanilla and React.

ECS (Entity Component System) is a design pattern for data-oriented programming. In React 3 Fiber, ECS enables composable global stores of data where entities are IDs that let developers query collections of components, and systems are functions that update these components.

Sweet ECS is an experimental library that provides declarative ECS with deep integration with React. It allows every entity committed to the view in React to be automatically added to the ECS, facilitating data-driven design.

The future roadmap for React 3 Fiber includes integrating the new scheduler in version 10 (V10) and enabling data-oriented workflows. V9 will focus on compatibility with React 19, followed by a beta release for V10 to roll out new features.

Kris Baumgartner
Kris Baumgartner
25 min
17 Jun, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk explores the future of React 3 Fiber and its potential for building immersive 3D worlds and video games on the web. The challenges of building immersive 3D apps and the solutions provided by React 3 Fiber are discussed, including decoupling simulation state updates and enhancing scheduling with stable references. The concept of data-oriented programming and the use of ECS (Entity-Component-System) design pattern for composable data in React 3 Fiber are explored. The Talk concludes by emphasizing the future focus on enabling data-oriented workflows and the integration of a built-in scheduler in future versions of React 3 Fiber.

1. Introduction to React 3 Fiber and its Future

Short description:

Hi, my name is Chris Baumgartner. This talk is about the future of React 3 Fiber and how we intend to tackle video games on the web. React 3 Fiber is a library for React that lets you render 3D declaratively. It is used everywhere from enterprise to hobbyists and even some games. We follow three design principles: keeping the API simple, pragmatic, and stable. I am a web 3D developer at Chauncey Technologies and a member of Poimandris, where I maintain React 3 Fiber. Come join us on our Discord if you'd like to learn more.

Hi, my name is Chris Baumgartner, and this is a talk about the future of React 3 Fiber and how we intend to tackle video games on the web. If you don't know React 3 Fiber, it is a library for React that lets you render declared the 3D declaratively as if it were a browser API. Under the hood, it is a React render for 3JS, which is itself an open source 3D render. R3F is used everywhere from enterprise to hobbyists and, yes, even some games.

Some adopters are Vercel, Zillow, Ready Player Me, to name a few. We have an estimated install base of 300,000 and make up a large portion of 3's own installs at this point. We follow three design principles. Keep the API simple, pragmatic, and stable. But enough of that, back to me. Professionally, I am a web 3D developer at Chauncey Technologies. Also professionally, but much less lucratively, I am a member of Poimandris, where I maintain React 3 Fiber alongside Cody Bennett and Paul Henschel. It is also Poimandris where I'm cooking up some new technologies we'll be talking about today. And if you catch me on Discord, you probably recognize me from my avatar on the left.

Poimandris is an open source collective started by Paul Henschel back in 2017. If you work with React, you probably have heard of our libraries, whether it's Zoos Donned, React Spring, or even React 3 Fiber itself. We are an entirely horizontal collective, dedicated knowledge share and enabling creativity for developers. If you'd like to sound of that, come join us on our Discord. We have a pretty big community over there.

So you might be like me. I began as a web developer. Not even a very good one. More like a web designer who's proud of writing his own CSS. I never thought I would be good enough at programming to make a game. But I love games, so I would dream about it. My skills at programming steadily grew, and I was beginning to learn React when I came across React 3 Fiber. There were these beautiful demos, like the one screenshotted there. I think that was actually the first one I saw. And it just appeared so simple. And for the first time looking at something interactive in 3D, I thought, I can do this. And I realized later this was a moment of self recognition.

2. Building Games with React

Short description:

React 3 Fiber has inspired many web devs. We want to take it further and make immersive 3D worlds, even video games. React is an abstraction over the DOM and is functional, composable, and declarative. It allows progressive enhancement and embraces a web-like feel. Let's see where we're at with React 3.5 today.

And those dreams suddenly felt a lot more real, and I suddenly got a new hobby. But as I soon learned, a demo is not a game. Even a 3D enterprise app is not a game. React 3 Fiber has inspired many web devs, but how can we take it further? How can we get to the moment of I can do this to make immersive 3D worlds? Even video games.

So the journey begins. And two years ago I started down this path, and today I'm going to share with you where it's led me. Ripple sponsored a lot of the research, so shout out to them, my company, Chauncey, and all of the community has helped along the way. So this starts with React. This is about building games with React. So let's start there. React is an abstraction over the DOM. Oops. I almost forgot what talk I was giving. React is an abstraction over document like renders. This is important because a 3D scene graph just happens to look a lot like a document. React is also functional, composable, and declarative. And all the traits that we know and love that make it scalable and testable.

React is also a framework. It makes you buy into its declarative approach and life cycle, but otherwise lets you bring your own tech stack. This is important because it allows progressive enhancement. And for the React ecosystem to move forward, you know, we need to be able to adopt whatever new technologies are coming out in the JS world in general. By contrast, game engines are almost always monolithic and require you to bring the whole kitchen sink with you everywhere, even if you refuse to use it. So React game engine, in my opinion, needs to embody all of these ideas. Needs to render like a document. It needs to be functional, be composable, be declarative, embrace progressive enhancement, and feel webified. And the last one is really important, but also impossible to define if you know it, if you see it as a web developer, you know if something feels webby. Let's see where we're at with React 3.5 today. And hey, looks like we did it. But it can't be that simple, right? But it does do all these things. It renders like a document.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Optimizing HTML5 Games: 10 Years of Learnings
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Optimizing HTML5 Games: 10 Years of Learnings
Top Content
PlayCanvas is an open-source game engine used by game developers worldwide. Optimization is crucial for HTML5 games, focusing on load times and frame rate. Texture and mesh optimization can significantly reduce download sizes. GLTF and GLB formats offer smaller file sizes and faster parsing times. Compressing game resources and using efficient file formats can improve load times. Framerate optimization and resolution scaling are important for better performance. Managing draw calls and using batching techniques can optimize performance. Browser DevTools, such as Chrome and Firefox, are useful for debugging and profiling. Detecting device performance and optimizing based on specific devices can improve game performance. Apple is making progress with WebGPU implementation. HTML5 games can be shipped to the App Store using Cordova.
Building Fun Experiments with WebXR & Babylon.js
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Building Fun Experiments with WebXR & Babylon.js
Top Content
This Talk explores the use of Babylon.js and WebXR to create immersive VR and AR experiences on the web. It showcases various demos, including transforming a 2D game into a 3D and VR experience, VR music composition, AR demos, and exploring a virtual museum. The speaker emphasizes the potential of web development in the metaverse and mentions the use of WebXR in Microsoft products. The limitations of WebXR on Safari iOS are discussed, along with the simplicity and features of Babylon.js. Contact information is provided for further inquiries.
Making Awesome Games with LittleJS
JS GameDev Summit 2022JS GameDev Summit 2022
34 min
Making Awesome Games with LittleJS
Top Content
Little.js is a super lightweight and fast JavaScript game engine that has everything included to start making games right away. It has a tiny footprint and no dependencies, making it perfect for size-coding competitions like JS13K. Little.js is built with an object-oriented structure and comes with several classes. It provides a fast rendering system, a comprehensive audio system, and various starter projects for different game types. Little.js is designed to be simple and easy to understand, allowing you to look at and modify the code.
How Not to Build a Video Game
React Summit 2023React Summit 2023
32 min
How Not to Build a Video Game
Watch video: How Not to Build a Video Game
The Talk showcases the development of a video game called Athena Crisis using web technologies like JavaScript, React, and CSS. The game is built from scratch and includes features like multiple game states, AI opponents, and map editing. It demonstrates the benefits of using CSS for game development, such as instant load times and smooth transitions. The Talk also discusses optimizing performance, supporting dark mode, and publishing the game to other platforms.
Boost the Performance of Your WebGL Unity Games!
JS GameDev Summit 2023JS GameDev Summit 2023
7 min
Boost the Performance of Your WebGL Unity Games!
The Talk discusses ways to boost the performance of WebGL Unity games, including issues with bundle size, memory usage, and runtime performance. It suggests using Brotli for compression and non-exception support for better performance. Choosing the appropriate texture compression format and experimenting with separate builds can also help. The Talk also covers optimizing textures, models, audio, and assets by reducing build size, using compression, disabling unnecessary models, and optimizing audio quality. Unity's optimization tools and profilers are recommended for analyzing performance and memory issues.
Embracing WebGPU and WebXR With Three.js
JSNation 2024JSNation 2024
27 min
Embracing WebGPU and WebXR With Three.js
The 3JS project has evolved into a community-driven effort with numerous contributors over the past 14 years. It started with 3D engine work in Flash and transitioned to using SVGs for rendering in HTML5 before adopting WebGL. The project showcases various projects and frameworks, including a no-code tool powered by 3.js. The team is working on a new render using WebGPU and developing a new shader language called TSL. The hope is that WebGPU will eventually replace WebGL, offering better control and performance.

Workshops on related topic

Make a Game With PlayCanvas in 2 Hours
JSNation 2023JSNation 2023
116 min
Make a Game With PlayCanvas in 2 Hours
Top Content
Featured WorkshopFree
Steven Yau
Steven Yau
In this workshop, we’ll build a game using the PlayCanvas WebGL engine from start to finish. From development to publishing, we’ll cover the most crucial features such as scripting, UI creation and much more.
Table of the content:- Introduction- Intro to PlayCanvas- What we will be building- Adding a character model and animation- Making the character move with scripts- 'Fake' running- Adding obstacles- Detecting collisions- Adding a score counter- Game over and restarting- Wrap up!- Questions
Workshop levelFamiliarity with game engines and game development aspects is recommended, but not required.
PlayCanvas End-to-End : the quick version
JS GameDev Summit 2022JS GameDev Summit 2022
121 min
PlayCanvas End-to-End : the quick version
Top Content
WorkshopFree
João Ruschel
João Ruschel
In this workshop, we’ll build a complete game using the PlayCanvas engine while learning the best practices for project management. From development to publishing, we’ll cover the most crucial features such as asset management, scripting, audio, debugging, and much more.
Introduction to WebXR with Babylon.js
JS GameDev Summit 2022JS GameDev Summit 2022
86 min
Introduction to WebXR with Babylon.js
Workshop
Gustavo Cordido
Gustavo Cordido
In this workshop, we'll introduce you to the core concepts of building Mixed Reality experiences with WebXR and Balon.js.
You'll learn the following:- How to add 3D mesh objects and buttons to a scene- How to use procedural textures- How to add actions to objects- How to take advantage of the default Cross Reality (XR) experience- How to add physics to a scene
For the first project in this workshop, you'll create an interactive Mixed Reality experience that'll display basketball player stats to fans and coaches. For the second project in this workshop, you'll create a voice activated WebXR app using Balon.js and Azure Speech-to-Text. You'll then deploy the web app using Static Website Hosting provided Azure Blob Storage.
Tiny Game Live Coding Workshop
JS GameDev Summit 2023JS GameDev Summit 2023
115 min
Tiny Game Live Coding Workshop
Workshop
Frank Force
Frank Force
Dive into the captivating world of micro-game development with Frank Force in this interactive live coding workshop. Tailored for both seasoned developers and curious newcomers, this session explores the unique challenges and joys of creating games and demos with extreme size constraints.