cd /news/developer-tools/how-i-built-a-3d-scroll-portfolio-wi… · home › topics › developer-tools › article
[ARTICLE · art-176774] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

How I built a 3D scroll portfolio with Astro, React Three Fiber, GSAP and Lenis

A product designer built a 3D scroll-based portfolio using Astro, React Three Fiber, Three.js, GSAP and Lenis, hosted on Cloudflare Pages, and documented the performance work needed to hold 60 fps. Key fixes included deferring WebGL scene initialization until the page load and hero intro finish, using checkVisibility to stop rendering faded or hidden canvases, decoding gallery images off the main thread with createImageBitmap, switching Lenis to frame-rate-independent lerp, and running the rope-hung About card on a fixed-step spring simulation.

recommendation

Gate heavy WebGL scenes behind a load-and-idle promise and pause render loops with checkVisibility rather than IntersectionObserver alone, since faded or hidden canvases still count as intersecting.

more in playbook: Running AI in production
by read3 min views6 publishedNov 26, 2026

I'm a product designer, and my portfolio is the one project where nobody can tell me what to cut. So I built it as a scroll experience: a hero that morphs into a 3D screen, a cube that turns between case studies, an About card hanging on ropes that you can tilt, drag and stretch, and a work grid you can throw around.

Live: nishar.xyz

It is built with Astro for the pages, React islands with React Three Fiber and Three.js for the 3D, GSAP (ScrollTrigger, Draggable, Inertia) and Lenis for motion, and Tailwind for layout. It is hosted on Cloudflare Pages. I designed it in Figma first, then built it with AI-assisted development (Claude Code, Codex and Cursor) so I could test how it felt in the browser instead of guessing from a prototype.

Making it look right was the easy part. Making it feel right at 60 fps took much longer. These are the problems that cost me the most time.

If every Three.js scene starts at page load, shader compilation and texture uploads land at exactly the moment the hero intro plays, and the intro stutters.

The fix was a small gate. WebGL scenes wait until the page has loaded, the hero intro has had time to play (about 2.6 seconds), and the main thread is idle:

export const whenIdle: Promise<void> = new Promise((resolve) => {
  const settle = () =>
    setTimeout(
      () => ('requestIdleCallback' in window
        ? requestIdleCallback(() => resolve(), { timeout: 3000 })
        : resolve()),
      3000
    );
  if (document.readyState === 'complete') settle();
  else addEventListener('load', settle, { once: true });
});

Every heavy scene awaits whenIdle before it starts. Nothing visual changed, but the first seconds stopped competing with the 3D.

I d scenes with IntersectionObserver, but that only tells you whether an element is inside the viewport. A canvas that GSAP has faded to opacity: 0, or that sits in a hidden chapter, still counts as intersecting, so it kept rendering for nothing.

I wrote a paintGate that asks whether the element can actually be seen right now, using checkVisibility:

painted = el.checkVisibility({ opacityProperty: true, visibilityProperty: true });

Each render loop calls it every frame, but the style check itself runs at most every 100 ms, so it is cheap. Layers that are faded out or hidden now stop rendering entirely.

The work grid is a WebGL gallery. Chrome decodes an <img> synchronously on the main thread when you upload it to WebGL, which costs roughly 10 to 30 ms per image, and the galleries load several at once. That adds up to dropped frames.

The fix has two parts:

fetch and createImageBitmap(blob), and resize during the decode. If createImageBitmap isn't available, the code falls back to a plain <img>.

I started with Lenis using a fixed duration of 1.8 seconds, which looks silky in a demo but makes the page trail behind the wheel.

I switched to Lenis's frame-rate-independent lerp (0.11). Each wheel tick now moves the page immediately and it settles in about 0.6 seconds, so the page follows the hand instead of trailing it. Lenis is driven by the GSAP ticker so ScrollTrigger and the smooth scroll stay on the same clock, and touch scrolling is left native on phones.

The About card hangs from four ropes. If the physics is tied to frame rate, it feels different on a 60 Hz laptop and a 120 Hz display. I used a fixed-step spring simulation (1/120 second per step) that has no DOM, renderer or frame-rate-dependent interpolation, so the same drag gives the same stretch everywhere.

On phones I removed the tilt, drag and stretch completely. The card stays on fixed ropes and touches scroll the page, because fighting the scroll gesture on a phone is a bad trade for a fun effect.

prefers-reduced-motion. Smooth scroll is switched off for those users. Build the motion you love, then budget as much time for performance as for the design. The visible effects are the easy part. The hard part is making sure they don't cost more than the user can feel.

If you try the site, I'd like feedback on how it performs on your device: nishar.xyz.

── more in #developer-tools 4 stories · sorted by recency
── more on @astro 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-i-built-a-3d-scr…] indexed:0 read:3min 2026-11-26 · —