You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementations of the glTF metadata extensions contain definitions of "model classes" that offer the actual structures and functionalities of the extensions. And they contain lower-level interface definitions that, roughly speaking, ensure type-safety in these classes. Some details are explained in this inline comment.
Right now, these interfaces do not properly reflect the optional and required properties. For example, they define some example: string property, but when this property is optional, then it should be example: string | null.
Until now, this was not a critical issue: The model objects are created, and when they don't receive a value for this property from the JSON input, then the value just remained undefined. But... the model classes derive the signature of their methods from these interfaces! And therefore, this can cause two more pressing issues:
The model class would offer a method like getExample() : string, asserting that the result should never be undefined - but it could be undefined if no value was given in the JSON input
Similarly, the model offers a method like setExample(example: string), which would not accept undefined as a parameter.
(The latter became apparent in a rabbit hole related to #117, where it was necessary to set the schemaUri of a StructuralMetadata to undefined, and this wasn't allowed...)
All properties should be checked accordingly, based on whether they are required or optional in the schema.
EDIT: An aside: Some details about null vs. undefined may require some attention here. From what I've seen, the glTF-Transform "model" classes generally never use undefined anywhere. They always use null. I'm not sure about the reasoning, but assume that the metadata extension implementations should follow whatever conventions already exist, and handle optional properties via null.
The text was updated successfully, but these errors were encountered:
The implementations of the glTF metadata extensions contain definitions of "model classes" that offer the actual structures and functionalities of the extensions. And they contain lower-level interface definitions that, roughly speaking, ensure type-safety in these classes. Some details are explained in this inline comment.
Right now, these interfaces do not properly reflect the optional and required properties. For example, they define some
example: string
property, but when this property is optional, then it should beexample: string | null
.Until now, this was not a critical issue: The model objects are created, and when they don't receive a value for this property from the JSON input, then the value just remained
undefined
. But... the model classes derive the signature of their methods from these interfaces! And therefore, this can cause two more pressing issues:getExample() : string
, asserting that the result should never beundefined
- but it could be undefined if no value was given in the JSON inputsetExample(example: string)
, which would not acceptundefined
as a parameter.(The latter became apparent in a rabbit hole related to #117, where it was necessary to set the
schemaUri
of aStructuralMetadata
toundefined
, and this wasn't allowed...)All properties should be checked accordingly, based on whether they are required or optional in the schema.
EDIT: An aside: Some details about
null
vs.undefined
may require some attention here. From what I've seen, the glTF-Transform "model" classes generally never useundefined
anywhere. They always usenull
. I'm not sure about the reasoning, but assume that the metadata extension implementations should follow whatever conventions already exist, and handle optional properties vianull
.The text was updated successfully, but these errors were encountered: