Browse Source

Exposed accessors Min/Max bounds. Fixes #222

vpenades 1 year ago
parent
commit
d348d7c542
1 changed files with 20 additions and 0 deletions
  1. 20 0
      src/SharpGLTF.Core/Schema2/gltf.Accessors.cs

+ 20 - 0
src/SharpGLTF.Core/Schema2/gltf.Accessors.cs

@@ -89,6 +89,26 @@ namespace SharpGLTF.Schema2
 
         public AttributeFormat Format => new AttributeFormat(this.Dimensions, _componentType, this._normalized.AsValue(false));
 
+        /// <summary>
+        /// Gets the bounds of this accessor.
+        /// </summary>
+        /// <remarks>
+        /// Bounds may not be available or up to date, call <see cref="UpdateBounds"/> for update.
+        /// </remarks>
+        public (IReadOnlyList<double> Min, IReadOnlyList<double> Max) Bounds
+        {
+            get
+            {
+                IReadOnlyList<double> min = _min;
+                min ??= Array.Empty<double>();
+
+                IReadOnlyList<double> max = _max;
+                max ??= Array.Empty<double>();
+
+                return (min, max);
+            }
+        }
+
         #endregion
 
         #region API