Updating per-Instance location of geometries in a Primitive

I would like to update the location of a shape that has been added to a primitive, without removing and re-adding it. Is there a way to programmatically access the position of an instance within the primitive collection?

The gist of what I'm trying to do is:

updateEllipse = function( position, index )
{
    position.lat = position.lat + 20;
    position.lon = position.lon - 10;
    var p = this.engine.viewer.scene.primitives.get(index);
    this.engine.viewer.scene.primitives[index].positions = position;
            /*{ lat : position.lat,
              lon : position.lon
            };*/
};

Is there a way to access the coordinates and update them on the fly? Or should the features be added to the scene as a different type of object?

Thanks!

1 Like

Hi Jay,

If you update any of the primitive positions, The ellipse needs to be recomputed for each new position. So the only way to move it would be to remove and recreate it. This is how we perform updates to Entities on a higher level.

Thanks,

Gabby

1 Like

Thanks Gabby - understood. Is there a type of object that can be used in Cesium to handle it this way (ie. a change of the position), or will you have to remove and recreate any feature that has its coordinates changed no matter what?

Hi,
Could you please let me know how to add SRTM DTM data and Landsat imagery on Cesium Globe (Localhost)

Please…

Akshay Gore

Hi Jay,

Take a look at DynamicGeometryUpdater.js. That’s how we “update” the primitive of an entity, you should be able to implement something similar.

Thanks,

Gabby

1 Like