fixes to camera orbit

This commit is contained in:
2024-10-29 20:52:53 -04:00
parent 9120c70b80
commit 3e12fcadbc
6 changed files with 194 additions and 90 deletions

View File

@@ -1,4 +1,5 @@
use bevy::prelude::*;
use bevy::{math::Direction3d, prelude::*};
use rayon::str;
use world_generation::{hex_utils::SHORT_DIAGONAL, prelude::Chunk};
#[derive(Component, Reflect)]
@@ -18,12 +19,28 @@ impl Default for PhosCamera {
min_height: 10.,
max_height: 420.,
speed: 100.,
zoom_speed: 0.3,
zoom_speed: 20.,
min_angle: (20. as f32).to_radians(),
max_angle: 1.,
}
}
}
#[derive(Component, Reflect)]
pub struct PhosOrbitCamera {
pub target: Vec3,
pub distance: f32,
pub forward: Vec3,
}
impl Default for PhosOrbitCamera {
fn default() -> Self {
Self {
target: Default::default(),
distance: 40.0,
forward: Vec3::new(0.0, -0.5, 0.5).normalize(),
}
}
}
#[derive(Component)]
pub struct PhosCameraTargets {
@@ -53,14 +70,11 @@ pub struct CameraBounds {
}
impl CameraBounds {
pub fn from_size(size: UVec2) -> Self {
pub fn from_size(world_size: Vec2) -> Self {
let padding = Chunk::WORLD_SIZE;
return Self {
min: Vec2::ZERO - padding,
max: Vec2::new(
(size.x as usize * Chunk::SIZE) as f32 * SHORT_DIAGONAL,
(size.y * Chunk::SIZE as u32) as f32 * 1.5,
) + padding,
max: world_size + padding,
};
}
}