GLTFState
Represents all data of a GLTF file.
GLTFState.swift:14class GLTFState
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.
Superclasses
class Resource
Base class for serializable objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
static let handleBinaryDiscardTextures: Int
Discards all embedded textures and uses untextured materials.
static let handleBinaryEmbedAsBasisu: Int
Embeds textures VRAM compressed with Basis Universal into the generated scene.
static let handleBinaryEmbedAsUncompressed: Int
Embeds textures compressed losslessly into the generated scene, matching old behavior.
static let handleBinaryExtractTextures: Int
Extracts embedded textures to be reimported and compressed. Editor only. Acts as uncompressed at runtime.
class var godotClassName: StringName
Instance members
var accessors: ObjectCollection<GLTFAccessor>
var animations: ObjectCollection<GLTFAnimation>
var basePath: String
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.
var bufferViews: ObjectCollection<GLTFBufferView>
var buffers: VariantCollection<PackedByteArray>
var cameras: ObjectCollection<GLTFCamera>
var copyright: String
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.
var createAnimations: Bool
var filename: String
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.var glbData: PackedByteArray
var handleBinaryImage: Int32
var images: ObjectCollection<Texture2D>
var json: GDictionary
var lights: ObjectCollection<GLTFLight>
var majorVersion: Int32
var materials: ObjectCollection<Material>
var meshes: ObjectCollection<GLTFMesh>
var minorVersion: Int32
var nodes: ObjectCollection<GLTFNode>
var rootNodes: PackedInt32Array
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.
var sceneName: String
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.
var skeletons: ObjectCollection<GLTFSkeleton>
var skins: ObjectCollection<GLTFSkin>
var textureSamplers: ObjectCollection<GLTFTextureSampler>
var textures: ObjectCollection<GLTFTexture>
var uniqueAnimationNames: VariantCollection<String>
var uniqueNames: VariantCollection<String>
var useNamedSkinBinds: Bool
func addUsedExtension(extensionName: 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_exportPost(state:)
, as that stage is too late to add extensions. The final list is sorted alphabetically.func getAdditionalData(extensionName: StringName
) -> Variant Gets additional arbitrary data in this
GLTFState
instance. This can be used to keep per-file state data inGLTFDocumentExtension
classes, which is important because they are stateless.func getAnimationPlayer(idx: Int32
) -> AnimationPlayer? Returns the
AnimationPlayer
node with the given index. These nodes are only used during the export process when converting GodotAnimationPlayer
nodes to GLTF animations.func getAnimationPlayersCount(idx: Int32
) -> Int32 Returns the number of
AnimationPlayer
nodes in thisGLTFState
. These nodes are only used during the export process when converting GodotAnimationPlayer
nodes to GLTF animations.func getNodeIndex(sceneNode: Node?
) -> Int32 Returns the index of the
GLTFNode
corresponding to this Godot scene node. This is the inverse ofgetSceneNode(idx:)
. Useful during the export process.func getSceneNode(idx: Int32
) -> Node? Returns the Godot scene node that corresponds to the same index as the
GLTFNode
it was generated from. This is the inverse ofgetNodeIndex(sceneNode:)
. Useful during the import process.func setAdditionalData(extensionName: StringName, additionalData: Variant
) Sets additional arbitrary data in this
GLTFState
instance. This can be used to keep per-file state data inGLTFDocumentExtension
classes, which is important because they are stateless.