Playcanvas 1.46.1 playcanvas-spine console error

We have confirmed the operation with playcanvas 1.45.3.
The following error has been issued since 1.46.
playcanvas-spine is using the latest.


[playcanvas-spine.3.6.min.js?id=54325666&branchId=d8c77f21-8760-47bc-a2a5-5e1cc58576b7:32]: Cannot read property ‘width’ of undefined

TypeError: Cannot read property ‘width’ of undefined
at new a (https://launch.playcanvas.com/api/assets/files/_/Spine/playcanvas-spine.3.6.min.js?id=54325666&branchId=d8c77f21-8760-47bc-a2a5-5e1cc58576b7:32:17)

1 Like

I’m not seeing this issue with my Spine test project and the latest build of playcanvas-spine: https://playcanvas.com/editor/scene/1128115

I have a same issue when spine atlas textures compressed by BASIS.

In playcanvas-spine.3.6.js

line 7347
textureData[path] = asset.resource;
From PlayCanvas Engine v1.46.1,
asset.resource is mapped into textureData as path like “xxx.basis”.

However
line 5200
page.texture = textureLoader(line);
line from .atlas file is “xxx.png

line 6726
return new SpineTextureWrapper(textureData[path]);
textureLoader get different path name, so textureData[path] is undefined.

line 6675
width: texture.width,
cause

TypeError: Cannot read property ‘width’ of undefined

I’m temporarily writing the code as follows.
This is probably the wrong way to fix it.

var atlas = new spine.TextureAtlas(atlasData, function (path) {
    if(!textureData[path]) {
        path = path.replace('.png', '.basis');
    }
    return new SpineTextureWrapper(textureData[path]);
});

Thanks for that, reproduced with Basis compression: PlayCanvas 3D HTML5 Game Engine

Looks like the issue originates from here.

In this PR we changed the workings of the asset file object to point to the selected variant. Now spine is picking up variant filename here instead of the original texture filename (.png).

I can see that asset.name is the original .png filename so the spine code could use that instead of asset.file.filename like so:

var path = asset.name ? asset.name : (asset.file ? asset.file.filename : null);
3 Likes

In a PR now including the build files if you need the fix now: Fixed issue with Basis compressed sprite sheets by yaustar · Pull Request #51 · playcanvas/playcanvas-spine · G

2 Likes

It works now. Thank you!

Thank you very much. It was helpful.