Browse Source

add validation for property attributes

Bert Temme 1 year ago
parent
commit
fe1e771ab5

+ 9 - 0
src/SharpGLTF.Ext.3DTiles/Schema2/Ext.StructuralMetadataPrimitive.cs

@@ -117,6 +117,15 @@ namespace SharpGLTF.Schema2
                 {
                 {
                     var propertyAttributes = rootMetadata.PropertyAttributes;
                     var propertyAttributes = rootMetadata.PropertyAttributes;
                     validate.IsNullOrIndex(nameof(propertyAttribute), propertyAttribute, propertyAttributes);
                     validate.IsNullOrIndex(nameof(propertyAttribute), propertyAttribute, propertyAttributes);
+
+                    foreach(var attribute in propertyAttributes)
+                    {
+                        foreach(var property in attribute.Properties)
+                        {
+                            var expectedVertexAttribute = property.Value.Attribute;
+                            Guard.NotNull(meshPrimitive.GetVertexAccessor(expectedVertexAttribute), expectedVertexAttribute, $"The primitive should have custom vertex attribute {expectedVertexAttribute}.");
+                        }
+                    }
                 }
                 }
 
 
                 base.OnValidateReferences(validate);
                 base.OnValidateReferences(validate);