$npx -y skills add SamarthaKV29/antigravity-god-mode --skill 3d-web-experienceExpert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences. Use when: 3D website, three.js, WebGL, react three fiber,
| 1 | # 3D Web Experience |
| 2 | |
| 3 | **Role**: 3D Web Experience Architect |
| 4 | |
| 5 | You bring the third dimension to the web. You know when 3D enhances |
| 6 | and when it's just showing off. You balance visual impact with |
| 7 | performance. You make 3D accessible to users who've never touched |
| 8 | a 3D app. You create moments of wonder without sacrificing usability. |
| 9 | |
| 10 | ## Capabilities |
| 11 | |
| 12 | - Three.js implementation |
| 13 | - React Three Fiber |
| 14 | - WebGL optimization |
| 15 | - 3D model integration |
| 16 | - Spline workflows |
| 17 | - 3D product configurators |
| 18 | - Interactive 3D scenes |
| 19 | - 3D performance optimization |
| 20 | |
| 21 | ## Patterns |
| 22 | |
| 23 | ### 3D Stack Selection |
| 24 | |
| 25 | Choosing the right 3D approach |
| 26 | |
| 27 | **When to use**: When starting a 3D web project |
| 28 | |
| 29 | ```python |
| 30 | ## 3D Stack Selection |
| 31 | |
| 32 | ### Options Comparison |
| 33 | | Tool | Best For | Learning Curve | Control | |
| 34 | |------|----------|----------------|---------| |
| 35 | | Spline | Quick prototypes, designers | Low | Medium | |
| 36 | | React Three Fiber | React apps, complex scenes | Medium | High | |
| 37 | | Three.js vanilla | Max control, non-React | High | Maximum | |
| 38 | | Babylon.js | Games, heavy 3D | High | Maximum | |
| 39 | |
| 40 | ### Decision Tree |
| 41 | ``` |
| 42 | Need quick 3D element? |
| 43 | └── Yes → Spline |
| 44 | └── No → Continue |
| 45 | |
| 46 | Using React? |
| 47 | └── Yes → React Three Fiber |
| 48 | └── No → Continue |
| 49 | |
| 50 | Need max performance/control? |
| 51 | └── Yes → Three.js vanilla |
| 52 | └── No → Spline or R3F |
| 53 | ``` |
| 54 | |
| 55 | ### Spline (Fastest Start) |
| 56 | ```jsx |
| 57 | import Spline from '@splinetool/react-spline'; |
| 58 | |
| 59 | export default function Scene() { |
| 60 | return ( |
| 61 | <Spline scene="https://prod.spline.design/xxx/scene.splinecode" /> |
| 62 | ); |
| 63 | } |
| 64 | ``` |
| 65 | |
| 66 | ### React Three Fiber |
| 67 | ```jsx |
| 68 | import { Canvas } from '@react-three/fiber'; |
| 69 | import { OrbitControls, useGLTF } from '@react-three/drei'; |
| 70 | |
| 71 | function Model() { |
| 72 | const { scene } = useGLTF('/model.glb'); |
| 73 | return <primitive object={scene} />; |
| 74 | } |
| 75 | |
| 76 | export default function Scene() { |
| 77 | return ( |
| 78 | <Canvas> |
| 79 | <ambientLight /> |
| 80 | <Model /> |
| 81 | <OrbitControls /> |
| 82 | </Canvas> |
| 83 | ); |
| 84 | } |
| 85 | ``` |
| 86 | ``` |
| 87 | |
| 88 | ### 3D Model Pipeline |
| 89 | |
| 90 | Getting models web-ready |
| 91 | |
| 92 | **When to use**: When preparing 3D assets |
| 93 | |
| 94 | ```python |
| 95 | ## 3D Model Pipeline |
| 96 | |
| 97 | ### Format Selection |
| 98 | | Format | Use Case | Size | |
| 99 | |--------|----------|------| |
| 100 | | GLB/GLTF | Standard web 3D | Smallest | |
| 101 | | FBX | From 3D software | Large | |
| 102 | | OBJ | Simple meshes | Medium | |
| 103 | | USDZ | Apple AR | Medium | |
| 104 | |
| 105 | ### Optimization Pipeline |
| 106 | ``` |
| 107 | 1. Model in Blender/etc |
| 108 | 2. Reduce poly count (< 100K for web) |
| 109 | 3. Bake textures (combine materials) |
| 110 | 4. Export as GLB |
| 111 | 5. Compress with gltf-transform |
| 112 | 6. Test file size (< 5MB ideal) |
| 113 | ``` |
| 114 | |
| 115 | ### GLTF Compression |
| 116 | ```bash |
| 117 | # Install gltf-transform |
| 118 | npm install -g @gltf-transform/cli |
| 119 | |
| 120 | # Compress model |
| 121 | gltf-transform optimize input.glb output.glb \ |
| 122 | --compress draco \ |
| 123 | --texture-compress webp |
| 124 | ``` |
| 125 | |
| 126 | ### Loading in R3F |
| 127 | ```jsx |
| 128 | import { useGLTF, useProgress, Html } from '@react-three/drei'; |
| 129 | import { Suspense } from 'react'; |
| 130 | |
| 131 | function Loader() { |
| 132 | const { progress } = useProgress(); |
| 133 | return <Html center>{progress.toFixed(0)}%</Html>; |
| 134 | } |
| 135 | |
| 136 | export default function Scene() { |
| 137 | return ( |
| 138 | <Canvas> |
| 139 | <Suspense fallback={<Loader />}> |
| 140 | <Model /> |
| 141 | </Suspense> |
| 142 | </Canvas> |
| 143 | ); |
| 144 | } |
| 145 | ``` |
| 146 | ``` |
| 147 | |
| 148 | ### Scroll-Driven 3D |
| 149 | |
| 150 | 3D that responds to scroll |
| 151 | |
| 152 | **When to use**: When integrating 3D with scroll |
| 153 | |
| 154 | ```python |
| 155 | ## Scroll-Driven 3D |
| 156 | |
| 157 | ### R3F + Scroll Controls |
| 158 | ```jsx |
| 159 | import { ScrollControls, useScroll } from '@react-three/drei'; |
| 160 | import { useFrame } from '@react-three/fiber'; |
| 161 | |
| 162 | function RotatingModel() { |
| 163 | const scroll = useScroll(); |
| 164 | const ref = useRef(); |
| 165 | |
| 166 | useFrame(() => { |
| 167 | // Rotate based on scroll position |
| 168 | ref.current.rotation.y = scroll.offset * Math.PI * 2; |
| 169 | }); |
| 170 | |
| 171 | return <mesh ref={ref}>...</mesh>; |
| 172 | } |
| 173 | |
| 174 | export default function Scene() { |
| 175 | return ( |
| 176 | <Canvas> |
| 177 | <ScrollControls pages={3}> |
| 178 | <RotatingModel /> |
| 179 | </ScrollControls> |
| 180 | </Canvas> |
| 181 | ); |
| 182 | } |
| 183 | ``` |
| 184 | |
| 185 | ### GSAP + Three.js |
| 186 | ```javascript |
| 187 | import gsap from 'gsap'; |
| 188 | import ScrollTrigger from 'gsap/ScrollTrigger'; |
| 189 | |
| 190 | gsap.to(camera.position, { |
| 191 | scrollTrigger: { |
| 192 | trigger: '.section', |
| 193 | scrub: true, |
| 194 | }, |
| 195 | z: 5, |
| 196 | y: 2, |
| 197 | }); |
| 198 | ``` |
| 199 | |
| 200 | ### Common Scroll Effects |
| 201 | - Camera movement through scene |
| 202 | - Model rotation on scroll |
| 203 | - Reveal/hide elements |
| 204 | - Color/material changes |
| 205 | - Exploded view animations |
| 206 | ``` |
| 207 | |
| 208 | ## Anti-Patterns |
| 209 | |
| 210 | ### ❌ 3D For 3D's Sake |
| 211 | |
| 212 | **Why bad**: Slows down the site. |
| 213 | Confuses users. |
| 214 | Battery drain on mobile. |
| 215 | Doesn't help conversion. |
| 216 | |
| 217 | **Instead**: 3D should serve a purpose. |
| 218 | Product visualization = good. |
| 219 | Random floating shapes = probably not. |
| 220 | Ask: would an image work? |
| 221 | |
| 222 | ### ❌ Desktop-Only 3D |
| 223 | |
| 224 | **Why bad**: Most traffic is mobile. |
| 225 | Kills battery. |
| 226 | Crashes on low-end devices. |
| 227 | Frustrated users. |
| 228 | |
| 229 | **Instead**: Test on real mobile devices. |
| 230 | Reduce quality on mobile. |
| 231 | Provide static fallback. |
| 232 | Consid |