From 905f4c6ece939ec0b262c4a9040a0e9fe0f58de3 Mon Sep 17 00:00:00 2001 From: Jimb Esser Date: Mon, 30 Jan 2023 03:51:47 -0800 Subject: [PATCH] [ts] Use existing, explicit atlas data instead of relying on an image's current width/height (#2085) This fixes a bug where UVs would sometimes be wrong if an image's size is not the same as when originally exported. This could happen in the wild to _any_ project, due to mobile ISPs/browsers that proxy requests and resize images before sending them to clients. Fixing this also allows `spine-core` to work with engines that: * use embedded, low-res textures while waiting for high res textures to load * automatically provide lower resolution textures to low-end devices or low-resolution displays --- spine-ts/spine-core/src/attachments/MeshAttachment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spine-ts/spine-core/src/attachments/MeshAttachment.ts b/spine-ts/spine-core/src/attachments/MeshAttachment.ts index e5b84e4c3..6a3b95247 100644 --- a/spine-ts/spine-core/src/attachments/MeshAttachment.ts +++ b/spine-ts/spine-core/src/attachments/MeshAttachment.ts @@ -93,8 +93,8 @@ export class MeshAttachment extends VertexAttachment implements HasTextureRegion let n = this.uvs.length; let u = this.region.u, v = this.region.v, width = 0, height = 0; if (this.region instanceof TextureAtlasRegion) { - let region = this.region, image = region.page!.texture!.getImage(); - let textureWidth = image.width, textureHeight = image.height; + let region = this.region, page = region.page; + let textureWidth = page.width, textureHeight = page.height; switch (region.degrees) { case 90: u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;