Open JamesGaskell opened 3 weeks ago
The 3D Tiles schema and values are stored separately.
The schema can be accessed using TryGetEmbeddedSchema of EXTStructuralMetadataRoot;
The values are in PropertyTables of EXTStructuralMetadataRoot, but it's an internal property. (https://github.com/vpenades/SharpGLTF/blob/master/src/SharpGLTF.Ext.3DTiles/Schema2/Ext.StructuralMetadataRoot.cs#L79) The propertyTables contains references to bufferViews for the property values (they are binary encoded).
So at the moment reading the values of the property tables back is not supported. Support can be added but it's some work to get right for all data types.
I'm using the SharpGLTF.Ext.3DTiles extension with Cesium and am able to build them and display them in Cesium reading values out of the property tables using conditions on the Cesium3DTileStyle. This is how I'm building them following examples from this repo.
` var scene = new SceneBuilder("scene"); // mesh contains the vertices/triangles with a custom property vertex and Feature Id scene.AddRigidMesh(mesh, transform); var model = scene.ToGltf2(); var rootMetadata = model.UseStructuralMetadata(); var schema = rootMetadata.UseEmbeddedSchema("Schema"); var metadataClass = schema.UseClassMetadata("ClassMetadata");
// Values is a list of doubles var propertyTable = metadataClass.AddPropertyTable(values.Length, "Property Table");
var heightMetaDataProperty = metadataClass.UseProperty("Value").WithFloat64Type(); propertyTable.UseProperty(heightMetaDataProperty).SetValues(propertyMaps.Heights);
var featureIdAttribute = new FeatureIDBuilder(values.Length, 0, propertyTable); model.LogicalMeshes[0].Primitives[0].AddMeshFeatureIds(featureIdAttribute);`
But what I want to do now is read those values back out of the GLTF property table so I can update the model based on some user input and push it back to the cesium web client. Based on 'src/SharpGLTF.Ext.3DTiles/README.md' and reading through unit tests I can read the feature Ids and access the StructuralMetadataClass and schema from the vertices but cannot find a way to get the "Value" array of doubles(/Float64s) from the property tables. Have I missed something obvious? Is this possible?