|
@@ -88,6 +88,20 @@ export class RegionAttachment extends Attachment implements HasTextureRegion {
|
|
|
updateRegion (): void {
|
|
|
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] = 1;
|
|
|
+ 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;
|
|
@@ -116,25 +130,24 @@ export class RegionAttachment extends Attachment implements HasTextureRegion {
|
|
|
offset[6] = localX2Cos - localYSin;
|
|
|
offset[7] = localYCos + localX2Sin;
|
|
|
|
|
|
- let uvs = this.uvs;
|
|
|
if (region.degrees == 90) {
|
|
|
- uvs[2] = region.u;
|
|
|
+ uvs[0] = region.u2;
|
|
|
+ uvs[1] = region.v;
|
|
|
+ uvs[2] = region.u2;
|
|
|
uvs[3] = region.v2;
|
|
|
uvs[4] = region.u;
|
|
|
- uvs[5] = region.v;
|
|
|
- uvs[6] = region.u2;
|
|
|
+ uvs[5] = region.v2;
|
|
|
+ uvs[6] = region.u;
|
|
|
uvs[7] = region.v;
|
|
|
- uvs[0] = region.u2;
|
|
|
- uvs[1] = region.v2;
|
|
|
} else {
|
|
|
- uvs[0] = region.u;
|
|
|
+ uvs[0] = region.u2;
|
|
|
uvs[1] = region.v2;
|
|
|
uvs[2] = region.u;
|
|
|
- uvs[3] = region.v;
|
|
|
- uvs[4] = region.u2;
|
|
|
+ uvs[3] = region.v2;
|
|
|
+ uvs[4] = region.u;
|
|
|
uvs[5] = region.v;
|
|
|
uvs[6] = region.u2;
|
|
|
- uvs[7] = region.v2;
|
|
|
+ uvs[7] = region.v;
|
|
|
}
|
|
|
}
|
|
|
|