瀏覽代碼

fix the tests

Bert Temme 2 年之前
父節點
當前提交
9d857386e2

+ 1 - 1
src/SharpGLTF.Cesium/Schema2/Ext.MeshFeatures.cs

@@ -154,7 +154,7 @@ namespace SharpGLTF.Schema2
             {
                 Guard.MustBeGreaterThanOrEqualTo((int)item.PropertyTable, 0, nameof(item.PropertyTable));
                 var metadataExtension = primitive.LogicalParent.LogicalParent.GetExtension<EXTStructuralMetadataRoot>();
-                Guard.NotNull(metadataExtension, nameof(metadataExtension), "EXT_Structural_Meatdata extension is not found.");
+                Guard.NotNull(metadataExtension, nameof(metadataExtension), "EXT_Structural_Metadata extension is not found.");
                 Guard.NotNull(metadataExtension.PropertyTables[item.PropertyTable.Value], nameof(item.PropertyTable), $"Property table index {item.PropertyTable.Value} does not exist");
             }
             if (item.Texture != null)

+ 2 - 0
src/SharpGLTF.Cesium/Schema2/Ext.StructuralMetadataPrimitive.cs

@@ -7,6 +7,8 @@ namespace SharpGLTF.Schema2
         internal ExtStructuralMetadataMeshPrimitive(MeshPrimitive meshPrimitive)
         {
             this.meshPrimitive = meshPrimitive;
+            _propertyTextures = new List<int>();
+            _propertyAttributes = new List<int>();
         }
 
         private MeshPrimitive meshPrimitive;

+ 15 - 14
tests/SharpGLTF.Cesium.Tests/ExtStructuralMetadataTests.cs

@@ -232,12 +232,6 @@ namespace SharpGLTF.Cesium
 
             var model = scene.ToGltf2();
 
-            var featureId0 = new MeshExtMeshFeatureID(2, 0, 0);
-            var featureId1 = new MeshExtMeshFeatureID(2, 1, 0);
-            var featureIds = new List<MeshExtMeshFeatureID>() { featureId0, featureId1 };
-
-            model.LogicalMeshes[0].Primitives[0].SetFeatureIds(featureIds);
-
             var schema = new StructuralMetadataSchema();
             schema.Id = "MultipleFeatureIdsAndPropertiesSchema";
 
@@ -282,6 +276,12 @@ namespace SharpGLTF.Cesium
 
             model.SetPropertyTable(examplePropertyTable, schema);
 
+            var featureId0 = new MeshExtMeshFeatureID(2, 0, 0);
+            var featureId1 = new MeshExtMeshFeatureID(2, 1, 0);
+            var featureIds = new List<MeshExtMeshFeatureID>() { featureId0, featureId1 };
+
+            model.LogicalMeshes[0].Primitives[0].SetFeatureIds(featureIds);
+
             var ctx = new ValidationResult(model, ValidationMode.Strict, true);
             model.AttachToCurrentTest("cesium_ext_structural_metadata_featureid_attribute_and_property_table.glb");
             model.AttachToCurrentTest("cesium_ext_structural_metadata_featureid_attribute_and_property_table.gltf");
@@ -309,9 +309,6 @@ namespace SharpGLTF.Cesium
 
             var model = scene.ToGltf2();
 
-            var featureId = new MeshExtMeshFeatureID(1, 0, 0);
-            model.LogicalMeshes[0].Primitives[0].SetFeatureId(featureId);
-
             var schema = new StructuralMetadataSchema();
             schema.Id = "FeatureIdAttributeAndPropertyTableSchema";
 
@@ -353,6 +350,9 @@ namespace SharpGLTF.Cesium
             
             model.SetPropertyTable(examplePropertyTable, schema);
 
+            var featureId = new MeshExtMeshFeatureID(1, 0, 0);
+            model.LogicalMeshes[0].Primitives[0].SetFeatureId(featureId);
+
             var ctx = new ValidationResult(model, ValidationMode.Strict, true);
             model.AttachToCurrentTest("cesium_ext_structural_metadata_multiple_featureids_and_properties.glb");
             model.AttachToCurrentTest("cesium_ext_structural_metadata_multiple_featureids_and_properties.gltf");
@@ -380,9 +380,6 @@ namespace SharpGLTF.Cesium
 
             var model = scene.ToGltf2();
 
-            var featureId = new MeshExtMeshFeatureID(1, 0, 0);
-            model.LogicalMeshes[0].Primitives[0].SetFeatureId(featureId);
-
             var schema = new StructuralMetadataSchema();
 
             var exampleMetadataClass = new StructuralMetadataClass();
@@ -473,6 +470,9 @@ namespace SharpGLTF.Cesium
 
             model.SetPropertyTable(examplePropertyTable, schema);
 
+            var featureId = new MeshExtMeshFeatureID(1, 0, 0);
+            model.LogicalMeshes[0].Primitives[0].SetFeatureId(featureId);
+
             var ctx = new ValidationResult(model, ValidationMode.Strict, true);
             model.AttachToCurrentTest("cesium_ext_structural_metadata_complex_types.glb");
             model.AttachToCurrentTest("cesium_ext_structural_metadata_complex_types.gltf");
@@ -504,8 +504,6 @@ namespace SharpGLTF.Cesium
             var featureId1Attribute = new MeshExtMeshFeatureID(1, 1, 1);
 
             // Set the FeatureIds
-            var featureIds = new List<MeshExtMeshFeatureID>() { featureId0Attribute, featureId1Attribute };
-            model.LogicalMeshes[0].Primitives[0].SetFeatureIds(featureIds);
 
             var schema = new StructuralMetadataSchema();
             schema.Id = "MultipleClassesSchema";
@@ -528,6 +526,9 @@ namespace SharpGLTF.Cesium
             var propertyTables = new List<PropertyTable>() { firstPropertyTable, secondPropertyTable };
             model.SetPropertyTables(propertyTables, schema);
 
+            var featureIds = new List<MeshExtMeshFeatureID>() { featureId0Attribute, featureId1Attribute };
+            model.LogicalMeshes[0].Primitives[0].SetFeatureIds(featureIds);
+
             var ctx = new ValidationResult(model, ValidationMode.Strict, true);
             model.AttachToCurrentTest("cesium_ext_structural_metadata_multiple_classes.glb");
             model.AttachToCurrentTest("cesium_ext_structural_metadata_multiple_classes.gltf");