From ec1f7cf96c933d2a80416890c3e06de13d9f9dc2 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 16 Mar 2024 23:11:56 +0100 Subject: [PATCH] add a sphere in space --- src/world.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/world.rs b/src/world.rs index be1282e..0e526f9 100644 --- a/src/world.rs +++ b/src/world.rs @@ -14,8 +14,11 @@ const CUBEMAP_PATH: &str = "textures/stars_cubemap.png"; pub fn setup( mut commands: Commands, + mut meshes: ResMut>, + mut materials: ResMut>, asset_server: Res, ) { + // Add skybox let skybox_handle = asset_server.load(CUBEMAP_PATH); commands.spawn(( Camera3dBundle { @@ -32,6 +35,25 @@ pub fn setup( is_loaded: false, image_handle: skybox_handle, }); + + // Add spheres + let sphere_radius = 0.25; + let sphere_handle = meshes.add(Sphere::new(sphere_radius)); + let white_handle = materials.add(StandardMaterial { + base_color: Color::WHITE, + perceptual_roughness: 1.0, + ..default() + }); + commands.spawn(PbrBundle { + mesh: sphere_handle.clone(), + material: white_handle.clone(), + transform: Transform::from_xyz( + 0.0, + sphere_radius, + 0.0, + ), + ..default() + }); } pub fn load_cubemap_asset(