glTF-CSharp-Loader icon indicating copy to clipboard operation
glTF-CSharp-Loader copied to clipboard

Support for Khronos Extensions

Open christinejohnson opened this issue 7 years ago • 3 comments

Is there a plan for including the Khronos Extensions schemas (e.g. KHR_materials_pbrSpecularGlossiness.schema.json) or should these be handled like custom extensions?

christinejohnson avatar Apr 06 '18 23:04 christinejohnson

It would be great to add them. I'm not aware of any plans to add this at the moment. You can however generate them using the generator executable that is built by this project. In fact, we did exactly this in the glTF asset generator project.

https://github.com/bghgary/glTF-Asset-Generator/blob/master/Source/Schema/MaterialPbrSpecularGlossiness.cs

bghgary avatar Apr 07 '18 00:04 bghgary

I was trying to include the KHR_techniques_webgl schema and the KHR_materials_pbrSpecularGlossiness schema to my loader as well. Unfortunately I'm always getting the "Attempting to overwrite non-Default schema." Exception. Is it not possible to create a loader which is supporting extensions with the Generator as you described before or what am I doing wrong?

arne1895 avatar Nov 22 '18 14:11 arne1895

The way we did it is a hack.

Copy the extension's schema to the core schema location (e.g. copy glTF\extensions\2.0\Khronos\KHR_materials_pbrSpecularGlossiness\schema\glTF.KHR_materials_pbrSpecularGlossiness.schema.json to glTF\specification\2.0\schema).

Then change Program.cs to point to the copied extension schema.

static void Main(string[] args)
{
    var generator = new CodeGenerator(@"..\..\..\..\..\glTF\specification\2.0\schema\glTF.KHR_materials_pbrSpecularGlossiness.schema.json");
    generator.ParseSchemas();
    generator.ExpandSchemaReferences();
    generator.EvaluateInheritance();
    generator.PostProcessSchema();
    generator.CSharpCodeGen(Path.GetFullPath(@"..\..\..\..\glTFLoader\Schema\KHR_materials_pbrSpecularGlossiness"));
}

Ideally, we should change Program.cs to take some parameters and modify CodeGenerator and relevant code to accept a schema from a separate location from the core schema directory. Then we'll be able to run the generator on extension.

Contributions for this is very welcomed.

bghgary avatar Jan 05 '21 17:01 bghgary