@@ -17,6 +17,7 @@ macro_rules! log_error {
1717
1818struct BevyPlugin {
1919 world : World ,
20+ main_camera : Option < Entity > ,
2021 setup_schedule : Schedule ,
2122 schedule : Schedule ,
2223 schedule_info : ScheduleInfo ,
@@ -541,13 +542,14 @@ impl BevyPlugin {
541542 self . world . despawn ( e) ;
542543 }
543544 let ( cam, vp, pos) = self . setup_camera ( ) ;
544- self . world . spawn ( (
545+ let entity = self . world . spawn ( (
545546 ViewProjectionMatrix ( vp) ,
546547 pos,
547548 cam,
548549 MainCamera ,
549550 Name ( String :: from ( "main_camera" ) )
550551 ) ) ;
552+ self . main_camera = Some ( entity. id ( ) ) ;
551553 }
552554
553555 fn setup_camera ( & mut self ) -> ( Camera , Mat4f , Position ) {
@@ -586,6 +588,7 @@ impl Plugin<gfx_platform::Device, os_platform::App> for BevyPlugin {
586588 fn create ( ) -> Self {
587589 BevyPlugin {
588590 world : World :: new ( ) ,
591+ main_camera : None ,
589592 setup_schedule : Schedule :: default ( ) ,
590593 schedule : Schedule :: default ( ) ,
591594 schedule_info : ScheduleInfo :: default ( ) ,
@@ -794,23 +797,25 @@ impl Plugin<gfx_platform::Device, os_platform::App> for BevyPlugin {
794797 }
795798 client. imgui . same_line ( ) ;
796799
797- let mut main_camera_query = self . world . query :: < ( & mut Camera , & MainCamera ) > ( ) ;
798- for ( mut camera, _) in & mut main_camera_query. iter_mut ( & mut self . world ) {
799- let camera_types = vec ! [
800- "Fly" . to_string( ) ,
801- "Orbit" . to_string( ) ,
802- "Editor" . to_string( ) ,
803- ] ;
804- let selected = format ! ( "{:?}" , camera. camera_type) ;
805- let ( _, selected) = client. imgui . combo_list ( "Camera" , & camera_types, & selected) ;
806- camera. camera_type = match selected. as_str ( ) {
807- "Fly" => CameraType :: Fly ,
808- "Orbit" => CameraType :: Orbit ,
809- "Editor" => CameraType :: Editor ,
810- _ => CameraType :: Fly
811- } ;
800+ if let Some ( id) = self . main_camera {
801+ if let Some ( mut cam) = self . world . get_mut :: < Camera > ( id) {
802+ let camera_types = vec ! [
803+ "Fly" . to_string( ) ,
804+ "Orbit" . to_string( ) ,
805+ "Editor" . to_string( ) ,
806+ ] ;
807+ let selected = format ! ( "{:?}" , cam. camera_type) ;
808+ let ( _, selected) = client. imgui . combo_list ( "Camera" , & camera_types, & selected) ;
809+ cam. camera_type = match selected. as_str ( ) {
810+ "Fly" => CameraType :: Fly ,
811+ "Orbit" => CameraType :: Orbit ,
812+ "Editor" => CameraType :: Editor ,
813+ _ => CameraType :: Fly
814+ } ;
815+ }
812816 }
813817
818+
814819 // -/+ to toggle through demos, ignore test missing and test failing demos
815820 let wrap_len = demo_list. len ( ) ;
816821
0 commit comments