feat: Extend Save3D to save vertex colors and textures (CORE-189)#13824
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR extends the MESH type to carry optional UVs, per-vertex colors, and a texture tensor; adds pack_variable_mesh_batch and get_mesh_batch_item for ragged per-item meshes; implements save_glb to write GLB files (including optional UVs/colors/embedded PNG textures); adds a SaveGLB ComfyUI node and Save3DExtension entrypoint; registers nodes_save_3d.py for startup loading; and updates VoxelToMesh nodes to return either stacked MESH batches or packed variable-size batches when shapes differ. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comfy_extras/nodes_save_3d.py`:
- Around line 20-57: The pack_variable_mesh_batch helper currently discards
texture data; update pack_variable_mesh_batch to accept a textures parameter
(e.g., textures=None), validate and pack per-item textures analogously to
colors/uvs (compute max_textures, create packed_textures, texture_counts tensor,
copy slices), and attach them to the returned Types.MESH as mesh.texture and
mesh.texture_counts; if mixed texture sizes are not supported, explicitly raise
a clear error inside pack_variable_mesh_batch instead of dropping textures so
SaveGLB.execute and other consumers receive or fail on texture data
consistently.
- Around line 100-118: Before serializing in the block that converts tensors to
numpy (symbols: vertices, faces, uvs, vertex_colors, vertices_np, faces_np,
uvs_np, colors_np), add validation: ensure faces is a 2D integer array with all
indices >=0 and < vertices.shape[0]; ensure uvs (if not None) has first-dim
length equal to vertices.shape[0] (or to faces.shape[0] depending on your UV
convention) and shape[1]==2; ensure vertex_colors (if not None) has first-dim
length equal to vertices.shape[0] and values in [0,1]; if any check fails raise
a clear exception describing the mismatch and which array failed so the exporter
fails fast instead of producing an invalid GLB.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 71d3745e-c0c5-4366-90ab-faa160ccccfe
📒 Files selected for processing (4)
comfy_api/latest/_util/geometry_types.pycomfy_extras/nodes_hunyuan3d.pycomfy_extras/nodes_save_3d.pynodes.py
|
Tested and working fine. |
…mfy-Org#13824) Split GLB save logic out of nodes_hunyuan3d.py into a new nodes_save_3d.py, and extend the writer to support UVs, per-vertex colors, and embedded baseColor textures. Extend the MESH type with optional uvs, vertex_colors, and texture fields so meshes can carry texture data through the graph. Add pack_variable_mesh_batch / get_mesh_batch_item helpers and switch VoxelToMesh / VoxelToMeshBasic to use them so batches with differing vertex/face counts no longer fail at torch.stack.
nodes_hunyuan3d.pyinto a newnodes_save_3d.py, and extend the writer to support UVs, per-vertex colors, and embedded baseColor textures.MESHtype with optionaluvs,vertex_colors, andtexturefields so meshes can carry texture data through the graph.pack_variable_mesh_batch/get_mesh_batch_itemhelpers and switchVoxelToMesh/VoxelToMeshBasicto use them so batches with differing vertex/face counts no longer fail attorch.stack.