Hi,
I’m new to Cesium, so apologies in advance for what is likely a naive question. Also, I’ve begun a task which will probably be a very large challenge (but might be useful for other people, as well as being needed for my work): I’d like to implement both access to, and some facility for visualization of, both real-time and forecast wind information in Cesium (from online NOAA information), basically somewhat similar to the globe at:
but, of course, within the full GIS Earth visualization capability, and API access, that Cesium has.
Being new to Cesium, I started out just drawing some random animated streaks, and the following Sandcastle code works (although is slow):
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var start = Cesium.JulianDate.fromDate(new Date(viewer.clock.currentTime));
var stop = Cesium.JulianDate.addSeconds(start, 19, new Cesium.JulianDate());
viewer.clock.startTime = start.clone();
viewer.clock.stopTime = stop.clone();
viewer.clock.currentTime = start.clone();
viewer.timeline.zoomTo(start, stop);
function computePos(initialLat,initialLong) {
var thePos = new Cesium.SampledPositionProperty();
for (var i = 0; i < 20; ++i) {
var time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate());
var position = Cesium.Cartesian3.fromDegrees(initialLong, initialLat + i, 100000);
thePos.addSample(time,position);
}
return thePos;
}
function computeCol(fadeFactor,delayTime) {
var theCol = new Cesium.SampledProperty(Cesium.Color);
for (var i = 0; i < 20; ++i) {
var time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate());
var color = Cesium.Color.WHITE.withAlpha(fadeFactorMath.max(0.0,Math.min(1.0,0.2(i+1),0.3*(19-i-delayTime))));
theCol.addSample(time,color);
}
return theCol;
}
for (var j = 0; j < 17; ++j) {
for (var k = 0; k < 45; ++k) {
var delayTime = Cesium.Math.nextRandomNumber() * 12.0;
for (var i = 0; i < 10; ++i) {
var segPositions = new Cesium.PositionPropertyArray([computePos(-90+(10j)+(0.5i),-180+(8k)),computePos(-90+(10j)+(0.5*(i+1)),-180+(8*k))]);
var sampledColor = new Cesium.ColorMaterialProperty(computeCol(0.1*(i+1),delayTime));
var streakSegment = viewer.entities.add({
polyline : {
positions : segPositions,
material : sampledColor,
width : 1
}
});
}
}
}
My question is: might there be a way of doing what the above does, that might possibly run a bit faster? The Primitive interface supports a per-instance color attribute, which would probably be helpful in the above case, but I have tried making a set of animated primitives that does what the above does, and so far not been successful. (And, making an EventListener function that changes all the primitives at each preRender, seems actually to be much slower.)
If not – i.e. if the above is pretty much as fast as code which does what the above does can get – then that’s fine, and I’ll just keep working on getting access to the NOAA data.
Thanks very much to all in advance!
Justin