pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
1 lines • 2.8 kB
Source Map (JSON)
{"version":3,"file":"createTexture.mjs","sources":["../../../../../../src/assets/loader/parsers/textures/utils/createTexture.ts"],"sourcesContent":["import { Texture } from '../../../../../rendering/renderers/shared/texture/Texture';\nimport { warn } from '../../../../../utils/logging/warn';\nimport { Cache } from '../../../../cache/Cache';\n\nimport type { TextureSource } from '../../../../../rendering/renderers/shared/texture/sources/TextureSource';\nimport type { Loader } from '../../../Loader';\n\n/**\n * Creates a texture from a source and adds it to the cache.\n * @param source - source of the texture\n * @param loader - loader\n * @param url - url of the texture\n * @ignore\n */\nexport function createTexture(source: TextureSource, loader: Loader, url: string)\n{\n source.label = url;\n source._sourceOrigin = url;\n\n const texture = new Texture({\n source,\n label: url,\n });\n\n const unload = () =>\n {\n delete loader.promiseCache[url];\n\n if (Cache.has(url))\n {\n Cache.remove(url);\n }\n };\n\n // remove the promise from the loader and the url from the cache when the texture is destroyed\n texture.source.once('destroy', () =>\n {\n if (loader.promiseCache[url])\n {\n // #if _DEBUG\n warn('[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! '\n + 'Use Assets.unload() instead of destroying the TextureSource.');\n // #endif\n\n unload();\n }\n });\n\n texture.once('destroy', () =>\n {\n if (!source.destroyed)\n {\n // #if _DEBUG\n warn('[Assets] A Texture managed by Assets was destroyed instead of unloaded! '\n + 'Use Assets.unload() instead of destroying the Texture.');\n // #endif\n\n unload();\n }\n });\n\n return texture;\n}\n"],"names":[],"mappings":";;;;;AAcgB,SAAA,aAAA,CAAc,MAAuB,EAAA,MAAA,EAAgB,GACrE,EAAA;AACI,EAAA,MAAA,CAAO,KAAQ,GAAA,GAAA,CAAA;AACf,EAAA,MAAA,CAAO,aAAgB,GAAA,GAAA,CAAA;AAEvB,EAAM,MAAA,OAAA,GAAU,IAAI,OAAQ,CAAA;AAAA,IACxB,MAAA;AAAA,IACA,KAAO,EAAA,GAAA;AAAA,GACV,CAAA,CAAA;AAED,EAAA,MAAM,SAAS,MACf;AACI,IAAO,OAAA,MAAA,CAAO,aAAa,GAAG,CAAA,CAAA;AAE9B,IAAI,IAAA,KAAA,CAAM,GAAI,CAAA,GAAG,CACjB,EAAA;AACI,MAAA,KAAA,CAAM,OAAO,GAAG,CAAA,CAAA;AAAA,KACpB;AAAA,GACJ,CAAA;AAGA,EAAQ,OAAA,CAAA,MAAA,CAAO,IAAK,CAAA,SAAA,EAAW,MAC/B;AACI,IAAI,IAAA,MAAA,CAAO,YAAa,CAAA,GAAG,CAC3B,EAAA;AAEI,MAAA,IAAA,CAAK,4IAC0D,CAAA,CAAA;AAG/D,MAAO,MAAA,EAAA,CAAA;AAAA,KACX;AAAA,GACH,CAAA,CAAA;AAED,EAAQ,OAAA,CAAA,IAAA,CAAK,WAAW,MACxB;AACI,IAAI,IAAA,CAAC,OAAO,SACZ,EAAA;AAEI,MAAA,IAAA,CAAK,gIACsD,CAAA,CAAA;AAG3D,MAAO,MAAA,EAAA,CAAA;AAAA,KACX;AAAA,GACH,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACX;;;;"}