3d map + light

This commit is contained in:
Arkitu 2025-05-14 21:44:15 +02:00
parent 52dde29d13
commit c6e8a3e232
3 changed files with 17 additions and 3 deletions

View File

@ -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()
}
);
}

View File

@ -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,

View File

@ -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::<Vec<_>>();
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());