Im adding some points via a GroundPrimitive, using a CircleGeometry:
primitiveCollection.add(new Cesium.GroundPrimitive({
geometryInstances: new Cesium.GeometryInstance({
geometry: new Cesium.CircleGeometry({
center: position,
radius: width * 10000
}),
attributes: {
color: new Cesium.ColorGeometryInstanceAttribute(color.r, color.g, color.b, alpha)
}
}),
asynchronous: false // avoids flickering
}));
The radius is in meters, so it is not relative to the distance of the camera. The question is, is there a way to set a ‘dynamic’ width? Or set it in pixels?
Thanks
Hi Juan,
PointPrimitive has options for scaling with distance, but is not a supported ground primitive. You could clamp it to the terrain, but it would not lie “flat” in terrain.
You could update your primitive geometry using a function like Camera.getPixelSize to determine the size in meters to set the radius, but you’d need to update this value every time the view changes.
Thanks,
Gabby
How can I clamp a PointPrimitive to the terrain?? Thanks Gabby!
You could use sampleTerrain to get the elevation of terrain at that position and level of detail.
Alternatively, if you want to do it at the Entity level, you would create a Point entity, and set heightReference to HeightReference.CLAMP_TO_GROUND.