Google Photorealistic 3D Tiles and Polygons

I am attempting to layer polygons on top of google photorealistic 3D tiles. So far I have been unable to get the polygons to show up on the 3D tiles, however the polygons do show up on the terrain layer.

Here is the relevant code

// Load the GeoJSON file
Cesium.GeoJsonDataSource.load("./data/test.geojson").then(
	(dataSource) => {
		viewer.dataSources.add(dataSource);

		// Iterate over each entity in the dataSource
		dataSource.entities.values.forEach((entity) => {
			// Check if the entity is a polygon
			if (entity.polygon) {
				// Set the classification type for the polygon
				entity.polygon.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
				entity.polygon.material = Cesium.Color.RED.withAlpha(0.5); // Example to set the material color and opacity
			}
		});

		// zoom to the data source entities
		viewer.zoomTo(dataSource);
	}
);

I have been wrestling with this issue for several days now. I would appreciate any guidance you all might have.

You will have to set the clampToGround property to true on either the datasource or entity level.
Please let me know if the following works:

Cesium.GeoJsonDataSource.load("./data/test.geojson", {
  clampToGround: true,
}).then(
 ...
1 Like

That worked perfectly! Thank you.

1 Like