diff --git a/src/Spine.ts b/src/Spine.ts index 9feff05c..56e17258 100644 --- a/src/Spine.ts +++ b/src/Spine.ts @@ -202,6 +202,11 @@ namespace pixi_spine { this.state.update(dt); this.state.apply(this.skeleton); + + //check we haven't been destroyed via a spine event callback in state update + if(!this.skeleton) + return; + this.skeleton.updateWorldTransform(); let slots = this.skeleton.slots; diff --git a/src/core/Bone.ts b/src/core/Bone.ts index 03b56a08..5a5fe052 100644 --- a/src/core/Bone.ts +++ b/src/core/Bone.ts @@ -100,9 +100,13 @@ namespace pixi_spine.core { let m = this.matrix; let sx = this.skeleton.scaleX; - let sy = this.skeleton.scaleY; + let sy = Bone.yDown? -this.skeleton.scaleY : this.skeleton.scaleY; if (parent == null) { // Root bone. + if(Bone.yDown){ + rotation = -rotation; + this.arotation = rotation; + } let skeleton = this.skeleton; let rotationY = rotation + 90 + shearY; m.a = MathUtils.cosDeg(rotation + shearX) * scaleX * sx; @@ -111,11 +115,6 @@ namespace pixi_spine.core { m.d = MathUtils.sinDeg(rotationY) * scaleY * sy; m.tx = x * sx + skeleton.x; m.ty = y * sy + skeleton.y; - - if (Bone.yDown) { - m.b = -m.b; - m.d = -m.d; - } return; } @@ -179,6 +178,12 @@ namespace pixi_spine.core { za *= s; zc *= s; s = Math.sqrt(za * za + zc * zc); + if ( + this.data.transformMode == TransformMode.NoScale + && (pa * pd - pb * pc < 0) != (Bone.yDown? + (this.skeleton.scaleX < 0 != this.skeleton.scaleY > 0) : + (this.skeleton.scaleX < 0 != this.skeleton.scaleY < 0)) + ) s = -s; let r = Math.PI / 2 + Math.atan2(zc, za); let zb = Math.cos(r) * s; let zd = Math.sin(r) * s; @@ -186,10 +191,6 @@ namespace pixi_spine.core { let lb = MathUtils.cosDeg(90 + shearY) * scaleY; let lc = MathUtils.sinDeg(shearX) * scaleX; let ld = MathUtils.sinDeg(90 + shearY) * scaleY; - if (this.data.transformMode != core.TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : ((this.skeleton.flipX != this.skeleton.flipY) != Bone.yDown)) { - zb = -zb; - zd = -zd; - } m.a = za * la + zb * lc; m.c = za * lb + zb * ld; m.b = zc * la + zd * lc; @@ -201,11 +202,6 @@ namespace pixi_spine.core { m.c *= sx; m.b *= sy; m.d *= sy; - - if (Bone.yDown) { - m.b = -m.b; - m.d = -m.d; - } } setToSetupPose() {