@@ -123,16 +123,22 @@ describe("TMX Renderers", () => {
123123 // This verifies the critical bug fix:
124124 // previously this.centers[i].sub(rel) mutated the centers
125125
126- // Call pixelToTileCoords multiple times with the same input
127- const result1 = renderer . pixelToTileCoords ( 50 , 50 ) ;
128- const result2 = renderer . pixelToTileCoords ( 50 , 50 ) ;
129- const result3 = renderer . pixelToTileCoords ( 50 , 50 ) ;
130-
131- // Results should be identical since centers are not mutated
132- expect ( result1 . x ) . toEqual ( result2 . x ) ;
133- expect ( result1 . y ) . toEqual ( result2 . y ) ;
134- expect ( result2 . x ) . toEqual ( result3 . x ) ;
135- expect ( result2 . y ) . toEqual ( result3 . y ) ;
126+ // Call pixelToTileCoords to trigger center calculations
127+ renderer . pixelToTileCoords ( 50 , 50 ) ;
128+
129+ // Save centers values after first call
130+ const centersAfterFirst = renderer . centers . map ( ( c ) => {
131+ return { x : c . x , y : c . y } ;
132+ } ) ;
133+
134+ // Call again — centers should be re-set to the same values
135+ renderer . pixelToTileCoords ( 50 , 50 ) ;
136+
137+ // Verify centers were not mutated by the distance calculation
138+ for ( let i = 0 ; i < 4 ; i ++ ) {
139+ expect ( renderer . centers [ i ] . x ) . toEqual ( centersAfterFirst [ i ] . x ) ;
140+ expect ( renderer . centers [ i ] . y ) . toEqual ( centersAfterFirst [ i ] . y ) ;
141+ }
136142 } ) ;
137143
138144 it ( "pixelToTileCoords should return consistent results (staggerX)" , ( ) => {
0 commit comments