fix: correct UV mapping horizontal flip issue on cylindrical and spherical projections
Build and Deploy / build-and-push (push) Successful in 1m13s
Build and Deploy / build-and-push (push) Successful in 1m13s
This commit is contained in:
@@ -40,7 +40,7 @@ export function reprojectUVs(geometry: THREE.BufferGeometry, mappingType: 'plana
|
|||||||
const centeredZ = z - center.z;
|
const centeredZ = z - center.z;
|
||||||
// atan2 returns -PI to PI. We want 0 to 1 around the cylinder.
|
// atan2 returns -PI to PI. We want 0 to 1 around the cylinder.
|
||||||
let angle = Math.atan2(centeredZ, centeredX);
|
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;
|
v = 1.0 - ny;
|
||||||
} else if (mappingType === 'sphere') {
|
} else if (mappingType === 'sphere') {
|
||||||
// Spherical projection
|
// Spherical projection
|
||||||
@@ -52,7 +52,7 @@ export function reprojectUVs(geometry: THREE.BufferGeometry, mappingType: 'plana
|
|||||||
const phi = Math.acos(centeredY / radius); // 0 to PI
|
const phi = Math.acos(centeredY / radius); // 0 to PI
|
||||||
let theta = Math.atan2(centeredZ, centeredX); // -PI 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
|
v = phi / Math.PI; // 0 at top, 1 at bottom
|
||||||
} else if (mappingType === 'box') {
|
} else if (mappingType === 'box') {
|
||||||
// Simple box projection (pick dominant axis based on normal)
|
// Simple box projection (pick dominant axis based on normal)
|
||||||
|
|||||||
Reference in New Issue
Block a user