Three.js 3D graphics — scenes, cameras, meshes, and lighting
- Three.js abstracts WebGL into scene, camera, renderer — you work with 3D objects, not raw GPU commands.
- Enable shadowMap on the renderer and set castShadow/receiveShadow on objects for realistic shadow rendering.
- PBR materials (MeshStandardMaterial) with metalness and roughness create physically realistic surfaces with minimal effort.
Understanding 3d graphics guide is the foundation of this guide. Below we break it down step by step so you can act with confidence.
Three.js is the most popular JavaScript library for 3D graphics. It abstracts WebGL into a scene-graph API — you work with scenes, cameras, meshes, and lights instead of raw shader code.
This lesson teaches you Three.js from the ground up: setting up a scene, creating geometry, applying materials, adding lights, casting shadows, and animating objects.
3d Graphics Guide: Setting up a Three.js scene
Every Three.js application needs three things: a scene (the world), a camera (the viewpoint), and a renderer (draws to canvas):
import * as THREE from 'three';
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a0a23);
const camera = new THREE.PerspectiveCamera(
75, // field of view
window.innerWidth / window.innerHeight, // aspect
0.1, // near plane
1000 // far plane
);
camera.position.set(0, 5, 10);
camera.lookAt(0, 0, 0);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
document.body.appendChild(renderer.domElement);
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();Geometry, materials, and meshes
A mesh is geometry (shape) + material (appearance). Three.js provides built-in geometries and PBR materials:
// Ground plane
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(20, 20),
new THREE.MeshStandardMaterial({ color: 0x1a1a2e })
);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
// Player cube
const player = new THREE.Mesh(
new THREE.BoxGeometry(1, 1, 1),
new THREE.MeshStandardMaterial({
color: 0xe94560,
metalness: 0.3,
roughness: 0.4
})
);
player.position.y = 0.5;
player.castShadow = true;
scene.add(player);
// Sphere obstacle
const sphere = new THREE.Mesh(
new THREE.SphereGeometry(0.5, 32, 32),
new THREE.MeshStandardMaterial({ color: 0x533483 })
);
sphere.position.set(3, 0.5, -2);
sphere.castShadow = true;
scene.add(sphere);Lighting and shadows
Lighting defines the mood of your scene. Combine ambient light (base brightness) with directional or point lights for depth:
// Soft ambient
const ambient = new THREE.AmbientLight(0x404060, 0.5);
scene.add(ambient);
// Key light (directional, like the sun)
const sun = new THREE.DirectionalLight(0xffffff, 1.2);
sun.position.set(5, 10, 5);
sun.castShadow = true;
sun.shadow.mapSize.width = 2048;
sun.shadow.mapSize.height = 2048;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 50;
scene.add(sun);
// Fill light (subtle color from opposite side)
const fill = new THREE.PointLight(0x4488ff, 0.4);
fill.position.set(-5, 3, -5);
scene.add(fill);Explore Crypto Trading
Cryptocurrency trading is one of the fastest-growing financial markets — open 24/7, globally accessible, and full of opportunity for those who learn the fundamentals first.
- Trade spot, futures & copy-trading on one platform
- Start with as little as $10 — practice risk-free on the testnet
- Built-in TradingView charts, grid bots & DCA tools
Animation and OrbitControls
Animate objects in the render loop. OrbitControls lets the user rotate the camera with mouse:
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const t = clock.getElapsedTime();
// Rotate player
player.rotation.y = t * 0.5;
// Bob sphere up and down
sphere.position.y = 0.5 + Math.sin(t * 2) * 0.3;
controls.update();
renderer.render(scene, camera);
}
animate();When evaluating 3d graphics guide, start with the fundamentals: what problem it solves, who it serves, and how it compares to the alternatives buyers consider first.
Start with the fundamentals. Define who you are serving, the single outcome you want, and the budget you are comfortable committing before you compare any options.
A practical rule is to favour clarity over cleverness. The choice that is easiest to understand, spell, remember and act on tends to win over the long run.
Context changes the answer. What is optimal for a fast-moving startup is rarely optimal for an established brand, so weigh your own stage, market and ambitions.
Avoid the common mistakes: rushing the decision, copying competitors blindly, and ignoring the total cost of ownership beyond the very first year of use.
Think in terms of trade-offs rather than a single perfect answer. Every option trades memorability, cost, reach and flexibility in a slightly different mix.
Document your reasoning. Writing down why you chose one path makes it far easier to revisit the decision later and to explain it to partners and investors.
Test with real people. A quick check with a handful of your actual customers will surface problems that no amount of internal debate ever reveals.
Plan for growth. The option that fits today should still make sense when your audience, catalogue or team is several times larger than it is right now.
Finally, revisit the decision periodically. Markets, tools and best practices move quickly, and a choice that was ideal last year may deserve a fresh look today.
When evaluating 3d graphics guide, start with the fundamentals: what problem it solves, who it serves, and how it compares to the alternatives buyers consider first.
Start with the fundamentals. Define who you are serving, the single outcome you want, and the budget you are comfortable committing before you compare any options.
A practical rule is to favour clarity over cleverness. The choice that is easiest to understand, spell, remember and act on tends to win over the long run.
Context changes the answer. What is optimal for a fast-moving startup is rarely optimal for an established brand, so weigh your own stage, market and ambitions.
Avoid the common mistakes: rushing the decision, copying competitors blindly, and ignoring the total cost of ownership beyond the very first year of use.
Think in terms of trade-offs rather than a single perfect answer. Every option trades memorability, cost, reach and flexibility in a slightly different mix.
Document your reasoning. Writing down why you chose one path makes it far easier to revisit the decision later and to explain it to partners and investors.
Test with real people. A quick check with a handful of your actual customers will surface problems that no amount of internal debate ever reveals.
Plan for growth. The option that fits today should still make sense when your audience, catalogue or team is several times larger than it is right now.
WSOT 2026: Squad Leader Slots Are Open — Up to $128,000 per Leader
Join NowFrequently asked questions
Is Three.js good for games?
Three.js is excellent for 3D browser games. Games like HexGL, Townscaper web demo, and many game-jam entries use it. For large-scale games you may want Babylon.js which has more built-in game features, but Three.js has a larger ecosystem and community.
How do I load 3D models in Three.js?
Use GLTFLoader to load .glb/.gltf files (the standard format). Export from Blender or download from Sketchfab. Three.js also supports FBX, OBJ, and other formats through loaders.
Free Courses — Learn New Skills
No sign-up · No fees · Learn at your own pace
Start Trading
Trade crypto and premium domains — digital assets with real opportunities.
📝 Need a custom article?
Our editorial team writes it for you — carefully crafted, SEO-optimized, about your topic, your domain name or your service. Multiple languages available. From $15 per language.
Find your name on Atom
DominantBrand curates the best premium, brandable names from Atom.com — the marketplace with a free AI appraisal, a USPTO trademark check, and secure escrow. Every listing even ships with a designed logo.