mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 16:48:43 +08:00
[ts] 4.3 porting (a012479f, 92723279).
This commit is contained in:
parent
9272327990
commit
e280924dc5
@ -152,8 +152,7 @@ export class BonePose extends BoneLocal implements Update {
|
||||
}
|
||||
case Inherit.NoScale:
|
||||
case Inherit.NoScaleOrReflection: {
|
||||
rotation *= MathUtils.degRad;
|
||||
const cos = Math.cos(rotation), sin = Math.sin(rotation);
|
||||
let r = rotation * MathUtils.degRad, cos = Math.cos(r), sin = Math.sin(r);
|
||||
let za = (pa * cos + pb * sin) / skeleton.scaleX;
|
||||
let zc = (pc * cos + pd * sin) / skeleton.scaleY;
|
||||
let s = Math.sqrt(za * za + zc * zc);
|
||||
@ -162,15 +161,15 @@ export class BonePose extends BoneLocal implements Update {
|
||||
zc *= s;
|
||||
s = Math.sqrt(za * za + zc * zc);
|
||||
if (this.inherit == Inherit.NoScale && (pa * pd - pb * pc < 0) != (skeleton.scaleX < 0 != skeleton.scaleY < 0)) s = -s;
|
||||
this.rotation = Math.PI / 2 + Math.atan2(zc, za);
|
||||
const zb = Math.cos(this.rotation) * s;
|
||||
const zd = Math.sin(this.rotation) * s;
|
||||
this.shearX *= MathUtils.degRad;
|
||||
this.shearY = (90 + shearY) * MathUtils.degRad;
|
||||
const la = Math.cos(this.shearX) * scaleX;
|
||||
const lb = Math.cos(this.shearY) * scaleY;
|
||||
const lc = Math.sin(this.shearX) * scaleX;
|
||||
const ld = Math.sin(this.shearY) * scaleY;
|
||||
r = Math.PI / 2 + Math.atan2(zc, za);
|
||||
const zb = Math.cos(r) * s;
|
||||
const zd = Math.sin(r) * s;
|
||||
const rx = MathUtils.degRad;
|
||||
const ry = (90 + shearY) * MathUtils.degRad;
|
||||
const la = Math.cos(rx) * scaleX;
|
||||
const lb = Math.cos(ry) * scaleY;
|
||||
const lc = Math.sin(rx) * scaleX;
|
||||
const ld = Math.sin(ry) * scaleY;
|
||||
this.a = za * la + zb * lc;
|
||||
this.b = za * lb + zb * ld;
|
||||
this.c = zc * la + zd * lc;
|
||||
|
||||
@ -87,19 +87,6 @@ export class RegionAttachment extends Attachment implements HasTextureRegion {
|
||||
if (!this.region) throw new Error("Region not set.");
|
||||
let region = this.region;
|
||||
let uvs = this.uvs;
|
||||
|
||||
if (region == null) {
|
||||
uvs[0] = 0;
|
||||
uvs[1] = 0;
|
||||
uvs[2] = 0;
|
||||
uvs[3] = 1;
|
||||
uvs[4] = 1;
|
||||
uvs[5] = 1;
|
||||
uvs[6] = 1;
|
||||
uvs[7] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
let regionScaleX = this.width / this.region.originalWidth * this.scaleX;
|
||||
let regionScaleY = this.height / this.region.originalHeight * this.scaleY;
|
||||
let localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX;
|
||||
@ -128,7 +115,16 @@ export class RegionAttachment extends Attachment implements HasTextureRegion {
|
||||
offset[6] = localX2Cos - localYSin;
|
||||
offset[7] = localYCos + localX2Sin;
|
||||
|
||||
if (region.degrees == 90) {
|
||||
if (region == null) {
|
||||
uvs[0] = 0;
|
||||
uvs[1] = 0;
|
||||
uvs[2] = 0;
|
||||
uvs[3] = 1;
|
||||
uvs[4] = 1;
|
||||
uvs[5] = 1;
|
||||
uvs[6] = 1;
|
||||
uvs[7] = 0;
|
||||
} else if (region.degrees == 90) {
|
||||
uvs[0] = region.u2;
|
||||
uvs[1] = region.v2;
|
||||
uvs[2] = region.u;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user