mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-18 22:36:27 +01:00
Add function to AssetManager
This commit is contained in:
parent
8d9c11ff6e
commit
2b5b1fe6ab
@ -12,6 +12,7 @@ export interface IAssetManager
|
|||||||
getAsset(name: string): IGraphicAsset;
|
getAsset(name: string): IGraphicAsset;
|
||||||
getCollection(name: string): IGraphicAssetCollection;
|
getCollection(name: string): IGraphicAssetCollection;
|
||||||
createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection;
|
createCollection(data: IAssetData, spritesheet: Spritesheet): IGraphicAssetCollection;
|
||||||
|
loadTextureFromUrl(url: string, name?: string): Promise<Texture>
|
||||||
downloadAssets(urls: string[]): Promise<boolean>;
|
downloadAssets(urls: string[]): Promise<boolean>;
|
||||||
downloadAsset(url: string): Promise<boolean>;
|
downloadAsset(url: string): Promise<boolean>;
|
||||||
readonly collections: Map<string, IGraphicAssetCollection>;
|
readonly collections: Map<string, IGraphicAssetCollection>;
|
||||||
|
@ -74,6 +74,27 @@ export class AssetManager implements IAssetManager
|
|||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async loadTextureFromUrl(url: string, name: string = null): Promise<Texture>
|
||||||
|
{
|
||||||
|
if(!url || !url.length) return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const texture = await Assets.load<Texture>(url);
|
||||||
|
|
||||||
|
if(!texture) return null;
|
||||||
|
|
||||||
|
this.setTexture(name ?? url, texture);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (err)
|
||||||
|
{
|
||||||
|
NitroLogger.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async downloadAssets(urls: string[]): Promise<boolean>
|
public async downloadAssets(urls: string[]): Promise<boolean>
|
||||||
{
|
{
|
||||||
if(!urls || !urls.length) return Promise.resolve(true);
|
if(!urls || !urls.length) return Promise.resolve(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user