block by mpmckenna8 1ab475821058c206a948

Gnomic projection rotating around North Pole d3.js

Full Screen

This is more or less what I was trying to do with the first transitioning gnomic projection example but I backtracked and tried to make use of this d3.timer() thing. I want to experiment changing the values I give to projection.rotate() and also see if I can figure out how to done rotate it a bit smoother using transitions or tweens or some such thing.

See these other poorly done gnomic d3 attempts:

I pretty much stole the rotating function in d3.timer() from http://bl.ocks.org/mbostock/5731578 which looks much smoother with a spherical (round) projections. I don’t really know what I’m talking about yet though and need to do some more research and experimenting.

index.html

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

.graticule {
  fill: none;
  stroke: rgb(243, 255, 107);
  stroke-width: 1.5px;
  stroke-opacity: .5;
}

.land {
  fill: rgb(229, 110, 255);
}

.boundary {
  fill: none;
  stroke:rgb(229, 110, 255);
  stroke-width: .5px;
}

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

var width = 960,
    height = 960,

// should try changing the rotate values. think first at 0 stops rolling hemispheres, tho I kind of like that.
        rotate = [5, -90],
    velocity = [.003, 0.000],
    time = Date.now();



var projection = d3.geo.gnomonic()
    .clipAngle(90 - 1e-3)
    .scale(150)
    .translate([width/2, height / 2])
    .precision(.1)
    // rotate([yaw, pitch, roll]) or long lat and roll
// This was unnecessary    .rotate([0,0 ,25])
  //  .center([-240,20])


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(graticule)
    .attr("class", "graticule")
    .attr("d", path);

d3.json("/mpmckenna8/raw/9965876/world-50m.json", function(error, world) {
  svg.insert("path", ".graticule")
      .datum(topojson.feature(world, world.objects.land))
      .attr("class", "land")
      .attr("d", path);

  svg.insert("path", ".graticule")
      .datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; }))
      .attr("class", "boundary")
      .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);
})




          d3.selectAll('.land')
            .transition()
            .delay(699)
            .duration(69999)
            .style("fill","rgb(108, 255, 110)");

});

d3.select('svg')
  .style('background', 'rgb(108, 129, 255)')

d3.select(self.frameElement).style("height", height + "px");








</script>