feat: BlackHoleParams tunable resource

This commit is contained in:
xfy 2026-07-10 10:27:10 +08:00
parent d039064efa
commit 1a2b157ef3
3 changed files with 54 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use bevy::window::WindowPlugin;
mod web;
mod render;
mod camera;
mod params;
fn main() {
// On web, abort startup if WebGPU isn't available and show a message.

52
src/params.rs Normal file
View File

@ -0,0 +1,52 @@
use bevy::prelude::*;
/// All tunable black-hole parameters. Edited by the egui panel (Task 17),
/// mirrored into BlackHoleUniforms each frame (Task 7).
#[derive(Resource, Clone)]
pub struct BlackHoleParams {
// Physics (natural units, Rs = 1)
pub rs: f32,
// Accretion disk
pub disk_inner: f32,
pub disk_outer: f32,
pub disk_tilt: f32, // radians, tilt of disk plane vs. camera
pub disk_brightness: f32,
pub disk_rotation_speed: f32,
pub doppler_enabled: bool,
pub doppler_strength: f32,
// Renderer
pub steps: u32,
pub render_scale: f32,
pub star_intensity: f32,
pub grid_enabled: bool,
pub grid_density: f32,
// Background
pub skybox_intensity: f32,
// Planets (count matches the storage buffer; Task 14)
pub planet_count: u32,
// Kerr (Phase 2; unused in Phase 1)
pub spin: f32,
}
impl Default for BlackHoleParams {
fn default() -> Self {
Self {
rs: 1.0,
disk_inner: 3.0,
disk_outer: 15.0,
disk_tilt: 1.318, // ~75.5 deg, matching the reference video
disk_brightness: 1.0,
disk_rotation_speed: 0.5,
doppler_enabled: true,
doppler_strength: 1.0,
steps: 300,
render_scale: 1.0,
star_intensity: 1.0,
grid_enabled: false,
grid_density: 1.0,
skybox_intensity: 0.0, // procedural stars only by default
planet_count: 0,
spin: 0.0,
}
}
}

View File

@ -11,6 +11,7 @@ impl Plugin for BlackHolePlugin {
.add_systems(Startup, spawn_fullscreen_quad)
.add_systems(Update, update_time)
.init_resource::<crate::camera::OrbitCamera>()
.init_resource::<crate::params::BlackHoleParams>()
.add_systems(Update, crate::camera::orbit_controller);
}
}