Skip to content

Commit 9ac8622

Browse files
committed
New plugin build
1 parent bb94238 commit 9ac8622

2 files changed

Lines changed: 39 additions & 19 deletions

File tree

plugins/spine/dist/SpinePlugin.js

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,8 +3135,9 @@ var Transform = {
31353135

31363136
/**
31373137
* The angle of this Game Object as expressed in degrees.
3138-
*
3139-
* Where 0 is to the right, 90 is down, 180 is left.
3138+
*
3139+
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
3140+
* and -90 is up.
31403141
*
31413142
* If you prefer to work in radians, see the `rotation` property instead.
31423143
*
@@ -3161,6 +3162,9 @@ var Transform = {
31613162

31623163
/**
31633164
* The angle of this Game Object in radians.
3165+
*
3166+
* Phaser uses a right-hand clockwise rotation system, where 0 is right, 90 is down, 180/-180 is left
3167+
* and -90 is up.
31643168
*
31653169
* If you prefer to work in degrees, see the `angle` property instead.
31663170
*
@@ -3713,9 +3717,10 @@ var TransformMatrix = new Class({
37133717
},
37143718

37153719
/**
3716-
* The rotation of the Matrix.
3720+
* The rotation of the Matrix, normalized to be within the Phaser right-handed
3721+
* clockwise rotation space. Value is in radians.
37173722
*
3718-
* @name Phaser.GameObjects.Components.TransformMatrix#rotation
3723+
* @name Phaser.GameObjects.Components.TransformMatrix#rotationNormalized
37193724
* @type {number}
37203725
* @readonly
37213726
* @since 3.4.0
@@ -3724,7 +3729,33 @@ var TransformMatrix = new Class({
37243729

37253730
get: function ()
37263731
{
3727-
return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1);
3732+
// Previous version:
3733+
// return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1);
3734+
3735+
// Normalized version:
3736+
var matrix = this.matrix;
3737+
3738+
var a = matrix[0];
3739+
var b = matrix[1];
3740+
var c = matrix[2];
3741+
var d = matrix[3];
3742+
3743+
if (a || b)
3744+
{
3745+
var r = Math.sqrt(a * a + b * b);
3746+
3747+
return (b > 0) ? Math.acos(a / r) : -Math.acos(a / r);
3748+
}
3749+
else if (c || d)
3750+
{
3751+
var s = Math.sqrt(c * c + d * d);
3752+
3753+
return Math.PI * 0.5 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));
3754+
}
3755+
else
3756+
{
3757+
return 0;
3758+
}
37283759
}
37293760

37303761
},
@@ -11065,8 +11096,6 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
1106511096
var spriteMatrix = renderer._tempMatrix2;
1106611097
var calcMatrix = renderer._tempMatrix3;
1106711098

11068-
// - 90 degrees to account for the difference in Spine vs. Phaser rotation
11069-
// spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY);
1107011099
spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
1107111100

1107211101
camMatrix.copyFrom(camera.matrix);
@@ -11109,24 +11138,15 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
1110911138
skeleton.scaleY = calcMatrix.scaleY;
1111011139
}
1111111140

11112-
// src.root.rotation = RadToDeg(calcMatrix.rotation);
11113-
11114-
// - 90 degrees to account for the difference in Spine vs. Phaser rotation
11115-
11116-
// Correct method via angle:
11117-
// spineBoy.root.rotation = RadToDeg(CounterClockwise(DegToRad(arrow.angle))) + 90;
11118-
11119-
// src.root.rotation = RadToDeg(CounterClockwise(calcMatrix.rotation)) + 90;
11120-
// src.root.rotation = RadToDeg(calcMatrix.rotation);
11141+
// +90 degrees to account for the difference in Spine vs. Phaser rotation
11142+
src.root.rotation = RadToDeg(CounterClockwise(calcMatrix.rotation)) + 90;
1112111143

1112211144
sceneRenderer.camera.position.x = viewportWidth / 2;
1112311145
sceneRenderer.camera.position.y = viewportHeight / 2;
1112411146

1112511147
sceneRenderer.camera.viewportWidth = viewportWidth;
1112611148
sceneRenderer.camera.viewportHeight = viewportHeight;
1112711149

11128-
// sceneRenderer.camera.update();
11129-
1113011150
// Add autoUpdate option
1113111151
skeleton.updateWorldTransform();
1113211152

plugins/spine/dist/SpinePlugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)