API

Interface IGLTFLoaderExtension

Interface for a glTF loader extension.

interface IGLTFLoaderExtension {
    enabled: boolean;
    name: string;
    order?: number;
    createMaterial?(
        context: string,
        material: IMaterial,
        babylonDrawMode: number,
    ): Nullable<Material>;
    loadAnimationAsync?(
        context: string,
        animation: IAnimation,
    ): Nullable<Promise<AnimationGroup>>;
    loadBufferAsync?(
        context: string,
        buffer: IBuffer,
        byteOffset: number,
        byteLength: number,
    ): Nullable<Promise<ArrayBufferView<ArrayBufferLike>>>;
    loadBufferViewAsync?(
        context: string,
        bufferView: IBufferView,
    ): Nullable<Promise<ArrayBufferView<ArrayBufferLike>>>;
    loadCameraAsync?(
        context: string,
        camera: ICamera,
        assign: (babylonCamera: Camera) => void,
    ): Nullable<Promise<Camera>>;
    loadMaterialPropertiesAsync?(
        context: string,
        material: IMaterial,
        babylonMaterial: Material,
    ): Nullable<Promise<void>>;
    loadNodeAsync?(
        context: string,
        node: GLTF2.INode,
        assign: (babylonMesh: TransformNode) => void,
    ): Nullable<Promise<TransformNode>>;
    loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
    loadTextureInfoAsync?(
        context: string,
        textureInfo: ITextureInfo,
        assign: (babylonTexture: BaseTexture) => void,
    ): Nullable<Promise<BaseTexture>>;
    onLoading?(): void;
    onReady?(): void | Promise<void>;
}

Hierarchy (View Summary)

Implemented by

Index
enabled: boolean

Defines whether this extension is enabled.

name: string

The name of this extension.

order?: number

Defines the order of this extension. The loader sorts the extensions using these values when loading.

  • Define this method to modify the default behavior when creating materials.

    Parameters

    • context: string

      The context when loading the asset

    • material: IMaterial

      The glTF material property

    • babylonDrawMode: number

      The draw mode for the Babylon material

    Returns Nullable<Material>

    The Babylon material or null if not handled

  • Define this method to modify the default behavior when loading animations.

    Parameters

    • context: string

      The context when loading the asset

    • animation: IAnimation

      The glTF animation property

    Returns Nullable<Promise<AnimationGroup>>

    A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled

  • Define this method to modify the default behavior when loading buffers.

    Parameters

    • context: string

      The context when loading the asset

    • buffer: IBuffer

      The glTF buffer property

    • byteOffset: number

      The byte offset to load

    • byteLength: number

      The byte length to load

    Returns Nullable<Promise<ArrayBufferView<ArrayBufferLike>>>

    A promise that resolves with the loaded data when the load is complete or null if not handled

  • Define this method to modify the default behavior when loading buffer views.

    Parameters

    • context: string

      The context when loading the asset

    • bufferView: IBufferView

      The glTF buffer view property

    Returns Nullable<Promise<ArrayBufferView<ArrayBufferLike>>>

    A promise that resolves with the loaded data when the load is complete or null if not handled

  • Define this method to modify the default behavior when loading cameras.

    Parameters

    • context: string

      The context when loading the asset

    • camera: ICamera

      The glTF camera property

    • assign: (babylonCamera: Camera) => void

      A function called synchronously after parsing the glTF properties

    Returns Nullable<Promise<Camera>>

    A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled

  • Define this method to modify the default behavior when loading material properties.

    Parameters

    • context: string

      The context when loading the asset

    • material: IMaterial

      The glTF material property

    • babylonMaterial: Material

      The Babylon material

    Returns Nullable<Promise<void>>

    A promise that resolves when the load is complete or null if not handled

  • Define this method to modify the default behavior when loading nodes.

    Parameters

    • context: string

      The context when loading the asset

    • node: GLTF2.INode

      The glTF node property

    • assign: (babylonMesh: TransformNode) => void

      A function called synchronously after parsing the glTF properties

    Returns Nullable<Promise<TransformNode>>

    A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled

  • Define this method to modify the default behavior when loading scenes.

    Parameters

    • context: string

      The context when loading the asset

    • scene: IScene

      The glTF scene property

    Returns Nullable<Promise<void>>

    A promise that resolves when the load is complete or null if not handled

  • Define this method to modify the default behavior when loading texture infos.

    Parameters

    • context: string

      The context when loading the asset

    • textureInfo: ITextureInfo

      The glTF texture info property

    • assign: (babylonTexture: BaseTexture) => void

      A function called synchronously after parsing the glTF properties

    Returns Nullable<Promise<BaseTexture>>

    A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled