|
|
@ -7,11 +7,13 @@ function init() { |
|
|
|
const globeSegments = 64 |
|
|
|
const globeWidth = 4098 / 2 |
|
|
|
const globeHeight = 1968 / 2 |
|
|
|
const traceSteps = 10; |
|
|
|
|
|
|
|
const groups = { |
|
|
|
globe: null, |
|
|
|
globePoints: null, |
|
|
|
tracePoints: null, |
|
|
|
traceLines: null, |
|
|
|
} |
|
|
|
|
|
|
|
let data, scene, renderer, globe |
|
|
@ -109,6 +111,7 @@ function init() { |
|
|
|
|
|
|
|
|
|
|
|
function addTracePoints(tracepoints) { |
|
|
|
console.log(tracepoints); |
|
|
|
const mergedGeometry = new THREE.Geometry() |
|
|
|
const pingGeometry = new THREE.SphereGeometry(1.9, 5, 5) |
|
|
|
const material = new THREE.MeshBasicMaterial({ |
|
|
@ -130,8 +133,66 @@ function init() { |
|
|
|
groups.tracePoints.name = 'Trace Points' |
|
|
|
scene.add(groups.tracePoints) |
|
|
|
groups.tracePoints.rotation.y = groups.globePoints.rotation.y - 0.05 |
|
|
|
//drawTraceLines(tracepoints);
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
function calculateLine(a, b) { |
|
|
|
var line = []; |
|
|
|
if (a < b) { |
|
|
|
var step = (a - b) / (traceSteps - 1); |
|
|
|
} else { |
|
|
|
var step = (b - a) / (traceSteps - 1); |
|
|
|
} |
|
|
|
var k; |
|
|
|
for (k = 0; k < traceSteps ; k++) { |
|
|
|
line.push(a + (step * k)); |
|
|
|
} |
|
|
|
return line; |
|
|
|
} |
|
|
|
|
|
|
|
function drawTraceLines(tracepoints) { |
|
|
|
const mergedGeometry = new THREE.Geometry() |
|
|
|
const pingGeometry = new THREE.SphereGeometry(1.9, 5, 5) |
|
|
|
const material = new THREE.MeshBasicMaterial({ |
|
|
|
color: '#FF4c4c', |
|
|
|
}) |
|
|
|
|
|
|
|
var i; |
|
|
|
for (i = 0; i < tracepoints.points.length; i++) { |
|
|
|
|
|
|
|
if (typeof tracepoints.points[i+1] === 'undefined') { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
var x1 = tracepoints.points[i].x; |
|
|
|
var x2 = tracepoints.points[i+1].x; |
|
|
|
xarray = calculateLine(x1, x2); |
|
|
|
|
|
|
|
var y1 = tracepoints.points[i].y; |
|
|
|
var y2 = tracepoints.points[i+1].y; |
|
|
|
yarray = calculateLine(y1, y2); |
|
|
|
|
|
|
|
var j; |
|
|
|
for (j = 0; j < xarray.length; j++) { |
|
|
|
const pos = convertLatLngToSphereCoords(xarray[j], yarray[j]) |
|
|
|
if (pos.x && pos.y && pos.z) { |
|
|
|
pingGeometry.translate(pos.x, pos.y, pos.z) |
|
|
|
mergedGeometry.merge(pingGeometry) |
|
|
|
pingGeometry.translate(-pos.x, -pos.y, -pos.z) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const total = new THREE.Mesh(mergedGeometry, material) |
|
|
|
groups.traceLines = total |
|
|
|
groups.traceLines.name = 'Trace Lines' |
|
|
|
scene.add(groups.traceLines) |
|
|
|
groups.traceLines.rotation.y = groups.globePoints.rotation.y - 0.05 |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
init.addTracePoints = addTracePoints; |
|
|
|
|
|
|
|
|
|
|
@ -229,6 +290,11 @@ function init() { |
|
|
|
if (groups.tracePoints !== null) { |
|
|
|
groups.tracePoints.rotation.y += 0.01 |
|
|
|
} |
|
|
|
/* |
|
|
|
if (groups.traceLines !== null) { |
|
|
|
groups.traceLines.rotation.y += 0.01 |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|