fix(USD): correct coordinate transform (Z-up stage) and store canonical_material in DB

- export_step_to_usd.py: change stage from Y-up to Z-up, keep (X,-Z,Y)
  transform — matches GLB orientation exactly (verified: bounding box match)
- export_glb.py: include canonical_material in resolved_material_assignments
  DB field (was being dropped during manifest parsing)
- import_usd.py: use pxr customData read (not string primvars — Blender
  ignores those, confirmed by testing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 23:17:45 +01:00
parent cc3071297b
commit b72d8498b9
2 changed files with 10 additions and 3 deletions
+5 -2
View File
@@ -634,7 +634,7 @@ def main() -> None:
# ── Create USD stage ──────────────────────────────────────────────────────
stage = Usd.Stage.CreateNew(str(output_path))
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.y)
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)
UsdGeom.SetStageMetersPerUnit(stage, 0.001) # mm; Blender handles m conversion on import
root_prim = UsdGeom.Xform.Define(stage, "/Root")
@@ -705,7 +705,10 @@ def main() -> None:
mesh = UsdGeom.Mesh.Define(stage, mesh_path)
mesh.CreateSubdivisionSchemeAttr(UsdGeom.Tokens.none)
# OCC (X, Y, Z) mm Z-up → USD (X, -Z, Y) mm Y-up
# OCC is Z-up (mm) but Y-forward. Blender is Z-up, Y-backward.
# GLB export uses: Blender(X, -Z_occ, Y_occ) × 0.001
# USD stage is Z-up with metersPerUnit=0.001, so Blender applies
# only the scale. Write (X, -Z, Y) to match GLB orientation.
mesh.CreatePointsAttr(Vt.Vec3fArray([
Gf.Vec3f(x, -z, y) for (x, y, z) in vertices
]))