use kalast::{
    EnvironmentSystem, Properties, SingleBody, Time, World, ASTRONAUMICAL_UNIT, HOUR, MINUTE, TAU,
    V3,
};

// This example is a test to obtain the latitude=longitude=0° point on the mesh of the asteroid.
// For the example to work, the mesh needs to be subdivided, which is not supported right now.
fn main() {
    // Define the body.
    let mut asteroid = SingleBody::new(
        "Dimorphos",
        "rsc/obj/ellipsoid.obj",
        -V3::new(1.0, 0.0, 0.0) * ASTRONAUMICAL_UNIT * 1.074,
        Properties::new(
            11.92 * HOUR,        // rotation period
            11.92 * HOUR,        // revolution period
            162.0 * TAU / 180.0, // obliquity
            500.0,               // thermal inertia
            2146.0,              // density
            600.0,               // heat capacity
            0.07,                // albedo
            0.9,                 // emissivity
        ),
    );
    asteroid.complete_model(false);

    // 133: [0.066819  0.010575 108.83989]
    asteroid.body_mut().object.mask_all_faces_except_this(133);

    // Time
    let time = Time::new(
        50. * asteroid.body().properties.revolution_period(),
        1.0 * MINUTE,
    );

    // World
    let mut world = World::new(time, asteroid);
    world.start();
    world.save_daily("rsc/data/tmp.txt");

    println!(
        "min: {:.2}, max: {:.2}",
        world.environment_system.body().surface_temperatures().min(),
        world.environment_system.body().surface_temperatures().max()
    );
}
