Description
The texture atlas currently maintains a workaround where regions are cached under coordinate-string keys ("x,y,w,h") in addUVs() so the Batcher can look them up by source coordinates. Additionally, getUVs() has a fallback that parses unknown region names as "x,y,w,h" strings and creates ad-hoc regions on the fly.
This is fragile and adds unnecessary complexity. The Batcher should work directly with region/frame objects that already carry their pre-computed UV float arrays, rather than performing string-based lookups.
Current behavior
addUVs() creates a duplicate atlas entry keyed by "x,y,w,h" coordinates (atlas.js:401-402)
getUVs() falls back to parsing the region name as "x,y,w,h" when no named region is found (atlas.js:370-372)
addRegion() allows creating arbitrary regions on the fly (atlas.js:285)
- The coordinate-string cache pollutes the atlas dictionary, causing
Object.assign in Sprite.addAnimation() to produce undefined entries in WebGL mode (sprite.js:409)
Proposed solution
- Refactor the Batcher to accept region objects with pre-computed UVs directly, instead of looking up regions by coordinate strings
- Remove the coordinate-string cache in
addUVs()
- Remove the
"x,y,w,h" parsing fallback in getUVs()
- Require proper pre-defined atlas regions via
addRegion()
Locations
src/video/texture/atlas.js — addRegion(), getUVs(), addUVs()
src/renderable/sprite.js — addAnimation() affected by atlas pollution
- Batcher/compositor code that consumes texture regions
Description
The texture atlas currently maintains a workaround where regions are cached under coordinate-string keys (
"x,y,w,h") inaddUVs()so the Batcher can look them up by source coordinates. Additionally,getUVs()has a fallback that parses unknown region names as"x,y,w,h"strings and creates ad-hoc regions on the fly.This is fragile and adds unnecessary complexity. The Batcher should work directly with region/frame objects that already carry their pre-computed UV float arrays, rather than performing string-based lookups.
Current behavior
addUVs()creates a duplicate atlas entry keyed by"x,y,w,h"coordinates (atlas.js:401-402)getUVs()falls back to parsing the region name as"x,y,w,h"when no named region is found (atlas.js:370-372)addRegion()allows creating arbitrary regions on the fly (atlas.js:285)Object.assigninSprite.addAnimation()to produce undefined entries in WebGL mode (sprite.js:409)Proposed solution
addUVs()"x,y,w,h"parsing fallback ingetUVs()addRegion()Locations
src/video/texture/atlas.js—addRegion(),getUVs(),addUVs()src/renderable/sprite.js—addAnimation()affected by atlas pollution