Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mlavik1 opened this issue Feb 6, 2024 · 3 comments
Open

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

mlavik1 opened this issue Feb 6, 2024 · 3 comments

Comments

@mlavik1
Copy link

mlavik1 commented Feb 6, 2024

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
Copy link
Member

kring commented Feb 7, 2024

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
Copy link
Author

mlavik1 commented Feb 7, 2024

@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:

  • Forked the glTF repository ("tree/3d-tiles-next" branch for 3d-tiles next) and added my schema.json files to new a folder inside "extensions/2.0/Vendor"
  • Forked cesium-native and replaced the Cesium's glTF-repo URL with our own fork in package.json, and also modified glTF.json by adding our extension to "extensions" and added class name overrides under "classes".
  • Ran the gltf-generate command as described here

@kring
Copy link
Member

kring commented Feb 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants