add the SUN
This commit is contained in:
parent
9cec03a34f
commit
571f886782
33
src/world.rs
33
src/world.rs
|
@ -4,6 +4,10 @@ use bevy::core_pipeline::Skybox;
|
|||
use bevy::asset::LoadState;
|
||||
use bevy::render::render_resource::{TextureViewDescriptor, TextureViewDimension};
|
||||
use bevy::pbr::CascadeShadowConfigBuilder;
|
||||
use bevy::core_pipeline::{
|
||||
bloom::{BloomCompositeMode, BloomSettings},
|
||||
tonemapping::Tonemapping,
|
||||
};
|
||||
use std::f32::consts::PI;
|
||||
|
||||
#[derive(Resource)]
|
||||
|
@ -25,6 +29,10 @@ pub fn setup(
|
|||
let skybox_handle = asset_server.load(CUBEMAP_PATH);
|
||||
commands.spawn((
|
||||
Camera3dBundle {
|
||||
camera: Camera {
|
||||
hdr: true, // HDR is required for bloom
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
},
|
||||
|
@ -33,6 +41,10 @@ pub fn setup(
|
|||
image: skybox_handle.clone(),
|
||||
brightness: 500.0,
|
||||
},
|
||||
BloomSettings {
|
||||
composite_mode: BloomCompositeMode::Additive,
|
||||
..default()
|
||||
},
|
||||
));
|
||||
commands.insert_resource(Cubemap {
|
||||
is_loaded: false,
|
||||
|
@ -52,7 +64,6 @@ pub fn setup(
|
|||
perceptual_roughness: 1.0,
|
||||
..default()
|
||||
});
|
||||
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: sphere_handle.clone(),
|
||||
material: gray_handle.clone(),
|
||||
|
@ -77,6 +88,26 @@ pub fn setup(
|
|||
..default()
|
||||
});
|
||||
|
||||
// Add THE SUN
|
||||
let hydrogenfusion_handle = materials.add(StandardMaterial {
|
||||
base_color: Color::WHITE,
|
||||
emissive: Color::rgb_linear(2300.0, 900.0, 300.0),
|
||||
perceptual_roughness: 0.0,
|
||||
..default()
|
||||
});
|
||||
let sphere_radius = 5000.0;
|
||||
let sphere_handle = meshes.add(Sphere::new(sphere_radius));
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: sphere_handle.clone(),
|
||||
material: hydrogenfusion_handle.clone(),
|
||||
transform: Transform::from_xyz(
|
||||
0.0,
|
||||
30000.0,
|
||||
-400000.0,
|
||||
),
|
||||
..default()
|
||||
});
|
||||
|
||||
// Add alien
|
||||
commands.spawn(SceneBundle {
|
||||
transform: Transform {
|
||||
|
|
Loading…
Reference in a new issue