Extensions enhance a glTF Document with additional features and schema, beyond the core
glTF specification. For example, extensions to Material properties might include additional
textures or scalar properties affecting the Material's appearance in a specific way.
Common extensions may be imported from the @gltf-transform/extensions package, or custom
extensions may be created by extending the Extension base class. No extensions are included
in the default @gltf-transform/core package, in order to (1) minimize the code size, and (2)
ensure that any extension can be implemented externally.
Because extensions rely on the same underlying graph structure as the core specification,
references to Texture, Accessor, and other resources will be managed
automatically, even by scripts or transforms written without prior knowledge of the extension.
An extension is added to a Document by calling Document.createExtension with the
extension constructor. The extension object may then be used to construct
ExtensionProperty instances, which are attached to properties throughout the Document
as prescribed by the extension itself.
In addition to the official Khronos and multi-vendor extensions, the glTF format can be extended
with custom extensions
for specific applications. glTF-Transform supports reading/writing custom extensions, without
modifications to the core codebase. Any extension implemented correctly and registered with the I/O
instance may be read from a file, modified programmatically, and written back to a file.
Extensions
Extensions enhance a glTF Document with additional features and schema, beyond the core glTF specification. For example, extensions to Material properties might include additional textures or scalar properties affecting the Material's appearance in a specific way.
Common extensions may be imported from the
@gltf-transform/extensions
package, or custom extensions may be created by extending the Extension base class. No extensions are included in the default@gltf-transform/core
package, in order to (1) minimize the code size, and (2) ensure that any extension can be implemented externally.Because extensions rely on the same underlying graph structure as the core specification, references to Texture, Accessor, and other resources will be managed automatically, even by scripts or transforms written without prior knowledge of the extension. An extension is added to a Document by calling Document.createExtension with the extension constructor. The extension object may then be used to construct ExtensionProperty instances, which are attached to properties throughout the Document as prescribed by the extension itself.
Khronos Extensions
Vendor Extensions
Installation
To use extensions, first install the
@gltf-transform/extensions
package:To open files containing an Extension, the Extension constructor must be registered with the PlatformIO instance used to read the file.
Reading or writing files requires registering the necessary Extensions with the I/O class. Some extensions may require installing dependencies:
Custom extensions
In addition to the official Khronos and multi-vendor extensions, the glTF format can be extended with custom extensions for specific applications. glTF-Transform supports reading/writing custom extensions, without modifications to the core codebase. Any extension implemented correctly and registered with the I/O instance may be read from a file, modified programmatically, and written back to a file.
For implementation examples, see packages/extensions. For further details on the general Extension API, see Extension and ExtensionProperty.