From ad9f6dbd397ff5c1438526b6ed8a59f4deb00396 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 14 Apr 2024 21:52:29 +0200 Subject: [PATCH] render stars as circles instead of spheres --- src/world.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/world.rs b/src/world.rs index 055ded2..d3f46fe 100644 --- a/src/world.rs +++ b/src/world.rs @@ -126,7 +126,7 @@ pub fn setup( commands.insert_resource(AsteroidModel2(asset_server.load(ASSET_ASTEROID2))); // Generate starmap - let sphere_handle = meshes.add(Sphere::new(1.0)); + let sphere_handle = meshes.add(Circle::new(1.0)); let mut starcount = 0; for star in stars::STARS { let mag = star.3; @@ -167,6 +167,12 @@ pub fn setup( } else { star.6.to_string() }; + let translation = Vec3::new( + mesh_distance * star.0, + mesh_distance * star.1, + mesh_distance * star.2, + ); + let rotation = Quat::from_rotation_arc(Vec3::Z, (-translation).normalize()); commands.spawn(( Star, hud::IsClickable { @@ -176,12 +182,11 @@ pub fn setup( PbrBundle { mesh: sphere_handle.clone(), material: star_color_handle, - transform: Transform::from_xyz( - mesh_distance * star.0, - mesh_distance * star.1, - mesh_distance * star.2, - ) - .with_scale(Vec3::splat(scale_size(mag))), + transform: Transform { + translation, + rotation, + scale: Vec3::splat(scale_size(mag)), + }, ..default() } ));