Add fading for olders nodes
This commit is contained in:
parent
d253493359
commit
04d63d393d
2 changed files with 16 additions and 5 deletions
|
@ -37,6 +37,11 @@ public class API{
|
||||||
obj.put("lat",node.getLatitude());
|
obj.put("lat",node.getLatitude());
|
||||||
obj.put("lng",node.getLongitude());
|
obj.put("lng",node.getLongitude());
|
||||||
obj.put("type",service.getType());
|
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);
|
points.put(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,13 @@ const POINT_RADIUS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
globe.pointAltitude(point => POINT_ALTITUDE[point.type]);
|
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.pointLabel(point => point.label);
|
||||||
globe.pointRadius(point => POINT_RADIUS[point.type]);
|
globe.pointRadius(point => POINT_RADIUS[point.type]);
|
||||||
|
|
||||||
|
@ -117,10 +123,10 @@ function updateGlobe(){
|
||||||
fetch('/api')
|
fetch('/api')
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
data = json;
|
data = json;
|
||||||
updatePointsData(json.points);
|
updatePointsData(json.points);
|
||||||
globe.arcsData(json.arcs);
|
globe.arcsData(json.arcs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(updateGlobe,1_000);
|
setInterval(updateGlobe,1_000);
|
||||||
|
|
Loading…
Add table
Reference in a new issue