Skip to content

SpinePlugin breaks generated images file path #6642

@rez23

Description

@rez23

Version

  • Phaser Version: nodejs [email protected]
  • Npm Version: '8.19.3',
  • NodeJs Version: '19.2.0',
  • TypeScript version: 5.2.2
  • Operating system: Windows
  • Browser: Chrome/Edge/Nodejs

The reference environment where I have encountered this issue is based on typescript and use nodejs versione of phaser 3

Description

The issue affects the phaser path system. when you set baseUrl and path properties of the loader via setBaseUrl() and setPath() functions and try to load spine's atlases/Jsons using phaser's Spine plugin (inside this repository).

When the loader tries to load the images obtained from the parsing of the atlases/jsons files provided to the loader through spine() function, the loader appends twice baseUrl to path and the result is an error in the GET stage when the loader tries to charge the Spine's multilayered images.

Example Test Code

You can reproduce (i suppose) the error with a code like:

#inside game scene
this.load.setBaseUrl('assets');

this.load
        .setPath('spine')
        .spine('MAIN.animations', 'spine.json', 'spine.atlas');

Supposing that inside my spine files I have linked a spine.png, this statement will result in the trying of the loader to load this image from "assets/assets/spine/spine.png" instead of "assets/spine/spine.png" that is what should happen.

Additional Information

I have circumscribed (and potentially fixed) this issue to this piece of code inside the onFileComplete() function present inside SpineFile,js in the spine plugin source code:

// This start at line 159 of SpineFile,js
var config = this.config;
var loader = this.loader;

var currentBaseURL = loader.baseURL;
var currentPath = loader.path;
var currentPrefix = loader.prefix;

var baseURL = GetFastValue(config, 'baseURL', this.baseURL);
var path = GetFastValue(config, 'path', file.src.match(/^.*\//))[0]; //Here is the problem
var prefix = GetFastValue(config, 'prefix', this.prefix);
var textureXhrSettings = GetFastValue(config, 'textureXhrSettings');

loader.setBaseURL(baseURL);
loader.setPath(path);
loader.setPrefix(prefix);

I've a possible solution on this fork

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 SpineAn issue arising from the Spine runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions