API

Class AssetsManager

This class can be used to easily import assets into a scene

Index
autoHideLoadingUI: boolean = true

Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen when all assets have been downloaded. If set to false, you need to manually call in hideLoadingUI() once your scene is ready.

onFinish: (tasks: AbstractAssetTask[]) => void

Callback called when all tasks are processed

onProgress: (
    remainingCount: number,
    totalCount: number,
    task: AbstractAssetTask,
) => void

Callback called when a task is done (whatever the result is)

onProgressObservable: Observable<IAssetsProgressEvent> = ...

Observable called when a task is done (whatever the result is)

onTaskError: (task: AbstractAssetTask) => void

Callback called when a task had an error

onTaskErrorObservable: Observable<AbstractAssetTask> = ...

Observable called when a task had an error

onTasksDoneObservable: Observable<AbstractAssetTask[]> = ...

Observable called when all tasks were executed

onTaskSuccess: (task: AbstractAssetTask) => void

Callback called when a task is successful

onTaskSuccessObservable: Observable<AbstractAssetTask> = ...

Observable called when all tasks are processed

useDefaultLoadingScreen: boolean = true

Gets or sets a boolean defining if the AssetsManager should use the default loading screen

  • Add a ContainerAssetTask to the list of active tasks

    Parameters

    • taskName: string

      defines the name of the new task

    • meshesNames: any

      defines the name of meshes to load

    • rootUrl: string

      defines the root url to use to locate files

    • sceneFilename: string | File

      defines the filename of the scene file or the File itself

    • Optionalextension: string

      defines the extension to use to load the file

    Returns ContainerAssetTask

    a new ContainerAssetTask object

  • Add a CubeTextureAssetTask to the list of active tasks

    Parameters

    • taskName: string

      defines the name of the new task

    • url: string

      defines the url of the file to load

    • OptionalextensionsOrOptions: string[] | ICubeTextureCreationOptions

      defines the extension to use to load the cube map (can be null) or the options to use for the cube texture

    • OptionalnoMipmap: boolean

      defines if the texture must not receive mipmaps (false by default)

    • Optionalfiles: string[]

      defines the list of files to load (can be null)

    • Optionalprefiltered: boolean

      defines the prefiltered texture option (default is false)

    Returns CubeTextureAssetTask

    a new CubeTextureAssetTask object

  • Add a EquiRectangularCubeTextureAssetTask to the list of active tasks

    Parameters

    • taskName: string

      defines the name of the new task

    • url: string

      defines the url of the file to load

    • size: number

      defines the size you want for the cubemap (can be null)

    • noMipmap: boolean = false

      defines if the texture must not receive mipmaps (false by default)

    • gammaSpace: boolean = true

      Specifies if the texture will be used in gamma or linear space

    • superSample: boolean = false

      specifies if the texture will be generated with super sampling (default is false) (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)

    Returns EquiRectangularCubeTextureAssetTask

    a new EquiRectangularCubeTextureAssetTask object

  • Add a HDRCubeTextureAssetTask to the list of active tasks

    Parameters

    • taskName: string

      defines the name of the new task

    • url: string

      defines the url of the file to load

    • size: number

      defines the size you want for the cubemap (can be null)

    • noMipmap: boolean = false

      defines if the texture must not receive mipmaps (false by default)

    • generateHarmonics: boolean = true

      defines if you want to automatically generate (true by default)

    • gammaSpace: boolean = false

      specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)

    • prefilterOnLoad: boolean = false

      specifies if the texture should be prefiltered on load (default is false)

    • supersample: boolean = false

      specifies if the texture will be generated with super sampling (default is false)

    • prefilterIrradianceOnLoad: boolean = false

      specifies if the irradiance should be prefiltered on load (default is false)

    • prefilterUsingCdf: boolean = false

      specifies if the texture should be prefiltered using CDF (default is false)

    Returns HDRCubeTextureAssetTask

    a new HDRCubeTextureAssetTask object

  • Add a MeshAssetTask to the list of active tasks

    Parameters

    • taskName: string

      defines the name of the new task

    • meshesNames: any

      defines the name of meshes to load

    • rootUrl: string

      defines the root url to use to locate files

    • sceneFilename: string | File

      defines the filename of the scene file or the File itself

    • Optionalextension: string

      defines the extension to use to load the file

    • Optionalfilename: string

      defines the name of the file, if the data is binary

    • OptionalpluginOptions: { [key: string]: { enabled?: boolean; [key: string]: unknown } | undefined }

      defines the options to use with the plugin

    Returns MeshAssetTask

    a new MeshAssetTask object

  • Add a TextureAssetTask to the list of active tasks

    Parameters

    • taskName: string

      defines the name of the new task

    • url: string

      defines the url of the file to load

    • OptionalnoMipmapOrOptions: boolean | ITextureCreationOptions

      defines if mipmap should not be generated (default is false) or the creation options to use

    • OptionalinvertY: boolean

      defines if you want to invert Y axis of the loaded texture (true by default)

    • samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE

      defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)

    Returns TextureAssetTask

    a new TextureAssetTask object