Skip to content

Allow customizing how the root node is handled in GLTF import/export #7791

Closed
@aaronfranke

Description

Describe the project you are working on

I am working on glTF support in Godot.

Describe the problem or limitation you are having in your project

Currently, when you import a glTF file in Godot, the glTF root nodes will be added as a child of the "real" root node. This is done because glTF supports multiple root nodes in a scene, but Godot only has one root node per scene. This means that on import an extra root node will be created, and there is no way for the glTF file to customize this extra "real" root node. One possible solution would be to treat the glTF root as the Godot scene root if there is just one, but due to the possibility of there being multiple root nodes, this is not sensible to do automatically.

Currently, when you export a glTF file in Godot, the root node of the Godot scene will always be placed as the root node of the glTF scene. This means that if you round-trip a scene out of Godot and back in, there will be an extra root node. There is no way to export a glTF file in a way that indicates an extra root node should not be created, and there is no way to export a glTF file from Godot in a way that has multiple root nodes.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The proposal is to do the following things:

  1. Create a new glTF extension called GODOT_single_root which specifies that a glTF file's root node is expected to be treated as the real single root node of the scene and imposes restrictions to ensure this works without issues.
  2. Support reading this extension when importing glTF files so that files can specify the scene's single root node.
  3. Add a setting to the glTF export code to control the root node behavior (single, keep, or multi root).
  4. Expose the export setting in point 3 to the editor's glTF export dialog, which will look like the below image.
  5. (Optional) Add a setting to the import dock to override point 2 on import.
Screenshot 2023-09-18 at 1 41 22 AM

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

If this enhancement will not be used often, can it be worked around with a few lines of script?

This will be used often. It is possible to work around in script, but only in a hacky way.

Is there a reason why this should be core and not an add-on in the asset library?

Root nodes are a part of Godot, and glTF support is core.

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions