<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: nishar multani</title>
    <description>The latest articles on DEV Community by nishar multani (@nishar_multani).</description>
    <link>https://dev.to/nishar_multani</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4266821%2F0c9a759b-29e6-450a-bab9-ef94233ab9e3.png</url>
      <title>DEV Community: nishar multani</title>
      <link>https://dev.to/nishar_multani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nishar_multani"/>
    <language>en</language>
    <item>
      <title>How I built a 3D scroll portfolio with Astro, React Three Fiber, GSAP and Lenis</title>
      <dc:creator>nishar multani</dc:creator>
      <pubDate>Thu, 26 Nov 2026 12:05:32 +0000</pubDate>
      <link>https://dev.to/nishar_multani/how-i-built-a-3d-scroll-portfolio-with-astro-react-three-fiber-gsap-and-lenis-1j06</link>
      <guid>https://dev.to/nishar_multani/how-i-built-a-3d-scroll-portfolio-with-astro-react-three-fiber-gsap-and-lenis-1j06</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Live: &lt;a href="https://nishar.xyz" rel="noopener noreferrer"&gt;nishar.xyz&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1so8rvl0gsvbcqu116ds.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1so8rvl0gsvbcqu116ds.jpg" alt="The About card hanging on ropes" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Making it look right was the easy part. Making it &lt;em&gt;feel&lt;/em&gt; right at 60 fps took much longer. These are the problems that cost me the most time.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. WebGL competed with the first paint
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9d1ghi2xjsg03iudz1w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9d1ghi2xjsg03iudz1w.png" alt="Timeline: WebGL scenes start after the hero intro instead of during it" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;whenIdle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;settle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'requestIdleCallback'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;
        &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;requestIdleCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="mi"&gt;3000&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'complete'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;settle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'load'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;settle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every heavy scene awaits &lt;code&gt;whenIdle&lt;/code&gt; before it starts. Nothing visual changed, but the first seconds stopped competing with the 3D.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. "Off-screen" canvases kept rendering
&lt;/h2&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1vi97m8hycs9de58l7n4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1vi97m8hycs9de58l7n4.png" alt="IntersectionObserver versus checkVisibility for a canvas faded to opacity 0" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wrote a &lt;code&gt;paintGate&lt;/code&gt; that asks whether the element can actually be seen right now, using &lt;code&gt;checkVisibility&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="n"&gt;painted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;checkVisibility&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;opacityProperty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;visibilityProperty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Images stalled scrolling
&lt;/h2&gt;

&lt;p&gt;The work grid is a WebGL gallery. Chrome decodes an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzgmpxkhydgwg0kn01nfh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzgmpxkhydgwg0kn01nfh.png" alt="Decoding images on the main thread versus off-thread with createImageBitmap" width="800" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix has two parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Decode off the main thread with &lt;code&gt;fetch&lt;/code&gt; and &lt;code&gt;createImageBitmap(blob)&lt;/code&gt;, and resize during the decode.&lt;/li&gt;
&lt;li&gt;Spread the texture uploads out so only one happens per frame.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If &lt;code&gt;createImageBitmap&lt;/code&gt; isn't available, the code falls back to a plain &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Figptirqh5w992rb7ukx9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Figptirqh5w992rb7ukx9.png" alt="The draggable WebGL work grid" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Smooth scroll that trailed my hand
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;I switched to Lenis's frame-rate-independent &lt;code&gt;lerp&lt;/code&gt; (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.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. A physics card that behaves the same on every machine
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Small things that added up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A 3D model that was too big:&lt;/strong&gt; I compressed the studio display model with meshopt, from 3.1 MB to 0.8 MB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fonts and images:&lt;/strong&gt; I self-hosted the fonts as woff2 and served responsive WebP variants instead of one large image.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced motion:&lt;/strong&gt; the site respects &lt;code&gt;prefers-reduced-motion&lt;/code&gt;. Smooth scroll is switched off for those users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pinned build:&lt;/strong&gt; I pinned the Node version so Cloudflare Pages builds are repeatable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd tell someone starting
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;If you try the site, I'd like feedback on how it performs on your device: &lt;a href="https://nishar.xyz" rel="noopener noreferrer"&gt;nishar.xyz&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>threejs</category>
      <category>gsap</category>
      <category>astro</category>
    </item>
  </channel>
</rss>
