Skip to content

feat: Add OBJ file import/export support#7

Closed
ebowwa wants to merge 2 commits intovibe-stack:mainfrom
ebowwa:feature/obj-import-export
Closed

feat: Add OBJ file import/export support#7
ebowwa wants to merge 2 commits intovibe-stack:mainfrom
ebowwa:feature/obj-import-export

Conversation

@ebowwa
Copy link
Copy Markdown
Contributor

@ebowwa ebowwa commented Sep 11, 2025

Summary

Re-submitting the OBJ import/export feature from PR #2, now on a proper feature branch.

Features

  • ✅ Complete OBJ parser with support for vertices, normals, UVs, and faces
  • ✅ Robust OBJ exporter with material support (MTL files)
  • ✅ Automatic triangulation of quads and n-gons
  • ✅ Error handling and validation for malformed files
  • ✅ Integration with existing import/export UI dialogs
  • ✅ Support for multiple objects per file
  • ✅ File size limits and comprehensive error reporting

Technical Implementation

  • Follows existing code patterns from glTF importer
  • Proper type safety and error boundaries
  • Memory-efficient parsing for large files
  • Maintains data integrity through round-trip operations

Files Added

  • src/utils/obj-importer.ts - OBJ parsing and mesh creation (478 lines)
  • src/utils/obj-exporter.ts - OBJ generation from meshes (359 lines)
  • src/utils/test-obj.ts - Test utilities (140 lines)
  • Updated src/features/menu/components/menu-bar.tsx - UI integration

UI Integration

  • Added "OBJ..." option to Import menu (replaces "OBJ... (soon)")
  • Leverages existing Three.js OBJExporter in Export dialog
  • Consistent error handling and user feedback

This enables interoperability with industry-standard 3D tools like Blender, Maya, and 3ds Max.


Note: This is a resubmission of PR #2 which was accidentally lost during branch synchronization. The code has been recovered and is now properly submitted from a feature branch.

ebowwa and others added 2 commits September 11, 2025 23:29
Implement comprehensive OBJ file format support for Gestalt 3D Editor:

Features:
- Complete OBJ parser with support for vertices, normals, UVs, and faces
- Robust OBJ exporter with material support (MTL files)
- Automatic triangulation of quads and n-gons
- Error handling and validation for malformed files
- Integration with existing import/export UI dialogs
- Support for multiple objects per file
- File size limits and comprehensive error reporting

Technical improvements:
- Follows existing code patterns from glTF importer
- Proper type safety and error boundaries
- Memory-efficient parsing for large files
- Maintains data integrity through round-trip operations

UI Integration:
- Added "OBJ..." option to Import menu (replaces "OBJ... (soon)")
- Leverages existing Three.js OBJExporter in Export dialog
- Consistent error handling and user feedback

This implementation enables interoperability with industry-standard 3D
tools like Blender, Maya, and 3ds Max, significantly improving workflow
integration for users.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@alightinastorm alightinastorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exporter appears to be trying to write it's own exporting logic. I believe it's best to let threejs handle exporting to various formats such as obj

They have a very robust exporting system and since the whole rendering happens on threejs, maybe that's a good tradeoff for now?

The only downside i see is that it automatically and unexpectedly changes the topology from quads to triangles

@ebowwa
Copy link
Copy Markdown
Contributor Author

ebowwa commented Sep 12, 2025

true dont pull yet

Copy link
Copy Markdown
Contributor Author

ebowwa commented Sep 12, 2025

Closing PR for now - OBJ import/export functionality is not ready yet.

The implementation has been refactored to use Three.js loaders/exporters instead of custom implementations, but needs more testing and debugging before it's production-ready.

Current status:

  • Export: Using Three.js OBJExporter ✅
  • Import: Switched to Three.js OBJLoader but still has issues with geometry conversion

Will resubmit once the functionality is fully working.

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.

2 participants