Resources
With resources you can dynamically load various game data like textures, objects, scenes and so on.
Meshes
Godot uses the glTF 3D format, which are always imported as scenes:
# Load an existing glTF scene.
# GLTFState is used by GLTFDocument to store the loaded scene's state.
# GLTFDocument is the class that handles actually
# loading glTF data into a Godot node tree,
# which means it supports glTF features such as lights and cameras.
var gltf_document_load = GLTFDocument.new()
var gltf_state_load = GLTFState.new()
var error = gltf_document_load.append_from_file("/path/to/file.gltf", gltf_state_load)
if error == OK:
var gltf_scene_root_node = gltf_document_load.generate_scene(gltf_state_load)
add_child(gltf_scene_root_node)
else:
show_error("Couldn't load glTF scene (error code: %s)." % error_string(error))
See also
- Runtime file loading and saving
- GLTFDocument: Class for importing and exporting glTF files in and out of Godot.
- GLTFState: Represents all data of a GLTF file.