Gents,
I need to redraw multiple circles and lines (nearly) each frame.
For maximum performance I want to combine them all into one primitive with PerInstanceColorAppearance.
It looks like while SimplePolylineGeometry works with PerInstanceColorAppearance, PolylineGeometry doesn’t.
And SimplePolylineGeometry doesn’t support line width.
Thus, I need to split geometries into two primitives:
-
CircleGeometry and SimplePolylineGeometry (for thin lines) with PerInstanceColorAppearance
-
PolylineGeometry (for thick lines) with PolylineColorAppearance (and fill “colors” with the same color for single-color polylines)
Are my findings correct?
Can you propose a better solution?
Thank you.
var geometryType = Cesium.SimplePolylineGeometry
// un-comment this and the line is not drawn anymore
// var geometryType = Cesium.PolylineGeometry
var viewer = new Cesium.Viewer(‘cesiumContainer’);
viewer.scene.primitives.add(new Cesium.Primitive({
geometryInstances : new Cesium.GeometryInstance({
geometry : new geometryType({
positions : Cesium.Cartesian3.fromDegreesArray([
-127, 70,
-80, 20
])
, width: 5
}),
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.YELLOW)
}
}),
appearance : new Cesium.PerInstanceColorAppearance({
flat : true,
renderState : {
lineWidth : Math.min(5, viewer.scene.maximumAliasedLineWidth)
}
})
}));