Polygon over 3D Tile

Hi Cesium community.
We are looking for a solution to display a polygon on a 3D Tile, not clamped, but showing the entire polygon, including the areas below the 3D Tile.
Similar to the polygon that Cesium ION draws in its area measurement tool.
Any ideas how to do it?
Maybe something like the zIndex but between the polygon and the 3dtile

Thank you very much.

Best
Moises

Hey,

I think you need to paint us a picture, I’m not sure what you’re after?

Cheers,

Alex

Thanks for your answer.
The picture shows 2 scenes. One with part of the polygon hidden below the 3D Tile, and another that is always shown above the 3D Tile.
Both Polygons are not clamped. We need the second option.

Thanks again

Hi Moises,

You can create a polygon as an entity if you know the coordinates of its corner points:

   var redPolygon = viewer.entities.add({
  name: "Red polygon on surface",
  polygon: {
    hierarchy: Cesium.Cartesian3.fromDegreesArray([
      -115.0,
      37.0,
      -115.0,
      32.0,
      -107.0,
      33.0,
      -102.0,
      31.0,
      -102.0,
      35.0,
    ]),
    material: Cesium.Color.RED,
  },
});

Here is a more detailed code example of different polygons you can create.

Here is an example of using HeightReference to change where the polygon is relative to the terrain. The documentation for HeightReference can be found here.

Thanks for you answer.
The problem with these polygons is over 3D Tile, not using Terrain.
I tested over my 3D Tile without success.

As you can see it is always clamp to ground. What I’m looking for is that it looks above the 3D Tile, even if it is below it. Just like Cesium ION does in its area measurement tool.

You can test with this code using:

var viewer = new Cesium.Viewer(“cesiumContainer”, {
terrainProvider: Cesium.createWorldTerrain(),
});

var redPolygon = viewer.entities.add({
name: “Red polygon on surface”,
polygon: {
hierarchy: [
new Cesium.Cartesian3(2099227.70719532,-5487539.075395014,-2473771.7869759765),
new Cesium.Cartesian3(2099341.2230988583,-5487489.511624259,-2473785.310523885),
new Cesium.Cartesian3(2099320.3257253477,-5487467.138429955,-2473852.222194764),
new Cesium.Cartesian3(2099220.4270702493,-5487517.176780349,-2473826.175029475),
new Cesium.Cartesian3(2099220.2220033766,-5487517.293980008,-2473826.0896431124)
],
material: Cesium.Color.RED,
// heightReference: Cesium.HeightReference.CLAMP_TO_GROUND ,
},
});

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: ‘http://test.blastreport.cl:8585/20200703_Esperanza_Cesium/Scene/20200703_Esperanza_Cesium.json’,
maximumScreenSpaceError: 1, // Temporary workaround for low memory mobile devices - Increase maximum error to 8.
maximumNumberOfLoadedTiles: 10000 // Temporary workaround for low memory mobile devices - Decrease (disable)
}));

viewer.scene.primitives.add(tileset);

viewer.flyTo(tileset);

Cheers
Moises

Have you tried setting the height reference to RELATIVE_TO_GROUND?

I did try with but it keeps coming out as clamped to ground on the 3D Tile.
Thank you for trying to help.

Hi Moises,

I created a Sandcastle to set the HeighReference and height of the red polygon in your example. I’m not sure if this is what you were looking for, but the polygon is no longer clamped to the ground. Please check it out here.

Hello
Thank you very much for the sanclastle.
I saw that 3d tileset failed to load, in this sandcastle, I even tried with variants in viewer.scene.globe.depthTestAgainstTerrain and it is still not seen.
Maybe it must be because it is not in https.
I will be able to do it in https to carry out the tests.

Thanks again

Hi, I slightly modified the sandcastle code to show what I’m looking for.
First do not use terrain to show the effect, because on Terrain it works differently.

I deployed the 3D Tile over https so it can be viewed in sandcastle without problems.

I finally used RELATIVE_TO_GROUND, but since it is a 3D Tile that is at a height of more than 2200 meters above sea level, the polygon is painted far below. So I fixed it to get the correct height.
As you can see, it is not clamped to ground, but is still hiding under the 3d Tile. I’m looking for it to always be visible, even when it’s below the 3D Tile.
I still don’t understand how the area measurement tool achieves it. I tested the cesium SDK for a month, and it works differently.
You can try it. I’m going to try uploading a 3D Tile to Cesium ION to compare the results.

You can compare the images that I placed in previous messages where you can see the difference between the polygons painted by me and by the Cesium SDK measurement tool. In the same coordinates, the polygon painted by me is seen below the tile and that of Cesium ION is seen above, in the same position.

Thank you very much.
sandcastle

Hey there,

So, I went back to your image explaining what you’re after. For me, it looks like what you’re after is a polygon that isn’t at the same place/height you picked your positions, as if they’re floating X meters above the point you chose?

You can do this by picking the position, then add X meters to the height before drawing the polygon. I’ve seen some do this by using two entities (I think Propellar does this, and a few others); a wall entity that mounts up from your chosen positions to an offset height, and then a polygon across that area. You can even get fancy by sampling the selected area for the heighest reference point of the terrain, and then choose that as your offset height, or have the height of the wall as an option for the user.

A simpler way could be to experiment with creating two entities; the one you’ve got, and another with the same coords, but remove the heightReference, and pop in;

classificationType: Cesium.ClassificationType.BOTH,
clampToGround : true

Use same color, or similar, mix them, etc. The effect is that the clamped polygon will color the bits that stick out over the first polygon. The con is that it will paint down to the terrain if you’re high up in the sky.

But beyond that, I’m not sure what a 3D object in relation to another 3D object but always be seen means, it kind defeats the purpose of 3D. :slight_smile: I guess you want a similar effect to eyeOffset on labels.

Cheers,

Alex

Thank you very much for your reply.
We are currently doing something similar. The objective of the post was to see if there was any way that it could be done on the 3D Tile, as it works on a Terrain, but apparently it has to be done using other alternatives such as using two entities.

Grateful for your ideas.

Cheers
Moises