Scroll 3D animation
When to use this skill
-
Use this skill when the user wants a website that animates as people scroll, with a 3D shape that turns, grows, or moves with the scroll position.
-
Use it when the user names Three.js, GSAP ScrollTrigger, or Lenis, or when they share the theoffbook video about making a website animate as people scroll.
-
Use it for a hero, a product page, a portfolio, or a landing page where scroll is the main interaction.
-
Do not use it for a plain static page, a page with no scroll, or a heavy 3D game, where a full 3D engine or a game framework fits better.
The three tools
-
Three.js draws the 3D shape in the browser, with no build step and no designer needed.
-
GSAP ScrollTrigger links that shape to scroll, so scrolling down turns the shape and scrolling back turns it back.
-
Lenis smooths the scrolling, so the movement feels soft instead of jumpy.
-
Use all three together for the effect in the video, and use only the first two when smooth scroll is not wanted.
-
Use this prompt with an AI builder, exactly as in the video: "Use Three.js for the 3D scene, GSAP ScrollTrigger for scroll, and Lenis for smooth scrolling."
Set up the page
-
Build one self-contained HTML file by default, with no build step, no API key, and no paid tool.
-
Pin every library to one version, and load them in this order: Three.js first, then GSAP core, then ScrollTrigger, then Lenis, then your own code.
-
Load Three.js as an ES module through an import map, and load GSAP, ScrollTrigger, and Lenis as classic scripts, because mixing those two loading styles is the part that breaks most often.
-
Use these pinned CDNs, verified 2026-11-30:
- Three.js 0.160.0:
https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js - GSAP 3.12.5:
https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js - ScrollTrigger 3.12.5:
https://cdn.jsdelivr.net/npm/[email protected]/dist/ScrollTrigger.min.js - Lenis 1.3.17:
https://cdn.jsdelivr.net/npm/[email protected]/dist/lenis.min.js
- Three.js 0.160.0:
-
Use npm instead when the project already has a build step:
npm install three gsap lenis, then importthree,gsap,gsap/ScrollTrigger, andlenisin code. -
Put the import map before the module script, and put the GSAP and Lenis scripts before your own script, or the page throws
gsap is not definedorScrollTrigger is not defined. -
Read
references/setup.mdfor the full setup, the npm version, and the CDN table.
Draw the 3D shape
-
Create one scene, one perspective camera, and one WebGL renderer with a transparent background, so the page background shows through.
-
Add a wireframe torus knot as the default shape, because it is the shape in the video and it reads clearly as a 3D object even as a wireframe.
-
Use
new THREE.TorusKnotGeometry(1.1, 0.32, 64, 8)and aTHREE.MeshBasicMaterialwithwireframe: true, and keep the colour dark on a light page or light on a dark page. -
Set the camera at
z4.5, centre the shape, and cap the pixel ratio at 2 on desktop and 1.5 on phones, because a high pixel ratio is the fastest way to kill phone performance. -
Render inside the GSAP ticker, not inside a second
requestAnimationFrameloop, because two clocks drift apart and make ScrollTrigger feel late. -
Keep the shape as the only 3D object in the first version, and add a second object only after the scroll link works.
Link the shape to scroll
-
Register ScrollTrigger once, before any scroll animation:
gsap.registerPlugin(ScrollTrigger); -
Make one tall scroll track, at least 300vh, with the canvas sticky inside it, so the user has enough scroll distance to turn the shape.
-
Animate the rotation with a scrubbed tween, not a timed tween, so scroll position drives the shape directly.
-
Use this shape for the core tween:
gsap.to(knot.rotation, { y: Math.PI * 2, ease: "none", scrollTrigger: { trigger: "#scroll-track", start: "top top", end: "bottom bottom", scrub: 1 } }); -
Set
scrub: 1for a soft catch-up, orscrub: truefor a direct one-to-one link, and keepease: "none"on every scrubbed tween, because an ease on a scrubbed tween fights the scroll. -
Show the scroll progress and the rotation in degrees on the page while testing, with
onUpdate: (self) => {}on the ScrollTrigger, so a broken link is visible at once. -
Add text reveals after the rotation works, with one ScrollTrigger per section, and keep each reveal short, with a fade and a small rise.
-
Call
ScrollTrigger.refresh()after images load or after the layout changes, or the start and end points will be wrong.
Wire Lenis to GSAP, with one motion clock
-
Create Lenis once, and let the GSAP ticker drive it, because that is the canonical integration and it keeps ScrollTrigger in sync.
-
Use this wiring, exactly:
const lenis = new Lenis({ duration: 1.2, smoothWheel: true }); lenis.on("scroll", ScrollTrigger.update); gsap.ticker.add((time) => { lenis.raf(time * 1000); }); gsap.ticker.lagSmoothing(0); -
Remember that GSAP time is in seconds and Lenis expects milliseconds, so multiply by 1000, or the scroll will feel far too slow.
-
Run only one scroll owner on a page, and never run Lenis and GSAP ScrollSmoother together, and never run a second
requestAnimationFrameloop for Lenis when GSAP is already driving it. -
Respect
prefers-reduced-motionby skipping Lenis and the scrubbed rotation when the user asks for reduced motion, and show the shape still, in its final position.
Test on a phone
-
Test on a real phone, not only on a desktop, because heavy 3D runs slowly on cheaper phones.
-
In the video, a flagship phone held 60 FPS and a cheaper phone dropped to 13 FPS on the same page, so treat phone FPS as the real test.
-
Lower the torus knot segments, lower the pixel ratio, and turn off antialiasing on phones when the FPS drops, and retest after each change.
-
Keep the page usable when WebGL is missing, by showing the text and a static image instead of a blank canvas.
-
Check the page with Playwright eyes before delivering it, by opening the built page, screenshotting it, and reading the screenshot back, and check the labels, the readout, and the layout like a human eye would.
What good looks like
-
Scrolling down turns the shape smoothly, scrolling back turns it back, and stopping stops the shape at once.
-
The scroll feels soft, not jumpy, and the text appears as its section arrives.
-
The page stays readable on a phone, the shape never covers the text, and every section has a visible way back.
-
The demo in
examples/demo.htmlis the reference for good: a cream page, a black wireframe knot, red accents, a scroll percent readout, and a rotation readout.
Available connectors
-
Use
muse.connector_searchto find other connectors andmuse.skill_searchto find related skills. -
If nothing here fits, look on the web for a maintained API or MCP server and set it up with Custom Connectors and MCPs, or build a custom connector.
Websites
-
Three.js for the 3D docs, examples, and the TorusKnotGeometry reference.
-
GSAP ScrollTrigger for the scrub, pin, start, end, and refresh docs.
-
Lenis for the smooth scroll docs and the GSAP integration.
-
theoffbook on Instagram for the original video this skill is based on.
Alternatives for better results
-
Swap the torus knot for a product shape, a logo, or a simple sphere when the knot does not fit the page.
-
Use CSS scroll-driven animations instead of GSAP when the page needs only a fade or a parallax, and no 3D shape.
-
Pin the canvas with ScrollTrigger instead of a sticky section when the design needs the shape to stay while several text sections pass over it.