The asset loader in loader's pipeline, it's by default the first pipe.
It's used to identify an asset's type, and determine how to download it.
The downloader in loader's pipeline, it's by default the second pipe.
It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
You can add your own download function with addDownloadHandlers
Gets a new XMLHttpRequest instance.
The loader in loader's pipeline, it's by default the third pipe.
It's used to parse downloaded content with several handlers: JSON, image, plist, fnt, uuid.
You can add your own download function with addLoadHandlers
The md5 pipe in loader's pipeline, it could be absent if the project isn't build with md5 option.
It's used to modify the url to the real downloadable url with md5 suffix.
The default progression callback during the loading process, if no progression callback is passed to {{load}} function, then this default callback will be used.
The item states of the LoadingItems, its value could be {{ItemState.WORKING}} | {{ItemState.COMPLETE}} | {{ItemState.ERROR}}
Find the asset's reference id in loader, asset could be asset object, asset uuid or asset url
Retrieve asset's uuid
Add custom supported types handler or modify existing type handler for download process.
Handlers for corresponding type in a map
Add custom supported types handler or modify existing type handler for load process.
Handlers for corresponding type in a map
Add a new pipe at the end of the pipeline.
A pipe must contain an id
in string and a handle
function, the id must be unique in the pipeline.
The pipe to be appended
Clear the current pipeline, this function will clean up the items.
Copy the item states from one source item to all destination items.
It's quite useful when a pipe generate new items from one source item,
then you should flowIn these generated items into pipeline,
but you probably want them to skip all pipes the source item already go through,
you can achieve it with this API.
For example, an unzip pipe will generate more items, but you won't want them to pass unzip or download pipe again.
The source item
A single destination item or an array of destination items
Let new items flow into the pipeline.
Each item can be a simple url string or an object,
if it's an object, it must contain id
property.
You can specify its type by type
property, by default, the type is the extension name in url.
By adding a skips
property including pipe ids, you can skip these pipe.
The object can contain any supplementary property as you want.
The {{IItem}} to be appended to the current pipeline
See: {{Pipeline.flowInDeps}}
This function is invoked when an item has completed all pipes, it will flow out of the pipeline.
The item which is completed
Get all resource dependencies of the requested asset in an array, including itself.
The owner parameter accept the following types: 1. The asset itself; 2. The resource url; 3. The asset's uuid.
The returned array stores the dependencies with their uuids, after retrieve dependencies,
you can release them, access dependent assets by passing the uuid to getRes, or other stuffs you want.
For release all dependencies of an asset, please refer to release
Here is some examples:
The asset itself or the asset url or the asset uuid
Returns an item in pipeline.
The id of the item
The asset url, it should be related path without extension to the resources
folder.
If type is provided, the asset for correspond type will be returned
Get total resources count in loader.
Initialize with director
The director instance of engine
Insert a new pipe at the given index of the pipeline.
A pipe must contain an id
in string and a handle
function, the id must be unique in the pipeline.
The pipe to be inserted
The index to insert
Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.
See: {{setAutoRelease}}, {{setAutoReleaseRecursively}}
asset object or the raw asset's url
Load resources with a progression callback and a complete callback.
The progression callback is the same as Pipeline's LoadingItems.onProgress
The complete callback is almost the same as Pipeline's LoadingItems.onComplete
The only difference is when user pass a single url as resources, the complete callback will set its result directly as the second parameter.
Url list or load request list
Progression callback
Completion callback
Load assets from the "resources" folder inside the "assets" folder of your project.
Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
The url of the asset to be loaded, this url should be related path without file extension to the resources
folder.
If type is provided, only asset for correspond type will be loaded
Progression callback
Completion callback
This method is like loadRes except that it accepts array of url.
If type is provided, only assets for correspond type will be loaded
Progression callback
Completion callback
Load all assets in a folder inside the "assets/resources" folder of your project.
Note: All asset URLs in Creator use forward slashes, URLs using backslashes will not work.
The url of the directory to be loaded, this url should be related path to the resources
folder.
If type is provided, only assets for correspond type will be loaded
Progression callback
Completion callback
Release the content of an asset or an array of assets by uuid.
This method will not only remove the cache of the asset in loader, but also clean up its content.
For example, if you release a texture, the texture asset and its gl texture data will be freed up.
In complexe project, you can use this function with getDependsRecursively to free up memory in critical circumstances.
Notice, this method may cause the texture to be unusable, if there are still other nodes use the same texture, they may turn to black and report gl errors.
If you only want to remove the cache of an asset, please use Pipeline.removeItem
Resource all assets. Refer to {{release}} for detailed informations.
Release the asset by its object. Refer to {{release}} for detailed informations.
The asset to be released
Release the asset loaded by {{loadRes}}. Refer to {{release}} for detailed informations.
The asset url, it should be related path without extension to the resources
folder.
If type is provided, the asset for correspond type will be returned
Release the all assets loaded by {{loadResDir}}. Refer to {{release}} for detailed informations.
The url of the directory to release, it should be related path to the resources
folder.
If type is provided, the asset for correspond type will be returned
Indicates whether to release the asset when loading a new scene.
By default, when loading a new scene, all assets in the previous scene will be released or preserved
according to whether the previous scene checked the "Auto Release Assets" option.
On the other hand, assets dynamically loaded by using loader.loadRes
or loader.loadResDir
will not be affected by that option, remain not released by default.
Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.
See: {{setAutoReleaseRecursively}}, {{isAutoRelease}}
The asset or its url or its uuid
Whether to release automatically during scene switch
Indicates whether to release the asset and its referenced other assets when loading a new scene.
By default, when loading a new scene, all assets in the previous scene will be released or preserved
according to whether the previous scene checked the "Auto Release Assets" option.
On the other hand, assets dynamically loaded by using loader.loadRes
or loader.loadResDir
will not be affected by that option, remain not released by default.
Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.
See: {{setAutoRelease}}, {{isAutoRelease}}
The asset or its url or its uuid
Whether to release automatically during scene switch
Generated using TypeDoc
Loader for resource loading process. The engine automatically initialize its singleton object {{loader}}.