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

Cannot read properties of undefined (reading 'substr') detectSpineVersion #559

Open
ramkrishnakuldeep opened this issue Jul 17, 2024 · 2 comments

Comments

@ramkrishnakuldeep
Copy link

I have created a custom component for Spine

Initializing a component

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

class CustomSpine extends Container {
	constructor(spineAsset, setting) {
		super();
		this.name = 'Container';
		Assets.load(spineAsset).then((resource) => {
			console.log(resource);
			const spine = new Spine(resource);
			spine.skeleton.setSkinByName('default');
			spine.skeleton.setSlotsToSetupPose();
			spine.visible = true;
			spine.position = { x: 0, y: 0 };
			spine.alpha = 0.6;
			spine.scale.set(1);
			spine.state.setAnimation(0, 'ani', false);
			spine.interactive = true;
			this.addChild(spine);
		});
	}
}

export default CustomSpine;

Registering the component

renderer.use({
	name: 'CustomSpine',
	createElement: (props) => new CustomSpine(props.spineAsset, props.setting),
	// nextSibling
	// insert
	// setElementText
	// setText
	// parentNode
});

adding the compoent to canvas
<custom-spine v-if="player?.emoji" :spineAsset="getEmojiAsset(player.emoji)" ></custom-spine>

But i am getting Spine error

pixi-spine.js?v=aff288ae:21985 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'substr')
    at detectSpineVersion (pixi-spine.js?v=aff288ae:21985:24)
    at Spine4.createSkeleton (pixi-spine.js?v=aff288ae:22097:17)
    at new _SpineBase (pixi-spine.js?v=aff288ae:1184:10)
    at new Spine4 (pixi-spine.js?v=aff288ae:22095:14)
    at CustomSpine.ts:11:18

my version

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

Could you please guide me through this issue

Attached is the Skeleton file (.json)

spine_selfEmoji-s1e0.json

@Megabyteceer
Copy link

Megabyteceer commented Dec 6, 2024

The same issue. Spine file loaded as plain JSON. No parser applied in ts es modules mode (VITE.js)

@Megabyteceer
Copy link

I solved the problem for my case. PIXI import was duplicated because of wrong vite.js config. So 'pixi-spine' injected it`s parsers in different PIXI instance.
I have removed resolve.alias['pixi-js'] entry from vite.json and problem has gone.

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

2 participants