Skip to content

Commit 64b3e83

Browse files
committed
Testing rotation fix
1 parent ff809f8 commit 64b3e83

4 files changed

Lines changed: 35 additions & 7 deletions

File tree

plugins/spine/dist/SpinePlugin.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7628,6 +7628,11 @@ var CONST = __webpack_require__(/*! ../const */ "../../../src/math/const.js");
76287628
*/
76297629
var CounterClockwise = function (angle)
76307630
{
7631+
if (angle > Math.PI)
7632+
{
7633+
angle -= CONST.PI2;
7634+
}
7635+
76317636
return Math.abs((((angle + CONST.TAU) % CONST.PI2) - CONST.PI2) % CONST.PI2);
76327637
};
76337638

@@ -11061,7 +11066,8 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
1106111066
var calcMatrix = renderer._tempMatrix3;
1106211067

1106311068
// - 90 degrees to account for the difference in Spine vs. Phaser rotation
11064-
spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY);
11069+
// spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY);
11070+
spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
1106511071

1106611072
camMatrix.copyFrom(camera.matrix);
1106711073

@@ -11103,15 +11109,23 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
1110311109
skeleton.scaleY = calcMatrix.scaleY;
1110411110
}
1110511111

11106-
src.root.rotation = RadToDeg(CounterClockwise(calcMatrix.rotation));
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);
1110711121

1110811122
sceneRenderer.camera.position.x = viewportWidth / 2;
1110911123
sceneRenderer.camera.position.y = viewportHeight / 2;
1111011124

1111111125
sceneRenderer.camera.viewportWidth = viewportWidth;
1111211126
sceneRenderer.camera.viewportHeight = viewportHeight;
1111311127

11114-
sceneRenderer.camera.update();
11128+
// sceneRenderer.camera.update();
1111511129

1111611130
// Add autoUpdate option
1111711131
skeleton.updateWorldTransform();

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.

plugins/spine/src/gameobject/SpineGameObjectWebGLRenderer.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
4343
var calcMatrix = renderer._tempMatrix3;
4444

4545
// - 90 degrees to account for the difference in Spine vs. Phaser rotation
46-
spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY);
46+
// spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY);
47+
spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
4748

4849
camMatrix.copyFrom(camera.matrix);
4950

@@ -85,15 +86,23 @@ var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercent
8586
skeleton.scaleY = calcMatrix.scaleY;
8687
}
8788

88-
src.root.rotation = RadToDeg(CounterClockwise(calcMatrix.rotation));
89+
// src.root.rotation = RadToDeg(calcMatrix.rotation);
90+
91+
// - 90 degrees to account for the difference in Spine vs. Phaser rotation
92+
93+
// Correct method via angle:
94+
// spineBoy.root.rotation = RadToDeg(CounterClockwise(DegToRad(arrow.angle))) + 90;
95+
96+
// src.root.rotation = RadToDeg(CounterClockwise(calcMatrix.rotation)) + 90;
97+
// src.root.rotation = RadToDeg(calcMatrix.rotation);
8998

9099
sceneRenderer.camera.position.x = viewportWidth / 2;
91100
sceneRenderer.camera.position.y = viewportHeight / 2;
92101

93102
sceneRenderer.camera.viewportWidth = viewportWidth;
94103
sceneRenderer.camera.viewportHeight = viewportHeight;
95104

96-
sceneRenderer.camera.update();
105+
// sceneRenderer.camera.update();
97106

98107
// Add autoUpdate option
99108
skeleton.updateWorldTransform();

src/math/angle/CounterClockwise.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ var CONST = require('../const');
2828
*/
2929
var CounterClockwise = function (angle)
3030
{
31+
if (angle > Math.PI)
32+
{
33+
angle -= CONST.PI2;
34+
}
35+
3136
return Math.abs((((angle + CONST.TAU) % CONST.PI2) - CONST.PI2) % CONST.PI2);
3237
};
3338

0 commit comments

Comments
 (0)