A vertical storytelling web experience exploring seven distinct approaches to rendering the third dimension in the browser.
This project serves as both a visual showcase and a technical reference for implementing different 3D libraries and techniques within a modern React framework.
- Framework: Next.js 16.2.6 (App Router + Turbopack)
- UI Library: React 19
- Styling: Tailwind CSS v4 + DaisyUI v5.0 (Dark/Black theme primary)
- Language: TypeScript
The page is structured as a single continuous scroll, featuring an alternating "zebra stripe" high-contrast background (Black and off-white/5% opacity).
- Phase 1: Setup & Hero
- Dual-overlay fixed Navbar utilizing
mix-blend-differencefor smart color inversion over scrolling backgrounds. - Responsive mobile dropdown menu.
- Reusable
BackgroundTextutility component for massive, subtle background typography. - Interactive volumetric ink-smoke particle effect integrated directly via
@tsparticles/engine.
- Dual-overlay fixed Navbar utilizing
- Phase 2: Framer Motion (DOM Physics)
- Raw HTML manipulated in 3D space using native
zprops and Framer Motion's physics engine (rotateX,rotateY). - Features interactive physical buttons (
whileHover,whileTap) to demonstrate that native DOM events function perfectly in CSS 3D space without requiring WebGL raycasting.
- Raw HTML manipulated in 3D space using native
- Phase 3: React Three Fiber (Native WebGL)
- Native WebGL pipeline via Three.js.
- Features a complex Torus Knot utilizing
MeshTransmissionMaterialfor real-time light refraction and glass physics. - Protected by a
<MobileSafeWebGL />firewall that requires explicit user consent before mounting heavy rendering contexts on mobile devices.
- Phase 4: Spline (Visual Editor)
- A full-bleed, responsive 3D background showcasing multiple scenes.
- Wrapped in a Framer Motion
<AnimatePresence>carousel for smooth scaling/fading between different Spline exports. - Glassmorphic overlay UI for scene control.
- Phase 5: Globe.gl (Data Geospatial)
- A "Hub and Spoke" data visualization mapping a central geographic node (Cairo) to random global destinations.
- Features pulsing radar rings, cinematic auto-rotation, and custom
onMouseEnter/onMouseLeaverotation pausing. - Forced client-side rendering via
next/dynamicwith strictisMountedlifecycle tracking to prevent asynchronous state leaks.
- Phase 6: Atropos (Micro-Interactions)
- A "Quantum Core" futuristic ID card utilizing
atroposfor deep holographic parallax hover effects. - Features extreme layer offsets (from -8 to +8) to exaggerate the optical illusion of depth.
- A "Quantum Core" futuristic ID card utilizing
- Phase 7: Pure Modern CSS (Native Browser Math)
- A 3D Lissajous knot built with zero JavaScript physics.
- Relies entirely on native CSS trigonometric functions (
sin()andcos()) insidecalc()combined with hardware-acceleratedtranslate3d.
- Phase 8: tsParticles (2D-to-3D Illusion)
- A "Quantum Constellation" full-bleed background utilizing the
@tsparticles/engine. - Demonstrates how 2D canvas rendering can simulate 3D depth using mathematical parallax and interactive pointer tethering.
- Bypasses the standard React wrapper for strict Turbopack compatibility.
- A "Quantum Constellation" full-bleed background utilizing the
We encountered and resolved several critical performance bottlenecks and configuration clashes due to the heavy nature of stacking multiple WebGL contexts:
- Aggressive VRAM Garbage Collection (
LazySceneWrapper): Running Three.js, Globe.gl, and Spline simultaneously causes severe GPU memory leaks and hard system freezes. We built a<LazyScene>wrapper using Framer Motion'suseInView(with a 600px margin) that strictly returnsnullwhen off-screen, forcing the browser to instantly dump the WebGL context from Video RAM. - Mobile WebGL Firewall: Calculating physical glass refraction causes mobile GPUs to violently overheat and crash. We implemented a strictly gated component that detects mobile viewports and suspends initialization until the user explicitly opts in.
- Resolution & DPR Capping: High-end laptops with Retina displays attempt to calculate 3D scenes at 4K density, causing extreme fan noise. We programmatically capped the
devicePixelRatiolimit across Three.js and Globe.gl instances to a maximum of1.5x, cutting GPU calculation loads by up to 60%. - Ghost Loaders (CSS Animations): Using
opacity-0to hide DaisyUI's continuous CSS loading rings causes the GPU to indefinitely process invisible frames. We switched to strict conditional React unmounting ({!isLoaded && <Loader />}) to permanently kill the animation cycles once scenes are ready. - 16-bit Depth Buffer Z-Fighting: Mobile GPUs compress depth buffers, causing
<ContactShadows>to flicker violently against base planes. We resolved this by passingdepthWrite={false}to transparent shadow materials. - Color Space Interpolation Bugs: Tailwind v4 defaults to
oklabcolor spaces, which Framer Motion cannot currently interpolate during hover animations. We bypassed this by explicitly declaringrgbastart states in inline styles for physical buttons. - Dual-Overlay Blend Modes: Applying
mix-blend-differenceto fixedz-indexnavbars causes stacking context trapping. We bypassed this by rendering two perfectly overlapping navbars—one handling the blend math, and one invisible layer passing clicks through to maintain primary accent colors. - Vercel Build Configurations (
.npmrc): Strict React 19 dependency resolution fails on beta packages (like@tsparticles). We included a local.npmrcfile withlegacy-peer-deps=trueandignore-scripts=trueto guarantee stable, automated cloud deployments. - Turbopack vs. Webpack Aliasing: To resolve "Multiple instances of Three.js" warnings between
@react-three/fiberand@splinetool/react-spline, we explicitly configured theturbopackblock alongsidewebpackinnext.config.ts.
- WebGL/ANGLE Compiler Warnings: You may see console warnings regarding "loop unrolling" or "uninitialized variables (f_blur)". These are low-level graphics driver optimizations triggered by Three.js shader compilation and do not affect performance or stability.
- Console Warnings in Dev: You will see warnings like
Multiple instances of Three.js being importedandTHREE.Clock: This module has been deprecated. This is caused by@splinetool/react-splinerelying on a pre-compiled, internal version of Three.js that bypasses Next.js alias configs. These only show in development and are stripped in production.
# Install dependencies
npm install
# Run the development server (uses Turbopack)
npm run devOpen http://localhost:3000 with your browser to see the result.