FlyTo Issues for a Point at Zero Elevation

1. A concise explanation of the problem you’re experiencing.

We are experiencing issues when using the FlyTo() function on the viewer if the datasource contains a single entity which is a point at zero elevation (Z). The data is loaded using the CZML format (CzmlDataSource), and the standard FlyTo() function is used on the entities of the datasource, which in this case is a point geometry. We are having issues in both 2D / 3D modes:

2D Mode:

We get a developer error causing cesium to crash:

DeveloperError: right must be greater than left.

``

3D Mode:

The camera actually zooms in way too far…

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

This can be easily reproduced. I’ve attached a demo.czml file containing a single point geometry.

viewer.flyTo(source.entities)

``

Or alternatively in Sandcastle (camera section):

function flyToLocation() {

Sandcastle.declare(flyToLocation);

viewer.camera.flyTo({

destination : Cesium.Cartesian3.fromDegrees(25.0931782016227, - 28.999510764784763)

});

}

``

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

We need a generic function that would zoom to the bounds of a datasource that works well in 2D and 3D mode. Also, all our geometries are drawn with no elevation and has a height of zero. Is there perhaps a function we can call that gets the bounding spheres of all the entities efficiently, hence using the camera with FlyToBoundingSphere() instead? What I like about the bounding sphere is that it internally checks and sets the minimum z to a 100, if the radius is zero or less. The function also yields much better results (based on the frustum far / near) on small points / polygons and larger ones, and is very consistent.

4. The Cesium version you’re using, your operating system and browser.

1.38

demo.czml (331 Bytes)

I had a look at the code, and it seems that the logic for camera.FlyTo() and viewer.FlyTo() is slightly different with regards to bounding spheres, as the camera actually clamps the offset for a bounding sphere (adjustBoundingSphereOffset), where the viewer.FlyTo() is not that comprehensive and missing similar logic…

Hi Andries,

The 2D flyTo issue has been brought up, and we have an issue open in GitHub here.

We have an issue open for improving how we deal with flyTo and data sources that we’re tracking here, if you’d like to add any more context to that discussion. Can you elaborate more on your second comment as to what functionality you need from flyToBoundingSphere that isn’t included in flyTo. They have very similar options, and if you needed, you could create a new BoundingSphere programmaticly from a position and a radius,

Thanks!

Gabby

Hi Gabby,

Just realized that I was going down the wrong rabbit hole… All these issues mentioned was caused by ground clamping for my point geometries (entities). Since we use czml for streaming entities and render a location as a point (not billboard) with a height reference (czml-writer)… If we use relative / clamp to ground, it zooms to far / beyond in 3D, and causes the runtime error in 2D…

What is frustrating though is that if we remove any height reference, we only see the point in 2D, and not in 3D…

using (var position = entity.OpenPositionProperty())

{

position.WriteCartographicDegrees(new Cartographic(longitude, latitude, 0.0));

}

using (var point = entity.OpenPointProperty())

{

point.WritePixelSizeProperty(5);

point.WriteHeightReferenceProperty(CesiumHeightReference.ClampToGround);

point.WriteColorProperty(FillColor);

point.WriteOutlineColorProperty(LineColor);

point.WriteOutlineWidthProperty(1);

}

}

``

Please advise if there are any workarounds? Surely I don’t need to provide more information on how to reproduce it.

Look forward to your response.

Cheers