🆙 the latest updates to Renderer

This commit is contained in:
duckietm
2024-07-15 10:23:54 +02:00
parent bd09ea8b25
commit 1e4f45a107
12 changed files with 100 additions and 45 deletions
+27
View File
@@ -74,6 +74,33 @@ export class AssetManager implements IAssetManager
return collection;
}
public async loadTextureFromUrl(url: string, name: string = null): Promise<Texture>
{
if(!url || !url.length) return null;
let texture = this.getTexture(name);
if(!texture) texture = this.getTexture(url);
if(texture) return texture;
try
{
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>
{
if(!urls || !urls.length) return Promise.resolve(true);