Add fading for olders nodes

This commit is contained in:
Ben van Hartingsveldt 2025-07-11 18:11:22 +02:00
parent d253493359
commit 04d63d393d
No known key found for this signature in database
GPG key ID: 261AA214130CE7AB
2 changed files with 16 additions and 5 deletions

View file

@ -37,6 +37,11 @@ public class API{
obj.put("lat",node.getLatitude());
obj.put("lng",node.getLongitude());
obj.put("type",service.getType());
long ttl = (300_000-(System.currentTimeMillis()-service.getLastSeen()));
if(ttl<0){
ttl = 0;
}
obj.put("ttl",ttl/1000);
points.put(obj);
}
}

View file

@ -49,7 +49,13 @@ const POINT_RADIUS = {
};
globe.pointAltitude(point => POINT_ALTITUDE[point.type]);
globe.pointColor(point => POINT_COLOR[point.type]);
globe.pointColor(function(point){
var color = POINT_COLOR[point.type];
if(point.ttl!==undefined){
color += Math.round(point.ttl/300*256).toString(16).padStart(2,'0');
}
return color;
});
globe.pointLabel(point => point.label);
globe.pointRadius(point => POINT_RADIUS[point.type]);
@ -117,10 +123,10 @@ function updateGlobe(){
fetch('/api')
.then(resp => resp.json())
.then(json => {
data = json;
updatePointsData(json.points);
globe.arcsData(json.arcs);
});
data = json;
updatePointsData(json.points);
globe.arcsData(json.arcs);
});
}
setInterval(updateGlobe,1_000);