spine icon indicating copy to clipboard operation
spine copied to clipboard

【BUG REPORT】load spine

Open yangliguo7 opened this issue 3 years ago • 33 comments

in my index.js,I use import * as PIXI from 'pixi.js'; import { Spine } from 'pixi-spine'; to load spine。

but the console show Uncaught TypeError: Cannot read properties of undefined (reading 'substr')。 I check the source @pixi-spine/load-uni/lib/loader-uni.es.js

the error code is that: function detectSpineVersion(version) { var ver3 = version.substr(0, 3); var verNum = Math.floor(+ver3 * 10 + 1e-3); if (ver3 === '3.7') { return SPINE_VERSION.VER37; } if (ver3 === '3.8') { return SPINE_VERSION.VER38; } if (ver3 === '4.0') { return SPINE_VERSION.VER40; } // try parse old versions with 3.7 if (verNum < SPINE_VERSION.VER37) { return SPINE_VERSION.VER37; } return SPINE_VERSION.UNKNOWN; }

This is my version "pixi-spine": "^3.0.13", "pixi.js": "^6.1.3"

This is the library I use https://github.com/YangLG-7/test_pixi.git

so,how can i load a spine?Thank you for your reply

yangliguo7 avatar Nov 08 '21 09:11 yangliguo7

That's obvious error. make a PR, change "substr" on "substring" , someone will merge it, rebuild pixi-spine and publish new version

ivanpopelyshev avatar Nov 08 '21 09:11 ivanpopelyshev

Alternatively: just make a polyfill on substr. This function existed before: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

ivanpopelyshev avatar Nov 08 '21 09:11 ivanpopelyshev

Actually, Uncaught TypeError: Cannot read properties of undefined (reading 'substr') means that there's no version field on your json file. Check what you are geting through the network.

ivanpopelyshev avatar Nov 08 '21 09:11 ivanpopelyshev

Actually, Uncaught TypeError: Cannot read properties of undefined (reading 'substr') means that there's no version field on your json file. Check what you are geting through the network.

I think this happens when the spine file is loaded. I installed the latest version

yangliguo7 avatar Nov 08 '21 09:11 yangliguo7

pixi-spine can't recognize pixi-version @ivanpopelyshev

yangliguo7 avatar Nov 08 '21 09:11 yangliguo7

Please debug this thing. Place a breakpoint there and look whether there's "version" field in json you load.

ivanpopelyshev avatar Nov 08 '21 10:11 ivanpopelyshev

hi,I submitted pr

yangliguo7 avatar Nov 08 '21 11:11 yangliguo7

作者解决了这个问题吗

edward677 avatar Apr 19 '22 13:04 edward677

Do we have any solution for this, im getting this error now, trying to use it in angular 13

image image image

kerimdragolj avatar Sep 16 '22 14:09 kerimdragolj

@kerimdragolj Its not the same issue. Please give me full reproduction. Most probably, you loaded wrong json file that doesnt have "version" field inside.

ivanpopelyshev avatar Sep 16 '22 14:09 ivanpopelyshev

@ivanpopelyshev yes you were correct, it was missing version, any idea why? i mean file was exported from Spine so it should be correct out of the box, containing all the needed data? After manually adding version i got rid of this error but stumbled on another one, but i guess i will just have to keep investigating these one by one... anyways thanks a lot for quick response, much appreciated!

kerimdragolj avatar Sep 16 '22 15:09 kerimdragolj

Which version of spine is it?

ivanpopelyshev avatar Sep 16 '22 15:09 ivanpopelyshev

@ivanpopelyshev SPINE PRO 4.1.08

kerimdragolj avatar Sep 16 '22 18:09 kerimdragolj

Can you please make issue at https://github.com/EsotericSoftware/spine-runtimes/issues ? With description how did you get that file, how problem was solved and link to this thread?

ivanpopelyshev avatar Sep 16 '22 18:09 ivanpopelyshev

@ivanpopelyshev can you please check if this exported json spine looks good to you, and if you can use it https://drive.google.com/file/d/1tKBNyPF2K_5nQXMr61DXdTRA-iQN8b3w/view?usp=sharing

kerimdragolj avatar Sep 19 '22 12:09 kerimdragolj

Thank you! Versoin: "spine": "4.0-from-4.1.09" . That's interesting

ivanpopelyshev avatar Sep 19 '22 14:09 ivanpopelyshev

@ivanpopelyshev Ahh sorry about that.. i was trying to get different output by changing version on export, but overall structure is the same either way, just that 'spine' field changes.. i've reuploaded 4.1.09, you can find it here

So I'm wondering is it working for you, can you load it in the pixi/spine or you receive same errors as i did

kerimdragolj avatar Sep 19 '22 14:09 kerimdragolj

Nevermind it was code related issue, but still have to manually add that version field on each export...

kerimdragolj avatar Sep 20 '22 19:09 kerimdragolj

What was the issue?? @kerimdragolj I'm running into the same thing, but I see another error with bones after adding version. Screen Shot 2022-10-09 at 8 35 16 PM

netherglaive avatar Oct 10 '22 00:10 netherglaive

Screen Shot 2022-10-09 at 8 52 13 PM to add more detail boneData.parent is a string and doesnt have a 'index' so parent_1 is undefined see here for uncompiled code: https://github.com/pixijs/spine/blob/master/packages/runtime-4.1/src/core/Skeleton.ts#L75

netherglaive avatar Oct 10 '22 00:10 netherglaive

my guess here is the loader is not implemented correctly.. will try fixing that..

netherglaive avatar Oct 10 '22 02:10 netherglaive

solved with the loader used this as an example: https://codesandbox.io/s/pixi-spine-30-test-0iopd?file=/src/index.ts

netherglaive avatar Oct 10 '22 04:10 netherglaive

parse runtime error Hi there! Have same problem when try to parse binary files: so some of files could return null during readString and after that runtime error it will not try to read it as 4.0 or 4.1 file, need to add some error handling for that case @ivanpopelyshev

Tousen avatar Oct 16 '22 13:10 Tousen

@badlogic Whats up with version in binary files?

ivanpopelyshev avatar Oct 16 '22 14:10 ivanpopelyshev

Nothing's up afaics https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/spine-ts/spine-core/src/SkeletonBinary.ts#L77

At a minimum, we need to know the exact Spine Editor versions the binary files have been exported from.

badlogic avatar Oct 16 '22 14:10 badlogic

@Tousen give us the files please and the version. @badlogic is Spine dev

ivanpopelyshev avatar Oct 16 '22 14:10 ivanpopelyshev

skeleton.zip so steps to reproduce is just to create emty project in spine(i used latest 4.1.14) and export as binary (you can use attached one) and it will throw error here if you'll try to load it https://github.com/pixijs/spine/blob/d625529c0edbbeaec7a9209ce299eff284f015d7/packages/loader-uni/src/SpineLoader.ts#L16 as version will be null

Tousen avatar Oct 16 '22 16:10 Tousen

@ivanpopelyshev pls review/comment/fixUsingOwnWay https://github.com/pixijs/spine/pull/468 , thanks)

Tousen avatar Oct 17 '22 12:10 Tousen

Is there any progress on this issue? 😭

StreakingMan avatar Nov 21 '23 15:11 StreakingMan

Is there any progress on this issue? 😭

I thought that one was fixed? Can you modify spine.js file directly for your project?

ivanpopelyshev avatar Nov 21 '23 15:11 ivanpopelyshev