Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mlemos/3dbay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Bay Area 3D Terrain Visualization

An interactive 3D visualization of the San Francisco Bay Area terrain using WebGL and Three.js. This web application transforms elevation data into an immersive, customizable 3D experience with real-time controls for visualization parameters, lighting, and rendering styles.

Bay Area 3D Terrain Visualization

Features

๐Ÿ”๏ธ Terrain Rendering

  • Multiple rendering modes: Voxels (3D blocks), Mesh (smooth surface), and Wireframe
  • Adjustable vertical exaggeration to emphasize topographical features
  • Quality settings from Low to Extreme for performance optimization
  • Gapless voxel rendering option for seamless terrain blocks

๐ŸŽจ Visual Customization

  • Multiple color schemes: HeyHo, Grayscale, Heatmap, Terrain, Ocean, Rainbow, Sunset
  • Sea level visualization: Scheme-based, solid color, or hidden
  • Adjustable opacity for water bodies
  • Background options: Gradient, solid color, or transparent sky view

๐Ÿ’ก Advanced Lighting

  • Ambient lighting with adjustable intensity and color
  • Directional lighting (sun) with angle and rotation controls
  • Hemisphere lighting for realistic sky/ground illumination
  • Shadow toggle for enhanced depth perception
  • Lighting presets: Noon, Sunset, Night, and Default

๐Ÿ“ธ Export & Sharing

  • Save as PNG with optional transparent background
  • Copy image to clipboard for quick sharing
  • Configuration export/import as JSON for saving and sharing exact views
  • Camera position tracking with real-time coordinate display

๐ŸŽฎ Navigation Controls

Mouse:

  • Left drag: Rotate view
  • Right drag: Pan camera
  • Scroll: Zoom in/out

Keyboard:

  • Arrow keys: Pan map
  • Shift + Arrows: Rotate view
  • Page Up/Down: Zoom in/out
  • U: Toggle UI on/off

Quick Start

  1. Clone the repository:
git clone https://github.com/mlemos/3dbay.git
cd 3dbay
  1. Open the application:

    • Simply open index.html in a modern web browser
    • The application automatically loads the included demo data (cropped_bayarea.tif)
    • No build process or server required (though a local server is recommended for better performance)
  2. Using a local server (recommended):

# Using Python 3
python -m http.server 8000

# Using Node.js (if http-server is installed)
npx http-server

# Then navigate to http://localhost:8000

Included Data Files

The repository includes two GeoTIFF elevation files for demonstration:

bayarea.tif (28 MB)

cropped_bayarea.tif (29 MB)

  • Source: Generated from bayarea.tif using the included crop.html tool
  • Coverage: Focused view of central Bay Area (San Francisco, Oakland, San Jose triangle)
  • Purpose: We created this cropped version to focus on our area of interest - the urban core and most dramatic topographical features
  • Benefits: Better performance while showcasing the Golden Gate, San Francisco Peninsula, East Bay hills, and South Bay
  • Process: Used the visual cropping tool to select and extract the most interesting portion of the full dataset

These files are included in the repository for immediate use. The application automatically loads cropped_bayarea.tif on startup, allowing you to explore the visualization without needing to prepare your own data.

Data Preparation

Using Your Own Data

The project includes crop.html for preparing your elevation data:

  1. Open crop.html in your browser
  2. Load a GeoTIFF elevation file
  3. Use the visual cropping tool to select your area of interest
  4. Export the cropped region for use in the main visualization

Supported Data Format

  • Format: GeoTIFF (.tif)
  • Type: Digital Elevation Model (DEM) data
  • Projection: Any standard projection (automatically parsed from GeoTIFF metadata)

Configuration

Saving and Loading Views

  1. Click "Copy Config" to save your current view settings to clipboard
  2. The configuration includes camera position, all control settings, and lighting
  3. Click "Paste Config" to restore a previously saved configuration

Example Configuration

{
  "camera": {
    "position": { "x": -541.2, "y": 385.2, "z": 62.4 },
    "target": { "x": -76.0, "y": -73.9, "z": -85.3 }
  },
  "controls": {
    "exaggeration": 0.2,
    "quality": 4,
    "colorScheme": "heyho",
    "renderMode": "voxel",
    "voxelGapless": true
  },
  "lighting": {
    "ambient": { "intensity": 60, "color": "#ffffff" },
    "directional": { 
      "intensity": 80, 
      "color": "#ffffff",
      "sunAngle": 45,
      "sunRotation": 45
    }
  },
  "version": "1.0",
  "timestamp": "2024-01-15T12:00:00.000Z"
}

Technical Details

Technologies Used

  • Three.js: 3D graphics rendering
  • WebGL: Hardware-accelerated graphics
  • GeoTIFF.js: Reading elevation data from GeoTIFF files
  • OrbitControls: Camera navigation
  • HTML5 Canvas: Image export functionality

Browser Requirements

  • Modern web browser with WebGL support
  • Recommended: Chrome, Firefox, Safari, or Edge (latest versions)
  • Sufficient GPU memory for large elevation datasets

Performance Tips

  • Start with "High" or "Ultra" quality for most datasets
  • Use "Low" or "Medium" quality for very large areas
  • Voxel mode is more GPU-intensive than mesh mode
  • Reduce quality if experiencing low frame rates

Data Attribution

Original elevation data provided by Stanford Earthworks

Development

This project is a single-page application with no build dependencies. The main components are:

  • index.html: Main 3D visualization application
  • crop.html: GeoTIFF cropping utility
  • CLAUDE.md: Development notes and technical documentation

Customization

The application can be easily customized by modifying the following in index.html:

  • Color schemes: Add new gradients in the getColorForElevation() function
  • Default settings: Modify initial values in the HTML control elements
  • Lighting presets: Add new presets in the lighting event handlers

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Developed by Manoel Lemos

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

Acknowledgments

  • Three.js community for the excellent 3D library
  • Stanford Earthworks for providing public elevation data
  • GeoTIFF.js contributors for enabling browser-based GeoTIFF processing
  • Claude Code for AI-assisted development and code optimization

About

3D visualization of the San Francisco Bay Area

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages