clampToGround not working as intended for geojson point feature

I have two 3D datasets - one mesh 3d tiles(top), one pointcloud 3d tiles(middle) and a geojson file in this scene above. I am using the resium library for loading this into my UI. There are two issues I have with the current state.

<GeoJsonDataSource
    clampToGround
    name={name}
    show={visible}
    stroke={Color.fromCssColorString(strokeColor)}
    strokeWidth={strokeWidth}
    fill={noFill ? Color.TRANSPARENT : Color.fromCssColorString(fillColor)}
    data={`${APP_FILES_BASE_URL}/file-download?fileUrl=${url}&authToken=${getAuthToken()}`}
    onLoad={(dataSourceRef) => {
        geojsonRef.current = dataSourceRef;
        // Get the array of entities
        const entities = dataSourceRef.entities.values;

        entities.forEach((entity) => {
            if (entity.position) {
                // eslint-disable-next-line no-param-reassign
                entity.label = new LabelGraphics({
                    text: 'testing',
                    font: '24px Helvetica',
                    heightReference: HeightReference.CLAMP_TO_GROUND,
                    showBackground: true,
                    pixelOffset: new Cartesian2(0, -20),
                });
            }
        });
    }}
/>

Issue 1: The point feature is only clamped to the surface(ellipsoid) and not the 3d tiles however the line and polygon features correctly gets “clamped”. If I enable cesium world terrain, it gets clamped properly to the terrain(but not the tilesets). There is no z value for the geojson features, only lat and lon.

Issue 2: The line and polygon is being clamped onto the pointcloud and mesh and the “ground” as well, I was hoping it would just appear on the “top”. How can I restrict it to appear on the “top” one alone?

Hi there,

I don’t think the change has made it into resium yet (as it is maintained by a third party), but we’ve recently released improvements to clamping in version 114 so that it will support 3D Tilesets by default.

Thanks,
Gabby

Thanks for the update @Gabby_Getz , I upgraded my Cesium version from 111 to 114 and that has fixed the clamping issue related to the point. (p.s. resium is not coupled to a specific cesium version)

I have one issue remaining now, as you can see the point feature is clamped only to the highest tileset in this scene but the line and polygon features are being clamped/painted on all tilesets as well as the base ellipsoid too, how can I make the line and polygon also behave similar to the point?

Hi @skydeck,

Good question. This comes down to a difference in the technique we use for rendering polylines and polygons.

Right now, there is no way to use clamp to ground to only clamp to the top tileset. You could set the height manually instead.

@Gabby_Getz Can you point me towards any example of how this is done? Like iterate over each vertex of the line and polygon to sample the height there and set it manually?

In our use cases we plan to overlay a contour lines geojson on top of a tiled mesh/pointcloud and some polygons as well - it would be performance wise not ideal to do the manual height adjustment at scale…

Can you point me towards any example of how this is done? Like iterate over each vertex of the line and polygon to sample the height there and set it manually?

Yes, that would be the approach.

I understand why it may not be be the best solution for your use case though.

In our use cases we plan to overlay a contour lines geojson on top of a tiled mesh/pointcloud and some polygons as well

We have built-in materials for rendering contour lines on terrain. Would a material similar to that be sufficient for your use case?

We have built-in materials for rendering contour lines on terrain. Would a material similar to that be sufficient for your use case?

Unfortunately that is not sufficient for our use case. The contour lines we have are custom generated in our platform and already in the geojson format(being used in a different, 2D map). These are derived from our own high detail elevation models and also have to be interactive to user mouse events and custom styling as well.

Are there any plans to address this issue(clamping inconsistencies) in the near future?

There are no plans to address how clamping works for the time being.

However, contour lines have been a common use case we’ve seen recently and we may prioritize an alternative workflow that could work in cases like this.

Would you mind telling us a bit about your data workflow, like how you generate the contour lines and why you’ve chosen to use geojson? Knowing this can help us prioritize.

Thank you!

There are no plans to address how clamping works for the time being.

Ahh that’s sad to hear, would love to see more options for the vector data side of things in Cesium!

We currently have a web based 2D GIS software solution which uses geojson and vector tiles. These are generated as part of our photogrammetry pipeline and one of its processed outputs is a contour geojson. It’s also our go-to format for anything vector based we do like user generated annotations, contours, watershed analysis etc. It was chosen because we believe that’s a “standard” which is accepted both in the web world and GIS world and it being JSON. There are other formats we internally use like shapefiles but browser based rendering is exclusively geojson and/or vector tiles.

We’re slowly bringing our 3D map pages in full parity with our 2D solution and this is one of the most requested features, to work with vector data in 3D…