Three.js: When 3D Magic Happens 

on the Web Screen

INTRODUCTION


Three.js, where 3D objects dance across your screen with the same bewitching magic as a David Copperfield performance. Known as the "holy grail" of web developers who want to explore the third dimension, Three.js is a powerful JavaScript library that transforms dry lines of code into living landscapes.

Examples from ThreeJS.org

What is Three.js?

Three.js is a free and open-source JavaScript library. It allows you to create and render 3D graphics in a web browser without the need for heavy plugins or installations. With just a few lines of code, you can bring a 3D world to life on the web. 

Why add Three.js to your website?

First, imagine a website without Three.js as a Monday morning Zoom meeting - necessary but quite boring. Now, add Three.js and suddenly the meeting becomes more engaging with stunning 3D effects. Three.js brings a new dimension to the web, transforming it from a flat canvas into a 3-dimensional work of art.


One of the main reasons to choose Three.js is its ability to create a powerful impact on the user experience. You can create realistic 3D effects, from interactive product models to virtual landscapes. This not only enhances the interactivity of your website but also helps your brand stand out from the crowd.

THE DEMO


What we’ve have done?


Check out our incredible 3D webpage at: https://udl-3d-landing-page.vercel.app/


We've created an amazing 3D webpage that lets you explore a realistic virtual room built with incredible details. As you scroll your mouse or click the navigating buttons, the camera shows you around, revealing all the exciting features and possibilities.

The embed demo we've done

Technical breakdown:


React-three-fiber: Seamless Integration of ThreeJS in React


For the front-end of this demo, we opted for ReactJS, the widely popular web framework, for its powerful capabilities and ease of use. To seamlessly integrate ThreeJS with our React application, we harnessed the magic of react-three-fiber (R3F). This library allows us to write ThreeJS code directly within JSX, a tag-based language resembling HTML, offering a familiar and organized structure.


R3F eliminated the burden of managing numerous default settings and leverages the power of React's built-in tools, making the development process smoother and more efficient.

JSX- Tag-based language

Drei: Supercharge Your React Three Fiber Workflow with Helpful Helpers


React Three Fiber is an amazing library for building 3D experiences in the browser. But sometimes, you get bogged down in repetitive tasks and boilerplate code. That's where Drei comes in.


Drei is a collection of pre-built components and functions designed to simplify and accelerate your React Three Fiber development. Think of it as a toolbox full of handy helpers that let you focus on the creative aspects of your 3D projects. Pre-built components like: Camera controls, lighting, animation, essentials pre-built, ready to boost your 3D magic. ✨ 

Pre-built mask provided by Drei.

Blender: Create realistic lighting

While ThreeJS provides a range of light types for scene illumination, we desired a level of visual fidelity exceeding its capabilities. To achieve this, we opted for pre-baking all the lighting in Blender, renowned 3D rendering software. This approach allowed us to surpass the limitations of ThreeJS lighting and attain the high-quality visuals we sought.

In Blender, we baked all lighting into a 4K texture and do some advanced compression techniques. This allows the entire website, including all 3D models and textures, to weigh in at a mere 12.3 MB.

The whole room is baked into 4k texture

Our Achievement:


The web FPS is constantly at 60

The web only comsumpt ~50mb in RAM.

WHAT’S NEXT


The ability to integrate 3D experiences directly into websites has opened up a new frontier for online engagement, but this is just the beginning. Here's a glimpse into what the future holds for 3D on the web:

Online 3D Applications: Directly integrate 3D applications into websites, eliminating the need for complicated downloads and installations. This simplifies user interaction and broadens accessibility.

Enhanced Product Design: Businesses can showcase products from multiple angles and offer customization options within a web view, revolutionizing the online shopping experience. Interior sellers can provide immersive 3D tours of properties, allowing potential buyers to explore spaces interactively without leaving their homes.

Gaming, No Downloads Needed: Games can now be played directly on the web, offering a seamless and instant gaming experience without extensive downloads.

Art and Culture in 3D: Museums, exhibitions, and showcases can use 3D dimensions to provide captivating virtual experiences, allowing audiences worldwide to explore art and culture interactively.

VR/AR Adventures: ThreeJS technology enables the development of immersive virtual reality (VR) and augmented reality (AR) adventures, providing users with unparalleled levels of presence.

This list is just the beginning. The potential of 3D on the web is truly limitless. With its ability to enhance marketing, education, entertainment, and even commerce, 3D promises to revolutionize the way we interact with the web.

Reference

https://threejs.org/

https://github.com/pmndrs/react-three-fiber

https://github.com/pmndrs/drei

We are a software development company based in Vietnam.

We offer DevOps development remotely to support the growth of your business.

If there is anything we can help with, please feel free to consult us.