forked from jdomingu/ThreeGeoJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
72 lines (60 loc) · 2.25 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<html>
<head>
<title>ThreeGeoJSON Demo</title>
<script src="lib/threeGeoJSON.js"></script>
<!-- Three.js library, movement controls, and jquery for the geojson-->
<script src="lib/three.min.js"></script>
<script src="lib/TrackballControls.js"></script>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<style>
html, body {
padding: 0;
margin: 0;
}
</style>
<script type="text/JavaScript">
//New scene and camera
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.5, 1000);
//New Renderer
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var planet = new THREE.Object3D();
//Create a sphere to make visualization easier.
var geometry = new THREE.SphereGeometry(10, 32, 32);
var material = new THREE.MeshBasicMaterial({
color: 0x333333,
wireframe: true,
transparent: true
});
var sphere = new THREE.Mesh(geometry, material);
planet.add(sphere);
//Draw the GeoJSON
$.getJSON("test_geojson/countries.json", function(data) {
drawThreeGeo(data, 10, 'sphere', {
color: 0x80FF80
}, planet);
});
$.getJSON("test_geojson/rivers.geojson", function(data) {
drawThreeGeo(data, 10, 'sphere', {
color: 0x8080FF
}, planet);
});
scene.add(planet);
//Set the camera position
camera.position.z = 20;
//Enable controls
var controls = new THREE.TrackballControls(camera);
//Render the image
function render() {
controls.update();
requestAnimationFrame(render);
renderer.render(scene, camera);
}
render();
</script>
</body>
</html>