Skip to content

Commit ba71a21

Browse files
committed
Actually do some rendering for testing
1 parent 8facad9 commit ba71a21

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

examples/window/expanding_window.rs

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ fn main() {
1818
.run();
1919
}
2020

21-
fn setup(mut commands: Commands) {
22-
commands.spawn_bundle(OrthographicCameraBundle::new_3d());
23-
}
24-
2521
enum Phase {
2622
ContractingY,
2723
ContractingX,
@@ -31,7 +27,17 @@ enum Phase {
3127

3228
use Phase::*;
3329

34-
fn change_window_size(mut windows: ResMut<Windows>, mut phase: ResMut<Phase>) {
30+
fn change_window_size(
31+
mut windows: ResMut<Windows>,
32+
mut phase: ResMut<Phase>,
33+
mut first_complete: Local<bool>,
34+
) {
35+
// Put off rendering for one frame, as currently for a frame where
36+
// resizing happens, nothing is presented.
37+
if !*first_complete {
38+
*first_complete = true;
39+
return;
40+
}
3541
let primary = windows.get_primary_mut().unwrap();
3642
let height = primary.height();
3743
let width = primary.width();
@@ -62,3 +68,39 @@ fn change_window_size(mut windows: ResMut<Windows>, mut phase: ResMut<Phase>) {
6268
}
6369
}
6470
}
71+
72+
/// A simple 3d scene, taken from the `3d_scene` example
73+
fn setup(
74+
mut commands: Commands,
75+
mut meshes: ResMut<Assets<Mesh>>,
76+
mut materials: ResMut<Assets<StandardMaterial>>,
77+
) {
78+
// plane
79+
commands.spawn_bundle(PbrBundle {
80+
mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })),
81+
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
82+
..default()
83+
});
84+
// cube
85+
commands.spawn_bundle(PbrBundle {
86+
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
87+
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
88+
transform: Transform::from_xyz(0.0, 0.5, 0.0),
89+
..default()
90+
});
91+
// light
92+
commands.spawn_bundle(PointLightBundle {
93+
point_light: PointLight {
94+
intensity: 1500.0,
95+
shadows_enabled: true,
96+
..default()
97+
},
98+
transform: Transform::from_xyz(4.0, 8.0, 4.0),
99+
..default()
100+
});
101+
// camera
102+
commands.spawn_bundle(PerspectiveCameraBundle {
103+
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
104+
..default()
105+
});
106+
}

0 commit comments

Comments
 (0)