Class: Asset
Utils.Asset
The Asset class is a manager for loading and handling resources in a scene.
Properties
onError
▪ Static
onError: (error
: unknown
) => void
Type declaration
▸ (error
): void
Default callback function for handling errors during resource loading.
This function is called with an error
object in case of loading errors.
Parameters
Name | Type |
---|---|
error | unknown |
Returns
void
Defined in
onProgress
▪ Static
onProgress: (ratio
: number
) => void
Type declaration
▸ (ratio
): void
Default callback function for reporting progress during resource loading. This function is called with a ratio (0 to 1) to indicate the loading progress.
Parameters
Name | Type |
---|---|
ratio | number |
Returns
void
Defined in
Methods
get
▸ Static
get<T
>(path
): T
Get a previously loaded result object for a specific path.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
path | string | The path of the resource. |
Returns
T
A previously loaded result object.
Defined in
▸ Static
get<T
>(...path
): T
[]
Get a list of previously loaded result objects for a series of specific paths.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
...path | string [] | An array of resource paths. |
Returns
T
[]
An array of previously loaded result objects.
Defined in
getLoader
▸ Static
getLoader<T
>(loaderType
): T
Get a specific loader based on the resource type.
Type parameters
Name | Type |
---|---|
T | extends Loader <unknown , string , T > |
Parameters
Name | Type | Description |
---|---|---|
loaderType | Object | The desired loader type. |
Returns
T
The loader associated with the resource type.
Defined in
load
▸ Static
load<T
>(loaderType
, path
, onProgress?
, onError?
): Promise
<T
>
Load a resource using a specified loader type and path.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
loaderType | Object | The type of loader to use for loading the resource. |
path | string | The path to the resource to be loaded. |
onProgress? | (event : ProgressEvent <EventTarget >) => void | (optional) A callback function to report loading progress with a ProgressEvent. |
onError? | (error : unknown ) => void | - |
Returns
Promise
<T
>
A Promise that resolves with the loaded resource when loading is complete.
Defined in
loadAll
▸ Static
loadAll(config?
, ...resources
): Promise
<void
[]>
Load all specified resources and return a promise that resolves when all resources are loaded.
Parameters
Name | Type | Description |
---|---|---|
config | LoadingConfig | Configuration for the loading process. |
...resources | Resource [] | An array of resource objects to load. |
Returns
Promise
<void
[]>
A promise that resolves when all resources are loaded.
Defined in
preload
▸ Static
preload(loader
, ...paths
): void
Preload resources for future use.
Parameters
Name | Type | Description |
---|---|---|
loader | Object | The loader type to be used for preloading. |
...paths | (string | ResourceConfig )[] | An array of resource paths or configurations to preload. |
Returns
void
Defined in
preloadAllPending
▸ Static
preloadAllPending(config?
): Promise
<void
[]>
Preload all pending resources and return a promise that resolves when all resources are loaded.
Parameters
Name | Type | Description |
---|---|---|
config | LoadingConfig | Optional configuration for the loading process. |
Returns
Promise
<void
[]>
A promise that resolves when all pending resources are loaded.