feat(export_gltf): embed sharp angle in GLB extras + restore script

- Add export_extras=True to bpy.ops.export_scene.gltf() call
- Store schaeffler_sharp_angle_deg in scene custom props before export
  → value is embedded in scenes[0].extras in the GLB JSON chunk
  → survives import/export round-trip intact (verified: 30.0 restored)
- Add tools/restore_sharp_marks.py: companion Blender script that reads
  the angle from scene.get("schaeffler_sharp_angle_deg") and re-applies
  mark_sharp() + mark_seam() on all mesh objects after GLB import

GLB format cannot store per-edge sharp/seam flags natively; the visual
shading is correct via vertex splits. The extras + restore script give
users the ability to reconstruct Edit Mode markers without a second format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 11:38:47 +01:00
parent ec35188353
commit 202b06a026
2 changed files with 55 additions and 1 deletions
+9 -1
View File
@@ -281,7 +281,14 @@ def main() -> None:
except Exception:
pass # non-critical; export proceeds regardless
# Export production GLB with full PBR material data
# Store the sharp angle in the scene so it is embedded in the GLB extras.
# After importing the production GLB in Blender, running restore_sharp_marks.py
# reads this value and re-applies mark_sharp()+mark_seam() on all mesh objects.
bpy.context.scene["schaeffler_sharp_angle_deg"] = args.smooth_angle
# Export production GLB with full PBR material data.
# export_extras=True embeds scene custom properties (incl. schaeffler_sharp_angle_deg)
# in the glTF scenes[0].extras JSON field, surviving the round-trip intact.
try:
bpy.ops.export_scene.gltf(
filepath=args.output_path,
@@ -290,6 +297,7 @@ def main() -> None:
use_selection=False,
export_materials="EXPORT",
export_image_format="AUTO",
export_extras=True,
)
except Exception as exc:
print(f"GLB export failed: {exc}", file=sys.stderr)