Repository navigation
feat(exporting): add native glTF 2.0 and GLB export - #515
Open
JarrettSJohnson wants to merge 11 commits into
Open
JarrettSJohnson wants to merge 11 commits into
JarrettSJohnson wants to merge 11 commits into
Conversation
…, colors, GLB limits
- Cylinder/cone shafts were wound clockwise relative to their outward normals, so viewers that flip back-face normals on double sided materials (e.g. three.js) shaded sticks, lines and mesh dark. - Tilt cone shaft normals by the taper and use r2 for the round nub at the cone's second end. - Orient the exported scene like the current view, centered on the origin of rotation, and honor geometry_export_mode=1 (keep model space coordinates), consistent with the COLLADA/OBJ/VRML/IDTF exporters. - cmd.get_glb() now returns bytes, like get_collada/get_vrml, and save writes them. - cmd.get_gltf falls back to collada2gltf when PyMOL is built without --json=true, so .gltf export does not regress for those builds. - Tests for triangle winding and view orientation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ray triangle primitives each carry their own copy of the corner vertices, so surfaces and cartoons were exported as triangle soup. Reuse vertices whose position, normal, and color match exactly, which recovers the mesh connectivity (corners are copied from the same representation data) and skip triangles that collapse to fewer than three vertices. Surfaces and cartoons have 5-6x fewer vertices, e.g. the 1rx1 surface GLB shrinks from 2.3 MB to 0.6 MB with identical rendering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f-glb # Conflicts: # testing/tests/api/test_exporting.py
get_gltf writes the file itself, so it bypassed the atomic write that save gained in #521 and a failed write could still truncate an existing .gltf file. Use exporting._write_file_atomic, and cover glb/gltf in the save failure test (requires_capability now returns a pytest mark, so it also works in pytest.param). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the glTF/GLB portion of #497 by adding native glTF 2.0 and binary GLB export without the external COLLADA2GLTF conversion step. The exporter preserves geometry scale (1 unit = 1 Å), vertex colors, normals, and transparency for sticks, spheres, cartoons, and surfaces.
save file.glb/cmd.get_glb()(returns bytes) andsave file.gltf/cmd.get_gltf(filename)(self-contained, base64-embedded buffer).geometry_export_mode=1keeps model space coordinates, matching the COLLADA/OBJ/VRML/IDTF exporters.--json=trueand requires nlohmann-json. Without it,.gltfexport falls back tocollada2gltfas before, and.glbraises a clear error.Testing
geometry_export_mode.collada2gltffallback with the native exporter disabled.--json=true.🤖 Generated with Claude Code