I don’t think the mesh is available, at least not in the current API, however you can create your own TIN from the polygon and sample heights (if that’s what you’re after) in a grid fashion (and there’s plenty of TIN libraries for JS you can use for this).
Let us know what you’re trying to achieve, maybe there’s other ways to get there.
I’m able to do this actually. The cons of sample height is that you need to generate a Terrain tiles so I was looking for other ways.
What I’m trying to do is creating TIN mesh of the point cloud within the polygon, so I need to get the z value of each point cloud but it is not available to get that based on research.
Or is there a way to do that?
A few things going on here, but let’s see if we can sort through it. From my understanding you’re after the heights of the polygon only (the boundry points, or even calculated points along it), or you’re after the heights of points inside (and possibly including) the polygon.
The answer to either of these are, yes, they are available, basically through two methods; sampleHeight() and sampleHeightMostDetailed(). You send them an array of your coordinates, and it will return an altered version of the array with the height adjusted.
So, the trick is how you create those coordinates. The simplest is to use the polygon itself, maybe calculate extra points along it. But what I think you’re after is to create a grid on the inside, and use those? Maybe for volume calculations, etc.
Let me know what you’re trying to do with the coordinates, maybe I can help from there. As I said, the mesh in the polygon isn’t (as far as I know; don’t take it as gospel, as there are many nooks of Cesium I don’t know much about) available, but you can recreate it. I do something similar where I create a grid inside the polygon and sample all those points. Keep in mind, this is a costly operation and takes some time, depending on your machine and hardware. SampleHeights() is the quickest as it gives you current values from the what you’re seeing, while SampleHeightMostDetailed() makes sure the data gives you the most accurate (slightly slower, depending on your zoom levels and what’s in the raster cache).
In your screenshot, is the mesh the red color blobs? One thing to note about sampling on a pointcloud is that there is a percent chance your sampling falls through the pointcloud to the ground, so you might see lots of reasonable heights and some that are at the height of the ellipsoid (or terrain, depending), so you might even filter (or resample) those as you go.
Hi @Alexander_Johannesen.
Sorry I had mistaken sampleHeightMostDetailed() for sampleTerrainMostDetailed().
I will take a look and test. Will let you the result. Thanks for the detailed advice @Alexander_Johannesen !
Well, you have to switch between them depending on whether you’re using a terrain or not, so it’s in the same ballpark of operation, but yes, do let us know where you’re up to.
Thanks for the advice. @Alexander_Johannesen
I’m almost there to finish implementing Volume calculation function for the point cloud surrounded by drawn polygon.
I have some questions::
What is the difference of height value retrieved between sampleHeight and sampleHeightMostDetailed? I understand that sampleHeightMostDetailed is more detailed but how much is it more detailed? How does it works?
What is the third parameter “width” of sampleHeight or sampleHeightMostDetailed actually mean? Is it the size of the detector (volume) that selects the entity in the scene?
sampleHeight() uses the data loaded at whatever zoom level or detail you currently got in the 3D engine (the buffers are filled on a needs basis as you fly and zoom around), while sampleHeightMostDetailed() makes sure it loads the best level of detail before sampling. If you’re zoomed close enough, and / or you’ve already filled the 3D engine with all the data, the results will be the same. The latter just guarantees it. Most of the time there will be little to no difference.
Width is the width of the intersection, ie. precission of where your beam hits objects. The documentation is quite scarce on it, so I don’t know about how different values affect the results.
When I have a grid on extent of my point cloud, and getting the height value of each intersection of the grid, some intersection of the grid are at the gap between point cloud and point cloud (or you can say it is not at the exact same XY) so it will get the ellipsoid height instead the point cloud’s height in this case.
Is there any way to avoid this situation? In other words, is there a way to get the height of point cloud always from a grid?
Picking on a pointcloud is a chapter of pain and suffering, and there’s no easy way around it. The only thing I can tell you is that you can do some extra work, in that you can detect that you’re hitting the ellipsoid (usually a 0 height on a pointcloud is a dead giveaway), and for all heights at 0, you can do a new pick, but shifted slightly until it hits something. So, if you’re picking at 0x0 and height is 0, pick at 0x1, and if that’s 0 then pick at 1x0, 2x0, or -1x1, -1x-1, or any number of points around the proginally failed pick. I use a slightly more sophisticated method of statistical binding and threshold driven up-scale picking (I usually have the method of three successful picks that’s not downward sloping) for points not picked on the first try. It’s tedious and slow, but there’s no other way around it except looking into making the points bigger (haven’t tested the payoff, or even if bigger dits actually help).
Hi, do you mind if I ask how you did the calculation for this? I’m also trying to implement something similar in my app and I’m wondering if it’s okay to ask about your approach. Thanks!