Closed issacclee closed 3 years ago
I need more context to understand what you want to do.
If you want to load an existing model, delete an image from a material, and then save the model with that change, then, it's still possible to do it, but it's not easy to do, and need to be aware of potential issues.
The scenario is that our application received bunch of gltf models that were exported from various CAD software, some CAD software's gltf exporter don't conform to gltf spec by the book, which leaves us with situation such as
Based on that, I would like to use SharpGLTF to load those models, check the validity of each image object and remove the ones that can not be fixed(such as situation 1 and 2)
Obviously when I m removing a gltf image with corrupted file, I would also like to remove the texture object that reference such image object and the relative map reference in material as well.
As you have noticed, the Schema2 namespace has classes and APIs that only allow the add new elements to the DOM, not remove. In order to fully edit a glTF (and add/remove) elements, you need to convert from Schema2 to SceneBuilder, and then it's when you can remove the images from the materials.
But all this is, assuming the gltf is well formed. In fact, trying to convert from Schema2 to SceneBuilder will probably fail if the textures are missing or malformed, so you can't really use that path.
Simply put: SharpGLTF cannot be used to fix malformed glTF models.
I can see two possible solutions:
Ultimately, you should contact the developers that are exporting malformed glTFs, the problem definitively needs to be fixed on their end.
Thanks @vpenades , much appreciated, I'll close this issue now.
Hi, After having done some digging through the source code, I still haven't found a way to delete a image and all other reference of deleted image. I was wondering if such behavior does not align with the purpose of this project?