Up to date
This page is up to date for Godot
If you still find outdated information, please open an issue.
Inherited By: GLTFDocumentExtensionConvertImporterMesh
GLTFDocument extension class.
Extends the functionality of the GLTFDocument class by allowing you to run arbitrary code at various stages of GLTF import or export.
To use, make a new class extending GLTFDocumentExtension, override any methods you need, make an instance of your class, and register it using GLTFDocument.register_gltf_document_extension.
Note: Like GLTFDocument itself, all GLTFDocumentExtension classes must be stateless in order to function properly. If you need to store data, use the
get_additional_data methods in GLTFState or GLTFNode.
_get_image_file_extension ( ) virtual
_get_saveable_image_formats ( ) virtual
_get_supported_extensions ( ) virtual
Runs when converting the data from a Godot scene node. This method can be used to process the Godot scene node data into a format that can be used by _export_node.
Part of the export process. This method is run after _get_saveable_image_formats and before _export_post. If this GLTFDocumentExtension is used for exporting images, this runs after _serialize_texture_json.
This method can be used to modify the final JSON of each node.
Part of the export process. This method is run last, after all other parts of the export process.
This method can be used to modify the final JSON of the generated GLTF file.
Part of the export process. This method is run first, before all other parts of the export process.
The return value is used to determine if this GLTFDocumentExtension instance should be used for exporting a given GLTF file. If @GlobalScope.OK, the export will use this GLTFDocumentExtension instance. If not overridden, @GlobalScope.OK is returned.
This method can be used to alter the state before performing serialization. It runs every time when generating a buffer with GLTFDocument.generate_buffer or writing to the file system with GLTFDocument.write_to_filesystem.
Runs when generating a Godot scene node from a GLTFNode. The returned node will be added to the scene tree. Multiple nodes can be generated in this step if they are added as a child of the returned node.
scene_parent parameter may be null if this is the single root node.
String _get_image_file_extension ( ) virtual
Returns the file extension to use for saving image data into, for example,
".png". If defined, when this extension is used to handle images, and the images are saved to a separate file, the image bytes will be copied to a file with this extension. If this is set, there should be a ResourceImporter class able to import the file. If not defined or empty, Godot will save the image into a PNG file.
PackedStringArray _get_saveable_image_formats ( ) virtual
Returns an array of the image formats that can be saved/exported by this extension. This extension will only be selected as the image exporter if the GLTFDocument's GLTFDocument.image_format is in this array. If this GLTFDocumentExtension is selected as the image exporter, one of the _save_image_at_path or _serialize_image_to_bytes methods will run next, otherwise _export_node will run next. If the format name contains
"Lossy", the lossy quality slider will be displayed.
PackedStringArray _get_supported_extensions ( ) virtual
Returns an array of the GLTF extensions supported by this GLTFDocumentExtension class. This is used to validate if a GLTF file with required extensions can be loaded.
This method can be used to make modifications to each of the generated Godot scene nodes.