I have a script that wants to run through creating and removing a variety of primitive types - markers, ellipses, polygons, etc. Is it possible to handle points generated in the same way as geometry instances handled by the primitive?
Each of the other shape types have been generated as GeometryInstances in their own function, like so:
initialize = function()
{
this.engine = {
viewer: new Cesium.Viewer('container', {
animation: false,
baseLayerPicker: false,
fullscreenButton: false,
geocoder: false,
infoBox: false,
timeline: false,
navigationHelpButton: false,
navigationInstructionsInitiallyVisible: false,
sceneMode: Cesium.SceneMode.SCENE3D /*,
imageryProvider: new Cesium.WebMapTileServiceImageryProvider({
url: 'http://hesperides/wmts/BlueWorldWMTS/{Style}/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png',
layer: 'BlueWorldWMTS',
style: 'tile',
format: 'image/png',
tileMatrixSetID: 'WorldWebMercatorQuad',
maximumLevel: 19
})*/
}),
primitive:
};
this.cameraLat = 0.0;
this.cameraLon = 0.0;
this.cameraRange = 4300000;
this.lastPoint.x = 0.0;
this.lastPoint.y = 0.0;
this.cameraRotation = 0.0;
this.cameraTilt = 0.0;
this.setCenter();
//this.setRange();
//this.tiltRoll();
}
createEllipse = function( position, hRadius, vRadius )
{
this.engine.primitive.push(new Cesium.GeometryInstance({
geometry : new Cesium.EllipseGeometry({
center : Cesium.Cartesian3.fromDegrees(position.lon, position.lat ),
semiMajorAxis : hRadius,
semiMinorAxis : vRadius,
rotation: Cesium.Math.toRadians(0.0)
}),
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
},
id: 'circle'
}));
}
The primitive array created by the shape creation is then rendered to the scene like so:
renderPrimitive = function( number )
{
for (var i = 0; i < this.engine.primitive.length; i++) {
this.engine.viewer.scene.primitives.add(new Cesium.Primitive({
geometryInstances: this.engine.primitive[i],
//geometryInstances : this.engine.primitiveList,
appearance : new Cesium.PerInstanceColorAppearance()
}));
};
}
I have been trying to determine whether to send the points to be created by the render function as a PointPrimitiveCollection or a BillboardCollection... What might be the best way to handle markers/points to be able to use them in the same way as the other shapes?
Thanks!