Interactive 3D WebGL Earth featuring high-resolution topographic displacement mapping, a real-time atmospheric glow shader, and dynamic solar shadow casting.
Live demo: https://pxnz3r.github.io/3d-globe
- Topographic detail — 1024×1024 sphere mesh with real elevation data via displacement mapping
- Dynamic sunlight — Adjustable sun azimuth and intensity with 4096² real-time shadow maps
- Atmospheric glow — Custom GLSL rim-light shader for a realistic atmospheric halo
- Orbit controls — Click-drag to rotate, scroll to zoom (2.5×–15× distance)
- Screen-recording mode — One-click toggle hides all UI overlays for clean captures
- Starfield backdrop — 5,000 randomly distributed stars with subtle twinkle animation
- Responsive — Adapts fluidly to any screen size
| Layer | Library | Role |
|---|---|---|
| UI Framework | React 19 | Component tree & state |
| 3D Engine | Three.js | WebGL rendering |
| React ↔ Three | React Three Fiber | Declarative JSX bindings |
| R3F Utilities | Drei | OrbitControls, texture loader, Stars |
| Styles | Tailwind CSS v4 | Utility-first CSS |
| Icons | Lucide React | Sun, Eye icons |
| Build | Vite | Dev server & production bundler |
npm install
npm run dev # → http://localhost:3000
npm run build # → dist/
npm run preview # Preview production buildRequires Node.js >= 18.
- Rotate — Click & drag the globe
- Zoom — Scroll wheel
- Sun controls — Bottom-right sun icon → sliders for azimuth & intensity
- Recording mode — Bottom-right eye icon → hides UI overlays
src/
├── main.tsx App entry point / React root
├── index.css Global styles, Tailwind import, reset
├── App.tsx Root component: UI overlay + solar controls
└── components/
├── Scene.tsx R3F Canvas: camera, lights, stars, orbit controls
├── Earth.tsx Earth sphere: geometry, textures, displacement
└── Atmosphere.tsx Custom GLSL shader for atmospheric rim glow
The site is hosted on GitHub Pages via a GitHub Actions workflow (.github/workflows/deploy.yml). Every push to main triggers a build and deploy.
To deploy your own fork:
- Push to your repo's
mainbranch - Go to Settings → Pages and set the source to GitHub Actions
- The workflow at
.github/workflows/deploy.ymlhandles the rest
Earth texture maps courtesy of three-globe (public-domain NASA Blue Marble & SRTM topography data).
MIT — feel free to use, modify, and share.