Skip to content
BENIBIX Learn

three.js

Design🧊 3D & Immersive3D Tools

Also known as Three.js, ThreeJS, three

A free JavaScript library for 3D on the web. It makes WebGL much easier to use.

Think of it like

It is like toy blocks for 3D on the web. You snap a scene, a camera and a light together.

Example

Noah adds a spinning 3D logo to his landing page with about 20 lines of three.js.

Why it matters

Designers and web coders can add real 3D to pages. They do not need to learn hard graphics code.

Definition

three.js is a free, open source JavaScript library that makes 3D on the web much easier. It sits on top of WebGL and hides most of its hard parts. You build a scene, add a camera, lights and models, and it draws them in the page. It can load models exported from 3D apps and supports VR and AR in the browser. Ricardo Cabello first released it in 2010, and it is now one of the most used 3D libraries on the web.

Example code

javascript
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 100);
const cube = new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshNormalMaterial());
scene.add(cube);
camera.position.z = 3;
const renderer = new THREE.WebGLRenderer();
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);
renderer.render(scene, camera);
A scene, a camera and a cube, drawn once into the page through WebGL.
three.js is the library step: it loads the model and sends it to WebGL.

Common mistake

Loading huge models straight from a 3D app. Shrink and compress them first, or the page loads slowly.

Key takeaways

  1. 1
    On top of WebGL. Hides the hard parts.
  2. 2
    Scene, camera, light. The building blocks.
  3. 3
    Keep models light. For fast pages.