fast construction and animation rendering of many entities (or primitives)

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

(And, making an EventListener function that changes all the primitives at each preRender, seems actually to be much slower.)

I totally agree with that. When dealing with such kind of things(a large time-series data), it's too slow. I hope Cesium development team fixed this problem.

Thanks very much confucius@gmail ! – I definitely agree, and also think that is probably an extremely challenging problem to solve in the general case, otherwise the very excellent Cesium development team would have solved it already.

Thinking a little more about this problem over the past week: I wonder if maybe instead of trying to visually represent fluid flow (winds, ocean currents, etc) in Cesium as numerous separate streak-like entities or primitives, for Cesium to possibly instead consider, and code, fluid flow streak pattern “masks” a bit more similarly to the animated water “terrain mask” that is available from Cesium TerrainProviders – but, of course, have such an animated “mask” take, as input, a planar spatial grid of 2D vectors, with each vector representing the 2D components of the (3D of course) fluid flow within the plane that one is visualizing. (And if one includes time-variability of the fluid flow patterns, then it should should be (2+1)D components, within the visualization plane, of the (3+1)D fluid flow, where the +1 dimension is time.)

Might there happen to be any AGI Cesium development team members who might possibly happen to be interested in this problem of visually representing fluid flow (winds, ocean currents, etc) within Cesium? – as it would be extremely helpful to have a contact or contacts “on the inside” to occasionally alpha-test one another’s code, to bounce ideas off, etc.

(By the way, in my particular case, this will be used for the flight control and monitoring system for the ALTAIR miniature stratospheric airship for telescope calibration – http://projectaltair.org – a U.S.-Canadian scientific collaboration.)

Thanks very much again!

Justin

hi Justin:
Did you solve this problem?

在 2016年9月21日星期三 UTC+8上午4:51:11,Justin Albert写道:

Hi all,

I think using the Primitive API over the Entity API would be the best bet here. I would suggest maybe updating the appearance attribute every few frames instead of very frame.

Thanks,

Gabby

hi Justin:
Did you solve this problem?

Apologies for the long delay in responding. I actually changed to utilizing wind streaks only in a 2D, non-Cesium viewer (I'm now additionally using https://www.windy.com/ , and so use Windy for the wind views), and using Cesium purely for the 3D, non-wind, viewing. I include my flight path in the 3D Cesium view, but I include the wind/fluid flow (at variable altitudes) only within the 2D Windy view.

The above is working for me, however I could imagine that different applications would most certainly still benefit from eventual full implementation of 4D fluid flow viewing within Cesium. (For example, the design of wind turbines, and/or ocean turbines, might definitely be able to utilize fully-implemented Cesium viewing of fluid flow. Also, for better understanding natural wind phenomena in realistic environments at various scales, like turbulence, tornados, or trade winds.)

cheers,
justin