Browse Source

make attributeOrTexture nullable

Bert Temme 1 year ago
parent
commit
f2eeecf970

+ 3 - 4
src/SharpGLTF.Ext.3DTiles/Schema2/FeatureIDBuilder.cs

@@ -6,8 +6,7 @@ namespace SharpGLTF.Schema2.Tiles3D
 {
 {
     public sealed class FeatureIDBuilder : IMeshFeatureIDInfo, IEquatable<IMeshFeatureIDInfo>
     public sealed class FeatureIDBuilder : IMeshFeatureIDInfo, IEquatable<IMeshFeatureIDInfo>
     {
     {
-
-        public FeatureIDBuilder(int featureCount, OneOf<int, Texture>? attributeOrTexture, PropertyTable propertyTable = null, string label = null, int? nullFeatureId = null)
+        public FeatureIDBuilder(int featureCount, OneOf<int, Texture>? attributeOrTexture = null, PropertyTable propertyTable = null, IReadOnlyList<int> channels = null, string label = null, int? nullFeatureId = null)
         {
         {
             Guard.MustBeGreaterThanOrEqualTo(featureCount, 1, nameof(featureCount));
             Guard.MustBeGreaterThanOrEqualTo(featureCount, 1, nameof(featureCount));
             FeatureCount = featureCount;
             FeatureCount = featureCount;
@@ -19,7 +18,7 @@ namespace SharpGLTF.Schema2.Tiles3D
                     texture =>
                     texture =>
                     {
                     {
                         Texture = texture;
                         Texture = texture;
-                        Channels = new[] { 0 };
+                        Channels = channels ?? new[] { 0 };
                     }
                     }
                 );
                 );
             }
             }
@@ -40,7 +39,7 @@ namespace SharpGLTF.Schema2.Tiles3D
 
 
         public int? PropertyTableIndex { get; set; }
         public int? PropertyTableIndex { get; set; }
 
 
-        public Texture Texture { get; set; }
+        public Texture Texture { get; set;  }
         public IReadOnlyList<int> Channels { get; set; }
         public IReadOnlyList<int> Channels { get; set; }
 
 
         public bool Equals(IMeshFeatureIDInfo other)
         public bool Equals(IMeshFeatureIDInfo other)

+ 1 - 1
tests/SharpGLTF.Cesium.Tests/ExtInstanceFeaturesTests.cs

@@ -38,7 +38,7 @@ namespace SharpGLTF.Schema2.Tiles3D
 
 
 
 
             var featureId0 = new FeatureIDBuilder(2, 0, label: "Forests");
             var featureId0 = new FeatureIDBuilder(2, 0, label: "Forests");
-            var featureId1 = new FeatureIDBuilder(9, 0, label: "Trees");            
+            var featureId1 = new FeatureIDBuilder(9, label: "Trees");            
 
 
             var model = sceneBuilder.ToGltf2(settings);
             var model = sceneBuilder.ToGltf2(settings);
             model.LogicalNodes[0].AddInstanceFeatureIds(featureId0, featureId1);
             model.LogicalNodes[0].AddInstanceFeatureIds(featureId0, featureId1);