threejs
Plan, code, and render GPU 3D motion graphics with Three.js (deterministic time-driven scenes captured headlessly to MP4). Acts as a creative director to storyboard the video, then writes a pure-function-of-time scene module, draft-renders frames, and delivers an MP4 path. Use for product spins, studio object showcases, particle fields, procedural landscapes, and cinematic 3D intros when you want maximum beauty per line of MIT-licensed code.
How do I install this agent skill?
npx skills add https://github.com/hmzbo/animation-skills --skill threejsIs this agent skill safe to install?
- Gen Agent Trust Hubwarn
The skill provides a toolchain for Three.js motion graphics rendering. It contains a path traversal vulnerability in its internal HTTP server which could allow malicious scenes to access files outside the project directory. The skill also performs system command execution and installs external dependencies.
- Socketwarn
1 alert: gptAnomaly
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
Three.js
Produce beautiful GPU motion graphics with Three.js. Act as a creative director and visual-storytelling expert first, and as a Three.js engineer second. One hero object, lit well and moved slowly, beats ten objects moving fast: restraint reads as premium.
All rendering is deterministic: scenes expose time explicitly, so the same second always renders the same pixels (verified byte-identical across runs). Never use wall-clock animation in scenes — see Hard rules.
Workflow at a glance
Phase 0 PREFLIGHT -> Phase 1 PLAN -> Phase 2 CODE -> Phase 3 DRAFT (60 frames)
-> Phase 4 FINAL (full) -> Phase 5 DELIVER
^
revisions: edit -> check -> DRAFT again -> user approves -> FINAL
Project layout contract
Every video is a hand-laid npm project under the current working directory:
<cwd>/videos3d/<topic-slug>/
├── plan.md # storyboard from Phase 1
├── package.json # {three, playwright}
├── index.html # import map (three, three/addons/) + <script src="/scene.mjs">
├── scene.mjs # the whole animation (single-scene default)
├── scenes/ # extra scenes only for multi-act videos (optional)
├── frames/ # stepped PNGs — never hand-edited, gitignored
└── final.mp4 # delivered video (Phase 4)
<topic-slug> is short kebab-case. Reuse the same folder for revisions.
frames/ and final.mp4 stay out of git.
The deterministic scene contract (non-negotiable)
window.__renderAt = t => { // t in seconds — EVERY animated value derives from t
knot.rotation.y = t * 0.9;
renderer.render(scene, camera);
};
window.__meta = {fps: 60, duration: 4, width: 1280, height: 720};
window.__renderAt(0);
The driver steps t = i/fps and screenshots the canvas per frame. Same t
=> same pixels, across machines and runs.
Phase 0: Preflight
node <skill-dir>/scripts/preflight.mjs
Then per video project (library once per project, Chromium binary once per machine):
npm i three playwright --prefix <cwd>/videos3d/<slug>
npx playwright install chromium
If Chromium cannot be installed, set strategy now: the agent can still write + syntax-check scenes, but stepping becomes user-assisted — say so in delivery.
Phase 1: Plan (no code yet)
Read references/three-api.md and classify into one tier:
| Tier | Criteria | Approval gate |
|---|---|---|
| S Simple | One hero object, fixed camera, <= 4s | Auto-proceed |
| M Moderate | Multi-object / particles, camera dolly, 4-8s | Auto-proceed |
| L Large | Multi-act, scene changes, post passes, 8s+ | Present plan, WAIT for approval |
Write <cwd>/videos3d/<slug>/plan.md: title, one-sentence arc, beat list with
concrete techniques (TorusKnotGeometry, smoothstep dolly, InstancedMesh
swarm), palette + lighting rig (ambient/key/rim colors), camera path.
Phase 2: Code
Lay out the project by hand (no scaffolder exists for this skill):
package.json:{three, playwright}(pin the three version you smoke-tested).index.html: copy examples/index.html (import map forthreeandthree/addons/).scene.mjs: implement the__renderAt/__metacontract.
Before writing nontrivial scenes, consult:
- references/three-api.md — blocks, materials, lights, addons
- references/troubleshooting.md — determinism traps, headless pitfalls
- examples/ —
product-spin.mjs(verified byte-identical),wave-grid.mjs(vertex pattern). Copy their patterns.
Coding standards:
- Every animated value is a pure function of
t. NorequestAnimationFrame,Clock,Date.now(), unseededMath.random(). - Async assets (textures, GLTF) must resolve before the first
__renderAt(0)(gate behindwindow.__readythe driver awaits — driver waits for__renderAtto exist; keep loads synchronous where possible). - Camera: interpolate position +
lookAtont. Never OrbitControls in scenes. - Design at final
__metasize: screenshots capture CSS pixels 1:1.
Gate before stepping (instant):
node --check <cwd>/videos3d/<slug>/scene.mjs
Phase 3: Draft render (mandatory, never skip)
Step 60 frames headlessly (driver serves, steps, screenshots, shuts down):
node <skill-dir>/scripts/render.mjs --project <cwd>/videos3d/<slug> --frames 60
- Default (no
--frames) steps the fullfps * durationspan. - Frames land in
<slug>/frames/as zero-padded 6-digit PNGs.
Visual frame review (mandatory): open 3 PNGs (first/middle/last). Check: object fully in frame, lighting reads on all sides, no clipping through near/far planes, background intentional (not default black unless planned). Fix, re-step the draft, re-review.
Phase 4: Final render
node <skill-dir>/scripts/render.mjs --project <cwd>/videos3d/<slug>
ffmpeg -y -framerate <fps> -i <slug>/frames/%06d.png -c:v libx264 -pix_fmt yuv420p -crf 18 <slug>/final.mp4
Take <fps> from the scene's __meta. Prefer the shared recipe in
shared/ffmpeg/README.md over inventing flags. Post passes (bloom via
EffectComposer) go on for finals only — drafts render plain.
Phase 5: Deliver
**Video ready**
Topic: <topic>
Plan recap:
- Beat 1: <one line>
...
File: <absolute path to final.mp4> (<WxH>@<fps>, ~M:SS estimated)
Source: <absolute path to videos3d/<slug>/scene.mjs>
Want any changes? Revisions re-step fast at 60 frames; full render once satisfied.
Revision policy
- Edit
scene.mjs. 2.node --check. 3. Draft-step 60 frames. 4. Iterate until satisfied. 5. Full step + encode + redeliver. Never ship without a draft pass.
Hard rules
- Time-driven scenes only: no rAF, Clock, Date.now, unseeded random.
- Always preflight before planning; always
node --checkbefore stepping; always draft-step + frame review before finals. - Never hand-edit
frames/; regenerate via the driver. - One video project per topic under
<cwd>/videos3d/<slug>/. - WebGL only in v1. WebGPU/TSL is parked (needs Dawn flags headless).
- If any phase fails repeatedly (2+ fix attempts), report the blocker honestly.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/hmzbo/animation-skills/threejs">View threejs on skillZs</a>