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
Allow filtering "extras" in GLTFExporter #18445
Comments
Is this sufficient? I'd rather avoid a userData-specific callback if we can. const originalUserData = new Map();
// stash userData
scene.traverse((o) => {
originalUserData.set(o, o.userData);
const {a, b, c} = o.userData;
o.userData = {a, b, c};
});
// export
exporter.parse( scene, ... );
// restore userData
scene.traverse((o) => {
o.userData = originalUserData.get(o);
}); You can also do post-export modifications to the JSON, iterating over |
You're thinking it should be a callback rather than my simple option + filter because the json object at that point may not be a dict (i.e. it might be an array)? That's a good point -- for my use case it would be fine to only filter if the object has keys, but it wouldn't prevent a giant array from being exported, so you're right that it's an incomplete solution. |
The root I'm hoping to avoid adding more options to GLTFExporter for things that could be done by processing the input data instead. There are, for better or worse, quite a lot of options that have been requested if we go down that road, and they eventually become difficult to maintain. |
Personally I'm interested in GLTFExporter extension mechanism you @garyo suggested at #11682 (comment) rather than adding new options. I agree with Don that I hope we can avoid a lot of options. |
Extension mechanism would work fine for me as well. |
Sounds good, and thanks for that PR! |
I'm using three.js with a system that attaches all kinds of info to the three.js objects as
userData
properties. When I export, I'm getting those (large) properties as "extras" on the glTF nodes, which is as designed but definitely suboptimal, and breaks importers like Blender 2.8 (which expects "extras" to only have primitive types, not giant nested objects). I'd like to be able to filter out some or all of those props during the export process. (My scene is very large, so I'd like to avoid copying the whole thing and removing the props from the clone.)I propose adding a new option,
filterOutUserDataKeys: string[]
, defaulting to[]
, which would be used here:three.js/examples/jsm/exporters/GLTFExporter.js
Line 416 in 4541808
Something like this (untested):
Does that make sense? If there's a way to do this already, that would be even better.
The text was updated successfully, but these errors were encountered: