I’m trying to port a hack I made to display storm data a WebGL globe (http://www.chromeexperiments.com/detail/storm-tracks-webgl/) into Cesium.
I’ve been using Sandcastle and finding it very slow to render a small portion of the data. Before I carry on and make it look pretty, I wanted to improve the performance. Likely I’ve done something silly so another pair of eyes would be much appreciated. For example, I thought I could create a circle for each type of storm track up front and clone it as required but I wasn’t able to figure out how to do that.
Code I pasted into the “Circles & Ellipses” example within Sandcastle here:
require([
'Cesium',
'Widgets/Dojo/CesiumViewerWidget',
'http://callum.com/sandbox/webglex/storm_tracks_webgl/js/storms.js'
], function(
Cesium, CesiumViewerWidget)
{
"use strict";
function plotStorms(widget) {
var start_date_time = new Date(2012, 1, 1);
var end_date_time = new Date(2012, 12, 31);
var scene = widget.scene;
var ellipsoid = widget.ellipsoid;
var primitives = scene.getPrimitives();
for (var i = 0; i < storms.length; ++i) {
var storm_date_time = new Date(storms[i][1][2]).getTime();
if (storm_date_time >= start_date_time && storm_date_time <= end_date_time) {
var storm_name = storms[i][0].toString();
for (var j = 1; j < storms[i].length; ++j) {
var lat = storms[i][j][0];
var lng = storms[i][j][1];
var wind_kts = storms[i][j][3];
var plot_size = 1;
var plot_col = '#ffff00';
if (wind_kts <= 34)
{
plot_col = '#5ebaff';
plot_size = 1;
}
else
if (wind_kts >= 35 && wind_kts <= 63)
{
plot_col = '#00faf4';
plot_size = 2;
}
else
if (wind_kts >= 64 && wind_kts <= 82)
{
plot_col = '#ffffcc';
plot_size = 3;
}
else
if (wind_kts >= 83 && wind_kts <= 95)
{
plot_col = '#ffe775';
plot_size = 4;
}
else
if (wind_kts >= 96 && wind_kts <= 112)
{
plot_col = '#ffc140';
plot_size = 5;
}
else
if (wind_kts >= 113 && wind_kts <= 136)
{
plot_col = '#ff8f20';
plot_size = 6;
}
else
if (wind_kts >= 137)
{
plot_col = '#ff6060';
plot_size = 7;
}
var circle = new Cesium.Polygon();
circle.setPositions(
Cesium.Shapes.computeCircleBoundary(
ellipsoid,
ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(lng, lat)),
10000.0 + plot_size * 10000.0));
circle.material = Cesium.Material.fromType(scene.getContext(), 'Color');
circle.material.uniforms.color = Cesium.Color.fromCssColorString(plot_col);
primitives.add(circle);
}
}
}
}
var widget = new CesiumViewerWidget({});
widget.placeAt('cesiumContainer');
widget.startup();
plotStorms(widget);
Sandcastle.finishedLoading();
});
Many thanks in advance.
Cal.