-
-
Save fasiha/5808405 to your computer and use it in GitHub Desktop.
BaseMap orthographic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"BaseMap orthographic","endpoint":"","display":"canvas","public":true,"require":[{"name":"topojson","url":"http://d3js.org/topojson.v0.min.js"},{"name":"d3.geo.projection","url":"http://d3js.org/d3.geo.projection.v0.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"world110.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"leap.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"fullscreen":false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://bl.ocks.org/4188334 | |
var world = tributary.world110; | |
var globe = {type: "Sphere"}; | |
var countries = topojson.object(world, world.objects.countries) | |
var projection = d3.geo.orthographic() | |
.scale(243) | |
.translate([495, 430]) | |
.rotate([-70, -30, 0]) | |
.clipAngle(90); | |
var context = tributary.ctx; | |
var path = d3.geo.path() | |
.projection(projection) | |
.context(context); | |
context.fillStyle = "#115311"; | |
context.beginPath(); | |
path(countries); | |
context.fill(); | |
context.strokeStyle = "#0D3500"; | |
context.beginPath(), path(globe), context.stroke(); | |
tributary.events.off("leap"); | |
tributary.events.on("leap", function(d) { | |
if(d.pointables[0] != undefined){ | |
tributary.clear(); | |
} | |
//console.log(d.pointables[0].tipPosition); | |
tip = d.pointables[0].tipPosition | |
var zoom = tip[2] | |
if( zoom > 100 ) { zoom = 100 } | |
else if ( zoom < 10 ) { zoom = 10 } | |
tip[2] = 0 | |
projection.rotate(tip) | |
projection.clipAngle(zoom) | |
path.projection(projection) | |
context.fillStyle = "#0B304D"; | |
context.beginPath(); | |
path(countries); | |
context.fill(); | |
context.beginPath(), path(globe), context.stroke(); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!tributary.leap) tributary.leap = {}; | |
var ws; | |
// Support both the WebSocket and MozWebSocket objects | |
if ((typeof(WebSocket) == 'undefined') && | |
(typeof(MozWebSocket) != 'undefined')) { | |
WebSocket = MozWebSocket; | |
} | |
// Create the socket with event handlers | |
tributary.leap.init = function() { | |
console.log("Starting"); | |
//Create and open the socket | |
ws = new WebSocket("ws://localhost:6437/"); | |
// On successful connection | |
ws.onopen = function(event) { | |
//document.getElementById("connection").innerHTML = "WebSocket connection open!"; | |
//$("#textoutput").html("Open...") | |
console.log("Open"); | |
}; | |
// On message received | |
ws.onmessage = function(event) { | |
tributary.events.trigger("leap", JSON.parse(event.data)); | |
}; | |
// On socket close | |
ws.onclose = function(event) { | |
ws = null; | |
} | |
//On socket error | |
ws.onerror = function(event) { | |
alert("Received error"); | |
}; | |
} | |
//control flow. we don't want to reinit | |
if(!tributary.leap.initialized) { | |
tributary.leap.init(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment