Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static use(resource, next)
{
// skip if no data or not xml data
if (!resource.data || resource.type !== LoaderResource.TYPE.XML)
{
next();
return;
}
// skip if not bitmap font data, using some silly duck-typing
if (resource.data.getElementsByTagName('page').length === 0
|| resource.data.getElementsByTagName('info').length === 0
|| resource.data.getElementsByTagName('info')[0].getAttribute('face') === null
)
{
next();
return;
}
static use(resource, next)
{
const imageResourceName = `${resource.name}_image`;
// skip if no data, its not json, it isn't spritesheet data, or the image resource already exists
if (!resource.data
|| resource.type !== LoaderResource.TYPE.JSON
|| !resource.data.frames
|| this.resources[imageResourceName]
)
{
next();
return;
}
const loadOptions = {
crossOrigin: resource.crossOrigin,
metadata: resource.metadata.imageMetadata,
parentResource: resource,
};
const resourcePath = SpritesheetLoader.getResourcePath(resource, this.baseUrl);