forked from jdomingu/ThreeGeoJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
98 lines (83 loc) · 3.3 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<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>
<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 );
//Add lighting
scene.add(new THREE.AmbientLight(0x333333));
//Create a sphere to make visualization easier.
var geometry = new THREE.SphereGeometry(10,32,32);
var material = new THREE.MeshPhongMaterial({
wireframe: true,
transparent: true
});
var sphere = new THREE.Mesh(geometry, material);
scene.add(sphere);
//Draw the GeoJSON
// var test_json = $.getJSON("test_geojson/countries_states.geojson", function (data) {
// drawThreeGeo(data, 10, 'sphere', {
// color: 'red'
// })
// });
var test_json = $.getJSON("data_unzipped/ethnicity/Water.geojson", function (data) {
drawThreeGeo(data, 10, 'sphere', {
color: 'blue',
blending: THREE.AdditiveBlending,
transparent: true,
opacity: 0.3
})
});
var pointSets = [
{
name: "Indigenous",
colour: "red"
},
{
name: "Other",
colour: "white"
},
{
name: "Aus-NZ",
colour: "green"
},
];
for (var i in pointSets) {
var name = pointSets[i].name;
var colour = pointSets[i].colour;
var test_json = $.getJSON("data_unzipped/ethnicity/" + name + ".geojson", function (data) {
drawThreeGeo(data, 10, 'sphere', {
color: colour,
blending: THREE.AdditiveBlending,
transparent: true,
opacity: 0.7,
sizeAttenuation: false
})
});
}
//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>