@@ -8,9 +8,6 @@ enum GameState {
88 Ready ,
99}
1010
11- #[ derive( Component ) ]
12- struct LoadingOnly ;
13-
1411// This value should be found experimentally by logging `PipelinesReady` in your app
1512// during normal use and noting the maximum value.
1613#[ cfg( not( target_arch = "wasm32" ) ) ]
@@ -28,6 +25,7 @@ fn main() {
2825 . add_plugins ( DefaultPlugins )
2926 . add_plugins ( PipelinesReadyPlugin )
3027 . init_state :: < GameState > ( )
28+ . enable_state_scoped_entities :: < GameState > ( )
3129 . add_systems ( Startup , setup_loading_screen)
3230 . add_systems ( Update , print. run_if ( resource_changed :: < PipelinesReady > ) )
3331 . add_systems (
@@ -36,7 +34,6 @@ fn main() {
3634 . run_if ( in_state ( GameState :: Loading ) )
3735 . run_if ( resource_changed :: < PipelinesReady > ) ,
3836 )
39- . add_systems ( OnExit ( GameState :: Loading ) , cleanup :: < LoadingOnly > )
4037 . run ( ) ;
4138}
4239
@@ -48,37 +45,34 @@ fn setup_loading_screen(
4845 mut materials : ResMut < Assets < StandardMaterial > > ,
4946) {
5047 commands. spawn ( (
51- TextBundle :: from_section ( "Pipelines loading..." . to_string ( ) , TextStyle :: default ( ) ) ,
52- LoadingOnly ,
48+ Text :: new ( "Pipelines loading..." . to_string ( ) ) ,
49+ StateScoped ( GameState :: Loading ) ,
5350 ) ) ;
5451
55- commands. spawn ( PointLightBundle {
56- point_light : PointLight {
52+ commands. spawn ( (
53+ PointLight {
5754 shadows_enabled : true ,
5855 intensity : 1_000_000. ,
5956 ..default ( )
6057 } ,
61- transform : Transform :: from_xyz ( 3.0 , 6.0 , 5.0 ) ,
62- ..default ( )
63- } ) ;
58+ Transform :: from_xyz ( 3.0 , 6.0 , 5.0 ) ,
59+ ) ) ;
6460
65- commands. spawn ( PbrBundle {
66- mesh : meshes. add ( Cylinder :: default ( ) ) ,
67- material : materials. add ( Color :: from ( bevy:: color:: palettes:: tailwind:: PINK_500 ) ) ,
68- ..default ( )
69- } ) ;
61+ commands. spawn ( (
62+ Mesh3d ( meshes. add ( Cylinder :: default ( ) ) ) ,
63+ MeshMaterial3d ( materials. add ( Color :: from ( bevy:: color:: palettes:: tailwind:: PINK_500 ) ) ) ,
64+ ) ) ;
7065
71- commands. spawn ( PbrBundle {
72- mesh : meshes. add ( Plane3d :: default ( ) . mesh ( ) . size ( 10.0 , 10.0 ) ) ,
73- material : materials. add ( Color :: from ( Srgba :: gray ( 0.6 ) ) ) ,
74- transform : Transform :: from_xyz ( 0. , -0.5 , 0. ) ,
75- ..default ( )
76- } ) ;
66+ commands. spawn ( (
67+ Mesh3d ( meshes. add ( Plane3d :: default ( ) . mesh ( ) . size ( 10.0 , 10.0 ) ) ) ,
68+ MeshMaterial3d ( materials. add ( Color :: from ( Srgba :: gray ( 0.6 ) ) ) ) ,
69+ Transform :: from_xyz ( 0. , -0.5 , 0. ) ,
70+ ) ) ;
7771
78- commands. spawn ( Camera3dBundle {
79- transform : Transform :: from_xyz ( 0.0 , 1.5 , 3.0 ) . looking_at ( Vec3 :: ZERO , Vec3 :: Y ) ,
80- .. default ( )
81- } ) ;
72+ commands. spawn ( (
73+ Camera3d :: default ( ) ,
74+ Transform :: from_xyz ( 0.0 , 1.5 , 3.0 ) . looking_at ( Vec3 :: ZERO , Vec3 :: Y ) ,
75+ ) ) ;
8276}
8377
8478fn print ( ready : Res < PipelinesReady > ) {
@@ -90,9 +84,3 @@ fn transition(ready: Res<PipelinesReady>, mut next_state: ResMut<NextState<GameS
9084 next_state. set ( GameState :: Ready ) ;
9185 }
9286}
93-
94- fn cleanup < T : Component > ( mut commands : Commands , query : Query < Entity , With < T > > ) {
95- for entity in query. iter ( ) {
96- commands. entity ( entity) . despawn_recursive ( ) ;
97- }
98- }
0 commit comments