mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2024-11-22 15:40:52 +01:00
Remove asset type check
This commit is contained in:
parent
a1ae6a384f
commit
0ac8aac5fb
@ -1,4 +1,4 @@
|
||||
import { BaseTexture, Resource, Texture } from '@pixi/core';
|
||||
import { Resource, Texture } from '@pixi/core';
|
||||
import { Loader, LoaderResource } from '@pixi/loaders';
|
||||
import { Spritesheet } from '@pixi/spritesheet';
|
||||
import { IGraphicAsset } from '../../room';
|
||||
@ -170,7 +170,7 @@ export class AssetManager extends Disposable implements IAssetManager
|
||||
const nitroBundle = new NitroBundle(resource.data);
|
||||
const assetData = (nitroBundle.jsonFile as IAssetData);
|
||||
|
||||
if(!assetData || !assetData.type)
|
||||
if(!assetData)
|
||||
{
|
||||
onDownloaded(loader, resource, false);
|
||||
|
||||
@ -231,77 +231,7 @@ export class AssetManager extends Disposable implements IAssetManager
|
||||
onDownloaded(loader, resource, true);
|
||||
}
|
||||
|
||||
else if(resource.type === LoaderResource.TYPE.JSON)
|
||||
{
|
||||
const assetData = (resource.data as IAssetData);
|
||||
|
||||
if(!assetData || !assetData.type)
|
||||
{
|
||||
onDownloaded(loader, resource, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(assetData.spritesheet && Object.keys(assetData.spritesheet).length)
|
||||
{
|
||||
const imageName = (assetData.spritesheet.meta && assetData.spritesheet.meta.image);
|
||||
|
||||
if(!imageName || !imageName.length)
|
||||
{
|
||||
onDownloaded(loader, resource, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const imageUrl = (resource.url.substring(0, (resource.url.lastIndexOf('/') + 1)) + imageName);
|
||||
const baseTexture = BaseTexture.from(imageUrl);
|
||||
|
||||
if(baseTexture.valid)
|
||||
{
|
||||
const spritesheet = new Spritesheet(baseTexture, assetData.spritesheet);
|
||||
|
||||
spritesheet.parse(() =>
|
||||
{
|
||||
this.createCollection(assetData, spritesheet);
|
||||
|
||||
onDownloaded(loader, resource, true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
baseTexture.once('loaded', () =>
|
||||
{
|
||||
baseTexture.removeAllListeners();
|
||||
|
||||
const spritesheet = new Spritesheet(baseTexture, assetData.spritesheet);
|
||||
|
||||
spritesheet.parse(() =>
|
||||
{
|
||||
this.createCollection(assetData, spritesheet);
|
||||
|
||||
onDownloaded(loader, resource, true);
|
||||
});
|
||||
});
|
||||
|
||||
baseTexture.once('error', () =>
|
||||
{
|
||||
baseTexture.removeAllListeners();
|
||||
|
||||
onDownloaded(loader, resource, false);
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.createCollection(assetData, null);
|
||||
|
||||
onDownloaded(loader, resource, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(resource.type === LoaderResource.TYPE.IMAGE)
|
||||
else if(resource.type === LoaderResource.TYPE.IMAGE)
|
||||
{
|
||||
if(resource.texture.valid)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { BaseTexture, Resource, Texture } from '@pixi/core';
|
||||
import { Resource, Texture } from '@pixi/core';
|
||||
import { Loader, LoaderResource } from '@pixi/loaders';
|
||||
import { Spritesheet } from '@pixi/spritesheet';
|
||||
import { IAssetData } from '../../core/asset/interfaces';
|
||||
@ -559,7 +559,7 @@ export class RoomContentLoader implements IFurnitureDataListener
|
||||
const nitroBundle = new NitroBundle(resource.data);
|
||||
const assetData = (nitroBundle.jsonFile as IAssetData);
|
||||
|
||||
if(!assetData || !assetData.type)
|
||||
if(!assetData)
|
||||
{
|
||||
onDownloaded(loader, resource, false);
|
||||
|
||||
@ -619,74 +619,6 @@ export class RoomContentLoader implements IFurnitureDataListener
|
||||
|
||||
onDownloaded(loader, resource, true);
|
||||
}
|
||||
|
||||
else if(resource.type === LoaderResource.TYPE.JSON)
|
||||
{
|
||||
const assetData = (resource.data as IAssetData);
|
||||
|
||||
if(!assetData.type)
|
||||
{
|
||||
onDownloaded(loader, resource, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(assetData.spritesheet && Object.keys(assetData.spritesheet).length)
|
||||
{
|
||||
const imageName = (assetData.spritesheet.meta && assetData.spritesheet.meta.image);
|
||||
|
||||
if(!imageName || !imageName.length)
|
||||
{
|
||||
onDownloaded(loader, resource, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const imageUrl = (resource.url.substring(0, (resource.url.lastIndexOf('/') + 1)) + imageName);
|
||||
const baseTexture = BaseTexture.from(imageUrl);
|
||||
|
||||
if(baseTexture.valid)
|
||||
{
|
||||
const spritesheet = new Spritesheet(baseTexture, assetData.spritesheet);
|
||||
|
||||
spritesheet.parse(() =>
|
||||
{
|
||||
this.createCollection(assetData, spritesheet);
|
||||
|
||||
onDownloaded(loader, resource, true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
baseTexture.once('loaded', () =>
|
||||
{
|
||||
baseTexture.removeAllListeners();
|
||||
|
||||
const spritesheet = new Spritesheet(baseTexture, assetData.spritesheet);
|
||||
|
||||
spritesheet.parse(() =>
|
||||
{
|
||||
this.createCollection(assetData, spritesheet);
|
||||
|
||||
onDownloaded(loader, resource, true);
|
||||
});
|
||||
});
|
||||
|
||||
baseTexture.once('error', () =>
|
||||
{
|
||||
baseTexture.removeAllListeners();
|
||||
|
||||
onDownloaded(loader, resource, false);
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.createCollection(assetData, null);
|
||||
|
||||
onDownloaded(loader, resource, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
onDownloaded(loader, resource, false);
|
||||
|
Loading…
Reference in New Issue
Block a user