|
@ -121,7 +121,6 @@ function init() { |
|
|
if (pos.x && pos.y && pos.z) { |
|
|
if (pos.x && pos.y && pos.z) { |
|
|
pingGeometry.translate(pos.x, pos.y, pos.z) |
|
|
pingGeometry.translate(pos.x, pos.y, pos.z) |
|
|
mergedGeometry.merge(pingGeometry) |
|
|
mergedGeometry.merge(pingGeometry) |
|
|
// Reset ping item position.
|
|
|
|
|
|
pingGeometry.translate(-pos.x, -pos.y, -pos.z) |
|
|
pingGeometry.translate(-pos.x, -pos.y, -pos.z) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -130,7 +129,7 @@ function init() { |
|
|
groups.tracePoints = total |
|
|
groups.tracePoints = total |
|
|
groups.tracePoints.name = 'Trace Points' |
|
|
groups.tracePoints.name = 'Trace Points' |
|
|
scene.add(groups.tracePoints) |
|
|
scene.add(groups.tracePoints) |
|
|
groups.tracePoints.rotation.y = groups.globePoints.rotation.y |
|
|
|
|
|
|
|
|
groups.tracePoints.rotation.y = groups.globePoints.rotation.y - 0.05 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
init.addTracePoints = addTracePoints; |
|
|
init.addTracePoints = addTracePoints; |
|
@ -146,9 +145,10 @@ function init() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function convertFlatCoordsToSphereCoords(x, y) { |
|
|
function convertFlatCoordsToSphereCoords(x, y) { |
|
|
// Convert latitude and longitude on the 90/180 degree axis.
|
|
|
|
|
|
let latitude = ((x - globeWidth) / globeWidth) * -180 |
|
|
let latitude = ((x - globeWidth) / globeWidth) * -180 |
|
|
let longitude = ((y - globeHeight) / globeHeight) * -90 |
|
|
let longitude = ((y - globeHeight) / globeHeight) * -90 |
|
|
|
|
|
latitude = (latitude * Math.PI) / 180 //(latitude / 180) * Math.PI
|
|
|
|
|
|
longitude = (longitude * Math.PI) / 180 //(longitude / 180) * Math.PI
|
|
|
const radius = Math.cos(longitude) * globeRadius |
|
|
const radius = Math.cos(longitude) * globeRadius |
|
|
const targetX = Math.cos(latitude) * radius |
|
|
const targetX = Math.cos(latitude) * radius |
|
|
const targetY = Math.sin(longitude) * globeRadius |
|
|
const targetY = Math.sin(longitude) * globeRadius |
|
@ -177,13 +177,16 @@ function init() { |
|
|
var projected = position.project(camera.object) |
|
|
var projected = position.project(camera.object) |
|
|
return { |
|
|
return { |
|
|
x: projected.x * width + width - contentWidth / 2, |
|
|
x: projected.x * width + width - contentWidth / 2, |
|
|
|
|
|
y: -(projected.y * height) + height - contentHeight - 10, // -10 for a small offset
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function returnCameraAngles(x, y) { |
|
|
function returnCameraAngles(x, y) { |
|
|
let targetAzimuthalAngle = ((x - globeWidth) / globeWidth) * Math.PI |
|
|
let targetAzimuthalAngle = ((x - globeWidth) / globeWidth) * Math.PI |
|
|
targetAzimuthalAngle = targetAzimuthalAngle + Math.PI / 2 |
|
|
targetAzimuthalAngle = targetAzimuthalAngle + Math.PI / 2 |
|
|
|
|
|
targetAzimuthalAngle += 0.3 |
|
|
let targetPolarAngle = (y / (globeHeight * 2)) * Math.PI |
|
|
let targetPolarAngle = (y / (globeHeight * 2)) * Math.PI |
|
|
|
|
|
targetPolarAngle += 0.1 // Add a small vertical offset
|
|
|
return { |
|
|
return { |
|
|
azimuthal: targetAzimuthalAngle, |
|
|
azimuthal: targetAzimuthalAngle, |
|
|
polar: targetPolarAngle, |
|
|
polar: targetPolarAngle, |
|
@ -221,6 +224,7 @@ function init() { |
|
|
function render() { |
|
|
function render() { |
|
|
renderer.render(scene, camera.object) |
|
|
renderer.render(scene, camera.object) |
|
|
requestAnimationFrame(render) |
|
|
requestAnimationFrame(render) |
|
|
|
|
|
//animate()
|
|
|
groups.globePoints.rotation.y += 0.01 |
|
|
groups.globePoints.rotation.y += 0.01 |
|
|
if (groups.tracePoints !== null) { |
|
|
if (groups.tracePoints !== null) { |
|
|
groups.tracePoints.rotation.y += 0.01 |
|
|
groups.tracePoints.rotation.y += 0.01 |
|
|