Class AssetsManager
Constructors
constructor
-
Creates a new AssetsManager
Parameters
Optionalscene: Scenedefines the scene to work on
Returns AssetsManager
Properties
auto Hide Loading UI
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.
on Finish
Callback called when all tasks are processed
on Progress
Callback called when a task is done (whatever the result is)
on Progress Observable
Observable called when a task is done (whatever the result is)
on Task Error
Callback called when a task had an error
on Task Error Observable
Observable called when a task had an error
on Tasks Done Observable
Observable called when all tasks were executed
on Task Success
Callback called when a task is successful
on Task Success Observable
Observable called when all tasks are processed
use Default Loading Screen
Gets or sets a boolean defining if the AssetsManager should use the default loading screen
Methods
add Binary File Task
-
Add a BinaryFileAssetTask 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
Returns BinaryFileAssetTask
a new BinaryFileAssetTask object
- taskName: string
add Container Task
-
addContainerTask(
taskName: string,
meshesNames: any,
rootUrl: string,
sceneFilename: string | File,
extension?: string,
): ContainerAssetTaskAdd 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: stringdefines the extension to use to load the file
Returns ContainerAssetTask
a new ContainerAssetTask object
- taskName: string
add Cube Texture Task
-
addCubeTextureTask(
taskName: string,
url: string,
extensionsOrOptions?: string[] | ICubeTextureCreationOptions,
noMipmap?: boolean,
files?: string[],
prefiltered?: boolean,
): CubeTextureAssetTaskAdd 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[] | ICubeTextureCreationOptionsdefines the extension to use to load the cube map (can be null) or the options to use for the cube texture
OptionalnoMipmap: booleandefines if the texture must not receive mipmaps (false by default)
Optionalfiles: string[]defines the list of files to load (can be null)
Optionalprefiltered: booleandefines the prefiltered texture option (default is false)
Returns CubeTextureAssetTask
a new CubeTextureAssetTask object
- taskName: string
add Equi Rectangular Cube Texture Asset Task
-
addEquiRectangularCubeTextureAssetTask(
taskName: string,
url: string,
size: number,
noMipmap?: boolean,
gammaSpace?: boolean,
superSample?: boolean,
): EquiRectangularCubeTextureAssetTaskAdd 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
- taskName: string
add HDR Cube Texture Task
-
addHDRCubeTextureTask(
taskName: string,
url: string,
size: number,
noMipmap?: boolean,
generateHarmonics?: boolean,
gammaSpace?: boolean,
prefilterOnLoad?: boolean,
supersample?: boolean,
prefilterIrradianceOnLoad?: boolean,
prefilterUsingCdf?: boolean,
): HDRCubeTextureAssetTaskAdd 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
- taskName: string
add Image Task
-
Add a ImageAssetTask 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
Returns ImageAssetTask
a new ImageAssetTask object
- taskName: string
add Mesh Task
-
addMeshTask(
taskName: string,
meshesNames: any,
rootUrl: string,
sceneFilename: string | File,
extension?: string,
filename?: string,
pluginOptions?: {
[key: string]:
| { enabled?: boolean; [key: string]: unknown }
| undefined;
},
): MeshAssetTaskAdd 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: stringdefines the extension to use to load the file
Optionalfilename: stringdefines 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
- taskName: string
add Text File Task
-
Add a TextFileAssetTask 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
Returns TextFileAssetTask
a new TextFileAssetTask object
- taskName: string
add Texture Task
-
addTextureTask(
taskName: string,
url: string,
noMipmapOrOptions?: boolean | ITextureCreationOptions,
invertY?: boolean,
samplingMode?: number,
): TextureAssetTaskAdd 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 | ITextureCreationOptionsdefines if mipmap should not be generated (default is false) or the creation options to use
OptionalinvertY: booleandefines 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
- taskName: string
load
load Async
-
Start the loading process as an async operation
Returns Promise<void>
a promise returning the list of failed tasks
remove Task
-
Remove a task from the assets manager.
Parameters
- task: AbstractAssetTask
the task to remove
Returns void
- task: AbstractAssetTask
reset
-
Reset the AssetsManager and remove all tasks
Returns AssetsManager
the current instance of the AssetsManager
This class can be used to easily import assets into a scene
See
https://doc.babylonjs.com/features/featuresDeepDive/importers/assetManager