Fix IcoSphere UV coordinates (#1871)

Changes made:
- Swap Y/Z when calculating UV coordinates
- Correct mapping in the UV coordinates
- Fix typo in Azimuth
This commit is contained in:
Patrik Buhring 2021-04-14 22:20:24 +00:00
parent b80814681a
commit df3f40afd4

View file

@ -64,13 +64,13 @@ impl From<Icosphere> for Mesh {
); );
} }
let generated = IcoSphere::new(sphere.subdivisions, |point| { let generated = IcoSphere::new(sphere.subdivisions, |point| {
let inclination = point.z.acos(); let inclination = point.y.acos();
let azumith = point.y.atan2(point.x); let azimuth = point.z.atan2(point.x);
let norm_inclination = 1.0 - (inclination / std::f32::consts::PI); let norm_inclination = inclination / std::f32::consts::PI;
let norm_azumith = (azumith / std::f32::consts::PI) * 0.5; let norm_azimuth = 0.5 - (azimuth / std::f32::consts::TAU);
[norm_inclination, norm_azumith] [norm_azimuth, norm_inclination]
}); });
let raw_points = generated.raw_points(); let raw_points = generated.raw_points();