Skip to content

Commit

Permalink
breaks again?
Browse files Browse the repository at this point in the history
  • Loading branch information
bertt committed Feb 1, 2024
1 parent 1de9422 commit 2743b28
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/SharpGLTF.Ext.3DTiles/Schema2/Ext.StructuralMetadataRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,10 +1579,25 @@ public StructuralMetadataClassProperty WithMatrix4x4ArrayType(int? count = null)
return WithArrayType(ELEMENTTYPE.MAT4, DATATYPE.FLOAT32, count);
}

public StructuralMetadataClassProperty WithStringArrayType(int? count = null, string noData = null)
public StructuralMetadataClassProperty WithStringArrayType(int? count = null, List<string> noData = null, List<string> defaultValue = null)
{
var property = WithArrayType(ELEMENTTYPE.STRING, null, count);
if (noData != null) property._noData = noData;
if (noData != null)
{
var arr = noData.ToArray();
var jsonNodes = new List<JsonNode>();
foreach(var item in arr)
{
jsonNodes.Add(item);
}
var jsonArray = new JsonArray(jsonNodes.ToArray());

property._noData = jsonArray;
}
if (noData != null)
{
property._default = new JsonArray(defaultValue[0]);
}
return property;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/SharpGLTF.Ext.3DTiles.Tests/ExtStructuralMetadataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ public void MetadataNullValuesAttributeSample()
.UseProperty("matrix4x4")
.WithMatrix4x4Type(Matrix4x4.Identity * -10);

var stringArrayProperty = schemaClass
.UseProperty("stringArray")
.WithStringArrayType(noData: ["test0", "test1"], defaultValue: ["nothing"]);

// todo add array types

var propertyTable = schemaClass.AddPropertyTable(1);
Expand Down Expand Up @@ -247,6 +251,13 @@ public void MetadataNullValuesAttributeSample()
.UseProperty(matrix4x4Property)
.SetValues(m4);

var strings = new List<List<string>>();
strings.Add(["test0", "test1"]);

propertyTable
.UseProperty(stringArrayProperty)
.SetArrayValues(strings);

foreach (var primitive in model.LogicalMeshes[0].Primitives)
{
var featureIdAttribute = new FeatureIDBuilder(1, 0, propertyTable);
Expand Down

0 comments on commit 2743b28

Please sign in to comment.