Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GLTFFileLoader

File loader for loading glTF files into a scene.

Hierarchy

  • GLTFFileLoader

Implements

Index

Properties

alwaysComputeBoundingBoxSearch playground for alwaysComputeBoundingBox

alwaysComputeBoundingBox: boolean

Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.

alwaysComputeSkeletonRootNodeSearch playground for alwaysComputeSkeletonRootNode

alwaysComputeSkeletonRootNode: boolean

Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using skin.skeleton. Defaults to false. Set this to true if loading assets with invalid skin.skeleton values.

animationStartModeSearch playground for animationStartMode

animationStartMode: GLTFLoaderAnimationStartMode

The animation start mode. Defaults to FIRST.

compileMaterialsSearch playground for compileMaterials

compileMaterials: boolean

Defines if the loader should compile materials before raising the success callback. Defaults to false.

compileShadowGeneratorsSearch playground for compileShadowGenerators

compileShadowGenerators: boolean

Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.

coordinateSystemModeSearch playground for coordinateSystemMode

coordinateSystemMode: GLTFLoaderCoordinateSystemMode

The coordinate system mode. Defaults to AUTO.

createInstancesSearch playground for createInstances

createInstances: boolean

Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.

loadAllMaterialsSearch playground for loadAllMaterials

loadAllMaterials: boolean

If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.

loadOnlyMaterialsSearch playground for loadOnlyMaterials

loadOnlyMaterials: boolean

If true, load only the materials defined in the file. Defaults to false.

nameSearch playground for name

name: string

Name of the loader ("gltf")

Readonly onCameraLoadedObservableSearch playground for onCameraLoadedObservable

onCameraLoadedObservable: Observable<Camera>

Observable raised when the loader creates a camera after parsing the glTF properties of the camera.

Readonly onCompleteObservableSearch playground for onCompleteObservable

onCompleteObservable: Observable<void>

Observable raised when the asset is completely loaded, immediately before the loader is disposed. For assets with LODs, raised when all of the LODs are complete. For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.

Readonly onDisposeObservableSearch playground for onDisposeObservable

onDisposeObservable: Observable<void>

Observable raised after the loader is disposed.

Readonly onErrorObservableSearch playground for onErrorObservable

onErrorObservable: Observable<any>

Observable raised when an error occurs.

Readonly onExtensionLoadedObservableSearch playground for onExtensionLoadedObservable

onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>

Observable raised after a loader extension is created. Set additional options for a loader extension in this event.

onLoaderStateChangedObservableSearch playground for onLoaderStateChangedObservable

onLoaderStateChangedObservable: Observable<Nullable<GLTFLoaderState>>

Observable raised when the loader state changes.

Readonly onMaterialLoadedObservableSearch playground for onMaterialLoadedObservable

onMaterialLoadedObservable: Observable<Material>

Observable raised when the loader creates a material after parsing the glTF properties of the material.

Readonly onMeshLoadedObservableSearch playground for onMeshLoadedObservable

onMeshLoadedObservable: Observable<AbstractMesh>

Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh. Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)

onParsedObservableSearch playground for onParsedObservable

onParsedObservable: Observable<IGLTFLoaderData>

Raised when the asset has been parsed

Readonly onSkinLoadedObservableSearch playground for onSkinLoadedObservable

onSkinLoadedObservable: Observable<{ node: TransformNode; skinnedNode: TransformNode }>

Callback raised when the loader creates a skin after parsing the glTF properties of the skin node.

see

https://doc.babylonjs.com/divingDeeper/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh

param

the transform node that corresponds to the original glTF skin node used for animations

param

the transform node that is the skinned mesh itself or the parent of the skinned meshes

Readonly onTextureLoadedObservableSearch playground for onTextureLoadedObservable

onTextureLoadedObservable: Observable<BaseTexture>

Observable raised when the loader creates a texture after parsing the glTF properties of the texture.

Readonly onValidatedObservableSearch playground for onValidatedObservable

onValidatedObservable: Observable<IGLTFValidationResults>

Observable raised after validation when validate is set to true. The event data is the result of the validation.

preprocessUrlAsyncSearch playground for preprocessUrlAsync

preprocessUrlAsync: (url: string) => Promise<string>

Function called before loading a url referenced by the asset.

param

Type declaration

    • (url: string): Promise<string>
    • Parameters

      • url: string

      Returns Promise<string>

skipMaterialsSearch playground for skipMaterials

skipMaterials: boolean

If true, do not load any materials defined in the file. Defaults to false.

targetFpsSearch playground for targetFps

targetFps: number

When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.

transparencyAsCoverageSearch playground for transparencyAsCoverage

transparencyAsCoverage: boolean

Defines if the Alpha blended materials are only applied as coverage. If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials. If true, no extra effects are applied to transparent pixels.

useClipPlaneSearch playground for useClipPlane

useClipPlane: boolean

Defines if the loader should also compile materials with clip planes. Defaults to false.

useRangeRequestsSearch playground for useRangeRequests

useRangeRequests: boolean

Defines if the loader should use range requests when load binary glTF files from HTTP. Enabling will disable offline support and glTF validator. Defaults to false.

useSRGBBuffersSearch playground for useSRGBBuffers

useSRGBBuffers: boolean

If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.

validateSearch playground for validate

validate: boolean

Defines if the loader should validate the asset.

Accessors

capturePerformanceCounters

  • get capturePerformanceCounters(): boolean
  • set capturePerformanceCounters(value: boolean): any
  • Defines if the loader should capture performance counters.

    Returns boolean

  • Defines if the loader should capture performance counters.

    Parameters

    • value: boolean

    Returns any

loaderState

  • The loader state or null if the loader is not active.

    Returns Nullable<GLTFLoaderState>

loggingEnabled

  • get loggingEnabled(): boolean
  • set loggingEnabled(value: boolean): any
  • Defines if the loader logging is enabled.

    Returns boolean

  • Defines if the loader logging is enabled.

    Parameters

    • value: boolean

    Returns any

onCameraLoaded

  • set onCameraLoaded(callback: (camera: Camera) => void): any
  • Callback raised when the loader creates a camera after parsing the glTF properties of the camera.

    Parameters

    • callback: (camera: Camera) => void
        • Parameters

          Returns void

    Returns any

onComplete

  • set onComplete(callback: () => void): any
  • Callback raised when the asset is completely loaded, immediately before the loader is disposed. For assets with LODs, raised when all of the LODs are complete. For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.

    Parameters

    • callback: () => void
        • (): void
        • Returns void

    Returns any

onDispose

  • set onDispose(callback: () => void): any
  • Callback raised after the loader is disposed.

    Parameters

    • callback: () => void
        • (): void
        • Returns void

    Returns any

onError

  • set onError(callback: (reason: any) => void): any
  • Callback raised when an error occurs.

    Parameters

    • callback: (reason: any) => void
        • (reason: any): void
        • Parameters

          • reason: any

          Returns void

    Returns any

onExtensionLoaded

onMaterialLoaded

  • set onMaterialLoaded(callback: (material: Material) => void): any
  • Callback raised when the loader creates a material after parsing the glTF properties of the material.

    Parameters

    Returns any

onMeshLoaded

  • set onMeshLoaded(callback: (mesh: AbstractMesh) => void): any
  • Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh. Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)

    Parameters

    Returns any

onParsed

  • Raised when the asset has been parsed

    Parameters

    Returns any

onTextureLoaded

  • set onTextureLoaded(callback: (texture: BaseTexture) => void): any
  • Callback raised when the loader creates a texture after parsing the glTF properties of the texture.

    Parameters

    Returns any

onValidated

  • set onValidated(callback: (results: IGLTFValidationResults) => void): any
  • Callback raised after a loader extension is created.

    Parameters

    • callback: (results: IGLTFValidationResults) => void
        • (results: IGLTFValidationResults): void
        • Parameters

          • results: IGLTFValidationResults

          Returns void

    Returns any

Methods

disposeSearch playground for dispose

  • dispose(): void
  • Disposes the loader, releases resources during load, and cancels any outstanding requests.

    Returns void

Optional rewriteRootURLSearch playground for rewriteRootURL

  • rewriteRootURL(rootUrl: string, responseURL?: string): string
  • The callback that allows custom handling of the root url based on the response url.

    Parameters

    • rootUrl: string

      the original root url

    • Optional responseURL: string

      the response url if available

    Returns string

    the new root url

whenCompleteAsyncSearch playground for whenCompleteAsync

  • whenCompleteAsync(): Promise<void>
  • Returns a promise that resolves when the asset is completely loaded.

    Returns Promise<void>

    a promise that resolves when the asset is completely loaded.

Legend

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