UNPKG

earthjs

Version:

D3 Earth JS using SVG, Canvas & THREE js, build with some plugins.

42 lines (41 loc) 1.78 kB
<!DOCTYPE html> <html> <head> <link type="text/css" rel="stylesheet" href="../css/earthjs.css"> <script type='text/javascript' src="../js/d3.min.js"></script> <script type='text/javascript' src='../js/three.min.js'></script> <script type='text/javascript' src="../js/topojson.min.js"></script> <script type='text/javascript' src='../js/earthjs.js'></script> </head> <body> <svg id="earth-js"></svg> <canvas id="three-js"></canvas> <canvas class="ej-canvas"></canvas> <script> const {offsetWidth, offsetHeight} = d3.select('body').node(); const g = earthjs({width: offsetWidth, height: offsetHeight, padding:5}) .register(earthjs.plugins.inertiaPlugin()) .register(earthjs.plugins.threejsPlugin()) .register(earthjs.plugins.autorotatePlugin()) .register(earthjs.plugins.world3dThreejs2('../d/countries.geo.json','../images/wgreen.jpg',0.9)) .register(earthjs.plugins.worldThreejs('../d/world-110m.json')) .register(earthjs.plugins.oceanThreejs()) .register(earthjs.plugins.graticuleThreejs()) .register(earthjs.plugins.iconsThreejs('../data/bars.json','../globe/check.svg')) .register(earthjs.plugins.barThreejs('../data/bars.json')); g.barThreejs.ready = function(err, json) { json.features.forEach(function(d) { d.geometry.value = d.properties.mag; }); g.barThreejs.data(json); }; g.ready(function(){ g.create(); var ocean = g.oceanThreejs.sphere(); ocean.scale.set(0.945,0.945,0.945); ocean.material.transparent = true; // g.graticuleThreejs.sphere().scale.set(0.945,0.945,0.945); }) </script> </body> </html>