Skip to content

Commit

Permalink
Add instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
richchurcher committed Sep 8, 2024
1 parent ac232eb commit 0025df5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions examples/3d/orthographic_zoom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// Camera3dBundle defaults to using a PerspectiveProjection
// Find the middle of the zoom range
let initial_scale = (CAMERA_ZOOM_RANGE.end - CAMERA_ZOOM_RANGE.start) / 2.0;

commands.spawn(Camera3dBundle {
projection: OrthographicProjection {
scaling_mode: ScalingMode::FixedVertical(initial_scale),
..default()
}
.into(),
transform: Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
Expand Down Expand Up @@ -76,7 +83,7 @@ fn camera_controls(
// Accumulate mouse wheel inputs for this tick
// TODO: going away in 0.15 with AccumulatedMouseScroll
let delta_zoom: f32 = mouse_wheel_input.read().map(|e| e.y).sum();
if delta_zoom != 0.0 {
if delta_zoom == 0.0 {
return;
}

Expand Down
4 changes: 3 additions & 1 deletion examples/3d/perspective_zoom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ fn setup(
transform: Transform::from_xyz(3.0, 8.0, 5.0),
..default()
});

info!("Zoom in and out with mouse wheel.");
info!("Orbit camera with A and D.");
}

fn camera_controls(
Expand Down Expand Up @@ -87,6 +90,5 @@ fn camera_controls(
// Adjust the field of view, but keep it within our stated range
perspective.fov = (perspective.fov + CAMERA_ZOOM_SPEED * delta_zoom)
.clamp(CAMERA_ZOOM_RANGE.start, CAMERA_ZOOM_RANGE.end);
dbg!(perspective.fov);
}
}

0 comments on commit 0025df5

Please sign in to comment.