Skip to content

fix(export): write the material and texture next to OBJ exports - #466

Merged
lightningpixel merged 1 commit into
devfrom
fix/obj-export-texture
Nov 18, 2026
Merged

lightningpixel merged 1 commit into
devfrom
fix/obj-export-texture

Conversation

@lightningpixel

Copy link
Copy Markdown
Owner

Closes #445. Refs #373

Exporting a textured mesh to OBJ wrote only the .obj, with no material and no texture. Now, like Blender, the user picks <name>.obj and gets <name>.obj, <name>.mtl and <name>_texture.png side by side. The OBJ and the MTL refer to the other files by relative name.

Changes

  • Generate page
    • OBJ export now goes through model:export: a save dialog for the .obj, then the main process writes the other files next to it.
    • New route: GET /export/obj/files?path=&name= returns the files as base64 and rejects names containing path separators.
    • GET /export/{fmt} still returns plain OBJ for modly-cli.
    • Untextured meshes export as before.
    • The OBJ row of the Export dropdown shows a hint: textures are saved as separate files, GLB keeps everything in one.
  • Mesh Exporter node
    • New obj.ts writes mtllib/usemtl, the MTL and the base color textures. Textures keep their GLB format (png/jpg/webp), are numbered when there are several, and untextured parts get their own material.
    • Fixes the V flip: glTF's UV origin is top-left, OBJ's is bottom-left.
    • Select options can carry a hint; the OBJ option uses it.
  • Real-world scale: unchanged in both paths (export_scale in the API, millimetres in the node).

#373

Hunyuan3D 2 mini turbo only textures when enable_texture is on (off by default), which may explain that report. With it on, exporting to OBJ hit this bug. PLY also drops the texture; that is out of scope here.

Testing

  • Python: 580 OK, 4 new export tests (the three files and their references, texture the right way up through a GLB round trip, untextured gives the OBJ alone, bad names rejected)
  • Node: 7 new obj.test.ts tests + 1 end-to-end Mesh Exporter test; lint clean; tsc errors identical to dev
  • Both outputs imported in Blender 5.2: textured and the right way up, file names with spaces included
  • Not checked in the app: the OBJ save dialog and the two hints

Exporting a textured mesh to OBJ wrote the .obj alone, so the texture was
lost. Like Blender, the user now picks <name>.obj and <name>.mtl and
<name>_texture.png are written beside it; untextured meshes export as
before.

- API: GET /export/obj/files answers the OBJ export as its separate files;
  the Generate page saves OBJ through the main process, which writes them
  side by side.
- Mesh Exporter node: writes the .mtl and the base color texture too, and
  flips V from glTF's top-left UV origin to OBJ's bottom-left one.
- A hint under OBJ says textures go to separate files and GLB keeps
  everything in one.
@lightningpixel
lightningpixel merged commit f815517 into dev Nov 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant