functions used there are :
function addData(locs) {
var index = Math.floor(Math.random() * locs.length) - 1;
var start_lat = locs[index].lat;
var start_lng = locs[index].lng;
var data_size = 1;
var start = Math.floor(Math.random() * locs.length) - 1;
if (start + data_size > locs.length) {
start = locs.length - data_size - 1;
}
var hue = Math.random();
var i;
for (i = start; i < start + data_size; i++) {
var obj = locs[i];
if (i != index) {
addTrack(25.2697, 55.3095, 28.6667, 77.2167, planetRadius, hue+.5);//delhi
addMarker(28.6667, 77.2167, planetRadius);
addTrack(25.2697, 55.3095, 35.6833, 51.4167, planetRadius, hue+.5);//terhan
addMarker(35.6833, 51.4167, planetRadius);
addTrack(25.2697, 55.3095, 51.0000, 9.0000, planetRadius, hue+.5);//germany
addMarker(51.0000, 9.0000, planetRadius);
addTrack(25.2697, 55.3095, 33.6667, 73.1667, planetRadius, hue+.5);//Islamabad
addMarker(33.6667, 73.1667, planetRadius);
addTrack(25.2697, 55.3095, 31.2000, 121.5000, planetRadius, hue+.5);//Shanghai,
addMarker(31.2000, 121.5000, planetRadius);
}
}
}
function addMarker(lat, lng, radius) {
var marker_mesh = new THREE.Mesh(markerGeom, markerMaterial);
var marker_position = latlngPosFromLatLng(lat, lng, radius);
marker_mesh.position.x = marker_position.x;
marker_mesh.position.y = marker_position.y;
marker_mesh.position.z = marker_position.z;
marker_mesh.name = “trackmarker”;
meshPlanet.add(marker_mesh);
}
function addTrackLine(spline, hue) {
var num_control_points = 32;
var i;
var colors = ;
var geometry = new THREE.Geometry();
var pos;
for (i = 0; i < num_control_points; i++) {
var index = i / num_control_points;
pos = spline.getPoint(index);
colors[i] = new THREE.Color(0xffffff);
colors[i].setHSV(hue, (1.0 - i / num_control_points), 1.0);
geometry.vertices.push(new THREE.Vector3(pos.x, pos.y, pos.z));
}
pos = spline.getPoint(1.0);
geometry.vertices.push(new THREE.Vector3(pos.x, pos.y, pos.z));
geometry.colors = colors;
var material = new THREE.LineBasicMaterial({
color: 0xffffff,
opacity: 1,
linewidth: 2
});
material.vertexColors = true;
var line = new THREE.Line(geometry, material);
line.name = “trackline”;
meshPlanet.add(line);
}
function addTrack(start_lat, start_lng, end_lat, end_lng, radius, hue) {
var num_control_points = 8;
var max_altitude = 500 + Math.random() * 1200;
var points = ;
var i;
for (i = 0; i < num_control_points + 1; i++) {
var arc_angle = i * 180.0 / num_control_points;
var arc_radius = radius + (Math.sin(latlngDeg2rad(arc_angle))) * max_altitude;
var latlng = latlngInterPoint(start_lat, start_lng, end_lat, end_lng, i / num_control_points);
var pos = latlngPosFromLatLng(latlng.lat, latlng.lng, arc_radius);
points.push(new THREE.Vector3(pos.x, pos.y, pos.z));
}
var spline = new THREE.SplineCurve3(points);
addTrackLine(spline, hue);
}