This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

View File

@@ -0,0 +1,11 @@
import { Texture } from '../../../../../rendering/renderers/shared/texture/Texture';
import type { TextureSource } from '../../../../../rendering/renderers/shared/texture/sources/TextureSource';
import type { Loader } from '../../../Loader';
/**
* Creates a texture from a source and adds it to the cache.
* @param source - source of the texture
* @param loader - loader
* @param url - url of the texture
* @ignore
*/
export declare function createTexture(source: TextureSource, loader: Loader, url: string): Texture<TextureSource<any>>;

View File

@@ -0,0 +1,37 @@
'use strict';
var Texture = require('../../../../../rendering/renderers/shared/texture/Texture.js');
var warn = require('../../../../../utils/logging/warn.js');
var Cache = require('../../../../cache/Cache.js');
"use strict";
function createTexture(source, loader, url) {
source.label = url;
source._sourceOrigin = url;
const texture = new Texture.Texture({
source,
label: url
});
const unload = () => {
delete loader.promiseCache[url];
if (Cache.Cache.has(url)) {
Cache.Cache.remove(url);
}
};
texture.source.once("destroy", () => {
if (loader.promiseCache[url]) {
warn.warn("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource.");
unload();
}
});
texture.once("destroy", () => {
if (!source.destroyed) {
warn.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture.");
unload();
}
});
return texture;
}
exports.createTexture = createTexture;
//# sourceMappingURL=createTexture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createTexture.js","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":["Texture","Cache","warn"],"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,IAAIA,eAAQ,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,IAAAC,WAAA,CAAM,GAAI,CAAA,GAAG,CACjB,EAAA;AACI,MAAAA,WAAA,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,MAAAC,SAAA,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,MAAAA,SAAA,CAAK,gIACsD,CAAA,CAAA;AAG3D,MAAO,MAAA,EAAA,CAAA;AAAA,KACX;AAAA,GACH,CAAA,CAAA;AAED,EAAO,OAAA,OAAA,CAAA;AACX;;;;"}

View File

@@ -0,0 +1,35 @@
import { Texture } from '../../../../../rendering/renderers/shared/texture/Texture.mjs';
import { warn } from '../../../../../utils/logging/warn.mjs';
import { Cache } from '../../../../cache/Cache.mjs';
"use strict";
function createTexture(source, loader, url) {
source.label = url;
source._sourceOrigin = url;
const texture = new Texture({
source,
label: url
});
const unload = () => {
delete loader.promiseCache[url];
if (Cache.has(url)) {
Cache.remove(url);
}
};
texture.source.once("destroy", () => {
if (loader.promiseCache[url]) {
warn("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource.");
unload();
}
});
texture.once("destroy", () => {
if (!source.destroyed) {
warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture.");
unload();
}
});
return texture;
}
export { createTexture };
//# sourceMappingURL=createTexture.mjs.map

View File

@@ -0,0 +1 @@
{"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;;;;"}