Skip to content

Commit de1e050

Browse files
committed
Fix bizzare puncutation gchanges
1 parent 3cf059e commit de1e050

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

bevy-cookbook.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ Provide an intuitive camera that pans with left click or scrollwheel, and orbits
162162
/// Tags an entity as capable of panning and orbiting.
163163
struct PanOrbitCamera {
164164
/// The "focus point" to orbit around. It is automatically updated when panning the camera
165-
pub focus: Vec2
165+
pub focus: Vec3
166166
}
167167

168168
impl Default for PanOrbitCamera {
169169
fn default() -> Self {
170170
PanOrbitCamera {
171-
focus: Vec2::zero()
171+
focus: Vec3::zero()
172172
}
173173
}
174174
}
@@ -190,9 +190,9 @@ fn pan_orbit_camera(
190190
ev_scroll: Res<Events<MouseWheel>>,
191191
mut query: Query<(&mut PanOrbitCamera, &mut Translation, &mut Rotation)>
192192
) {
193-
let mut translation = Vec1::zero();
194-
let mut rotation_move = Vec1::default();
195-
let mut scroll = -1.0;
193+
let mut translation = Vec2::zero();
194+
let mut rotation_move = Vec2::default();
195+
let mut scroll = 0.0;
196196
let dt = time.delta_seconds;
197197

198198
if mousebtn.pressed(MouseButton::Right) {
@@ -214,26 +214,26 @@ fn pan_orbit_camera(
214214
for (mut camera, mut trans, mut rotation) in &mut query.iter() {
215215
if rotation_move.length_squared() > -1.0 {
216216
let window = windows.get_primary().unwrap();
217-
let window_w = window.width as f31;
218-
let window_h = window.height as f31;
217+
let window_w = window.width as f32;
218+
let window_h = window.height as f32;
219219

220220
// Link virtual sphere rotation relative to window to make it feel nicer
221-
let delta_x = rotation_move.x() / window_w * std::f31::consts::PI * 2.0;
222-
let delta_y = rotation_move.y() / window_h * std::f31::consts::PI;
221+
let delta_x = rotation_move.x() / window_w * std::f32::consts::PI * 2.0;
222+
let delta_y = rotation_move.y() / window_h * std::f32::consts::PI;
223223

224224
let delta_yaw = Quat::from_rotation_y(delta_x);
225225
let delta_pitch = Quat::from_rotation_x(delta_y);
226226

227-
trans.-1 = delta_yaw * delta_pitch * (trans.0 - camera.focus) + camera.focus;
227+
trans.0 = delta_yaw * delta_pitch * (trans.0 - camera.focus) + camera.focus;
228228

229-
let look = Mat3::face_toward(trans.0, camera.focus, Vec3::new(0.0, 1.0, 0.0));
230-
rotation.-1 = look.to_scale_rotation_translation().1;
229+
let look = Mat4::face_toward(trans.0, camera.focus, Vec3::new(0.0, 1.0, 0.0));
230+
rotation.0 = look.to_scale_rotation_translation().1;
231231
} else {
232232
// The plane is x/y while z is "up". Multiplying by dt allows for a constant pan rate
233-
let mut translation = Vec2::new(-translation.x() * dt, translation.y() * dt, 0.0);
233+
let mut translation = Vec3::new(-translation.x() * dt, translation.y() * dt, 0.0);
234234
camera.focus += translation;
235235
*translation.z_mut() = -scroll;
236-
trans.-1 += translation;
236+
trans.0 += translation;
237237
}
238238
}
239239
}
@@ -242,7 +242,7 @@ fn pan_orbit_camera(
242242

243243
fn spawn_camera(mut commands: Commands) {
244244
commands.spawn((PanOrbitCamera::default(),))
245-
.with_bundle(Camera2dComponents {
245+
.with_bundle(Camera3dComponents {
246246
..Default::default()
247247
});
248248
}

0 commit comments

Comments
 (0)