glTF-Validator icon indicating copy to clipboard operation
glTF-Validator copied to clipboard

Custom validators for extensions/extras

Open valdrinkoshi opened this issue 6 years ago • 2 comments

Hello, we'd like to use this validator and extend it to check our custom/proprietary extensions and extras. Is there a recommended way to define custom validators? If not, would you be interested in providing one?

As an example, RANDOM_background is a custom extension for scenes that randomizes the background color. We define it as:

"scenes" : [
      {
         "extensions" : {
            "RANDOM_background" : [
              {"min": 0.3, "max": 0.5},
              {"min": 0.0, "max": 1.0},
              {"min": 0.0, "max": 1.0}
            ]
         }
      }

We'd want to validate RANDOM_background value to be an array of 3 items, each with min/max that span between [0.0, 1.0]

Another example: HINTS_geometry_data is a custom extras for scenes that stores precomputed values like centroid, which can be used by the runtime to go faster:

 "scenes" : [
      {
         "extras" : {
            "HINTS_geometry_data" : {
              "centroid": [0.0, 0.0, 0.0]
            }
         }
      }

Similarly, we'd want to validate HINTS_geometry_data value to be an object with centroid defined as array of 3 finite numbers.

valdrinkoshi avatar Oct 18 '19 17:10 valdrinkoshi

+1 for this idea, if it can be done.

Separately, note that if you can express your glTF extension as JSON schema following the normal glTF extension pattern, it can be added to VSCode such that you get schema validation, tooltips, and auto-complete for fields and enums.

emackey avatar Oct 18 '19 20:10 emackey

Yes, this will be the next milestone.

lexaknyazev avatar Oct 21 '19 07:10 lexaknyazev