DEV Community

Cover image for ๐ŸŒ How I Built a Real-Time 3D Earth That Knows Where You Are โ€” In Just One Weekend
Raj Aryan
Raj Aryan

Posted on

๐ŸŒ How I Built a Real-Time 3D Earth That Knows Where You Are โ€” In Just One Weekend

Imagine a website that loads a live, glowing Earthโ€ฆ then immediately points to where you are in the world โ€” in real time.

Thatโ€™s exactly what I built last weekend using JavaScript, Globe.gl, and a bit of UI magic.


๐Ÿ”— Live Project & GitHub


๐Ÿš€ The Goal

I wanted to build a lightweight, modern, and interactive 3D Earth that:

  • Rotates in real time
  • Shows your live location
  • Looks clean and stylish (glassmorphism FTW ๐Ÿ’Ž)
  • Can be used as a portfolio feature, landing page, or just a cool visualization

๐Ÿ› ๏ธ Stack & Tools

Tool Purpose
Globe.gl 3D Earth visualization (built on top of Three.js)
HTML/CSS UI + layout
JavaScript Logic + geolocation
Netlify Deployment

๐Ÿงฑ Step-by-Step Breakdown

1. Set Up the Globe ๐ŸŒŽ

I started with Globe.gl, which makes it super simple to render a fully interactive 3D globe with bump mapping and atmosphere.

const world = Globe()(document.getElementById('container'))
  .globeImageUrl('earth-dark.jpg')
  .bumpImageUrl('earth-topology.png')
  .showAtmosphere(true)
  .atmosphereColor('#3a228a')
  .backgroundColor('#000');
Enter fullscreen mode Exit fullscreen mode

One line of setup = fully functional Earth.


2. Add Geolocation ๐Ÿ“

Next, I used the browser's native navigator.geolocation API to fetch the userโ€™s live latitude and longitude.

navigator.geolocation.getCurrentPosition(position => {
  const { latitude, longitude } = position.coords;
  addMarker(latitude, longitude);
});
Enter fullscreen mode Exit fullscreen mode

If permissions were denied, I defaulted to New Delhi.

Then, I mapped those coordinates to the globe and added a red point marker using Globe.gl's .pointsData() method.


3. Add a Modern UI with Glassmorphism ๐ŸงŠ

I styled the navbar and footer using backdrop-filter and translucent RGBA backgrounds to create a glassmorphism effect.

nav {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.05);
}
Enter fullscreen mode Exit fullscreen mode

The result? Clean, modern, and layered UI โ€” and no external UI libraries needed!


4. Sign It Like a Developer-Artist โœ๏ธ

To make the project feel more personal, I added a floating signature in cursive font at the bottom right.

<div class=\"signature\">Er Raj Aryan</div>
Enter fullscreen mode Exit fullscreen mode
.signature {
  font-family: 'Great Vibes', cursive;
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.15);
  transform: rotate(-10deg);
}
Enter fullscreen mode Exit fullscreen mode

Itโ€™s subtle. But trust me โ€” it leaves a lasting impression.


โœจ Final Result

  • โœ… Real-time location detection
  • โœ… 3D rotating Earth
  • โœ… Atmosphere & lighting
  • โœ… Glassmorphism UI
  • โœ… Floating signature watermark

๐Ÿ“ฆ What You Can Build With It

This isnโ€™t just eye candy. This project can be the foundation for other ideas like:

  • Live website visitor tracking (with server-side data)
  • Geolocation-based portfolio
  • Day/night zone simulation
  • 3D story-driven landing page

๐Ÿ“˜ What I Learned

  • High-level libraries like Globe.gl save time and headaches
  • CSS details matter (glassmorphism was a win here)
  • You donโ€™t need React or Vue for every project
  • Finishing touches (like a signature) make your work memorable

๐ŸŒ Try It Yourself

๐ŸŽฏ Live Demo: https://realtime-geo.netlify.app
๐Ÿ“ GitHub: https://github.com/er-raj-aryan/realtime-geo


๐Ÿง  Got Feedback?

Iโ€™d love to hear your thoughts โ€” or see your remixed version of this. Fork it, tweak it, and tag me if you do something cool!

And if you liked this breakdown, consider following me here for more front-end experiments like this. ๐Ÿ™Œ

Top comments (0)