use despero::prelude::*; #[derive(Clone, Default, Debug)] struct CameraConfiguration { limit: (f32, f32), target_x: f32, target_y: f32, latest_pos: Point2, } fn main() { Despero::init(WindowBuilder { title: Some("PBR Test"), fullscreen: Some(true), renderer: Some(RenderType::Forward), ..Default::default() }) .default_systems() .add_setup_system(create_scene) .add_system(process_scene) .add_system(get_material) .run(); } fn get_material( asset_manager: Read, ){ if let Some(mut material) = asset_manager.get_material_downcast::(AssetHandle::from_index(0)) { material.color[0] += 0.01; } } fn create_scene( mut cmd: Write, mut asset_manager: Write, ){ let diffuse = asset_manager.create_texture("assets/pbr_test/diffuse.jpg", Filter::Linear); cmd.spawn( ModelBundle::builder() .mesh(Mesh::plane()) .material(asset_manager.create_material( DefaultMat::builder() .albedo(diffuse) .metallic(0.0) .roughness(0.5) .build() )) .transform(Transform::from_rotation(UnitQuaternion::from_axis_angle(&Vector3::x_axis(), to_radian(-45.0)))) .build() ); cmd.spawn(( Camera::builder() .is_active(true) .camera_type(CameraType::FirstPerson) .build(), Transform::from_translation(Vector3::new(0.0, 0.0, 3.0)), CameraConfiguration { limit: (-85.0, 85.0), ..Default::default() }, )); cmd.spawn(( DirectionalLight { direction: Vector3::new(-1., -1., 0.), illuminance: [0.5, 0.5, 0.5], }, )); let sky_tex = asset_manager.create_texture("assets/StandardCubeMap.png", Filter::Linear); cmd.spawn( ModelBundle::builder() .mesh(Mesh::load_obj("assets/skybox.obj").swap_remove(0)) .material( asset_manager.create_material( DefaultMat::builder() .albedo(sky_tex) .build() ) ) .transform(Transform::default()) .build() ); } fn process_scene( camera_world: SubWorld<(&Camera, &mut CameraConfiguration, &mut Transform)>, gui_events: Read>, time: Read