KML clampping to 3Dtiles

Hi,

Is it possible to clamp a KML to a 3Dtile?

Hello,

Currently not automatically. We are currently working on a way to easily clamp entities to tilesets, and in the meantime we have a demo with a workaround for clamping to tilesets.

Thanks!

Gabby

Not yet developed??

kml only can clamp to terrain.

Not to photogrammetry 3dtiles.

I do this work by using FME ‘surface draper tool’ clamp kml to DSM and give alpha z value.

This should actually work now! You can clamp entities in Cesium (when you load a KML in Cesium it gets added to the scene as entities) on either terrain, 3D Tiles, or both.

Here’s an example of textured materials on 3D Tiles and terrain: https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Classification%20Types.html

And this one shows polylines: https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Polylines%20on%203D%20Tiles.html

You can even have dynamic entities clamped: https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Clamp%20to%203D%20Tiles.html

Hi Omar.
Is it kml clamp to 3dtiles working now??
It seems not working for me
my code is below

    var options = {
		camera : viewer.scene.camera,
		canvas : viewer.scene.canvas,
	};
	var kml = viewer.dataSources.add(Cesium.KmlDataSource.load('/project/autodesk/3dtiles/auto_line_kmz.kml', options));

Thank you

You need to set clampToGround: true in your KML options, so it would look like this:

var options = {
		camera : viewer.scene.camera,
		canvas : viewer.scene.canvas,
        clampToGround: true,
};
var kml = viewer.dataSources.add(Cesium.KmlDataSource.load('/project/autodesk/3dtiles/auto_line_kmz.kml', options));

If it’s still not working, I would check that your entities inside the KML have an altitude mode of “clampToGround” as well. And note that lines can only be clamped to ground when they have tessellate set to true: https://github.com/CesiumGS/cesium/issues/8760

Hi omar.
Thank you for your reply. I just solve the problem about polyline clamptoground. but point is still not working. point clamptoground to 3dtiles is not support??

Points should be clamped to ground in the same way. It must have a height reference of clamp to ground or relative to ground. If it’s not working, try uploading your file to Cesium ion and share a Sandcastle here (see How to share custom Sandcastle examples) and I can take a look.

Hello everyone, I am currently using cesium 1.121 and I loaded the kml file in the picture. It does not say gx:AltitudeMode on the polygon on the left, but it does on the polygons on the right. The code section is below. I want to determine it with cesium settings instead of the value written in the kml. How can I follow?

const kmlDataSource = await CesiumJs.KmlDataSource.load(kmlText, {
            camera: CesiumViewer.scene.camera,
            canvas: CesiumViewer.scene.canvas,
            clampToGround: true,
          });
          CesiumViewer.dataSources.add(kmlDataSource);
          const entities = kmlDataSource.entities.values;
  
          entities.forEach((entity:any) => {
            // Poligonların zeminle hizalanması
           if (entity.polygon) {
             entity.polygon.heightReference = CesiumJs.HeightReference.NONE;
             entity.polygon.extrudedHeightReference = CesiumJs.HeightReference.NONE;
           }