D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
mbostock
Full window
Github gist
Rotating Orthographic
<!DOCTYPE html> <meta charset="utf-8"> <style> path { fill: none; stroke-linejoin: round; } .sphere, .graticule { stroke: #aaa; } .equator { stroke: red; stroke-width: 2px; } </style> <body> <script src="//d3js.org/d3.v3.min.js"></script> <script> var width = 960, height = 500, rotate = [10, -10], velocity = [.003, -.001], time = Date.now(); var projection = d3.geo.orthographic() .scale(240) .translate([width / 2, height / 2]) .clipAngle(90 + 1e-6) .precision(.3); var path = d3.geo.path() .projection(projection); var graticule = d3.geo.graticule(); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); svg.append("path") .datum({type: "Sphere"}) .attr("class", "sphere") .attr("d", path); svg.append("path") .datum(graticule) .attr("class", "graticule") .attr("d", path); svg.append("path") .datum({type: "LineString", coordinates: [[-180, 0], [-90, 0], [0, 0], [90, 0], [180, 0]]}) .attr("class", "equator") .attr("d", path); var feature = svg.selectAll("path"); d3.timer(function() { var dt = Date.now() - time; projection.rotate([rotate[0] + velocity[0] * dt, rotate[1] + velocity[1] * dt]); feature.attr("d", path); }); </script>
https://d3js.org/d3.v3.min.js