spine
spine copied to clipboard
【BUG REPORT】load spine
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
That's obvious error. make a PR, change "substr" on "substring" , someone will merge it, rebuild pixi-spine and publish new version
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
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.
Actually,
Uncaught TypeError: Cannot read properties of undefined (reading 'substr')
means that there's noversion
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
pixi-spine can't recognize pixi-version @ivanpopelyshev
Please debug this thing. Place a breakpoint there and look whether there's "version" field in json you load.
hi,I submitted pr
作者解决了这个问题吗
Do we have any solution for this, im getting this error now, trying to use it in angular 13
@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 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!
Which version of spine is it?
@ivanpopelyshev SPINE PRO 4.1.08
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 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
Thank you! Versoin: "spine": "4.0-from-4.1.09" . That's interesting
@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
Nevermind it was code related issue, but still have to manually add that version field on each export...
What was the issue?? @kerimdragolj I'm running into the same thing, but I see another error with bones after adding version.

my guess here is the loader is not implemented correctly.. will try fixing that..
solved with the loader used this as an example: https://codesandbox.io/s/pixi-spine-30-test-0iopd?file=/src/index.ts
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
@badlogic Whats up with version in binary files?
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.
@Tousen give us the files please and the version. @badlogic is Spine dev
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
@ivanpopelyshev pls review/comment/fixUsingOwnWay https://github.com/pixijs/spine/pull/468 , thanks)
Is there any progress on this issue? 😭
Is there any progress on this issue? 😭
I thought that one was fixed? Can you modify spine.js file directly for your project?