Up to date

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

GLTFDocument

Inherits: Resource < RefCounted < Object

Description

Append a glTF2 3d format from a file, buffer or scene and then write to the filesystem, buffer or scene.

Methods

Error

append_from_buffer ( PackedByteArray bytes, String base_path, GLTFState state, int flags=0 )

Error

append_from_file ( String path, GLTFState state, int flags=0, String base_path="" )

Error

append_from_scene ( Node node, GLTFState state, int flags=0 )

PackedByteArray

generate_buffer ( GLTFState state )

Node

generate_scene ( GLTFState state, float bake_fps=30, bool trimming=false, bool remove_immutable_tracks=true )

void

register_gltf_document_extension ( GLTFDocumentExtension extension, bool first_priority=false ) static

void

unregister_gltf_document_extension ( GLTFDocumentExtension extension ) static

Error

write_to_filesystem ( GLTFState state, String path )


Method Descriptions

Error append_from_buffer ( PackedByteArray bytes, String base_path, GLTFState state, int flags=0 )

Takes a PackedByteArray defining a GLTF and imports the data to the given GLTFState object through the state parameter.

Note: The base_path tells append_from_buffer where to find dependencies and can be empty.


Error append_from_file ( String path, GLTFState state, int flags=0, String base_path="" )

Takes a path to a GLTF file and imports the data at that file path to the given GLTFState object through the state parameter.

Note: The base_path tells append_from_file where to find dependencies and can be empty.


Error append_from_scene ( Node node, GLTFState state, int flags=0 )

Takes a Godot Engine scene node and exports it and its descendants to the given GLTFState object through the state parameter.


PackedByteArray generate_buffer ( GLTFState state )

Takes a GLTFState object through the state parameter and returns a GLTF PackedByteArray.


Node generate_scene ( GLTFState state, float bake_fps=30, bool trimming=false, bool remove_immutable_tracks=true )

Takes a GLTFState object through the state parameter and returns a Godot Engine scene node.


void register_gltf_document_extension ( GLTFDocumentExtension extension, bool first_priority=false ) static

Registers the given GLTFDocumentExtension instance with GLTFDocument. If first_priority is true, this extension will be run first. Otherwise, it will be run last.

Note: Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the set_additional_data and get_additional_data methods in GLTFState or GLTFNode.


void unregister_gltf_document_extension ( GLTFDocumentExtension extension ) static

Unregisters the given GLTFDocumentExtension instance.


Error write_to_filesystem ( GLTFState state, String path )

Takes a GLTFState object through the state parameter and writes a glTF file to the filesystem.

Note: The extension of the glTF file determines if it is a .glb binary file or a .gltf file.