How are 3D vertices deformed about the Sphere (earth)?

I have a specific use-case in mind that I’d like to explain and get some clarification on. Let’s say I have geojson data with abstract polygons in it, and I’d like to render those polygons on my map. Let’s say I do this with Cesium’s GeoJsonDataSource.

What will happen internally is that essentially the GeoJSON is triangulated via the earcut library, and then it will eventually end up as a GeometryInstance stored in a PrimitiveCollection. So far, so good.

My question then is this: how are the vertices of the resulting triangulation deformed about the sphere so as to curve with the surface of the earth? What I’d specifically like to know is - does this happen on the CPU or in a shader? It would be very helpful if you could point me towards the specific code where this happens (be it in GLSL or javascript).

I’ve studied the CesiumJS internals extensively, and have a pretty good idea of how the rendering engine works and the overall structure of the project. So far, this is the only question that I haven’t been able to answer by reading the code itself.

Hi there,

Once triangulation happens, the polygon is further subdivided based on the geometry granularity property. Each of this subdivided points are then offset along the ellipsoid normal to the ellipsoid surface. Do note that this process is slightly different depending on if the polygon edges are treated as geodesics or rhumb lines (from the geomerty’s ‘arcType’ property).

This is happening asynchronously in a web worker while the geometry is being created. Relevant code can be found in PolygonPipeline.computeSubdivision in packages/engine/Source/Core/PolygonPipeline.js.

1 Like