pub mod camera;
pub mod controls;
#[cfg(feature = "egui-ui")]
pub mod egui_panel;
pub mod plugin;
pub mod scenes;
pub mod wasm_sync;
pub use camera::{CameraPlugin, FirstPersonCamera};
pub use controls::{
calculate_all_luminaire_transforms, calculate_light_position, LuminaireTransform,
};
pub use plugin::EulumdatViewerPlugin;
pub use scenes::{SceneGeometry, ScenePlugin, SceneType};
pub use wasm_sync::{
load_default_ldt, load_from_local_storage, poll_viewer_settings_changes, LdtTimestamp,
ViewerSettingsTimestamp,
};
use bevy::prelude::*;
use eulumdat::Eulumdat;
#[derive(Resource, Clone)]
pub struct ViewerSettings {
pub scene_type: SceneType,
pub room_width: f32,
pub room_length: f32,
pub room_height: f32,
pub mounting_height: f32,
pub pendulum_length: f32,
pub light_intensity: f32,
pub show_luminaire: bool,
pub show_photometric_solid: bool,
pub show_shadows: bool,
pub ldt_data: Option<Eulumdat>,
pub luminaire_tilt: f32,
pub lane_width: f32,
pub num_lanes: u32,
pub sidewalk_width: f32,
pub pole_spacing: f32,
}
impl Default for ViewerSettings {
fn default() -> Self {
Self {
scene_type: SceneType::Room,
room_width: 4.0,
room_length: 5.0,
room_height: 2.8,
mounting_height: 8.0, pendulum_length: 0.3, light_intensity: 1000.0,
show_luminaire: true,
show_photometric_solid: false,
show_shadows: false,
ldt_data: None,
luminaire_tilt: 15.0, lane_width: 3.5, num_lanes: 2, sidewalk_width: 2.0, pole_spacing: 0.0, }
}
}
impl ViewerSettings {
pub fn effective_pole_spacing(&self) -> f32 {
if self.pole_spacing > 0.0 {
self.pole_spacing
} else {
self.mounting_height * 3.5
}
}
pub fn total_road_width(&self) -> f32 {
self.num_lanes as f32 * self.lane_width + 2.0 * self.sidewalk_width
}
}
impl ViewerSettings {
pub fn luminaire_height(&self, ldt: &Eulumdat) -> f32 {
let lum_height = (ldt.height / 1000.0).max(0.05) as f32;
match self.scene_type {
SceneType::Room => {
self.room_height - self.pendulum_length - lum_height / 2.0
}
SceneType::Road | SceneType::Parking | SceneType::Outdoor => {
let arm_bottom = self.mounting_height - 0.25;
arm_bottom - 0.05 - lum_height / 2.0
}
}
}
pub fn attachment_height(&self) -> f32 {
match self.scene_type {
SceneType::Room => self.room_height,
_ => self.mounting_height,
}
}
}