CesiumGS / cesium-native

Apache License 2.0
414 stars 210 forks source link

Generate classes/writers/readers for custom glTF extensions #805

Open mlavik1 opened 7 months ago

mlavik1 commented 7 months ago

Hi, I'm wondering what would be the best way to add support for custom glTF extensions.

I suppose I could fork your glTF repository and add my schema files there, and then also fork cesium-native add reference them in glTF.json - but that complicates things a bit more than I had hoped. Are there any other ways, or would you consider adding support for a custom extension folder and config file, so that I could call:

node index.js --schema [SAME PARAMS AS USUAL]... --customExtensions myProject/my_extension --customExtConfig myglTF.json

Thanks for reading!

Update: Ok, so while the generated JsonHandlers are output as separate files, that's not the case for the Json-writer code - which are a collection of "writeJson" functions inside ModelJsonWriter.cpp So I guess this means that the only way of adding custom extensions would be to fork these two repositories then, right?

kring commented 7 months ago

Yeah I think the two forks are the only option right now. Otherwise, as you suggested, the code generator needs to be extended to support externally-defined extensions. That'll likely require a bit of refactoring.

mlavik1 commented 7 months ago

@kring Yeah. For generating the extension class files and JSON reader code it would maybe not be that much work, but the code generation output for the JSON writers would have to be changed quite a bit..

But thanks for answering! I've forked both repos now, and that worked fine for me :) So should we close this issue, or is it worth keeping it open?


And just in case other users who want to do the same read this issue someday in future, this is what I did:

kring commented 7 months ago

So should we close this issue, or is it worth keeping it open?

Let's leave it open. This is a use-case we'd like to support at some point.