A Next.js application that displays an interactive 3D globe of Earth with country boundaries, coordinate mapping, and advanced lighting controls.
- Realistic Earth texture with country boundaries
- Place markers at specific latitude/longitude coordinates
- Interactive lighting controls to adjust the globe's appearance
- Markers can be sized based on data values (e.g., population)
- Interactive markers that display information on click
- Fully rotatable and zoomable 3D globe
- Responsive design that works on different screen sizes
First, install the dependencies:
npm install
# or
yarn installThen, run the development server:
npm run dev
# or
yarn devOpen http://localhost:3000 with your browser to see the result.
Click the "Show Lighting Controls" button in the top-right corner to access the lighting control panel. You can adjust:
- Ambient light (overall scene illumination)
- Directional light (sun-like directional light)
- Hemisphere light (sky and ground colors)
After making adjustments, click "Apply Lighting Changes" to see the results.
The application exposes several functions through the browser console:
-
addCoordinateMarker(latitude, longitude, name, value, color)- Add a new marker at the specified coordinates
- Parameters:
latitude: Latitude in decimal degrees (e.g., 40.7128)longitude: Longitude in decimal degrees (e.g., -74.0060)name: Location name (e.g., "New York")value: Numeric value that determines marker size (e.g., population)color: Hexadecimal color value (optional, default is red)
-
updateMarkerData(marker, newData)- Update an existing marker's data
- Parameters:
marker: The marker object returned byaddCoordinateMarkernewData: Object containing properties to update (e.g.,{value: 10000000, color: 0x00ff00})
-
adjustLighting(options)- Update the globe's lighting settings
- Parameters:
options: Object containing lighting properties to update
Open your browser's console and try:
// Add a new marker for Berlin
const berlinMarker = addCoordinateMarker(52.5200, 13.4050, "Berlin", 3769000, 0x00ffff);
// Later, update the marker's data
updateMarkerData(berlinMarker, {
value: 4000000, // Update the value
color: 0xff00ff // Change the color
});
// Adjust lighting
adjustLighting({
ambientIntensity: 0.5,
directionalIntensity: 1.2,
directionalPosition: { x: -5, y: 8, z: 2 }
});- Next.js
- React
- Three.js for 3D rendering
- D3.js and TopoJSON for geographical data