-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] Using Dictionary-Key instead of List-Index #1576
Comments
This is pretty unlikely to happen. In glTF 1.0, the top-level elements had been dictionaries. In glTF 2.0, this was changed to be arrays. I fully agree that this makes modifications difficult or impossible. But the reasoning behind the changes are summarized in #831 |
@javagl Okey, it makes sense them to be arrays.... it quite limits edition, but we will have to live with that. |
@vpenades It should be possible for a script to renumber things after removing an element from an array, although this gets complicated when extensions are involved. It's been a feature request in VSCode for some time now, but no one has had time to work on it, see AnalyticalGraphicsInc/gltf-vscode#96. |
I've written some general-purpose "modify a glTF file" utilities in this project as well: https://github.com/donmccurdy/glTF-Transform, including adding/removing accessors. That project is not polished or production-ready by any stretch, though. |
Right now, the current glTF.2 schema defines the root node as the container of all the object of the scene, which are stored in plain arrays. Referencing between elements is done with indices pointing to the appropiate list.
This is a quite simple implementation, but it makes extremely difficult to modify an existing model, specially when dealing with removing elements. With the current implementation, if you want to remove an element, lets say, an accessor it is no longer in use, it needs to be removed from the Accessors list, but then, all the references to all the accessors above the one that's been removed become out of order, so we need to traverse the whole model hunting down all the elements that reference accessors, and fixing the indices, so they point back to the appropiate accessor.
This becomes even more difficult if we also need to handle extensions that also reference elements in the model. Editing (removing) elements in a glTF model without caring about extensions might render the model unusable.
So at this point, I consider glTF.2 as an Append Only format; you can add elements to it, but you cannot remove elements.
And maybe this is just the right approach, because it enforces everybody to write authoring layers on top, and then create the glTF.2 model just at the time of exporting, so an appending only API would be enough.
But, if at some point, editing glTF models (including allow to remove elements) is considered useful, maybe replacing the Lists at model root with Dictionaries, and change the referencing with integer keys could greatly simplify this issue.
The text was updated successfully, but these errors were encountered: