-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimal.rs
69 lines (67 loc) · 2.25 KB
/
minimal.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use bevy::{prelude::*, window::PresentMode};
use bevy_mod_picking::DefaultPickingPlugins;
use bevy_transform_gizmo::TransformGizmoPlugin;
fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.insert_resource(ClearColor(Color::BLACK))
.add_plugins((
DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
present_mode: PresentMode::Immediate,
..default()
}),
..default()
}),
DefaultPickingPlugins,
TransformGizmoPlugin::new(
Quat::from_rotation_y(-0.2), // Align the gizmo to a different coordinate system.
// Use TransformGizmoPlugin::default() to align to the
// scene's coordinate system.
),
))
.add_systems(Startup, setup)
.run();
}
/// set up a simple 3D scene
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// plane
commands.spawn((
PbrBundle {
mesh: meshes.add(Plane3d::default()),
material: materials.add(Color::rgb(0.8, 0.8, 0.8)),
transform: Transform::from_scale(Vec3::splat(5.0)),
..Default::default()
},
bevy_mod_picking::PickableBundle::default(),
bevy_transform_gizmo::GizmoTransformable,
));
// cube
commands.spawn((
PbrBundle {
mesh: meshes.add(Cuboid::from_size(Vec3::splat(1.0))),
material: materials.add(Color::rgb(0.8, 0.8, 0.8)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
},
bevy_mod_picking::PickableBundle::default(),
bevy_transform_gizmo::GizmoTransformable,
));
// light
commands.spawn(PointLightBundle {
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..Default::default()
});
// camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
},
bevy_transform_gizmo::GizmoPickSource::default(),
));
}