-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
GLTFExporter: Plugin system for extensibility #20842
Conversation
502f10b
to
b743970
Compare
Hi; I ended up doing my processing by duplicating the geometry and making my tweaks there before exporting, so no conflict with my work at all. It would be great to use this instead of my hack when it's ready though! (And I would really love to optimize the resulting glTF.) |
fcdb49a
to
8ad2b55
Compare
Any thoughts on this change? @donmccurdy |
No opposite opinion so far so I marked the PR as ready for review. |
@elalish does this help with the variants issue? |
@mrdoob Yes, this is necessary for variants export. I didn't notice any red flags when I read through it. If you merge this I'll start building on it in model-viewer and let you know if I run into anything. |
@donmccurdy How do you feel about this one? |
I won't be able to do a detailed review or testing on the code changes here, but I like the intention of making this extensible and agree with the design in this PR. It seems like a good structure for the exporter's code moving forward. Once @takahirox or others feel this is ready to merge, that is fine with me. 👍 On naming — I would suggest renaming GLTFParser, parseMesh, parseTexture, etc. to something like GLTFWriter, writeMesh, writeTexture. The word "parse" usually refers to reading and not writing. |
Sounds good to me 👍 |
67f6ca8
to
56da80e
Compare
Thanks for the comments. I renamed them. And I would be happy if you folks would help this
|
I'll merge so people have time to test before the next release. |
Thanks! |
Found a variable that we missed in this refactoring: 9d8ed27 |
Thanks! |
Found another issue in this refactoring: 1435180 |
Thanks again! |
Description
This PR proposes a extensibility mechanism for
GLTFExporter
similar to theGLTFLoader
plugin system.The idea is originally proposed by @garyo at #11682 (comment). If you @garyo have been also working on the exporter extensibility mechanism and my work is conflicted with yours, please let me know.
API
Advantages
Similar to
GLTFLoader
plugin system,GLTFExporter
code will be simpler and clearer because we can separate the extension handler logics from the core codeExpected use cases
Change
Similar to
GLTFLoader
.register(callback)
and.unregister(callback)
toGLTFExporter
GLTFParser
(English question, is this name good in the exporter?) inGLTFExporter
for internal and plugin use. Parser instance is passed to plugins constructors. The plugins can use the parser to handle their logicsparseMesh/Texture/Material/Node
(English question, are these names good?) hook points so far. They are called at the end ofprocessMesh/Texture/Material/Node()
. The hook points take the two arguments, input Three.js object and glTF core spec definition made by the core parser. The plugins add or override glTF definition depending on the Three.js object. We may add other hook points later.before/afterParse
(are they good name?) hook points. It would be used for the root level extensions or processing something at the beginning/end of the export._invokeAll()
method toGLTFExporter
to call plugins' methods.GLTFExporter.js
file. They are registered by default.GLTFLoader
.Ask for help
misc_exporter_gltf.html
and the example unit tests keep working fine but I would test more. If you use the existing exporter, would you please try to locally merge this change and check if your apps keep working?/cc @donmccurdy @zeux @fernandojsg @robertlong @garyo