mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-12-03 12:16:28 +01:00
Merge pull request #1 from brenoepics/fix-mpu
Fix MPU and room background path
This commit is contained in:
commit
9c6eec637e
@ -87,42 +87,46 @@ export class AssetManager implements IAssetManager
|
|||||||
{
|
{
|
||||||
if(!urls || !urls.length) return Promise.resolve(true);
|
if(!urls || !urls.length) return Promise.resolve(true);
|
||||||
|
|
||||||
const responses = await Promise.allSettled(urls.map(url => fetch(url)));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for(const response of responses)
|
for(const url of urls)
|
||||||
{
|
{
|
||||||
if(response.status === 'rejected') continue;
|
const response = await fetch(url);
|
||||||
|
|
||||||
|
if(response.status !== 200) continue;
|
||||||
|
|
||||||
let contentType = 'application/octet-stream';
|
let contentType = 'application/octet-stream';
|
||||||
|
|
||||||
if(response.value.headers.has('Content-Type'))
|
if(response.headers.has('Content-Type'))
|
||||||
{
|
{
|
||||||
contentType = response.value.headers.get('Content-Type');
|
contentType = response.headers.get('Content-Type');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(contentType)
|
switch(contentType)
|
||||||
{
|
{
|
||||||
case 'application/octet-stream': {
|
case 'application/octet-stream': {
|
||||||
const buffer = await response.value.arrayBuffer();
|
const buffer = await response.arrayBuffer();
|
||||||
const nitroBundle = new NitroBundle(buffer);
|
const nitroBundle = new NitroBundle(buffer);
|
||||||
|
|
||||||
await this.processAsset(nitroBundle.baseTexture, (nitroBundle.jsonFile as IAssetData));
|
await this.processAsset(
|
||||||
|
nitroBundle.baseTexture,
|
||||||
|
nitroBundle.jsonFile as IAssetData
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'image/png':
|
case 'image/png':
|
||||||
case 'image/jpeg':
|
case 'image/jpeg':
|
||||||
case 'image/gif': {
|
case 'image/gif': {
|
||||||
const buffer = await response.value.arrayBuffer();
|
const buffer = await response.arrayBuffer();
|
||||||
const base64 = ArrayBufferToBase64(buffer);
|
const base64 = ArrayBufferToBase64(buffer);
|
||||||
const baseTexture = BaseTexture.from(`data:${contentType};base64,${base64}`);
|
const baseTexture = BaseTexture.from(
|
||||||
|
`data:${ contentType };base64,${ base64 }`
|
||||||
|
);
|
||||||
|
|
||||||
const createAsset = async () =>
|
const createAsset = async () =>
|
||||||
{
|
{
|
||||||
const texture = new Texture(baseTexture);
|
const texture = new Texture(baseTexture);
|
||||||
|
this.setTexture(url, texture);
|
||||||
this.setTexture(response.value.url, texture);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if(baseTexture.valid)
|
if(baseTexture.valid)
|
||||||
@ -148,7 +152,6 @@ export class AssetManager implements IAssetManager
|
|||||||
|
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (err)
|
catch (err)
|
||||||
{
|
{
|
||||||
NitroLogger.error(err);
|
NitroLogger.error(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user