Geometry and Appearances problem

Hello all,

In the examples below, it draws 2592 rectangles with unique color, then combine all the rectangles together to one geometry.

I debug through the code, and I saw that combining all the 2592 rectangles into one geometry is very time consuming. In my application, I need to draw way more than 2592 rectangles. So is there a way that I can only draw one geometry with a lot of different colors? Thanks in advance.

var widget = new Cesium.CesiumWidget('cesiumContainer');
var scene = widget.scene;

var instances = [];

for (var lon = -180.0; lon < 180.0; lon += 5.0) {
  for (var lat = -90.0; lat < 90.0; lat += 5.0) {
    instances.push(new Cesium.GeometryInstance({
      geometry : new Cesium.ExtentGeometry({
        extent : Cesium.Extent.fromDegrees(lon, lat, lon + 5.0, lat + 5.0)
      }),
      attributes : {
        color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromRandom({alpha : 0.5}))
      }
    }));
  }
}

scene.getPrimitives().add(new Cesium.Primitive({
  geometryInstances : instances,
  appearance : new Cesium.PerInstanceColorAppearance()
}));

This is a known issue. The problem is the overhead we incur for the way we are using web workers for background processing. Keep an eye on https://github.com/AnalyticalGraphicsInc/cesium/issues/1487. I may look into fixing this myself for the April release.

For now, you can try adding “asynchronous: false” to the Primitive constructor. This should speed it up a lot (at the penalty of locking up the application while it is doing so). For one set of data I have it decreased the processing time from 36 seconds to 4 seconds.

Hi Matt,

I tried as you said. It does improve the speed significantly. I am looking forward to the April release. Thanks a lot.

Steven

在 2014年3月1日星期六UTC-8下午4时54分14秒,Matthew Amato写道: