From 8191d581994d04e2d4579677d8b2bc9a3d9f0ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pasteau?= <4895034+ClementPasteau@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:36:51 +0100 Subject: [PATCH] TODO: fix asset not loading --- Extensions/Spine/JsExtension.js | 1 + .../Spine/managers/pixi-spine-atlas-manager.ts | 2 ++ .../src/ObjectsRendering/PixiResourcesLoader.js | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/Extensions/Spine/JsExtension.js b/Extensions/Spine/JsExtension.js index 94f107a0d757..bbded11ec05d 100644 --- a/Extensions/Spine/JsExtension.js +++ b/Extensions/Spine/JsExtension.js @@ -323,6 +323,7 @@ module.exports = { this._pixiResourcesLoader .getSpineData(this._project, this._spineResourceName) .then((spineDataOrLoadingError) => { + console.log(spineDataOrLoadingError); if (this._wasDestroyed) return; if (this._spine) this._pixiObject.removeChild(this._spine); diff --git a/Extensions/Spine/managers/pixi-spine-atlas-manager.ts b/Extensions/Spine/managers/pixi-spine-atlas-manager.ts index 379346b5c804..6f54de8e0197 100644 --- a/Extensions/Spine/managers/pixi-spine-atlas-manager.ts +++ b/Extensions/Spine/managers/pixi-spine-atlas-manager.ts @@ -147,8 +147,10 @@ namespace gdjs { : 'anonymous', }); PIXI.Assets.add(resource.name, url, { images }); + console.log('Loading spine atlas:', resource.name, url, images); PIXI.Assets.load(resource.name).then( (atlas) => { + console.log('Loaded spine atlas:', resource.name, atlas); /** * Ideally atlas of TextureAtlas should be passed here * but there is known issue in case of preloaded images (see https://github.com/pixijs/spine/issues/537) diff --git a/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js b/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js index 4fcee216748e..3663b95bc1da 100644 --- a/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js +++ b/newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js @@ -622,6 +622,8 @@ export default class PixiResourcesLoader { const promise = spineAtlasPromises[spineTextureAtlasName]; if (promise) return promise; + console.log('in _getSpineTextureAtlas', spineTextureAtlasName); + if (!spineTextureAtlasName) { return { textureAtlas: null, @@ -679,6 +681,7 @@ export default class PixiResourcesLoader { ); return (spineAtlasPromises[spineTextureAtlasName] = new Promise(resolve => { + console.log('in _getSpineTextureAtlas promise', spineTextureAtlasName); const atlasUrl = ResourcesLoader.getResourceFullUrl( project, spineTextureAtlasName, @@ -686,6 +689,7 @@ export default class PixiResourcesLoader { isResourceForPixi: true, } ); + console.log(atlasUrl); PIXI.Assets.setPreferences({ preferWorkers: false, crossOrigin: checkIfCredentialsRequired(atlasUrl) @@ -693,8 +697,17 @@ export default class PixiResourcesLoader { : 'anonymous', }); PIXI.Assets.add(spineTextureAtlasName, atlasUrl, { images }); + console.log( + 'added', + spineTextureAtlasName, + resource, + embeddedResourcesMapping + ); PIXI.Assets.load(spineTextureAtlasName).then( atlas => { + // TODO: FIX. + // atlas returned here is null for some reason even if the resource exists. + console.log('loaded atlas', atlas); // Ideally atlas of type `TextureAtlas` should be passed here. // But there is a known issue in case of preloaded images (see https://github.com/pixijs/spine/issues/537 // and search the other mentions to this issue in the codebase). @@ -787,6 +800,8 @@ export default class PixiResourcesLoader { }; } + console.log(spineName); + return (spineDataPromises[spineName] = new Promise(resolve => { this._getSpineTextureAtlas(project, spineTextureAtlasName).then( textureAtlasOrLoadingError => { @@ -798,6 +813,8 @@ export default class PixiResourcesLoader { }); } + console.log(textureAtlasOrLoadingError); + const spineUrl = ResourcesLoader.getResourceFullUrl( project, spineName,