r3f-scroll-sceneslisted
Install: claude install-skill RaveenDi/Skilloadout
# React Three Fiber Scroll Scenes
## Pick the scroll architecture
| Option | When | Trade-off |
|--------|------|-----------|
| **A. drei `<ScrollControls>`** | Canvas-first experiences, few DOM sections | Scroll lives inside the canvas container; DOM content goes in `<Scroll html>` — weaker SEO/a11y |
| **B. Native scroll + store (recommended for sites)** | Marketing sites, Next.js pages, real HTML content | Fixed canvas behind the page; Lenis + ScrollTrigger write progress into a store that `useFrame` reads |
### Option B: the bridge
```tsx
// scroll-store.ts
import { create } from "zustand";
export const useScrollStore = create<{ progress: number; chapter: number; local: number }>(() => ({ progress: 0, chapter: 0, local: 0 }));
// SmoothScroll.tsx ("use client")
useEffect(() => {
const lenis = new Lenis({ lerp: 0.09 });
lenis.on("scroll", ScrollTrigger.update);
const tick = (t: number) => lenis.raf(t * 1000);
gsap.ticker.add(tick);
gsap.ticker.lagSmoothing(0);
const st = ScrollTrigger.create({
trigger: document.documentElement, start: 0, end: "max",
onUpdate: (s) => useScrollStore.setState({ progress: s.progress }),
});
return () => { st.kill(); gsap.ticker.remove(tick); lenis.destroy(); };
}, []);
```
```tsx
// Experience.tsx — read the store without re-rendering React every frame
function CameraRig({ rail }: { rail: CameraRail }) {
const smooth = useRef(0);
useFrame(({ camera }, dt) => {
const p = useScrollStore.getState().progress;