Skip to content

GLTF: Allow importing files as Mesh or MeshLibrary directly #107840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Jun 22, 2025

Alternative to PR #107856 (mutually exclusive: only one can be merged, the other must be closed)

Implements godotengine/godot-proposals#7494 for glTF, ArrayMesh, and MeshLibrary.

Depends on #107838 and goes well with #107836 (both of those PRs are good to merge even without this PR).

Screenshot 2025-06-22 at 1 14 53 AM
  • The "Mesh Library" import option imports all meshes in the glTF file as items in a MeshLibrary, and optionally can save these meshes to a file, and optionally can use node names as mesh names. This is useful for glTF files intended to be used as a collection of meshes, rather than a single model or scene.
  • The "Single Mesh" import option imports the glTF file as a single ArrayMesh, which is that exact mesh as-is when importing a file with a single mesh, or imports a merged mesh if the file contains multiple meshes.

This PR is marked as a discussion because this ResourceImporter approach is just one of the possible implementations. The other approach is to make a mesh out of a generated Godot scene with ResourceImporterScene: #107856 I briefly discussed this with @fire on Discord and he said he prefers ResourceImporterScene, but I'm putting both options on the table.

Here's a copy of what I sent on Discord. We basically have 3 options:

  • Support importing any 3D model as Mesh or MeshLibrary by disassembling the generated scene in ResourceImporterScene. 3D scene import: Allow importing files as Mesh or MeshLibrary via ResourceImporterScene #107856
    • Advantages: Supports all 3D model formats at once, including glTF, FBX, Blend, Collada, etc. Keeps using the Advanced Import Settings dialog, so it shows the same dialog as when importing as a scene.
    • Disadvantages: More complex, slower since it involves generating a scene, does not support resource-only glTF files, harder to expose mesh-specific import options, not thread safe because physics may exist.
  • Support importing glTF directly as Mesh or MeshLibrary using ResourceImporter. (this PR)
    • Advantages: Simpler, faster to run since it skips scene generation, supports resource-only glTF files (requires PR #107836), easier to expose mesh-specific import options, should be thread safe and Godot may crash when generating physics objects on a thread.
    • Disadvantages: Only gives us glTF, would need duplicate code for FBX, Blend, etc, if desired there. Does not show the Advanced Import Settings dialog, because it bypasses that system, instead double-clicking on the source file will show the imported Resource in the inspector like with other non-scene files.
  • Wait for Add ability to reference subresources and inspect them in filesystem godot-proposals#8750 instead?

Also, @fire mentioned that "It won't support multi meshes" and that mesh merging "is better done in blender since it's pretty tricky", but I managed to support it anyway, so long as we have PR #107838. I think mesh merging functionality should be supported, regardless of how the importer exposes it.

@jcostello
Copy link
Contributor

jcostello commented Jun 22, 2025

Will this option also be in the import modal?

@aaronfranke
Copy link
Member Author

@jcostello The Advanced Import Settings dialog already contains a menu for getting the meshes out of an imported scene (Actions... -> Set Mesh Save Paths). This menu exists for when you want to have fine-grained control over the import of your 3D model, or when you need a scene in addition to mesh resources.

The feature added by this PR (and likewise by PR #107856) does not really use that dialog, because most of the options in there are for customizing a generated scene. This feature is for when you want course-grained control and just want to get a resource ("why is this so complicated, just gimme a mesh!"). Currently, many Godot users use OBJ for this purpose, but glTF is a much better format than OBJ, so I'd like to move away from OBJ if possible. This was also inspired by seeing videos like Gierki Dev's workflow and wanting to make this process easier for the use case of "mesh bundle" glTF files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants