use bevy::prelude::*;
use bevy_mod_async::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, AsyncTasksPlugin))
.insert_resource(GlobalAmbientLight {
color: Color::WHITE,
brightness: 1_000.0,
affects_lightmapped_meshes: true,
})
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn((
Camera3d::default(),
Transform::from_xyz(2.0, 1.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
));
commands.spawn_task(|cx| async move {
let loading_screen = cx
.with_world(|world| {
world
.spawn((
Node {
align_self: AlignSelf::Center,
justify_self: JustifySelf::Center,
..default()
},
children![(
Text::new("Loading..."),
TextFont {
font_size: 36.0,
..default()
},
)],
))
.id()
})
.await;
let scene = cx.load_asset("FlightHelmet.gltf#Scene0").await.unwrap();
cx.despawn(loading_screen).detach();
cx.spawn(SceneRoot(scene)).detach();
});
}