An interactive, cartoony 3D globe built with Next.js 14, React Three Fiber, and OpenAI.
Users can spin and zoom the globe, click on any country, and see a popup panel with facts, history, languages, and landmarks, all generated on demand via the OpenAI API.
Includes Google Maps search/autocomplete to jump to specific countries or cities.
Currently working on better selected country overlay and fixing bug with slecting a country through the globe
-
3D Interactive Globe
- Cartoony Earth with blue oceans and green land.
- Crisp black outlines separate each country.
- Smooth spin/zoom with inertia and camera tween.
-
Clickable Countries
- Hover outlines and highlight on click.
- Selected country gently lifts out like a Jenga piece.
- Works for all countries (even microstates) using ISO3 or name fallback.
-
Country Facts Panel
- Shows summary, key landmarks, languages, fun fact.
- Powered by OpenAI API with deterministic prompts.
- “Regenerate” button to fetch fresh facts.
-
Search Integration
- Google Places Autocomplete for searching countries/cities.
- Geocoding → find country → focus globe.
-
Cartoony Style
- Green land, blue oceans, soft glow rim.
- Clean dark mode styling with Tailwind CSS.
-
Performance
- Lazy-loads heavy 3D deps.
- SWR client caching.
- Stateless: no database, ephemeral LRU cache in memory.
- Next.js 14 (App Router, Edge/serverless ready)
- React + React Three Fiber
- @react-three/drei helpers
- Three.js
- Tailwind CSS (with dark mode)
- Zustand for global state
- OpenAI Node SDK (server-side facts generation)
- Google Maps JS API (Autocomplete + Geocoding)
- world-atlas + topojson-client for polygons
- SWR for client-side caching
- Jest + React Testing Library for unit tests
app/
├─ api/
│ ├─ facts/route.ts # OpenAI facts API
│ └─ geocode/route.ts # Google Geocode proxy
├─ layout.tsx
├─ page.tsx
components/
├─ Globe.tsx # 3D globe
├─ CountryPanel.tsx # Info side drawer
├─ SearchBox.tsx # Google Autocomplete
lib/
├─ topojson.ts # World topojson loader
├─ countryMap.ts # ISO/name mapping helpers
├─ openai.ts # OpenAI client wrapper
├─ cache.ts # In-memory LRU
└─ utils.ts # Camera tween helpers
store/
└─ useAppStore.ts # Zustand global state
public/
└─ textures/ # Globe textures
.env file to hold API keys (the .env file goes in the Globe-facts file):
OPENAI_API_KEY=your_openai_key_here
GOOGLE_MAPS_API_KEY=your_restricted_google_key_here-
Tiny countries (e.g. Monaco, Vatican) exist in dataset but can be hard to click.
-
OpenAI responses may vary slightly; schema is validated but facts are not “guaranteed”.
-
No permanent cache: redeploying clears in-memory cache.
- Refine the overall globe to look better
- Fix the issue with Russia (because its polygon crosses the 180 degree meridian, causing triangulation to draw long diagonal spikes across the globe.)
- Make selected countries stick out from teh globe like a lifted puzzle piece
- Add right click to move the globe orientation
- Add more countires to countryMap.ts