add a sphere in space

This commit is contained in:
yuni 2024-03-16 23:11:56 +01:00
parent 3ab0a82181
commit ec1f7cf96c

View file

@ -14,8 +14,11 @@ const CUBEMAP_PATH: &str = "textures/stars_cubemap.png";
pub fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
asset_server: Res<AssetServer>,
) {
// 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(