Get the current PixelSize of a model

Dear all,

I would like to know if there’s a way to get the current PixelSize of a model?

I have an entity defined as follow:

var entity = viewer.entities.add({
id :,
name :,
position : position,
model : {
uri : ‘models/node.gltf’,
minimumPixelSize: 128,
maximumScale : 1000


In the viewer, if I understood correctly the documentation, my 3d model is scaled depending on the camera zoom between a maximum scale value of 1000 and a minimum pixel size of 128.

I have to connect another 3d model with a polyline, not mapped on the terrain but with a specific height, defined as follow:

var entity = viewer.entities.add({
id :,
type : “physical”,
polyline : {
positions : Cesium.Cartesian3.fromDegreesArrayHeights(positions),
width : 2,
material : defaultPhysicalColor


Everything is fine, obviously when I zoomin/out the models change their dimensions but the heights of the polyline is always the same.

So, my idea is to update the heights values of the polyline depending on the 3d model dimensions in order to keep the connection point of the 3d model and the line always at the same position.

Is this possible? Thanks, Michele

Hi Michele,

Sorry, I don’t think there is an easy way to get the current pixel size of the model


Hi Michele,

You can actually achieve this by getting the model’s bounding sphere and passing it to camera.getPixelSize. This is true for any boundingsphere.

camera.getPixelSize(model.boundingSphere, scene.drawingBufferWidth, scene.drawingBufferHeight)

Oh, I never noticed this function in the camera… sorry for that, good to know!
Thank you,


That function returns meters per pixel so to get the size in pixels there’s one more step:

var sizeInPixels = (2.0 * model.boundingSphere.radius) / metersPerPixel;

If you set the minimum pixel size on the model, then the value is:

Math.min(sizeInPixels, minimumPixelSize)

Thank you for your the detailed clarification, it will be useful in other contexts also, great!