API

The glTF 2.0 loader

Index
_babylonLights: Light[] = []

Storage

DefaultSampler: ISampler = ...

The default glTF sampler.

  • Creates a Babylon material from a glTF material.

    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 Material

    The Babylon material

  • Checks for presence of an extension.

    Parameters

    • name: string

      The name of the extension to check

    Returns boolean

    A boolean indicating the presence of the given extension name in extensionsUsed

  • Test if the given material is an instance of any PBR material type known to this loader.

    Parameters

    • material: Nullable<Material>

      The material to test

    Returns boolean

    true if the material matches one of the loaded PBR implementations

  • Loads a glTF animation.

    Parameters

    • context: string

      The context when loading the asset

    • animation: IAnimation

      The glTF animation property

    Returns Promise<AnimationGroup>

    A promise that resolves with the loaded Babylon animation group when the load is complete

  • Loads a glTF buffer.

    Parameters

    • context: string

      The context when loading the asset

    • buffer: IBuffer

      The glTF buffer property

    • byteOffset: number

      The byte offset to use

    • byteLength: number

      The byte length to use

    Returns Promise<ArrayBufferView<ArrayBufferLike>>

    A promise that resolves with the loaded data when the load is complete

  • Loads a glTF buffer view.

    Parameters

    • context: string

      The context when loading the asset

    • bufferView: IBufferView

      The glTF buffer view property

    Returns Promise<ArrayBufferView<ArrayBufferLike>>

    A promise that resolves with the loaded data when the load is complete

  • Loads a glTF camera.

    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 Promise<Camera>

    A promise that resolves with the loaded Babylon camera when the load is complete

  • Loads a glTF image.

    Parameters

    • context: string

      The context when loading the asset

    • image: GLTF2.IImage

      The glTF image property

    Returns Promise<ArrayBufferView<ArrayBufferLike>>

    A promise that resolves with the loaded data when the load is complete

  • Loads the alpha properties from a glTF material into a Babylon material. Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.

    Parameters

    • context: string

      The context when loading the asset

    • material: IMaterial

      The glTF material property

    • babylonMaterial: Material

      The Babylon material

    Returns void

  • Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.

    Parameters

    • context: string

      The context when loading the asset

    • material: IMaterial

      The glTF material property

    • babylonMaterial: Material

      The Babylon material

    Returns Promise<void>

    A promise that resolves when the load is complete

  • Loads properties from a glTF material into a Babylon material.

    Parameters

    • context: string

      The context when loading the asset

    • material: IMaterial

      The glTF material property

    • babylonMaterial: Material

      The Babylon material

    Returns Promise<void>

    A promise that resolves when the load is complete

  • Loads a glTF node.

    Parameters

    • context: string

      The context when loading the asset

    • node: GLTF2.INode

      The glTF node property

    • assign: (babylonTransformNode: TransformNode) => void = ...

      A function called synchronously after parsing the glTF properties

    Returns Promise<TransformNode>

    A promise that resolves with the loaded Babylon mesh when the load is complete

  • Loads a glTF texture info.

    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 Promise<BaseTexture>

    A promise that resolves with the loaded Babylon texture when the load is complete

  • Loads a glTF uri.

    Parameters

    • context: string

      The context when loading the asset

    • property: IProperty

      The glTF property associated with the uri

    • uri: string

      The base64 or relative uri

    Returns Promise<ArrayBufferView<ArrayBufferLike>>

    A promise that resolves with the loaded data when the load is complete

  • Adds a JSON pointer to the _internalMetadata of the Babylon object at <object>._internalMetadata.gltf.pointers.

    Parameters

    • babylonObject: IWithMetadata

      the Babylon object with _internalMetadata

    • pointer: string

      the JSON pointer

    Returns void

  • Helper method called by a loader extension to load an glTF extension.

    Type Parameters

    • TExtension = unknown
    • TResult = void

    Parameters

    • context: string

      The context when loading the asset

    • property: IProperty

      The glTF property to load the extension from

    • extensionName: string

      The name of the extension to load

    • actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>

      The action to run

    Returns Nullable<Promise<TResult>>

    The promise returned by actionAsync or null if the extension does not exist

  • Helper method called by a loader extension to load a glTF extra.

    Type Parameters

    • TExtra = unknown
    • TResult = void

    Parameters

    • context: string

      The context when loading the asset

    • property: IProperty

      The glTF property to load the extra from

    • extensionName: string

      The name of the extension to load

    • actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>

      The action to run

    Returns Nullable<Promise<TResult>>

    The promise returned by actionAsync or null if the extra does not exist

  • Unregisters a loader extension.

    Parameters

    • name: string

      The name of the loader extension.

    Returns boolean

    A boolean indicating whether the extension has been unregistered

    Please use unregisterGLTFExtension instead.