From b4bd92d62c4abb244f1773c588588dc26a522a23 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sun, 31 May 2026 22:03:26 -0700 Subject: [PATCH] fix(webgl): use stable numeric sort for merging texture pages The merging-pages index sort used (a, b) => a > b ? 1 : -1, which returns -1 when a === b and violates the comparator contract. Use (a, b) => a - b for ascending numeric order. Co-authored-by: Cursor --- addons/addon-webgl/src/TextureAtlas.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/addon-webgl/src/TextureAtlas.ts b/addons/addon-webgl/src/TextureAtlas.ts index dab0b1c85..0180fd781 100644 --- a/addons/addon-webgl/src/TextureAtlas.ts +++ b/addons/addon-webgl/src/TextureAtlas.ts @@ -191,7 +191,7 @@ export class TextureAtlas implements ITextureAtlas { return newPage; } - const sortedMergingPagesIndexes = mergingPages.map(e => e.glyphs[0].texturePage).sort((a, b) => a > b ? 1 : -1); + const sortedMergingPagesIndexes = mergingPages.map(e => e.glyphs[0].texturePage).sort((a, b) => a - b); const mergedPageIndex = this.pages.length - mergingPages.length; // Merge into the new page