Profile
Back to NewsBack
GitHub Trending 2 min
Reader Mode
gkjohnson/three-geojson: Three.js shape loaders for GeoJSON and WKT formats

gkjohnson/three-geojson: Three.js shape loaders for GeoJSON and WKT formats

7 hours ago

three-geojson

build</a> github</a> twitter</a> sponsors</a>

Three.js shape loaders for GeoJSON (readable html) and WKT formats. Supports generation of three.js line geometry in addition to flat and extruded tringulated meshes. All generated geometry are transformed and centered using 64-bit Javascript floating point operations with meshes are offset to retain precision in GPU operations.

Uses @turfjs/unkink-polygon, @mapbox/delaunator, @kninnug/constrainautor, and @placemark/betterknown packages for polygon triangulation and WKT parsing. World GeoJSON file courtesy of geojson-maps.

Some key features supported by this project:

  • Support for detecting and fixing self-intersecting polygons so they tringulate correctly.
  • Uses constrained delaunay triangulation for correct, high quality triangulation and support for inner vertices.
  • Smooth surface normals are generated for ellipsoid-projected shapes.
  • Outputs centered geometry with and matrix transform offset to avoid preceision-related artifacts on CPU and GPU when processing high-detail shapes.
  • Supports altitude values.
[!NOTE]
This project is not hosted on npm and must be installed via Github repository.

Examples

WGS84 Lines

WGS84 Extruded Polygons

WGS84 Wireframe Polygons

Extruded Polygon

WKT Polygon

Installation

npm install github:@gkjohnson/three-geojson

Use

// load the content
const result = await new GeoJSON().loadAsync( url );

// extract polygon lines and project them onto the globe const transformer = new GeoJSONTransformer(); result.polygons.forEach( polygon => {

const line = polygon.getLineObject(); transformer.transformObject( line ); scene.add( line );

} );

API

See API.md for full API documentation.

Chat with me