Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

GLTFState

Inherits: Resource < RefCounted < Object

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

String

base_path

""

PackedByteArray[]

buffers

[]

String

copyright

""

bool

create_animations

true

String

filename

""

PackedByteArray

glb_data

PackedByteArray()

Dictionary

json

{}

int

major_version

0

int

minor_version

0

PackedInt32Array

root_nodes

PackedInt32Array()

String

scene_name

""

bool

use_named_skin_binds

false

Methods

void

add_used_extension ( String extension_name, bool required )

GLTFAccessor[]

get_accessors ( )

Variant

get_additional_data ( StringName extension_name )

AnimationPlayer

get_animation_player ( int idx )

int

get_animation_players_count ( int idx )

GLTFAnimation[]

get_animations ( )

GLTFBufferView[]

get_buffer_views ( )

GLTFCamera[]

get_cameras ( )

int

get_handle_binary_image ( )

Texture2D[]

get_images ( )

GLTFLight[]

get_lights ( )

Material[]

get_materials ( )

GLTFMesh[]

get_meshes ( )

int

get_node_index ( Node scene_node )

GLTFNode[]

get_nodes ( )

Node

get_scene_node ( int idx )

GLTFSkeleton[]

get_skeletons ( )

GLTFSkin[]

get_skins ( )

GLTFTextureSampler[]

get_texture_samplers ( )

GLTFTexture[]

get_textures ( )

String[]

get_unique_animation_names ( )

String[]

get_unique_names ( )

void

set_accessors ( GLTFAccessor[] accessors )

void

set_additional_data ( StringName extension_name, Variant additional_data )

void

set_animations ( GLTFAnimation[] animations )

void

set_buffer_views ( GLTFBufferView[] buffer_views )

void

set_cameras ( GLTFCamera[] cameras )

void

set_handle_binary_image ( int method )

void

set_images ( Texture2D[] images )

void

set_lights ( GLTFLight[] lights )

void

set_materials ( Material[] materials )

void

set_meshes ( GLTFMesh[] meshes )

void

set_nodes ( GLTFNode[] nodes )

void

set_skeletons ( GLTFSkeleton[] skeletons )

void

set_skins ( GLTFSkin[] skins )

void

set_texture_samplers ( GLTFTextureSampler[] texture_samplers )

void

set_textures ( GLTFTexture[] textures )

void

set_unique_animation_names ( String[] unique_animation_names )

void

set_unique_names ( String[] unique_names )


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

String base_path = ""

  • void set_base_path ( String value )

  • String get_base_path ( )

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.


PackedByteArray[] buffers = []

There is currently no description for this property. Please help us by contributing one!


  • void set_copyright ( String value )

  • String get_copyright ( )

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

  • void set_create_animations ( bool value )

  • bool get_create_animations ( )

There is currently no description for this property. Please help us by contributing one!


String filename = ""

  • void set_filename ( String value )

  • String get_filename ( )

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.