AnalyticalGraphicsInc/cesium — pull request #2223 by mramato (2014-10-24 03:06:01+00:00)
Title: More visualizer cleanup

While working on #2044 I discovered that loading CZML would call `removeAll` outside of `suspendUpdates`; which hurts performance. However, performing a `removeAll` while updates when suspended would cause duplicate primitives to appear in many of the visualizers (an obvious bug). This is because visualizers were storing data directly on entity instances, and if an entity was swapped (for another entity with the same id) inside of a suspend updates; it would lose track of the primitive created for that entity and it would just stay in the scene forever.

To replicate the above problem in master, take the minor edit to `CzmlDataSource` in this branch and then paste the below into Sandcastle. Every time you hit the button, the old primitives will remain in the scene in addition to new ones being created. This is not fixed in this branch for all visualizers that had this problem. It should also help performance since we're no longer changing the hidden class of an entity instance.

```
var gallery = '../../SampleData/';
var viewer = new Cesium.Viewer('cesiumContainer');

var czmlDataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(czmlDataSource);

Sandcastle.addDefaultToolbarButton('Satellites', function() {
czmlDataSource.loadUrl(gallery + 'simple.czml');
});
```