Base class for all Extensions.

Extensions enhance a glTF Document with additional features and schema, beyond the core glTF specification. Common extensions may be imported from the @gltf-transform/extensions package, or custom extensions may be created by extending this base class.

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.

For more information on available extensions and their usage, see Extensions.

Reference:

Hierarchy

  • Extension

Implements

  • ExtensionPropertyParent

Properties

dependencies: string[] = []

Dependency IDs needed by this extension, to be installed before I/O.

extensionName: string

Official name of the extension.

provideTypes: PropertyType[] = []

Property types this extension will provide. Most extensions don't need to implement this.

EXTENSION_NAME: string

Official name of the extension.

Methods

  • dispose(): void
  • Disables and removes the extension from the Document.

  • install(key: string, dependency: unknown): this
  • Installs dependencies required by the extension.

  • isRequired(): boolean
  • Indicates to the client whether it is OK to load the asset when this extension is not recognized. Optional extensions are generally preferred, if there is not a good reason to require a client to completely fail when an extension isn't known.

  • Used by the PlatformIO utilities when reading a glTF asset. This method may optionally be implemented by an extension, and should then support any property type declared by the Extension's Extension.provideTypes list. The Extension will be given a ReaderContext instance, and is expected to update either the context or its JSONDocument with resources known to the Extension. Most extensions don't need to implement this.

  • Used by the PlatformIO utilities when reading a glTF asset. This method must be implemented by each extension in order to support reading files. The extension will be given a ReaderContext instance, and should update the current Document accordingly.

  • setRequired(required: boolean): this
  • Indicates to the client whether it is OK to load the asset when this extension is not recognized. Optional extensions are generally preferred, if there is not a good reason to require a client to completely fail when an extension isn't known.

  • write(writerContext: WriterContext): this
  • Used by the PlatformIO utilities when writing a glTF asset. This method must be implemented by each extension in order to support writing files. The extension will be given a WriterContext instance, and should modify the JSONDocument output accordingly. Adding the extension name to the extensionsUsed and extensionsRequired list is done automatically, and should not be included here.

Function symbol, f(📦) → 📦, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy TypeDoc documentation Copyright 2020 under MIT license