block by mbostock 3734168

Rotating Orthographic

Full Screen

index.html

<!DOCTYPE html>
<meta charset="utf-8">
<style>

circle {
  fill: none;
  stroke: #000;
  stroke-width: 2px;
}

</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>

var width = 960,
    height = 500,
    radius = 240;

var origin = [-71, 42],
    velocity = [.012, -.002],
    t0 = Date.now();

var projection = d3.geo.orthographic()
    .scale(radius)
    .clipAngle(90);

var path = d3.geo.path()
    .projection(projection);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

svg.append("circle")
    .attr("cx", width / 2)
    .attr("cy", height / 2)
    .attr("r", radius);

d3.json("/mbostock/raw/4090846/world-110m.json", function(error, world) {
  if (error) throw error;

  var feature = svg.append("path")
      .datum(topojson.feature(world, world.objects.land))
      .attr("d", path);

  d3.timer(function() {
    var t = Date.now() - t0;
    projection.rotate([origin[0] + velocity[0] * t, origin[1] + velocity[1] * t]);
    feature.attr("d", path);
  });
});

</script>