From cf3c1141724be718ecf340ac2b3a7495ac822791 Mon Sep 17 00:00:00 2001 From: AI Bot Date: Wed, 30 Sep 2026 18:26:43 +0530 Subject: [PATCH] fix: correct UV mapping horizontal flip issue on cylindrical and spherical projections --- src/lib/bakingUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/bakingUtils.ts b/src/lib/bakingUtils.ts index e1661b5..2233e07 100644 --- a/src/lib/bakingUtils.ts +++ b/src/lib/bakingUtils.ts @@ -40,7 +40,7 @@ export function reprojectUVs(geometry: THREE.BufferGeometry, mappingType: 'plana const centeredZ = z - center.z; // atan2 returns -PI to PI. We want 0 to 1 around the cylinder. let angle = Math.atan2(centeredZ, centeredX); - u = (angle + Math.PI) / (2 * Math.PI); + u = 1.0 - ((angle + Math.PI) / (2 * Math.PI)); v = 1.0 - ny; } else if (mappingType === 'sphere') { // Spherical projection @@ -52,7 +52,7 @@ export function reprojectUVs(geometry: THREE.BufferGeometry, mappingType: 'plana const phi = Math.acos(centeredY / radius); // 0 to PI let theta = Math.atan2(centeredZ, centeredX); // -PI to PI - u = (theta + Math.PI) / (2 * Math.PI); + u = 1.0 - ((theta + Math.PI) / (2 * Math.PI)); v = phi / Math.PI; // 0 at top, 1 at bottom } else if (mappingType === 'box') { // Simple box projection (pick dominant axis based on normal)