Decode one named extension object, such as KHR_materials_ior, from the extensions of a document,
node, material or texture reference into a typed struct. The result is true when the extension is
present; an object of the wrong shape gives a .JSON error and found is still true. Extensions
that no struct covers stay raw in extensions. Release the value with free_json (needed only for
types with pointers or extras, but always allowed) and the error with gltf_error_free.
Signature
gltf_extension :: (
extensions: *Json_Value,
name: string,
$T: Type
) -> (T, bool, Gltf_Error)
asset, error := gltf_load("{\"asset\":{\"version\":\"2.0\"},\"extensionsUsed\":[\"KHR_materials_ior\"],\"materials\":[{\"extensions\":{\"KHR_materials_ior\":{\"ior\":1.33}}},{}]}");
assert(error.kind == .NONE);
defer gltf_free(*asset);
ior, found, ior_error := gltf_extension(*asset.document.materials[0].extensions, "KHR_materials_ior", Gltf_Ior);
assert(found && ior_error.kind == .NONE && ior.ior == 1.33);
_, found = gltf_extension(*asset.document.materials[1].extensions, "KHR_materials_ior", Gltf_Ior);
assert(!found);