2020-05-15 23:55:44 +00:00
|
|
|
use bevy::prelude::*;
|
2020-01-08 07:03:09 +00:00
|
|
|
|
|
|
|
fn main() {
|
2020-04-20 02:29:33 +00:00
|
|
|
App::build()
|
|
|
|
.add_default_plugins()
|
2020-05-14 00:31:56 +00:00
|
|
|
.add_startup_system(setup.system())
|
2020-04-20 02:29:33 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2020-05-14 00:31:56 +00:00
|
|
|
fn setup(
|
2020-07-10 04:18:35 +00:00
|
|
|
mut commands: Commands,
|
2020-05-18 01:09:29 +00:00
|
|
|
asset_server: Res<AssetServer>,
|
2020-05-14 00:52:47 +00:00
|
|
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
2020-05-14 00:31:56 +00:00
|
|
|
) {
|
2020-04-20 05:31:14 +00:00
|
|
|
// load the mesh
|
2020-05-15 23:55:44 +00:00
|
|
|
let mesh_handle = asset_server
|
2020-05-16 00:22:45 +00:00
|
|
|
.load("assets/models/monkey/Monkey.gltf")
|
2020-05-15 23:55:44 +00:00
|
|
|
.unwrap();
|
2020-04-20 02:29:33 +00:00
|
|
|
|
2020-04-20 05:31:14 +00:00
|
|
|
// create a material for the mesh
|
2020-05-13 23:42:27 +00:00
|
|
|
let material_handle = materials.add(StandardMaterial {
|
2020-04-20 02:29:33 +00:00
|
|
|
albedo: Color::rgb(0.5, 0.4, 0.3),
|
|
|
|
..Default::default()
|
|
|
|
});
|
|
|
|
|
|
|
|
// add entities to the world
|
2020-07-10 04:18:35 +00:00
|
|
|
commands
|
2020-04-20 02:29:33 +00:00
|
|
|
// mesh
|
2020-07-10 04:18:35 +00:00
|
|
|
.spawn(PbrComponents {
|
2020-04-20 02:29:33 +00:00
|
|
|
mesh: mesh_handle,
|
|
|
|
material: material_handle,
|
|
|
|
..Default::default()
|
|
|
|
})
|
|
|
|
// light
|
2020-07-10 04:18:35 +00:00
|
|
|
.spawn(LightComponents {
|
2020-06-24 22:29:10 +00:00
|
|
|
translation: Translation::new(4.0, 5.0, 4.0),
|
2020-04-20 02:29:33 +00:00
|
|
|
..Default::default()
|
|
|
|
})
|
|
|
|
// camera
|
2020-07-20 00:00:08 +00:00
|
|
|
.spawn(Camera3dComponents {
|
2020-06-24 02:15:05 +00:00
|
|
|
transform: Transform::new_sync_disabled(Mat4::face_toward(
|
2020-06-24 22:29:10 +00:00
|
|
|
Vec3::new(-2.0, 2.0, 6.0),
|
2020-04-20 02:29:33 +00:00
|
|
|
Vec3::new(0.0, 0.0, 0.0),
|
2020-06-24 22:29:10 +00:00
|
|
|
Vec3::new(0.0, 1.0, 0.0),
|
2020-04-20 02:29:33 +00:00
|
|
|
)),
|
|
|
|
..Default::default()
|
|
|
|
});
|
2020-01-11 09:59:39 +00:00
|
|
|
}
|