Module 08 / THREE.JS
three.js
Configure the FX01
three.js puts a real-time 3D scene on any page with plain JavaScript: the library most web 3D is built on.
Why it matters
- What you're looking at
- The FX01 assembled from one library file: each bay, finish and mount you choose is cloned and dressed live, and the link you share rebuilds it.
- Why it matters
- A configurator needs your own code around the scene: three.js gives you the scene graph and leaves the rest to you, with nothing hidden in an editor.
- The trade-off
- A library, not an editor: lighting, framing, controls and loading are yours to write, and every product file is a build step.
Loading stage…
Module notes
The FX01 Instrument Rack, built to order in the browser: pick the frame, an instrument for every bay, the finishes and the mount, then share the link. three.js, the most-used web 3D library, assembles it live.
- This browser
- checking…
- Native path
- three.js on WebGL 2 · glTF material variants needs WebGL 2
- Fallback
- The default rack as a still render needs nothing extra
- Status
- Live since 2026-10-17
- Payload
- The FX01 library: every frame, module and mount (fx01-library.glb) · 3.2 MB
- three.js core · 188 KB
- GLTFLoader and OrbitControls · 19 KB
- Stage code and the library's manifest · 23 KB
- USDZExporter (the USDZ itself is made on the phone) · 9 KB (on iPhone and iPad)
- Budget
- Payload 3.4 MB · budget ≤ 3.5 MB Within
- First frame desktop 4.1 s · budget ≤ 4.5 s To measure
- Frame rate desktop 60 fps · budget ≥ 55 fps desktop · ≥ 30 phone To measure
- Browser support
-
First version with each feature · caniuse, 2026-10-14Feature Chrome Safari Firefox WebGL 2 (three.js, the configurator) 56 15 51 AR Quick Look link (rel=ar), with a USDZ made in the browser Not yet 12 (iOS) Not yet WebXR immersive AR with hit test (Android, ARCore) 81 (Android) Not yet Not yet Async Clipboard writeText (Copy link) 66 13.1 63 - Tags
Module 08 / Use it on your page
three.js with your own code around it: load one GLB of parts, clone what the visitor picks, swap finishes with glTF material variants, and keep the choice in the URL.
npm three 0.183 (core, GLTFLoader and OrbitControls about 200 KB) · one library GLB of every part (3.2 MB gzipped) · USDZExporter (9 KB) on iPhone only
-
Step 1
Load one library of parts
Every frame, module and mount once, in one GLB, with a small manifest of where each sits. A clone shares geometry and materials, so seven of the same module cost no more than one.
import * as THREE from "three"; import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"; const gltf = await new GLTFLoader().loadAsync("rack-library.glb"); const part = (name, x) => { const o = gltf.scene.getObjectByName(name).clone(true); o.position.set(x, 0, 0); return o; }; rack.add(part("frame5", 0), part("clock", -0.16), part("meter", -0.08)); -
Step 2
Swap finishes with material variants
KHR_materials_variants keeps every finish in the file. three.js leaves the extension in userData, so a few lines switch it: load the variant's material once, then assign it.
const names = gltf.userData.gltfExtensions.KHR_materials_variants.variants.map((v) => v.name); async function variant(root, name) { const i = names.indexOf(name); const jobs = []; root.traverse((m) => { const hit = m.userData.gltfExtensions?.KHR_materials_variants?.mappings.find((x) => x.variants.includes(i)); if (hit) jobs.push(gltf.parser.getDependency("material", hit.material).then((mat) => (m.material = mat))); }); await Promise.all(jobs); } await variant(rack, "frame-graphite"); -
Step 3
Keep the configuration in the URL
Plain words a person can read, replaced on each change so Back still leaves the page. Read it back field by field, with a default for anything unknown.
const q = new URLSearchParams({ modules: config.modules.join("."), frame: config.frame }); history.replaceState(null, "", "?" + q); await navigator.clipboard.writeText(location.href); // "Copy link" -
Step 4
Hand the result to AR Quick Look
USDZExporter turns what is on screen into a USDZ in the browser. Make it ahead, after each change: Quick Look opens from a plain tap on a link whose first child is an image.
import { USDZExporter } from "three/addons/exporters/USDZExporter.js"; const bytes = await new USDZExporter().parseAsync(rack, { quickLookCompatible: true }); const url = URL.createObjectURL(new Blob([bytes], { type: "model/vnd.usdz+zip" })); arLink.href = url + "#allowsContentScaling=1"; // <a rel="ar"><img …>View in AR</a>
Serving it
- Render on demand: draw a frame only while something moves. Don't pin OrbitControls' minDistance to maxDistance: it reports a change every frame.
- Load every variant's material up front and a swatch swaps instantly.
- On Android Chrome, the same renderer runs a WebXR immersive-ar session (renderer.xr) with a hit test to place the product.
- Serve the GLB gzipped: its geometry halves (7.8 → 3.2 MB here).