3d map + light
This commit is contained in:
parent
52dde29d13
commit
c6e8a3e232
@ -21,4 +21,16 @@ fn setup(mut cmds: Commands, window: Query<&Window>) {
|
|||||||
.with_translation(Vec3::new(0., -1., 1.))
|
.with_translation(Vec3::new(0., -1., 1.))
|
||||||
.looking_to(Vec3::new(0., 1., -1.), Vec3::Y),
|
.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()
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ pub fn main() {
|
|||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins,
|
DefaultPlugins,
|
||||||
// bevy_inspector_egui::DefaultInspectorConfigPlugin,
|
// bevy_inspector_egui::DefaultInspectorConfigPlugin,
|
||||||
bevy_editor_pls::EditorPlugin::default(), // for debug
|
//bevy_editor_pls::EditorPlugin::default(), // for debug
|
||||||
// WorldInspectorPlugin::default(),
|
// WorldInspectorPlugin::default(),
|
||||||
camera::Plugin,
|
camera::Plugin,
|
||||||
map::Plugin,
|
map::Plugin,
|
||||||
|
@ -111,16 +111,17 @@ fn setup(
|
|||||||
|
|
||||||
let mut poss = Vec::new();
|
let mut poss = Vec::new();
|
||||||
let mut indices = Vec::new();
|
let mut indices = Vec::new();
|
||||||
|
let mut normals = Vec::new();
|
||||||
|
|
||||||
for (c, cd) in voronoi
|
for (c, cd) in voronoi
|
||||||
.iter_cells()
|
.iter_cells()
|
||||||
.zip(cells.iter_mut())
|
.zip(cells.iter_mut())
|
||||||
.filter(|(_, cd)| cd.kind != CellKind::Forest)
|
|
||||||
{
|
{
|
||||||
let vs = c.iter_vertices().collect::<Vec<_>>();
|
let vs = c.iter_vertices().collect::<Vec<_>>();
|
||||||
let i = poss.len();
|
let i = poss.len();
|
||||||
for v in vs.iter() {
|
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) {
|
for v in 1..(vs.len() - 1) {
|
||||||
indices.extend_from_slice(&[(i + v + 1) as u32, (i + v) as u32, i as u32]);
|
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.
|
// 3D space), for each of the corners of the parallelogram.
|
||||||
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, poss)
|
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, poss)
|
||||||
.with_inserted_attribute(Mesh::ATTRIBUTE_COLOR, colors.clone())
|
.with_inserted_attribute(Mesh::ATTRIBUTE_COLOR, colors.clone())
|
||||||
|
.with_inserted_attribute(Mesh::ATTRIBUTE_NORMAL, normals)
|
||||||
.with_inserted_indices(Indices::U32(indices));
|
.with_inserted_indices(Indices::U32(indices));
|
||||||
|
|
||||||
let mut cells_entities = Vec::with_capacity(cells.len());
|
let mut cells_entities = Vec::with_capacity(cells.len());
|
||||||
|
Loading…
Reference in New Issue
Block a user