From 0025df5d29fadc874482f6c4bb3774435cab038a Mon Sep 17 00:00:00 2001 From: Rich Churcher Date: Sun, 8 Sep 2024 20:01:11 +1200 Subject: [PATCH] Add instructions --- examples/3d/orthographic_zoom.rs | 11 +++++++++-- examples/3d/perspective_zoom.rs | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/3d/orthographic_zoom.rs b/examples/3d/orthographic_zoom.rs index 5d8a43d440bff2..07092a282054e1 100644 --- a/examples/3d/orthographic_zoom.rs +++ b/examples/3d/orthographic_zoom.rs @@ -25,8 +25,15 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - // 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() }); @@ -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; } diff --git a/examples/3d/perspective_zoom.rs b/examples/3d/perspective_zoom.rs index 871a34a35db31c..75caa82c71d404 100644 --- a/examples/3d/perspective_zoom.rs +++ b/examples/3d/perspective_zoom.rs @@ -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( @@ -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); } }