Browse Source

thing

master
root 5 years ago
parent
commit
6d7dae29d2
2 changed files with 28 additions and 4 deletions
  1. +7
    -3
      js/animations.js
  2. +21
    -1
      php/traceroute.php

+ 7
- 3
js/animations.js View File

@ -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


+ 21
- 1
php/traceroute.php View File

@ -20,12 +20,32 @@ function ip2geo ($host) {
} }
} }
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$data = array("points" => array()); $data = array("points" => array());
$traceroute = ""; $traceroute = "";
function traceroute() { function traceroute() {
global $data, $traceroute; global $data, $traceroute;
$traceroute = shell_exec("traceroute google.com");
$traceroute = shell_exec("traceroute " . get_client_ip());
$first = true; $first = true;
foreach(preg_split("/((\r?\n)|(\r\n?))/", $traceroute) as $line){ foreach(preg_split("/((\r?\n)|(\r\n?))/", $traceroute) as $line){


Loading…
Cancel
Save