Skip to content

Commit

Permalink
TODO: fix asset not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau authored and D8H committed Feb 7, 2025
1 parent 41ccb3a commit 8191d58
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Extensions/Spine/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions Extensions/Spine/managers/pixi-spine-atlas-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<pixi_spine.TextureAtlas | string>(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)
Expand Down
17 changes: 17 additions & 0 deletions newIDE/app/src/ObjectsRendering/PixiResourcesLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -679,22 +681,33 @@ export default class PixiResourcesLoader {
);

return (spineAtlasPromises[spineTextureAtlasName] = new Promise(resolve => {
console.log('in _getSpineTextureAtlas promise', spineTextureAtlasName);
const atlasUrl = ResourcesLoader.getResourceFullUrl(
project,
spineTextureAtlasName,
{
isResourceForPixi: true,
}
);
console.log(atlasUrl);
PIXI.Assets.setPreferences({
preferWorkers: false,
crossOrigin: checkIfCredentialsRequired(atlasUrl)
? 'use-credentials'
: '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).
Expand Down Expand Up @@ -787,6 +800,8 @@ export default class PixiResourcesLoader {
};
}

console.log(spineName);

return (spineDataPromises[spineName] = new Promise(resolve => {
this._getSpineTextureAtlas(project, spineTextureAtlasName).then(
textureAtlasOrLoadingError => {
Expand All @@ -798,6 +813,8 @@ export default class PixiResourcesLoader {
});
}

console.log(textureAtlasOrLoadingError);

const spineUrl = ResourcesLoader.getResourceFullUrl(
project,
spineName,
Expand Down

0 comments on commit 8191d58

Please sign in to comment.