Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GLTFLoader

The glTF 2.0 loader

Hierarchy

  • GLTFLoader

Implements

  • IGLTFLoader

Index

Properties

_babylonLightsSearch playground for _babylonLights

_babylonLights: Light[]

Storage

Static Readonly DefaultSamplerSearch playground for DefaultSampler

DefaultSampler: ISampler

The default glTF sampler.

Accessors

babylonScene

  • get babylonScene(): Scene
  • The Babylon scene when loading the asset.

    Returns Scene

bin

  • The BIN chunk of a binary glTF.

    Returns Nullable<IDataBuffer>

gltf

  • The object that represents the glTF JSON.

    Returns IGLTF

parent

  • The parent file loader.

    Returns GLTFFileLoader

rootBabylonMesh

  • get rootBabylonMesh(): Mesh
  • The root Babylon mesh when loading the asset.

    Returns Mesh

Methods

createMaterialSearch playground for createMaterial

  • createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material
  • 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

endPerformanceCounterSearch playground for endPerformanceCounter

  • endPerformanceCounter(counterName: string): void
  • Ends a performance counter.

    Parameters

    • counterName: string

      The name of the performance counter

    Returns void

isExtensionUsedSearch playground for isExtensionUsed

  • isExtensionUsed(name: string): boolean
  • 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

loadAnimationAsyncSearch playground for loadAnimationAsync

  • 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

loadBufferAsyncSearch playground for loadBufferAsync

  • loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>
  • 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>

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

loadBufferViewAsyncSearch playground for loadBufferViewAsync

  • loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>
  • Loads a glTF buffer view.

    Parameters

    • context: string

      The context when loading the asset

    • bufferView: IBufferView

      The glTF buffer view property

    Returns Promise<ArrayBufferView>

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

loadCameraAsyncSearch playground for loadCameraAsync

  • loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>
  • Loads a glTF camera.

    Parameters

    • context: string

      The context when loading the asset

    • camera: ICamera

      The glTF camera property

    • Optional assign: (babylonCamera: Camera) => void

      A function called synchronously after parsing the glTF properties

        • (babylonCamera: Camera): void
        • Parameters

          Returns void

    Returns Promise<Camera>

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

loadImageAsyncSearch playground for loadImageAsync

  • loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>
  • Loads a glTF image.

    Parameters

    • context: string

      The context when loading the asset

    • image: IImage

      The glTF image property

    Returns Promise<ArrayBufferView>

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

loadMaterialAlphaPropertiesSearch playground for loadMaterialAlphaProperties

  • loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void
  • 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

loadMaterialBasePropertiesAsyncSearch playground for loadMaterialBasePropertiesAsync

  • loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<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

loadMaterialPropertiesAsyncSearch playground for loadMaterialPropertiesAsync

  • loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>
  • 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

loadNodeAsyncSearch playground for loadNodeAsync

  • Loads a glTF node.

    Parameters

    • context: string

      The context when loading the asset

    • node: INode

      The glTF node property

    • Optional 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

loadSceneAsyncSearch playground for loadSceneAsync

  • loadSceneAsync(context: string, scene: IScene): Promise<void>
  • Loads a glTF scene.

    Parameters

    • context: string

      The context when loading the asset

    • scene: IScene

      The glTF scene property

    Returns Promise<void>

    A promise that resolves when the load is complete

loadTextureInfoAsyncSearch playground for loadTextureInfoAsync

  • Loads a glTF texture info.

    Parameters

    • context: string

      The context when loading the asset

    • textureInfo: ITextureInfo

      The glTF texture info property

    • Optional 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

loadUriAsyncSearch playground for loadUriAsync

  • loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>
  • 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>

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

logSearch playground for log

  • log(message: string): void
  • Logs a message

    Parameters

    • message: string

      The message to log

    Returns void

logCloseSearch playground for logClose

  • logClose(): void
  • Decrements the indentation level.

    Returns void

logOpenSearch playground for logOpen

  • logOpen(message: string): void
  • Increments the indentation level and logs a message.

    Parameters

    • message: string

      The message to log

    Returns void

startPerformanceCounterSearch playground for startPerformanceCounter

  • startPerformanceCounter(counterName: string): void
  • Starts a performance counter.

    Parameters

    • counterName: string

      The name of the performance counter

    Returns void

Static AddPointerMetadataSearch playground for AddPointerMetadata

  • AddPointerMetadata(babylonObject: { metadata: any }, pointer: string): void
  • Adds a JSON pointer to the metadata of the Babylon object at <object>.metadata.gltf.pointers.

    Parameters

    • babylonObject: { metadata: any }

      the Babylon object with metadata

      • metadata: any
    • pointer: string

      the JSON pointer

    Returns void

Static LoadExtensionAsyncSearch playground for LoadExtensionAsync

  • LoadExtensionAsync<TExtension, TResult>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>
  • Helper method called by a loader extension to load an glTF extension.

    Type parameters

    • TExtension = any

    • 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

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

          • extensionContext: string
          • extension: TExtension

          Returns Nullable<Promise<TResult>>

    Returns Nullable<Promise<TResult>>

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

Static LoadExtraAsyncSearch playground for LoadExtraAsync

  • LoadExtraAsync<TExtra, TResult>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>
  • Helper method called by a loader extension to load a glTF extra.

    Type parameters

    • TExtra = any

    • 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

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

          • extraContext: string
          • extra: TExtra

          Returns Nullable<Promise<TResult>>

    Returns Nullable<Promise<TResult>>

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

Static RegisterExtensionSearch playground for RegisterExtension

Static UnregisterExtensionSearch playground for UnregisterExtension

  • UnregisterExtension(name: string): boolean
  • Unregisters a loader extension.

    Parameters

    • name: string

      The name of the loader extension.

    Returns boolean

    A boolean indicating whether the extension has been unregistered

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method