Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【BUG REPORT】load spine #415

Open
yangliguo7 opened this issue Nov 8, 2021 · 33 comments
Open

【BUG REPORT】load spine #415

yangliguo7 opened this issue Nov 8, 2021 · 33 comments

Comments

@yangliguo7
Copy link

yangliguo7 commented Nov 8, 2021

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

@ivanpopelyshev
Copy link
Collaborator

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

@ivanpopelyshev
Copy link
Collaborator

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
Copy link
Collaborator

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.

@yangliguo7
Copy link
Author

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
Copy link
Author

yangliguo7 commented Nov 8, 2021

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

@ivanpopelyshev
Copy link
Collaborator

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

@yangliguo7
Copy link
Author

hi,I submitted pr

@edward677
Copy link

作者解决了这个问题吗

@kerimdragolj
Copy link

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

image
image
image

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Sep 16, 2022

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

@kerimdragolj
Copy link

@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!

@ivanpopelyshev
Copy link
Collaborator

Which version of spine is it?

@kerimdragolj
Copy link

@ivanpopelyshev SPINE PRO 4.1.08

@ivanpopelyshev
Copy link
Collaborator

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?

@kerimdragolj
Copy link

@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

@ivanpopelyshev
Copy link
Collaborator

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

@kerimdragolj
Copy link

kerimdragolj commented Sep 19, 2022

@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
Copy link

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

@netherglaive
Copy link

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
Copy link

netherglaive commented Oct 10, 2022

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
Copy link

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

@netherglaive
Copy link

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

@Tousen
Copy link

Tousen commented Oct 16, 2022

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

@ivanpopelyshev
Copy link
Collaborator

@badlogic Whats up with version in binary files?

@badlogic
Copy link

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.

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Oct 16, 2022

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

@Tousen
Copy link

Tousen commented Oct 16, 2022

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 pushed a commit to Tousen/spine that referenced this issue Oct 17, 2022
@Tousen
Copy link

Tousen commented Oct 17, 2022

@ivanpopelyshev pls review/comment/fixUsingOwnWay #468 , thanks)

ivanpopelyshev added a commit that referenced this issue Jan 8, 2023
fix version detection of binary spine file #415
@StreakingMan
Copy link

Is there any progress on this issue? 😭

@ivanpopelyshev
Copy link
Collaborator

Is there any progress on this issue? 😭

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

@StreakingMan
Copy link

StreakingMan commented Nov 21, 2023

Is there any progress on this issue? 😭

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

here's my package versions:

        "pixi-spine": "^4.0.4",
        "pixi.js": "^7.2.4",

still got error Uncaught TypeError: Cannot read properties of undefined (reading 'substr'), and I manualy add version field in spine json file it got this same error:

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

It seems SpinePhaser still not work...

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

some other information

my code:

import 'pixi-spine';
import { Application, Assets } from 'pixi.js';
import { Spine } from 'pixi-spine';

const app: any = new Application();
document.body.appendChild(app.view);

Assets.load('/assets/mix-and-match-pro-json/mix-and-match-pro.json').then(
    (resource) => {
        console.log(resource);
        const animation = new Spine(resource);
        app.stage.addChild(animation);

        // add the animation to the scene and render...
        app.stage.addChild(animation);

        if (animation.state.hasAnimation('run')) {
            // run forever, little boy!
            animation.state.setAnimation(0, 'run', true);
            // dont run too fast
            animation.state.timeScale = 0.1;
            // update yourself
            animation.autoUpdate = true;
        }
    }
);

mix-and-match-pro.json using spine 4.1
mix-and-match-pro.json

@Tousen
Copy link

Tousen commented Nov 21, 2023

Is there any progress on this issue? 😭

the described issue was for binary files and it was fixed since 3.1.2, I think it is better to create a new one for this case with your details

@StreakingMan
Copy link

After upgrading Pixi.js to 7.3.2, everything works fine. Just ignore me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants