Any 3D in a film - an object, product, logo or set in 3D, a camera move through space, an exploded view, a 3D data or science scene. Read before writing a three.js code layer.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Three D?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/humanharness-three-d)
---
name: three-d
kind: guide
description: Any 3D in a film - an object, product, logo or set in 3D, a camera move through space, an exploded view, a 3D data or science scene. Read before writing a three.js code layer.
---
3D in MOGA is a code layer (`add_code`) whose page draws with three.js. `three` and its addons are already there: import them by name, never import_file them. Words, buttons and UI stay ordinary MOGA layers above the code layer (lint reads them; it cannot read pixels in a canvas).
A 3D shot is judged on three things before materials: the object reads by its silhouette, the camera does what was asked (direction, extent, start and end framing), and nothing pops, slides or clips. Build in that order.
## 1. The page
```html
<canvas id="c"></canvas>
<script type="module">
import * as THREE from 'three';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
const { width, height, colors } = window.MOGA_CODE;
const renderer = new THREE.WebGLRenderer({ canvas: document.getElementById('c'), antialias: true, alpha: true, preserveDrawingBuffer: true });
renderer.setPixelRatio(window.devicePixelRatio || 1);
renderer.setSize(width, height);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.NeutralToneMapping; // ACES greys out brand colours
const scene = new THREE.Scene(); // no background: the composition shows through (alpha)
scene.environment = new THREE.PMREMGenerator(renderer).fromScene(new RoomEnvironment(), 0.04).texture;
const camera = new THREE.PerspectiveCamera(35, width / height, 0.1, 100);
const ease = (x) => (x <= 0 ? 0 : x >= 1 ? 1 : x * x * (3 - 2 * x));
const span = (t, a, b) => ease((t - a) / (b - a));
const hero = new THREE.Mesh(
new THREE.TorusKnotGeometry(1, 0.32, 256, 48),
new THREE.MeshPhysicalMaterial({ color: colors['md.sys.color.primary'], roughness: 0.35, clearcoat: 0.6 }),
);
scene.add(hero);
const key = new THREE.DirectionalLight(0xffffff, 2.5);
key.position.set(3, 4, 5);
scene.add(key);
// everything from t: the same t always draws the same frame, in any order
window.seek = (t) => {
hero.rotation.y = 0.6 * t;
const u = span(t, 0, 4); // a 4 s dolly in
camera.position.set(0, 0.4, 9 - 3.5 * u);
camera.lookAt(0, 0, 0);
renderer.render(scene, camera);
};
</script>
```
- Colours come from `MOGA_CODE.colors` (`md.sys.color.*`, light or dark as the film is), so 3D matches the project's tokens and theme.
- `seek` may be `async`: load what it needs once (`const ready = load()`) and `await ready` inside, so the first frame is never drawn half-loaded. A model or texture is a file under `media/` (`'/media/x.glb'`, after `import_file`); never fetch from the network.
- Units are metres. `camera.near` as large as the scene allows (0.1–0.5), `far` just past the scene.
- Give the layer the box it needs (`w`, `h`); a 1600×900 canvas over a 1920×1080 frame is a lot of pixels each frame, so keep it to what is seen.
## 2. Time is the only input
- No `clock.getDelta()`, `requestAnimationFrame` loop or state carried from the last frame. An `AnimationMixer` is posed with `mixer.setTime(t)` before `render`.
- Physics (falling, stacking, dominoes): simulate once on load with a fixed step and seed, store each step's transforms, and interpolate between the two nearest steps in `seek`.
- Randomness: `Math.random` is seeded per layer; draw it once on load into arrays, never inside `seek`.
- Springs and eases are closed-form functions of t; a value that changes several times is a sum of eased segments.
## 3. Shapes that read
Build recognisable silhouettes from primitives; detail only where the camera goes close.
| Need | Tool |
| ------------------------------------- | --------------------------------------------------------------------------------------- |
| bottles, vases, towers, lamps, wheels | `LatheGeometry` from a 2D profile |
| logos, letters, panels, frames | `ExtrudeGeometry` from a `Shape` with a bevel; an SVG logo through `SVGLoader` (addons) |
| cables, rails, roads, paths | `TubeGeometry` along a `CatmullRomCurve3` |
| terrain, rock | a `PlaneGeometry` displaced by seeded noise, then `computeVertexNormals()` |
| many repeated parts | `InstancedMesh`, one matrix each |
| devices, furniture | `RoundedBoxGeometry` (addons) |
| a model file (.glb best) | `GLTFLoader` (addons); `STLLoader` and others need `computeVertexNormals()` |
- Parent parts the way they move (car → body, wheels; arm → shoulder → elbow), each group pivoted at its joint.
- Fit the camera to the subject: `new THREE.Box3().setFromObject(obj).getBoundingSphere(s)`, then distance = s.radius / sin(fov / 2) with a little margin. The subject fills at least a third of the frame height at its key moment.
- Text in 3D only when it must sit in the scene (`TextGeometry` needs a font file); otherwise a MOGA text layer over the canvas, which stays sharp and is linted.
## 4. Camera
- Write the path as data and sample it: `CatmullRomCurve3` for position and one for the look target, `getPointAt(ease(u))` for even speed. Ease in and out; the middle of a move is the fastest.
- Do what was asked exactly: orbit direction (counter-clockwise from above = angle grows with t), extent (~90°), crane up, dolly in. A static shot or the wrong direction fails even if it looks good.
- Fly into or through one hero rather than circling it; one dive is worth ten turns. End on a short hold of the final framing.
- Keep the horizon level unless a roll was asked for (FPV may bank ≤ 10°). Chase cameras follow a lagged point on the subject's path, never a rigid parent.
- No clipping: the camera never passes through geometry; check the closest moment with `look`.
## 5. Light and materials
- Studio: the room environment above plus one warm key and a cool rim light; turn the environment or the light, not only the object, so highlights sweep across it. A soft contact shadow (a dark radial-gradient plane, or a shadow map 2048 with tight bounds) keeps it from floating.
- Brushed metal: `metalness` 1, `roughness` 0.3–0.45 (lower gives white streaks). Matte plastic: roughness 0.6–0.8. Glass: `transmission` 1, `thickness` 0.5. Clearcoat for car paint and phones.
- Bloom (`UnrealBloomPass`) eats detail: only on the brightest points, and clamp values that can divide by zero (one NaN pixel blacks the frame).
- A colour that must match a brand: `MeshBasicMaterial` or emissive, since lit colours shift.
- Metal reflects its surroundings: with no `scene.environment` it renders nearly black. Keep the room environment from the page above.
- Lint cannot see inside the canvas: keep MOGA text layers clear of where the 3D subject is drawn at every moment (shrink or move the subject before a title lands), and `look` to check.
## 6. Motion that reads as physical
- Wheels turn by distance / radius; objects on a path face along `getTangentAt(u)`.
- Exploded views: each part moves along one axis by a staggered amount, nothing intersects, and reassembly returns to the stored original transforms.
- Product UI is never tilted into 3D; a screen on a device mesh shows a picture from `media/` as a texture, straight on.
## 7. Check
`look` at the start, the key moment and the end: the subject reads in a cold glance, the camera moved the way the brief said, no clipping, nothing floating. Then `look` over the fastest move (from/to) to catch pops. If a frame is slow to draw (software WebGL renders slowly), lower geometry segments, shadow map size and pixel ratio where the camera cannot tell.