I have this function that sets random skin for object. it works on click on button (button is HTML element).
const setSkin = () => {
const skin = new Skin('custom')
skin.addSkin(skeletonData.findSkin('skin-base')!)
groupedSkins.forEach((skinGroup: any) => {
const skinName = skinGroup[getRandomInt(0, (skinGroup.length - 1))]
skin.addSkin(skeletonData.findSkin(skinName)!)
})
spineObject!.skeleton.setSkin(skin)
spineObject!.skeleton.setSlotsToSetupPose()
}
Everything works ok. The next thing i want to do is to add interactivity to spineObject itself, make it animate on click for example.
Here is what i do:
spineObject.eventMode = 'dynamic'
spineObject.on('pointerdown', () => {
spineObject.state.setAnimation(1, 'blink', false)
spineObject.state.setAnimation(2, 'aware', false)
spineObject.state.addEmptyAnimation(2, 0.2, 0)
})
And it works too. But when i click on the button that calls setSkin
i have an error in console:
Uncaught TypeError: Cannot read properties of undefined (reading 'batcher')
at SpinePipe.updateRenderable (@pixi_spine-pixi.js?t=1721202700303&v=cef1a748:11956:34)
at RenderGroup.updateRenderable (chunk-HF2HE6F3.js?v=cef1a748:3750:61)
at updateRenderables (chunk-3STGYXCO.js?v=cef1a748:996:19)
at RenderGroupSystem.render (chunk-3STGYXCO.js?v=cef1a748:960:9)
at SystemRunner.emit (chunk-3STGYXCO.js?v=cef1a748:187:21)
at WebGLRenderer.render (chunk-3STGYXCO.js?v=cef1a748:342:25)
at _Application2.render (chunk-VHV5RU3V.js?v=cef1a748:6017:19)
at TickerListener.emit (chunk-OWQFXLRL.js?v=cef1a748:233:18)
at _Ticker2.update (chunk-OWQFXLRL.js?v=cef1a748:492:29)
at _tick (chunk-OWQFXLRL.js?v=cef1a748:301:14)
It only happens when i add eventMode
to spineObject
. What am i doing wrong?
Runtime information
@pixi/spine-pixi: 2.0.2 (it's a port for Pixi v8 by Pixi team, it uses "@esotericsoftware/spine-core": "~4.2.45"
under the hood).
pixi.js: 8.2.5