Up to date
This page is up to date for Godot 4.3
.
If you still find outdated information, please open an issue.
GLTFStateΒΆ
Inherits: Resource < RefCounted < Object
Inherited By: FBXState
Represents all data of a GLTF file.
DescriptionΒΆ
Contains all nodes and resources of a GLTF file. This is used by GLTFDocument as data storage, which allows GLTFDocument and all GLTFDocumentExtension classes to remain stateless.
GLTFState can be populated by GLTFDocument reading a file or by converting a Godot scene. Then the data can either be used to create a Godot scene or save to a GLTF file. The code that converts to/from a Godot scene can be intercepted at arbitrary points by GLTFDocumentExtension classes. This allows for custom data to be stored in the GLTF file or for custom data to be converted to/from Godot nodes.
TutorialsΒΆ
PropertiesΒΆ
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
MethodsΒΆ
ConstantsΒΆ
HANDLE_BINARY_DISCARD_TEXTURES = 0
π
Discards all embedded textures and uses untextured materials.
HANDLE_BINARY_EXTRACT_TEXTURES = 1
π
Extracts embedded textures to be reimported and compressed. Editor only. Acts as uncompressed at runtime.
HANDLE_BINARY_EMBED_AS_BASISU = 2
π
Embeds textures VRAM compressed with Basis Universal into the generated scene.
HANDLE_BINARY_EMBED_AS_UNCOMPRESSED = 3
π
Embeds textures compressed losslessly into the generated scene, matching old behavior.
Property DescriptionsΒΆ
The baking fps of the animation for either import or export.
The folder path associated with this GLTF data. This is used to find other files the GLTF file references, like images or binary buffers. This will be set during import when appending from a file, and will be set during export when writing to a file.
Array[PackedByteArray] buffers = []
π
void set_buffers(value: Array[PackedByteArray])
Array[PackedByteArray] get_buffers()
There is currently no description for this property. Please help us by contributing one!
The copyright string in the asset header of the GLTF file. This is set during import if present and export if non-empty. See the GLTF asset header documentation for more information.
bool create_animations = true
π
There is currently no description for this property. Please help us by contributing one!
The file name associated with this GLTF data. If it ends with .gltf
, this is text-based GLTF, otherwise this is binary GLB. This will be set during import when appending from a file, and will be set during export when writing to a file. If writing to a buffer, this will be an empty string.
PackedByteArray glb_data = PackedByteArray()
π
void set_glb_data(value: PackedByteArray)
PackedByteArray get_glb_data()
The binary buffer attached to a .glb file.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedByteArray for more details.
bool import_as_skeleton_bones = false
π
True to force all GLTFNodes in the document to be bones of a single Skeleton3D godot node.
Dictionary json = {}
π
void set_json(value: Dictionary)
Dictionary get_json()
The original raw JSON document corresponding to this GLTFState.
There is currently no description for this property. Please help us by contributing one!
There is currently no description for this property. Please help us by contributing one!
PackedInt32Array root_nodes = PackedInt32Array()
π
void set_root_nodes(value: PackedInt32Array)
PackedInt32Array get_root_nodes()
The root nodes of the GLTF file. Typically, a GLTF file will only have one scene, and therefore one root node. However, a GLTF file may have multiple scenes and therefore multiple root nodes, which will be generated as siblings of each other and as children of the root node of the generated Godot scene.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedInt32Array for more details.
The name of the scene. When importing, if not specified, this will be the file name. When exporting, if specified, the scene name will be saved to the GLTF file.
bool use_named_skin_binds = false
π
There is currently no description for this property. Please help us by contributing one!
Method DescriptionsΒΆ
void add_used_extension(extension_name: String, required: bool) π
Appends an extension to the list of extensions used by this GLTF file during serialization. If required
is true, the extension will also be added to the list of required extensions. Do not run this in GLTFDocumentExtension._export_post, as that stage is too late to add extensions. The final list is sorted alphabetically.
int append_data_to_buffers(data: PackedByteArray, deduplication: bool) π
Appends the given byte array data to the buffers and creates a GLTFBufferView for it. The index of the destination GLTFBufferView is returned. If deduplication
is true, the buffers will first be searched for duplicate data, otherwise new bytes will always be appended.
Array[GLTFAccessor] get_accessors() π
There is currently no description for this method. Please help us by contributing one!
Variant get_additional_data(extension_name: StringName) π
Gets additional arbitrary data in this GLTFState instance. This can be used to keep per-file state data in GLTFDocumentExtension classes, which is important because they are stateless.
The argument should be the GLTFDocumentExtension name (does not have to match the extension name in the GLTF file), and the return value can be anything you set. If nothing was set, the return value is null.
AnimationPlayer get_animation_player(idx: int) π
Returns the AnimationPlayer node with the given index. These nodes are only used during the export process when converting Godot AnimationPlayer nodes to GLTF animations.
int get_animation_players_count(idx: int) π
Returns the number of AnimationPlayer nodes in this GLTFState. These nodes are only used during the export process when converting Godot AnimationPlayer nodes to GLTF animations.
Array[GLTFAnimation] get_animations() π
Returns an array of all GLTFAnimations in the GLTF file. When importing, these will be generated as animations in an AnimationPlayer node. When exporting, these will be generated from Godot AnimationPlayer nodes.
Array[GLTFBufferView] get_buffer_views() π
There is currently no description for this method. Please help us by contributing one!
Array[GLTFCamera] get_cameras() π
Returns an array of all GLTFCameras in the GLTF file. These are the cameras that the GLTFNode.camera index refers to.
int get_handle_binary_image() π
There is currently no description for this method. Please help us by contributing one!
Array[Texture2D] get_images() π
Gets the images of the GLTF file as an array of Texture2Ds. These are the images that the GLTFTexture.src_image index refers to.
Array[GLTFLight] get_lights() π
Returns an array of all GLTFLights in the GLTF file. These are the lights that the GLTFNode.light index refers to.
Array[Material] get_materials() π
There is currently no description for this method. Please help us by contributing one!
Array[GLTFMesh] get_meshes() π
Returns an array of all GLTFMeshes in the GLTF file. These are the meshes that the GLTFNode.mesh index refers to.
int get_node_index(scene_node: Node) π
Returns the index of the GLTFNode corresponding to this Godot scene node. This is the inverse of get_scene_node. Useful during the export process.
Note: Not every Godot scene node will have a corresponding GLTFNode, and not every GLTFNode will have a scene node generated. If there is no GLTFNode index for this scene node, -1
is returned.
Array[GLTFNode] get_nodes() π
Returns an array of all GLTFNodes in the GLTF file. These are the nodes that GLTFNode.children and root_nodes refer to. This includes nodes that may not be generated in the Godot scene, or nodes that may generate multiple Godot scene nodes.
Node get_scene_node(idx: int) π
Returns the Godot scene node that corresponds to the same index as the GLTFNode it was generated from. This is the inverse of get_node_index. Useful during the import process.
Note: Not every GLTFNode will have a scene node generated, and not every generated scene node will have a corresponding GLTFNode. If there is no scene node for this GLTFNode index, null
is returned.
Array[GLTFSkeleton] get_skeletons() π
Returns an array of all GLTFSkeletons in the GLTF file. These are the skeletons that the GLTFNode.skeleton index refers to.
Array[GLTFSkin] get_skins() π
Returns an array of all GLTFSkins in the GLTF file. These are the skins that the GLTFNode.skin index refers to.
Array[GLTFTextureSampler] get_texture_samplers() π
Retrieves the array of texture samplers that are used by the textures contained in the GLTF.
Array[GLTFTexture] get_textures() π
There is currently no description for this method. Please help us by contributing one!
Array[String] get_unique_animation_names() π
Returns an array of unique animation names. This is only used during the import process.
Array[String] get_unique_names() π
Returns an array of unique node names. This is used in both the import process and export process.
void set_accessors(accessors: Array[GLTFAccessor]) π
There is currently no description for this method. Please help us by contributing one!
void set_additional_data(extension_name: StringName, additional_data: Variant) π
Sets additional arbitrary data in this GLTFState instance. This can be used to keep per-file state data in GLTFDocumentExtension classes, which is important because they are stateless.
The first argument should be the GLTFDocumentExtension name (does not have to match the extension name in the GLTF file), and the second argument can be anything you want.
void set_animations(animations: Array[GLTFAnimation]) π
Sets the GLTFAnimations in the state. When importing, these will be generated as animations in an AnimationPlayer node. When exporting, these will be generated from Godot AnimationPlayer nodes.
void set_buffer_views(buffer_views: Array[GLTFBufferView]) π
There is currently no description for this method. Please help us by contributing one!
void set_cameras(cameras: Array[GLTFCamera]) π
Sets the GLTFCameras in the state. These are the cameras that the GLTFNode.camera index refers to.
void set_handle_binary_image(method: int) π
There is currently no description for this method. Please help us by contributing one!
void set_images(images: Array[Texture2D]) π
Sets the images in the state stored as an array of Texture2Ds. This can be used during export. These are the images that the GLTFTexture.src_image index refers to.
void set_lights(lights: Array[GLTFLight]) π
Sets the GLTFLights in the state. These are the lights that the GLTFNode.light index refers to.
void set_materials(materials: Array[Material]) π
There is currently no description for this method. Please help us by contributing one!
void set_meshes(meshes: Array[GLTFMesh]) π
Sets the GLTFMeshes in the state. These are the meshes that the GLTFNode.mesh index refers to.
void set_nodes(nodes: Array[GLTFNode]) π
Sets the GLTFNodes in the state. These are the nodes that GLTFNode.children and root_nodes refer to. Some of the nodes set here may not be generated in the Godot scene, or may generate multiple Godot scene nodes.
void set_skeletons(skeletons: Array[GLTFSkeleton]) π
Sets the GLTFSkeletons in the state. These are the skeletons that the GLTFNode.skeleton index refers to.
void set_skins(skins: Array[GLTFSkin]) π
Sets the GLTFSkins in the state. These are the skins that the GLTFNode.skin index refers to.
void set_texture_samplers(texture_samplers: Array[GLTFTextureSampler]) π
Sets the array of texture samplers that are used by the textures contained in the GLTF.
void set_textures(textures: Array[GLTFTexture]) π
There is currently no description for this method. Please help us by contributing one!
void set_unique_animation_names(unique_animation_names: Array[String]) π
Sets the unique animation names in the state. This is only used during the import process.
void set_unique_names(unique_names: Array[String]) π
Sets the unique node names in the state. This is used in both the import process and export process.