feat: Initial commit
This commit is contained in:
80
src/main.rs
Normal file
80
src/main.rs
Normal file
@@ -0,0 +1,80 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[cfg(all(feature = "wasm", not(target_arch = "wasm32")))]
|
||||
compile_error!("The `wasm` feature is only supported on the `wasm32` target architecture.");
|
||||
#[cfg(all(feature = "wayland", not(target_os = "linux")))]
|
||||
compile_error!("The `wayland` feature is only supported on the `linux` target operating system.");
|
||||
|
||||
pub fn main() {
|
||||
App::new()
|
||||
.insert_resource(ClearColor(Color::BLACK))
|
||||
.add_plugins((
|
||||
DefaultPlugins,
|
||||
bevy_debug_grid::DebugGridPlugin::without_floor_grid(),
|
||||
bevy_panorbit_camera::PanOrbitCameraPlugin,
|
||||
))
|
||||
.add_systems(Startup, setup)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
commands.spawn((
|
||||
bevy_panorbit_camera::PanOrbitCamera {
|
||||
axis: [Vec3::X, Vec3::Y, Vec3::Z],
|
||||
allow_upside_down: false,
|
||||
zoom_smoothness: 0.0,
|
||||
target_focus: Vec3::new(10.0, 10.0, 10.0),
|
||||
target_radius: 10.0,
|
||||
..default()
|
||||
},
|
||||
Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
));
|
||||
// commands.spawn((
|
||||
// Transform::from_translation(Vec3::new(0.0, 1.5, 6.0)),
|
||||
// Projection::from(OrthographicProjection {
|
||||
// scaling_mode: bevy::camera::ScalingMode::FixedVertical {
|
||||
// viewport_height: 1.0,
|
||||
// },
|
||||
// ..OrthographicProjection::default_3d()
|
||||
// }),
|
||||
// bevy_panorbit_camera::PanOrbitCamera::default(),
|
||||
// ));
|
||||
|
||||
commands.spawn((
|
||||
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
|
||||
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
|
||||
));
|
||||
commands.spawn((
|
||||
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
|
||||
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
|
||||
Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
));
|
||||
commands.spawn((
|
||||
PointLight {
|
||||
shadows_enabled: true,
|
||||
// intensity: 4000.0,
|
||||
..default()
|
||||
},
|
||||
Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
));
|
||||
|
||||
commands.spawn((
|
||||
bevy_debug_grid::Grid {
|
||||
spacing: 10.0_f32,
|
||||
count: 16,
|
||||
..default()
|
||||
},
|
||||
bevy_debug_grid::SubGrid::default(),
|
||||
bevy_debug_grid::GridAxis::new_rgb(),
|
||||
bevy_debug_grid::TrackedGrid {
|
||||
alignment: bevy_debug_grid::GridAlignment::Y,
|
||||
..default()
|
||||
},
|
||||
Transform::default(),
|
||||
Visibility::default(),
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user