GeoJSON in Three.js
A rotating three-dimensional wireframe globe renders world landmasses in red over a gray graticule grid, animated via Three.js WebGL. The code loads world-atlas TopoJSON, converts it to a GeoJSON mesh with topojson.mesh, and maps longitude/latitude coordinates to Cartesian points on a sphere. A spherical MultiLineString graticule is built manually, and both layers use Three.js LineSegments with LineBasicMaterial, rotated continuously by d3.timer.
AI-generated descriptionThis example demonstrates how to display a GeoJSON MultiLineString geometry object as a wireframe using Three.js. Each point in the GeoJSON is converted from spherical coordinates (longitude and latitude in degrees) to three-dimensional Cartesian coordinates as follows:
<blockquote> <i>x</i> = <i>cos</i>(<i>φ</i>)<i>cos</i>(<i>λ</i>) <br><i>y</i> = <i>cos</i>(<i>φ</i>)<i>sin</i>(<i>λ</i>) <br><i>z</i> = <i>sin</i>(<i>φ</i>) </blockquote>GeoJSON is often represented in equirectangular coordinates, which are planar rather than spherical. A visual artifact of this is extra lines along the antimeridian. You can convert equirectangular coordinates to spherical coordinates using d3.geoStitch; the world-atlas TopoJSON used in this example is already stitched. See also antimeridian cutting.