diff --git a/src/camera.rs b/src/camera.rs index 97e7ef6..c590e22 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -21,4 +21,16 @@ fn setup(mut cmds: Commands, window: Query<&Window>) { .with_translation(Vec3::new(0., -1., 1.)) .looking_to(Vec3::new(0., 1., -1.), Vec3::Y), )); + cmds.spawn( + DirectionalLightBundle { + directional_light: DirectionalLight { + color: Color::WHITE, + illuminance: 17000., + //shadows_enabled: true, + ..Default::default() + }, + transform: Transform::default().looking_to(Vec3::new(1., -1., -1.), Vec3::ZERO), + ..Default::default() + } + ); } diff --git a/src/lib.rs b/src/lib.rs index ba5479a..533ed4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ pub fn main() { .add_plugins(( DefaultPlugins, // bevy_inspector_egui::DefaultInspectorConfigPlugin, - bevy_editor_pls::EditorPlugin::default(), // for debug + //bevy_editor_pls::EditorPlugin::default(), // for debug // WorldInspectorPlugin::default(), camera::Plugin, map::Plugin, diff --git a/src/map.rs b/src/map.rs index c826182..f2bca0a 100644 --- a/src/map.rs +++ b/src/map.rs @@ -111,16 +111,17 @@ fn setup( let mut poss = Vec::new(); let mut indices = Vec::new(); + let mut normals = Vec::new(); for (c, cd) in voronoi .iter_cells() .zip(cells.iter_mut()) - .filter(|(_, cd)| cd.kind != CellKind::Forest) { let vs = c.iter_vertices().collect::>(); let i = poss.len(); for v in vs.iter() { - poss.push(Vec3::new(v.x as f32, v.y as f32, 0.)); + poss.push(Vec3::new(v.x as f32, v.y as f32, (cd.altitude as f32)/255./4.)); + normals.push(Vec3::new(0., 0., 1.)); } for v in 1..(vs.len() - 1) { indices.extend_from_slice(&[(i + v + 1) as u32, (i + v) as u32, i as u32]); @@ -137,6 +138,7 @@ fn setup( // 3D space), for each of the corners of the parallelogram. .with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, poss) .with_inserted_attribute(Mesh::ATTRIBUTE_COLOR, colors.clone()) + .with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, normals) .with_inserted_indices(Indices::U32(indices)); let mut cells_entities = Vec::with_capacity(cells.len());