use std::{f32::consts::FRAC_PI_2, time::Duration}; use avian3d::{math::Vector, prelude::*}; use bevy::{ color::palettes, math::{vec2, vec3}, prelude::*, time::common_conditions::on_timer, }; use polyanya::Triangulation; use rand::Rng; use vleue_navigator::prelude::*; const MESH_UNIT: u32 = 100; const UPDATE_MODE: NavMeshUpdateMode = NavMeshUpdateMode::Direct; const UP_SHIFT: f32 = 0.1; const RATIO: f32 = 0.8; #[derive(Component)] struct Obstacle(Timer); fn main() { App::new() .insert_resource(ClearColor(palettes::css::BLACK.into())) .add_plugins(( DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { title: "Navmesh with Polyanya".to_string(), fit_canvas_to_parent: true, ..default() }), ..default() }), PhysicsPlugins::default().with_length_unit(2.0), VleueNavigatorPlugin, NavmeshUpdaterPlugin::::default(), )) .insert_resource(Gravity(Vector::NEG_Y * 9.81 * 10.0)) .add_systems(Startup, setup) .add_systems(Update, (despawn_obstacles, rotate_camera)) .add_systems(PostUpdate, display_path) .add_systems( Update, spawn_obstacles.run_if(on_timer(Duration::from_secs_f32(0.5))), ) .run(); } fn rotate_camera(time: Res