-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
USDZExporter: Refactor to use two stages #31400
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
Conversation
First create node trees, then stringify
66eb6e5
to
3ef5c92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the USDZExporter to use a two-stage process: first building a tree of USD nodes, then converting that tree to final USD string output. The refactoring maintains the same final output while improving code maintainability and making future changes easier.
- Introduces a new
USDNode
class to represent USD nodes with properties, metadata, and children - Refactors material, mesh, and camera building functions to create node trees instead of direct string output
- Consolidates string generation into the
USDNode.toString()
method for consistent formatting
Comments suppressed due to low confidence (2)
examples/jsm/exporters/USDZExporter.js:679
- [nitpick] The function name 'buildTextureNodes' is inconsistent with the existing naming pattern. Other functions in the file use 'build' prefix for single objects (buildMaterial, buildCamera, buildMeshObject). Consider renaming to 'buildTextureNodeSet' or 'createTextureNodes' to better reflect that it returns multiple nodes.
function buildTextureNodes( texture, mapType, color ) {
examples/jsm/exporters/USDZExporter.js:507
- [nitpick] The function name 'buildMeshNode' is inconsistent with the original 'buildMesh' function it replaces. Since this is a refactoring, consider keeping the original name 'buildMesh' to maintain consistency with other build functions in the codebase.
function buildMeshNode( geometry ) {
Anything from the copilot review that seems worth doing? |
Yes, the metadata handling suggestion makes sense. I simplified in a similar way. |
Description
This is a refactoring of the exporter to process in two stages: first building up trees of nodes, and then doing the final stringifying (and with the same final output as before, modulo whitespace which is improved). It stops short of fully breaking down properties and leaves most as strings.
This has the significant benefits of making upcoming changes much simpler (like object hierarchy (#31235), just change the tree layout), and in general easier to maintain and extend.