when you drag and drop a folder with GLB files in godot, when you access those files with code... they are automatically imported with useless spatial nodes as their root scene. like swordmesh1 will be imported as a child of an utterly useless scene root node called swordmesh1... same name but one is a spatial by default. I've seen that I can change the type of scene root but I have not found how to delete the scene root to begin with... I want the raw mesh to be the only node in the scene that is being imported.


1 Answer 1


Sadly this is not straightforward, so...

  1. Do you want the Mesh or the MeshInstance3D?

    • If you need a Mesh you can enable "Save to File" in the Mesh in the Advanced Import Settings dialog.
    • If you need a MeshInstance3D, keep reading.
  2. Does it has to be what is imported, or is it OK to extract it?

    • If it is OK to extract it, you can add the imported scene as a child of another scene, then select "Make Local" on the context menu in the Scene dock, and take the node you want, and remove the rest.
    • Otherwise, keep reading.
  3. Are you willing to write code for this?

    • If you are OK writing code for this, then you are going to create a @tool script that extends EditorScenePostImport. In it you override the _post_import method to extract the MeshInstance3D you want:

      extends EditorScenePostImport
      func _post_import(scene:Node) -> Object:
         return find_mesh_instance(scene)        
      func find_mesh_instance(node:Node) -> MeshInstance3D:
         if not is_instance_valid(node):
             return null
         for child in node.get_children():
             if child is MeshInstance3D:
                 return child
             var found := find_mesh_instance(child)
             if is_instance_valid(found):
                 return found
         return null

      And you are going to set this script as "Import Script" in the import settings and reimport.


      • Be aware that there might not be a MeshInstance3D or there might be multiple. The code above only takes one, and it does not apply transforms from the skipped Node3D to the returned MeshInstance3D, modify it to your needs.
      • If you are authoring the GLB file, you might define a naming convention so the script can use the names of the nodes to better identify what it should get.
    • If you are not willing to write code... I don't know how to solve this.

The relevant documentation is in Importing 3D scenes.

  • \$\begingroup\$ thank you so much for this explanation. it helps me understand import scripts so much. \$\endgroup\$
    – JasonS
    Commented May 17 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .