diff --git a/CHANGES.md b/CHANGES.md index e7ae411f..9ab69347 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ##### Additions :tada: - Added support for the Linux platform (x86-64 only). +- Added `CesiumVectorPointStyle` and a `pointStyle` field on `CesiumVectorStyle`, enabling `CesiumGeoJsonDocumentRasterOverlay` to render GeoJSON `Point` and `MultiPoint` features. ## v1.24.0 - 2026-07-01 diff --git a/Source/Runtime/CesiumVectorStyle.cs b/Source/Runtime/CesiumVectorStyle.cs index 0e10640c..f19ac44a 100644 --- a/Source/Runtime/CesiumVectorStyle.cs +++ b/Source/Runtime/CesiumVectorStyle.cs @@ -156,6 +156,61 @@ public struct CesiumVectorPolygonStyle }; } + /// + /// The style used to draw points. + /// + [Serializable] + public struct CesiumVectorPointStyle + { + /// + /// The radius of the point in pixels. + /// + [Tooltip("The radius of the point in pixels.")] + [Min(0)] + public double radius; + + /// + /// Whether the point should be filled. + /// + [Tooltip("Whether the point should be filled.")] + public bool fill; + + /// + /// If fill is true, this style will be used when filling the point. + /// + [Tooltip("If fill is true, this style will be used when filling the point.")] + public CesiumVectorPolygonFillStyle fillStyle; + + /// + /// Whether the point should be outlined. + /// + [Tooltip("Whether the point should be outlined.")] + public bool outline; + + /// + /// If outline is true, this style will be used when outlining the point. + /// + [Tooltip("If outline is true, this style will be used when outlining the point.")] + public CesiumVectorLineStyle outlineStyle; + + /// + /// Creates a default point style with a 5 pixel radius, fill enabled, and + /// outline disabled. + /// + /// + /// Fill is enabled by default because the underlying native point style + /// renders nothing when neither fill nor outline is set. + /// + public static CesiumVectorPointStyle Default => new CesiumVectorPointStyle + { + radius = 5.0, + fill = true, + fillStyle = CesiumVectorPolygonFillStyle.Default, + outline = false, + outlineStyle = CesiumVectorLineStyle.Default + }; + } + /// /// Style information to use when drawing vector data. /// @@ -174,13 +229,20 @@ public struct CesiumVectorStyle [Tooltip("Styles to use when drawing polygons.")] public CesiumVectorPolygonStyle polygonStyle; + /// + /// Styles to use when drawing points. + /// + [Tooltip("Styles to use when drawing points.")] + public CesiumVectorPointStyle pointStyle; + /// /// Creates a default vector style. /// public static CesiumVectorStyle Default => new CesiumVectorStyle { lineStyle = CesiumVectorLineStyle.Default, - polygonStyle = CesiumVectorPolygonStyle.Default + polygonStyle = CesiumVectorPolygonStyle.Default, + pointStyle = CesiumVectorPointStyle.Default }; } } diff --git a/Source/Runtime/ConfigureReinterop.cs b/Source/Runtime/ConfigureReinterop.cs index 8146391f..85bd313d 100644 --- a/Source/Runtime/ConfigureReinterop.cs +++ b/Source/Runtime/ConfigureReinterop.cs @@ -1013,6 +1013,18 @@ Cesium3DTilesetLoadFailureDetails tilesetDetails polygonStyleV.outline = outlineEnabled; CesiumVectorLineStyle outlineStyle = polygonStyleV.outlineStyle; polygonStyleV.outlineStyle = outlineStyle; + CesiumVectorPointStyle pointStyleV = vectorStyle.pointStyle; + vectorStyle.pointStyle = pointStyleV; + double pointRadius = pointStyleV.radius; + pointStyleV.radius = pointRadius; + bool pointFillEnabled = pointStyleV.fill; + pointStyleV.fill = pointFillEnabled; + CesiumVectorPolygonFillStyle pointFillStyle = pointStyleV.fillStyle; + pointStyleV.fillStyle = pointFillStyle; + bool pointOutlineEnabled = pointStyleV.outline; + pointStyleV.outline = pointOutlineEnabled; + CesiumVectorLineStyle pointOutlineStyle = pointStyleV.outlineStyle; + pointStyleV.outlineStyle = pointOutlineStyle; baseOverlay = geoJsonOverlay; TestGltfModel testModel = new TestGltfModel(); diff --git a/Tests/TestCesiumVectorStyle.cs b/Tests/TestCesiumVectorStyle.cs index dabec07d..591ecef0 100644 --- a/Tests/TestCesiumVectorStyle.cs +++ b/Tests/TestCesiumVectorStyle.cs @@ -106,6 +106,46 @@ public void PolygonStyleCanDisableBothFillAndOutline() #endregion + #region CesiumVectorPointStyle Tests + + [Test] + public void PointStyleDefaultHasFillEnabledOutlineDisabled() + { + CesiumVectorPointStyle style = CesiumVectorPointStyle.Default; + + Assert.AreEqual(5.0, style.radius, 0.001); + Assert.IsTrue(style.fill); + Assert.IsFalse(style.outline); + } + + [Test] + public void PointStyleCanEnableBothFillAndOutline() + { + CesiumVectorPointStyle style = new CesiumVectorPointStyle(); + style.radius = 8.0; + style.fill = true; + style.fillStyle = CesiumVectorPolygonFillStyle.Default; + style.outline = true; + style.outlineStyle = CesiumVectorLineStyle.Default; + + Assert.AreEqual(8.0, style.radius, 0.001); + Assert.IsTrue(style.fill); + Assert.IsTrue(style.outline); + } + + [Test] + public void PointStyleCanDisableBothFillAndOutline() + { + CesiumVectorPointStyle style = new CesiumVectorPointStyle(); + style.fill = false; + style.outline = false; + + Assert.IsFalse(style.fill); + Assert.IsFalse(style.outline); + } + + #endregion + #region CesiumVectorStyle Tests [Test] @@ -120,6 +160,11 @@ public void VectorStyleDefaultHasCorrectSubStyles() // Polygon style defaults Assert.IsTrue(style.polygonStyle.fill); Assert.IsFalse(style.polygonStyle.outline); + + // Point style defaults + Assert.AreEqual(5.0, style.pointStyle.radius, 0.001); + Assert.IsTrue(style.pointStyle.fill); + Assert.IsFalse(style.pointStyle.outline); } [Test] diff --git a/native~/src/Runtime/CesiumVectorStyleConversions.h b/native~/src/Runtime/CesiumVectorStyleConversions.h index 4ed225fb..fd5f37b8 100644 --- a/native~/src/Runtime/CesiumVectorStyleConversions.h +++ b/native~/src/Runtime/CesiumVectorStyleConversions.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,22 @@ inline CesiumVectorData::ColorStyle fromUnityFillStyle( return native; } +inline CesiumVectorData::PointStyle fromUnityPointStyle( + const DotNet::CesiumForUnity::CesiumVectorPointStyle& pointStyle) { + CesiumVectorData::PointStyle native; + native.radius = pointStyle.radius; + + if (pointStyle.fill) { + native.fill = fromUnityFillStyle(pointStyle.fillStyle); + } + + if (pointStyle.outline) { + native.outline = fromUnityLineStyle(pointStyle.outlineStyle); + } + + return native; +} + inline CesiumVectorData::VectorStyle fromUnityStyle(const DotNet::CesiumForUnity::CesiumVectorStyle& style) { CesiumVectorData::VectorStyle native; @@ -66,6 +83,8 @@ fromUnityStyle(const DotNet::CesiumForUnity::CesiumVectorStyle& style) { fromUnityLineStyle(style.polygonStyle.outlineStyle); } + native.point = fromUnityPointStyle(style.pointStyle); + return native; } @@ -133,6 +152,27 @@ toUnityStyle(const CesiumVectorData::VectorStyle& style) { toUnityLineWidthMode(style.polygon.outline->widthMode); } + // Point style + result.pointStyle.radius = style.point.radius; + + result.pointStyle.fill = style.point.fill.has_value(); + if (style.point.fill.has_value()) { + result.pointStyle.fillStyle.color = toUnityColor(style.point.fill->color); + result.pointStyle.fillStyle.colorMode = + toUnityColorMode(style.point.fill->colorMode); + } + + result.pointStyle.outline = style.point.outline.has_value(); + if (style.point.outline.has_value()) { + result.pointStyle.outlineStyle.color = + toUnityColor(style.point.outline->color); + result.pointStyle.outlineStyle.colorMode = + toUnityColorMode(style.point.outline->colorMode); + result.pointStyle.outlineStyle.width = style.point.outline->width; + result.pointStyle.outlineStyle.widthMode = + toUnityLineWidthMode(style.point.outline->widthMode); + } + return result; }