mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[ts] 4.3 - Added yDir and applied to transform contraints where needed.
This commit is contained in:
parent
528223a2cf
commit
13e2231628
@ -49,6 +49,9 @@ import { Color, Utils, Vector2, NumberArrayLike } from "./Utils.js";
|
|||||||
export class Skeleton {
|
export class Skeleton {
|
||||||
private static quadTriangles = [0, 1, 2, 2, 3, 0];
|
private static quadTriangles = [0, 1, 2, 2, 3, 0];
|
||||||
static yDown = false;
|
static yDown = false;
|
||||||
|
static get yDir(): number {
|
||||||
|
return Skeleton.yDown ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
/** The skeleton's setup pose data. */
|
/** The skeleton's setup pose data. */
|
||||||
readonly data: SkeletonData;
|
readonly data: SkeletonData;
|
||||||
|
|||||||
@ -195,7 +195,7 @@ export class ToRotate extends ToProperty {
|
|||||||
bone.rotation += value * pose.mixRotate;
|
bone.rotation += value * pose.mixRotate;
|
||||||
} else {
|
} else {
|
||||||
const a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
const a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
||||||
value *= MathUtils.degRad;
|
value *= MathUtils.degRad * Skeleton.yDir;
|
||||||
if (!additive) value -= Math.atan2(c, a);
|
if (!additive) value -= Math.atan2(c, a);
|
||||||
if (value > MathUtils.PI)
|
if (value > MathUtils.PI)
|
||||||
value -= MathUtils.PI2;
|
value -= MathUtils.PI2;
|
||||||
@ -253,8 +253,8 @@ export class ToY extends ToProperty {
|
|||||||
if (!additive) value -= bone.y;
|
if (!additive) value -= bone.y;
|
||||||
bone.y += value * pose.mixY;
|
bone.y += value * pose.mixY;
|
||||||
} else {
|
} else {
|
||||||
if (!additive) value -= bone.worldY;
|
if (!additive) value -= Skeleton.yDir * bone.worldY;
|
||||||
bone.worldY += value * pose.mixY;
|
bone.worldY += Skeleton.yDir * value * pose.mixY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ export class ToScaleY extends ToProperty {
|
|||||||
if (additive)
|
if (additive)
|
||||||
s = 1 + (value - 1) * pose.mixScaleY;
|
s = 1 + (value - 1) * pose.mixScaleY;
|
||||||
else {
|
else {
|
||||||
s = Math.sqrt(bone.b * bone.b + bone.d * bone.d) / skeleton.scaleY;
|
s = Math.sqrt(bone.b * bone.b + bone.d * bone.d) / skeleton.scaleY * Skeleton.yDir;
|
||||||
if (s != 0) s = 1 + (value / s - 1) * pose.mixScaleY;
|
if (s != 0) s = 1 + (value / s - 1) * pose.mixScaleY;
|
||||||
}
|
}
|
||||||
bone.b *= s;
|
bone.b *= s;
|
||||||
@ -345,7 +345,7 @@ export class ToShearY extends ToProperty {
|
|||||||
bone.shearY += value * pose.mixShearY;
|
bone.shearY += value * pose.mixShearY;
|
||||||
} else {
|
} else {
|
||||||
const b = bone.b, d = bone.d, by = Math.atan2(d, b);
|
const b = bone.b, d = bone.d, by = Math.atan2(d, b);
|
||||||
value = (value + 90) * MathUtils.degRad;
|
value = (value + 90) * MathUtils.degRad * Skeleton.yDir;
|
||||||
if (additive)
|
if (additive)
|
||||||
value -= MathUtils.PI / 2;
|
value -= MathUtils.PI / 2;
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user