Skip to main content

What is Three.js


Have you ever navigated to a website and thought, wow, this 3D graphics animation looks great! If you find yourself asking how that was done, more often than not it is some library, and Three.js is one of the popular ones that allow for complicated 3D visuals to be rendered in a browser, and today you’ll learn all about it.

What is Three.js

Three.js is a JavaScript-based WebGL engine that can run GPU-powered games and other graphics-powered apps straight from the browser. The three.js library provides many features and APIs for drawing 3D scenes in your browser. The aim of the project is to create an easy-to-use, lightweight, cross-browser, general-purpose 3D library.

Although it is initially released in 2010, Ricardo Cabello, the original author and designer, had actually begun working on the library as far back as the early 2000s, first being developed on ActionScript, and later being ported to JavaScript as Cabello realized the potential benefits of transferring to a language that did not need to be compiled before each execution and offered platform independence.

How does the library work?

Most of the Three.js projects rely heavily on WebGL. WebGL expands on a lot of traditionally non-3D APIs, like the ‘canvas’ and ‘svg’ tags that you can use to tell the browser to draw certain shapes.

Benefits of leveraging Three.js

Three.js is an open-source library that you can easily incorporate into your own project. It has very detailed official documentation regarding installation, drawing lines, cubes and spheres, how to move the camera perspective and the objects, and much more. This makes it easy to learn. Three.js also comes with a large variety of examples that you can play with to learn.

A big part of rendering 3D graphics is the math involved. Normally, you may need separate libraries to handle the complex calculations. But Three.js includes all of this in its library, and since it is all under the same library, you never have to worry about compatibility issues between different libraries and you won’t have to spend time trying to figure out how to get two libraries working together the way you want it to.

Since it’s been around for more than a decade and is widely adapted, it has a large community of users and if you run into any problems or questions, there are often resources and answers available that you can search for because more likely than not, someone else has encountered this issue before.

Although three.js recommends the 3D models imported be in glTF format, it also supports other popular formats such as FBX, Collada and OBJ. This gives the users a lot of flexibility when it comes to utilizing 3D models created elsewhere.

In terms of performance, Three.js has a very impressive score. Obviously, it also depends on how complicated your animations are, how many objects are present and how much calculation it needs to do before and while the animations are doing their thing, and don’t forget about the models that you imported, that could make a big difference as well. However, three.js fundamentally is good on performance. There are always ways to improve the performance of your 3D animation as well if it’s not as fast as you expect it to be.

If you have a project that you want to incorporate 3D graphics and animations, send us a message and we will be happy to discuss how we can help you.

Three.js Frontend Design