add a sphere in space
This commit is contained in:
parent
3ab0a82181
commit
ec1f7cf96c
22
src/world.rs
22
src/world.rs
|
@ -14,8 +14,11 @@ const CUBEMAP_PATH: &str = "textures/stars_cubemap.png";
|
||||||
|
|
||||||
pub fn setup(
|
pub fn setup(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
) {
|
) {
|
||||||
|
// Add skybox
|
||||||
let skybox_handle = asset_server.load(CUBEMAP_PATH);
|
let skybox_handle = asset_server.load(CUBEMAP_PATH);
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3dBundle {
|
||||||
|
@ -32,6 +35,25 @@ pub fn setup(
|
||||||
is_loaded: false,
|
is_loaded: false,
|
||||||
image_handle: skybox_handle,
|
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(
|
pub fn load_cubemap_asset(
|
||||||
|
|
Loading…
Reference in a new issue