So I made the code for a planet like structure that orbits around my player even tho is a sun.
The thing is as I move around my camera well shadows get cutted any ideas on what causes this?
/// Will add lighting to the sun
fn add_cosmetic_sun(
suns: Query<Entity, Added<SunMarker>>,
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
for sun in suns.iter() {
let sun_light = DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: light_consts::lux::OVERCAST_DAY,
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(0.0, 4.0, 0.0),
cascade_shadow_config: CascadeShadowConfigBuilder {
first_cascade_far_bound: 4.0,
maximum_distance: 10.0,
..default()
}
.into(),
..default()
};
commands
.entity(sun)
// .insert(PbrBundle {
// mesh: meshes.add(Cuboid::default()),
// material: materials.add(Color::srgb(1.0, 1.0, 1.0)),
// ..default()
// })
.insert(sun_light)
.insert(Orbit {
center: Vec3::new(0.0, 0.0, 0.0), // Orbit center point
radius: 5.0, // Orbit radius
});
}
}
}```