-
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
Inconsistent object field naming in Material for generic properties #2420
Comments
RFC 8259 that defines JSON format says:
glTF does not define (let alone require) any specific order of object properties. |
That said, we'll update the schema file for consistency. |
It may be worth noting that these properties are actually not defined in the
material is ""inheriting"" from, as far as one can say this for JSON schema...)
(EDIT: The point is that the order can even be different in the "base" definition and the ""inheriting"" one...) |
Is there any way I could put some hidden or meaningless tag somewhere into the glTF file that still conforms with the spec? I am planning on writing a Parser that would try and detect that tag, and then if it exists use a parser that is a lot quicker since it assumes a certain field order. Perhaps something in the |
Assuming that the flag should be located as close as possible to the beginning of the file, I'd suggest adding something to the {
"extras": {
"fastgltfFieldOrder": true
},
"asset": {
"version": "2.0"
}
} |
hmm though I am not sure how we'll that'd work in a generic library, since I currently just forward the extra object's JSON as a string to the user. And when exporting glTF's I essentially ask the user for the object string, and it'd be hard or at least a little hacky to add another field into that object... And what about other loaders... would they be fine with that extra field just existing? Is it the norm to ignore unknown fields when working with JSON? I don't know much of the glTF ecosystem and quirks of JSON loaders apart from what exists for C++. |
The spec explicitly defines |
The
name
,extras
, andextensions
fields exist on every object, in that order, and always at the end as the last fields. However, for theMaterial
object these fields come first, as declared here in the JSON schema:glTF/specification/2.0/schema/material.schema.json
Lines 9 to 11 in 082d5a9
Is there any reason for this inconsistency? I'm interested since I want to speed up the JSON deserialization in
fastgltf
by assuming a certain field order, that is consistent with the spec, when I can safely detect the asset was serialized using the library. And it feels wrong to me that these three fields appear at the beginning here instead of the end.The text was updated successfully, but these errors were encountered: