From 52b291493c069cec526b0f674b105ab58fdd7b83 Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Sat, 5 Oct 2024 09:46:57 +0200 Subject: [PATCH] planeee --- src/main.rs | 73 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/src/main.rs b/src/main.rs index 450471f..0e624a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,35 +11,66 @@ fn main() { .run(); } -/// set up a simple 3D scene +#[derive(Component)] +struct Star; + fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { - - let star_material = materials.add(Color::WHITE); - - let star = meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(1.0))); - - // circular base - commands.spawn(MaterialMeshBundle { - mesh: star, - material: star_material.clone(), - transform: Transform::from_xyz(0.0, 1.0, 0.0), - ..default() - }); - // light + // plane commands.spawn(( - PointLight { - shadows_enabled: true, + PbrBundle { + mesh: meshes.add(Plane3d::default().mesh().size(20., 20.)), + material: materials.add(Color::srgb(0.3, 0.5, 0.3)), ..default() }, - Transform::from_xyz(0.0, 0.8, 1.0), + Star, )); + + // light + commands.spawn(DirectionalLightBundle { + transform: Transform::from_translation(Vec3::ONE).looking_at(Vec3::ZERO, Vec3::Y), + ..default() + }); + // camera - commands.spawn(( - Camera3d::default(), - Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), - )); + commands.spawn(Camera3dBundle { + transform: Transform::from_xyz(15.0, 5.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y), + ..default() + }); } + + +// fn setup( +// mut commands: Commands, +// mut meshes: ResMut>, +// mut materials: ResMut>, +// ) { +// +// let star_material = materials.add(Color::WHITE); +// +// let star = meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(1.0))); +// +// // circular base +// commands.spawn(MaterialMeshBundle { +// mesh: star, +// material: star_material.clone(), +// transform: Transform::from_xyz(0.0, 1.0, 0.0), +// ..default() +// }); +// // light +// commands.spawn(( +// PointLight { +// shadows_enabled: true, +// ..default() +// }, +// Transform::from_xyz(0.0, 0.8, 1.0), +// )); +// // camera +// commands.spawn(( +// Camera3d::default(), +// Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), +// )); +// }