mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
feat(camera): add 3d orthogrpahic camera setup
This commit is contained in:
parent
0a64641941
commit
846b2326a3
30
src/lib.rs
30
src/lib.rs
@ -4,10 +4,10 @@ pub mod audio;
|
|||||||
mod demo;
|
mod demo;
|
||||||
#[cfg(feature = "dev")]
|
#[cfg(feature = "dev")]
|
||||||
mod dev_tools;
|
mod dev_tools;
|
||||||
|
#[cfg(not(feature = "demo"))]
|
||||||
|
mod grid;
|
||||||
mod screens;
|
mod screens;
|
||||||
mod theme;
|
mod theme;
|
||||||
#[cfg(not(feature = "demo"))]
|
|
||||||
mod tiles;
|
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
asset::AssetMetaCheck,
|
asset::AssetMetaCheck,
|
||||||
@ -26,7 +26,10 @@ impl Plugin for AppPlugin {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Spawn the main camera.
|
// Spawn the main camera.
|
||||||
|
#[cfg(not(feature = "demo"))]
|
||||||
app.add_systems(Startup, spawn_camera);
|
app.add_systems(Startup, spawn_camera);
|
||||||
|
#[cfg(feature = "demo")]
|
||||||
|
app.add_systems(Startup, spawn_2d_camera);
|
||||||
|
|
||||||
// Add Bevy plugins.
|
// Add Bevy plugins.
|
||||||
app.add_plugins(
|
app.add_plugins(
|
||||||
@ -51,7 +54,7 @@ impl Plugin for AppPlugin {
|
|||||||
})
|
})
|
||||||
.set(AudioPlugin {
|
.set(AudioPlugin {
|
||||||
global_volume: GlobalVolume {
|
global_volume: GlobalVolume {
|
||||||
volume: Volume::new(0.3),
|
volume: Volume::new(0.),
|
||||||
},
|
},
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
@ -63,7 +66,7 @@ impl Plugin for AppPlugin {
|
|||||||
#[cfg(feature = "demo")]
|
#[cfg(feature = "demo")]
|
||||||
demo::plugin,
|
demo::plugin,
|
||||||
#[cfg(not(feature = "demo"))]
|
#[cfg(not(feature = "demo"))]
|
||||||
tiles::plugin,
|
grid::plugin,
|
||||||
screens::plugin,
|
screens::plugin,
|
||||||
theme::plugin,
|
theme::plugin,
|
||||||
));
|
));
|
||||||
@ -87,7 +90,26 @@ enum AppSet {
|
|||||||
Update,
|
Update,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "demo"))]
|
||||||
fn spawn_camera(mut commands: Commands) {
|
fn spawn_camera(mut commands: Commands) {
|
||||||
|
commands.spawn((
|
||||||
|
Name::new("Camera"),
|
||||||
|
Camera3dBundle {
|
||||||
|
transform: Transform::from_xyz(0., 60., 0.).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
// Render all UI to this camera.
|
||||||
|
// Not strictly necessary since we only use one camera,
|
||||||
|
// but if we don't use this component, our UI will disappear as soon
|
||||||
|
// as we add another camera. This includes indirect ways of adding cameras like using
|
||||||
|
// [ui node outlines](https://bevyengine.org/news/bevy-0-14/#ui-node-outline-gizmos)
|
||||||
|
// for debugging. So it's good to have this here for future-proofing.
|
||||||
|
IsDefaultUiCamera,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "demo")]
|
||||||
|
fn spawn_2d_camera(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Name::new("Camera"),
|
Name::new("Camera"),
|
||||||
Camera2dBundle::default(),
|
Camera2dBundle::default(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user