CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
347 stars 83 forks source link

Add bezier support to Cesium Cartographic Polygon #439

Open csciguy8 opened 6 months ago

csciguy8 commented 6 months ago

We finally have Cartographic Polygons in Unity as of this PR! Looks great, but of course we always want more...

Cartographic Polygons rely on Unity's Spline editor, and we currently only support Linear splines, yet Bezier curves are also available. Bezier curves are incredibly useful for following curved features, like roads and shorelines.

Here is an example spline following a road: image

Looking through the code, one of the easiest ways to accomplish this could be to convert bezier curves into linear curves in our Unity plugin, CesiumCartographicPolygon::GetCartographicPoints. We are already dealing with BezierKnot objects (cubic beziers), so it would just be a matter of segmenting the curve into a collection of lines, at some level of granularity.

A harder, but maybe more valuable task, could be to support bezier curves completely, all the way down to cesium-native's CesiumGeospatial::CartographicPolygon class.