AnalyticalGraphicsInc/cesium — pull request #1902 by mramato (2014-07-09 21:08:03+00:00)
Title: Prevent geometry flashing when re-batching primitives

When we need to rebatch "static" primitives, for example because an object has gone from solid to translucent or the data sources performed an update; the old primitives would be removed but the new primitives would not show up until they were ready. This caused it to look like the data was flashing on/off as it was being processed.

This change simply keeps the old primitive around until the new one is ready. It also needed to tweak `Primitive.show` in order to actually cause geometry to be created when the show was set to false.

Also use `Primitive.ready` where appropriate instead of the private variable.

Here's some CZML to demonstrate this. In `master`, if you start at the earliest time and then click anywhere else on the timeline (no need to animate) you'll see several of the primitives blink. This no longer happens in this branch.

```
[
{
"id":"document",
"clock":{
"interval":"2010-11-12T17:00:00Z/2010-11-13T17:00:00Z",
"currentTime":"2010-11-12T17:00:00Z",
"range":"LOOP_STOP",
"step":"SYSTEM_CLOCK_MULTIPLIER"
}
},
{
"id":"solid",
"position":{
"cartographicDegrees":[0.0, 0.0, 0.0]
},
"label":{"text":"solid", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":2000,
"semiMinorAxis":1000,
"material":{"solidColor":{"color":{"rgba":[255,255,0,255]}}},
"outline":true,
"outlineColor":{"rgba":[0,0,0,255]}
}
},
{
"id":"translucent",
"position":{
"cartographicDegrees":[0.05, 0.0, 0.0]
},
"label":{"text":"translucent", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":2000,
"semiMinorAxis":1000,
"material":{"solidColor":{"color":{"rgba":[255,255,0,128]}}},
"outline":true,
"outlineColor":{"rgba":[0,0,0,128]}
}
},
{
"id":"extrudedsolid",
"position":{
"cartographicDegrees":[0.0, 0.05, 0.0]
},
"label":{"text":"solid", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":2000,
"semiMinorAxis":1000,
"material":{"solidColor":{"color":{"rgba":[255,255,0,255]}}},
"outline":true,
"outlineColor":{"rgba":[0,0,0,255]},
"extrudedHeight":1000
}
},
{
"id":"extrudedtranslucent",
"position":{
"cartographicDegrees":[0.05, 0.05, 0.0]
},
"label":{"text":"translucent", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":2000,
"semiMinorAxis":1000,
"material":{"solidColor":{"color":{"rgba":[255,255,0,128]}}},
"outline":true,
"outlineColor":{"rgba":[0,0,0,255]},
"extrudedHeight":1000
}
},
{
"id":"extrudedsolidNoOutline",
"position":{
"cartographicDegrees":[0.0, 0.1, 0.0]
},
"label":{"text":"solid no outline", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":2000,
"semiMinorAxis":1000,
"material":{"solidColor":{"color":{"rgba":[255,255,0,255]}}},
"outline":false,
"extrudedHeight":1000
}
},
{
"id":"extrudedtranslucentNoOutline",
"position":{
"cartographicDegrees":[0.1, 0.1, 0.0]
},
"label":{"text":"translucent no outline", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":2000,
"semiMinorAxis":1000,
"material":{"solidColor":{"color":{"rgba":[255,255,0,128]}}},
"outline":false,
"extrudedHeight":1000
}
},
{
"id":"solidToTranslucent",
"position":{
"cartographicDegrees":[0.1, 0.0, 0.0]
},
"label":{"text":"solid to translucent", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":2000,
"semiMinorAxis":1000,
"material":{
"solidColor":{
"color":{
"interval":"2010-11-12T17:00:00Z/2010-11-13T17:00:00Z",
"interpolationAlgorithm":"LINEAR",
"interpolationDegree":1,
"rgba":["2010-11-12T17:00:00Z",0,128,0,255,
"2010-11-13T17:00:00Z",0,128,0,0]
}
}
},
"outline":true,
"outlineColor":{
"interval":"2010-11-12T17:00:00Z/2010-11-13T17:00:00Z",
"interpolationAlgorithm":"LINEAR",
"interpolationDegree":1,
"rgba":["2010-11-12T17:00:00Z",0,128,0,255,
"2010-11-13T17:00:00Z",0,128,0,0]
}
}},
{
"id":"dynamic",
"position":{
"cartographicDegrees":[0.1, 0.05, 0.0]
},
"label":{"text":"dynamic", "eyeOffset":{"cartesian":[0,0,-10000]}},
"ellipse":{
"semiMajorAxis":{
"number":["2010-11-12T17:00:00Z",2000,"2010-11-13T17:00:00Z",1000]
},
"semiMinorAxis":{
"number":["2010-11-12T17:00:00Z",1000,"2010-11-13T17:00:00Z",100]
},
"material":{"solidColor":{"color":{"rgba":[255,255,0,255]}}},
"outline":true,
"outlineColor":{"rgba":[0,0,0,255]},
"height":{
"number":["2010-11-12T17:00:00Z",0,"2010-11-13T17:00:00Z",5000]
},
"extrudedHeight":{
"number":["2010-11-12T17:00:00Z",10000,"2010-11-13T17:00:00Z",5000]
}
}
}
]
```