From df3f40afd4b419344117cc76a31981b955d6a208 Mon Sep 17 00:00:00 2001 From: Patrik Buhring Date: Wed, 14 Apr 2021 22:20:24 +0000 Subject: [PATCH] Fix IcoSphere UV coordinates (#1871) Changes made: - Swap Y/Z when calculating UV coordinates - Correct mapping in the UV coordinates - Fix typo in Azimuth --- crates/bevy_render/src/mesh/shape/icosphere.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/bevy_render/src/mesh/shape/icosphere.rs b/crates/bevy_render/src/mesh/shape/icosphere.rs index f3a4736b22..f1e07a0ecf 100644 --- a/crates/bevy_render/src/mesh/shape/icosphere.rs +++ b/crates/bevy_render/src/mesh/shape/icosphere.rs @@ -64,13 +64,13 @@ impl From for Mesh { ); } let generated = IcoSphere::new(sphere.subdivisions, |point| { - let inclination = point.z.acos(); - let azumith = point.y.atan2(point.x); + let inclination = point.y.acos(); + let azimuth = point.z.atan2(point.x); - let norm_inclination = 1.0 - (inclination / std::f32::consts::PI); - let norm_azumith = (azumith / std::f32::consts::PI) * 0.5; + let norm_inclination = inclination / std::f32::consts::PI; + let norm_azimuth = 0.5 - (azimuth / std::f32::consts::TAU); - [norm_inclination, norm_azumith] + [norm_azimuth, norm_inclination] }); let raw_points = generated.raw_points();