Svelte Globe App š
An interactive 3D Earth globe application built with Svelte, TypeScript, Vite, and Cesium.
Features
- š Interactive 3D Earth globe with zoom and rotation
- š Real-time camera position tracking
- š
Dynamic lighting based on sun/moon positions
- šØ Responsive design with information panels
- š§ Built with TypeScript for type safety
- š¾ Svelte stores for state management
Prerequisites
Before running this application, you'll need:
- Node.js (version 18 or higher)
- A Cesium Ion Access Token:
- Sign up at Cesium Ion
- Create a new access token
- Replace
'your-cesium-ion-access-token-here' in src/lib/GlobeViewer.svelte with your actual token
Getting Started
Install dependencies:
npm install
Configure Cesium Ion Token:
Start the development server:
npm run dev
Open your browser:
- Navigate to
http://localhost:5173
- You should see the interactive 3D globe!
Available Scripts
npm run dev - Start development server
npm run build - Build for production
npm run preview - Preview production build
npm run check - Run Svelte type checking
Project Structure
src/
āāā lib/
ā āāā GlobeViewer.svelte # Main Cesium globe component
āāā stores/
ā āāā globeStore.ts # Svelte store for globe state
āāā App.svelte # Main application component
āāā main.ts # Application entry point
āāā app.css # Global styles
Technologies Used
Usage
Interacting with the Globe
- Rotate: Click and drag to rotate the globe
- Zoom: Use mouse wheel or pinch gestures to zoom in/out
- Pan: Hold Shift + click and drag to pan
- Tilt: Hold Ctrl + click and drag to tilt the camera
Monitoring Camera Position
The application displays real-time camera position information including:
- Longitude and latitude coordinates
- Camera height above sea level
State Management
The app uses Svelte stores to manage:
- Globe viewer instance
- Loading states
- Error handling
- Camera position tracking
Customization
You can extend the application by:
- Adding data layers - Import GeoJSON, KML, or other data formats
- Custom styling - Modify terrain, imagery, or lighting
- Interactive features - Add markers, popups, or drawing tools
- Additional stores - Create new stores for specific features
Troubleshooting
Globe not loading
- Ensure your Cesium Ion access token is valid and properly configured
- Check browser console for error messages
- Verify internet connection for loading Cesium assets
- Reduce terrain detail level in viewer options
- Disable lighting for better performance on older devices
- Consider using imagery with lower resolution
License
This project is open source and available under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.