Skip to content

Conversation

@aaronfranke
Copy link
Member

@aaronfranke aaronfranke commented Jun 22, 2025

This PR allows parsing glTF files that contain no nodes. Such files, well, have no nodes, so the best we can do is import an empty scene. However, this adds flexibility, allowing for us to support non-scene glTF files in the engine in the future, and allows users to handle such files in their own code if they wish.

I think this is best explained with a diagram:

GLTF_with_no_Nodes drawio

glTF files without nodes are explicitly supported by the glTF specification:

... so this allows Godot to parse such files, even if they have no nodes so result in an empty Godot scene.

Trivial example. This imports correctly with this PR, but errors too early in the current master, which makes it fail to import, even though the file is spec-compliant. gltf_file_without_nodes_imported_as_a_mesh_instance.zip

Another trivial example. This file can now be imported:

{
    "asset": {
        "version": "2.0"
    }
}

I also renamed some variables in GLTFDocument::generate_scene for clarity, including a duplicated state vs p_state.

@lyuma
Copy link
Contributor

lyuma commented Jun 22, 2025

Why does a scene with no nodes generate an error? It should be able to import as just the root node. I understand that such a scene would not have GODOT_single_root, but without that extension, there should be no need to fail the import

@aaronfranke
Copy link
Member Author

@lyuma That's true, we could do that, taking this PR even farther. Somehow, that did not occur to me. PR updated.

Now even this glTF file can be imported:

{
    "asset": {
        "version": "2.0"
    }
}
@fire
Copy link
Member

fire commented Aug 19, 2025

This makes sense from a design perspective, I haven't reviewed the code yet though.

@yankscally
Copy link
Member

yankscally commented Sep 30, 2025

For game development, a feature like this is extremely powerful because you can use the gltf as a "3D .zip file".

That data could be a bunch of different meshes from an asset pack, so that you are able to extract the resources you need without making a scene.

Using scenes to export a bunch of components like this I find strange, but this PR unlocks a lot of potential by allowing developers to package assets much more efficiently for game development purposes. It changes the precedent for how gltf could be used, and I think this is very worthwhile

Copy link
Contributor

@lyuma lyuma left a comment

Choose a reason for hiding this comment

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

I like the warning. Otherwise allows using these assets

@Repiteo Repiteo merged commit e825169 into godotengine:master Oct 14, 2025
20 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Done in Asset Pipeline Issue Triage Oct 14, 2025
@Repiteo
Copy link
Contributor

Repiteo commented Oct 14, 2025

Thanks!

@aaronfranke aaronfranke deleted the gltf-without-nodes branch October 14, 2025 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment