crcbl_render/fly.rs
1//! The free-fly camera: keys and mouse deltas in, a [`Camera`] out.
2//!
3//! ```text
4//! key(code, pressed) ─┐
5//! advance(dt) ────────┼─▶ Flyer { eye, yaw, pitch, speed } ─▶ Camera
6//! look(motion) ───────┘
7//! ```
8//!
9//! Lantern's plan asked for "a free-fly camera, a fixed
10//! camera set for goldens". The two are the same [`Camera`] type and the same
11//! projection — what differs is whether anything moves it — so this module is
12//! the moving half, and the pose it starts at is the app's to choose. It is here
13//! beside [`OrbitCamera`](crate::OrbitCamera) rather than in a sample for the
14//! same reason that one is: it is arithmetic, it needs no device, and every one
15//! of its claims is a unit test.
16//!
17//! # Why it is stepped on the fixed timestep
18//!
19//! [`Flyer::advance`] is meant to be called from `tick`, not from `draw`. A
20//! camera integrated on the frame rate flies at a speed proportional to how fast
21//! the machine is, which makes "walk to the corner and look at the contact
22//! shadow" a different journey on every machine — and it makes a headless run's
23//! camera a function of the frame budget rather than of the clock.
24//!
25//! # The mouse and the arrow keys both turn it
26//!
27//! [`Flyer::look`] is driven by `PointerUpdate::motion` — the unaccelerated
28//! delta — and never by differencing positions: an absolute position is clamped
29//! at the edge of the display and has pointer acceleration already applied, so a
30//! look built from one stops turning exactly when the cursor runs out of screen.
31//! The pointer is captured for it, which the app's `HostedGame::pointer_mode` is
32//! what asks for; a look that turned while a *visible* cursor walked out of the
33//! window would click on whatever is behind it, so [`Flyer::look`] should be
34//! called only on the frames that capture produces.
35//!
36//! The arrow keys stay, and are not a fallback: they are what a reviewer with no
37//! mouse hand free uses to nudge the framing a few degrees, and they are the
38//! only turn a shell without pointer lock has.
39
40use core::f32::consts::{FRAC_PI_2, PI};
41
42use crcbl_core::input::KeyCode;
43use glam::{Vec2, Vec3};
44
45use crate::camera::{Camera, Projection};
46
47/// How fast the camera walks by default, in metres a second.
48///
49/// A brisk walk rather than a fly-through speed, because the scene a fly camera
50/// is pointed at is usually a room-sized one: a camera that crossed a
51/// six-metre room in a second is one a reviewer overshoots every time they try
52/// to stand in the corner. A scene measured in hundreds of metres wants more,
53/// and [`Flyer::with_speed`] is how it says so.
54pub const SPEED: f32 = 2.4;
55
56/// How fast the arrow keys turn it, in radians a second.
57pub const TURN: f32 = 1.6;
58
59/// How far the view turns per pixel of mouse movement, in radians.
60///
61/// A tenth of a degree a pixel, written as that arithmetic so the number and
62/// the sentence cannot drift apart. It is a *rate* rather than a scale: the
63/// units are `PointerUpdate::motion`'s — framebuffer pixels — so the same
64/// movement of the hand turns the same amount whatever size the window is, and
65/// no aspect ratio enters into it.
66///
67/// Where the value comes from: this is the low end of what a first-person game
68/// ships as its default, and a lighting fixture wants the slow end. A reviewer's
69/// job here is to hold a highlight in frame and walk around it, not to flick
70/// onto a target.
71pub const LOOK: f32 = 0.1 * (PI / 180.0);
72
73/// How far the pitch may go from level, in radians.
74///
75/// Just short of straight up and straight down: at exactly vertical the
76/// forward vector is parallel to `up` and the view matrix is degenerate, which
77/// arrives as a frame of nothing.
78const PITCH_LIMIT: f32 = FRAC_PI_2 - 0.05;
79
80/// Which of the movement keys are down.
81///
82/// A struct of flags rather than a set, because the loop hands keys over one
83/// edge at a time and what [`Flyer::advance`] needs is the *held* state — a
84/// camera driven by edges alone would move one step per press.
85#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
86struct Held {
87 forward: bool,
88 back: bool,
89 left: bool,
90 right: bool,
91 up: bool,
92 down: bool,
93 turn_left: bool,
94 turn_right: bool,
95 look_up: bool,
96 look_down: bool,
97}
98
99/// A camera the keyboard flies.
100///
101/// Holds a position and two angles rather than a [`Camera`], because a camera is
102/// an eye and a *target*: integrating a target directly makes turning depend on
103/// how far away it happens to be.
104#[derive(Clone, Copy, Debug, PartialEq)]
105pub struct Flyer {
106 eye: Vec3,
107 /// Rotation about `+Y`, measured so that `0` looks down `-Z`.
108 yaw: f32,
109 /// Rotation away from the horizon, positive up.
110 pitch: f32,
111 /// How fast a held movement key walks, in metres a second.
112 speed: f32,
113 held: Held,
114 /// Whether any key has moved it since it was built — what a debug panel
115 /// reports, so "free-fly, and nobody has flown it" is distinguishable from
116 /// "this is the golden pose".
117 moved: bool,
118}
119
120impl Flyer {
121 /// A flyer standing where `camera` stands and looking where it looks, at
122 /// [`SPEED`].
123 ///
124 /// Starting at the golden pose is what makes a sample's free camera and its
125 /// fixed camera the same first frame: a reviewer comparing a windowed run
126 /// against a golden is comparing the same picture until they press a key.
127 #[must_use]
128 pub fn at(camera: &Camera) -> Self {
129 let forward = (camera.target - camera.eye).normalize_or_zero();
130 Self {
131 eye: camera.eye,
132 // `atan2(x, -z)`, not `atan2(z, x)`: yaw is measured from `-Z`,
133 // which is the direction a zero yaw looks.
134 yaw: forward.x.atan2(-forward.z),
135 pitch: forward.y.clamp(-1.0, 1.0).asin(),
136 speed: SPEED,
137 held: Held::default(),
138 moved: false,
139 }
140 }
141
142 /// The same flyer walking at `speed` metres a second instead of [`SPEED`].
143 ///
144 /// The default is sized for a room, and a scene that is not room-sized needs
145 /// its own number: a camera that takes a minute and a half to cross the
146 /// subject is as unusable as one that overshoots it. The turn rates are not
147 /// configurable beside it, because an angle is an angle at every scale.
148 #[must_use]
149 pub const fn with_speed(mut self, speed: f32) -> Self {
150 self.speed = speed;
151 self
152 }
153
154 /// How fast a held movement key walks it, in metres a second.
155 #[must_use]
156 pub const fn speed(&self) -> f32 {
157 self.speed
158 }
159
160 /// Whether a key has ever moved this camera.
161 #[must_use]
162 pub const fn has_moved(&self) -> bool {
163 self.moved
164 }
165
166 /// Where the camera is.
167 #[must_use]
168 pub const fn eye(&self) -> Vec3 {
169 self.eye
170 }
171
172 /// Takes a key edge, and says whether it was one of this camera's.
173 ///
174 /// Returning the answer rather than swallowing everything: the loop hands a
175 /// game every key its own three did not claim, and a camera that reported
176 /// "mine" for all of them would leave the sample unable to bind anything
177 /// else later.
178 pub const fn key(&mut self, key: KeyCode, pressed: bool) -> bool {
179 let held = &mut self.held;
180 let slot = match key {
181 KeyCode::KeyW => &mut held.forward,
182 KeyCode::KeyS => &mut held.back,
183 KeyCode::KeyA => &mut held.left,
184 KeyCode::KeyD => &mut held.right,
185 KeyCode::Space => &mut held.up,
186 KeyCode::ShiftLeft | KeyCode::ShiftRight => &mut held.down,
187 KeyCode::ArrowLeft => &mut held.turn_left,
188 KeyCode::ArrowRight => &mut held.turn_right,
189 KeyCode::ArrowUp => &mut held.look_up,
190 KeyCode::ArrowDown => &mut held.look_down,
191 _ => return false,
192 };
193 *slot = pressed;
194 true
195 }
196
197 /// Lets go of every key.
198 ///
199 /// Called when the window loses focus: a platform sends no release for a key
200 /// that was down when focus went away, so without this the camera keeps
201 /// walking into a wall for as long as the window is in the background.
202 pub fn release_all(&mut self) {
203 self.held = Held::default();
204 }
205
206 /// Turns by one frame's worth of mouse movement.
207 ///
208 /// `motion` is `PointerUpdate::motion`: framebuffer pixels, **Y down**.
209 /// That is why the pitch subtracts where the yaw adds — pushing the mouse
210 /// away from the hand is a *negative* Y and has to raise the view — and it
211 /// is the one sign in this file that no compiler can check.
212 ///
213 /// # Not on the fixed timestep, unlike [`advance`](Self::advance)
214 ///
215 /// A held key is a *rate* and has to be integrated against the clock or the
216 /// camera flies at a speed proportional to how fast the machine is. A mouse
217 /// delta is already a distance the hand moved: scaling it by `dt` would make
218 /// the same sweep turn a different amount on a slow frame, and running it
219 /// once per tick would apply one frame's movement two or three times over on
220 /// a frame that owed the clock several. So this lands where it arrives, in
221 /// the frame, exactly once.
222 pub fn look(&mut self, motion: Vec2) {
223 if motion == Vec2::ZERO {
224 return;
225 }
226 self.yaw += motion.x * LOOK;
227 self.pitch = (self.pitch - motion.y * LOOK).clamp(-PITCH_LIMIT, PITCH_LIMIT);
228 self.moved = true;
229 }
230
231 /// Advances by `dt` seconds of held input.
232 pub fn advance(&mut self, dt: f32) {
233 let axis = |positive: bool, negative: bool| f32::from(positive) - f32::from(negative);
234 // **`turn_right` first, and that order is the bug this had.** Yaw is
235 // measured from `-Z` and `ahead` is `(sin_yaw, 0, -cos_yaw)`, so a
236 // *rising* yaw swings the view toward `+X` — which is right, as `aside`
237 // below asserts by being `cross(ahead, up)` and being driven by
238 // `axis(right, left)`. Naming `turn_left` first therefore added to yaw
239 // for the left arrow and turned the camera the other way, which reached
240 // a user. Both lines now read the same way round: positive argument is
241 // the `+X` side.
242 let turn = axis(self.held.turn_right, self.held.turn_left) * TURN * dt;
243 let tilt = axis(self.held.look_up, self.held.look_down) * TURN * dt;
244 self.yaw += turn;
245 self.pitch = (self.pitch + tilt).clamp(-PITCH_LIMIT, PITCH_LIMIT);
246
247 // **Walking is on the level plane, and rising is on the world's `+Y`.**
248 // Folding the pitch into the walk would make `W` fly downhill whenever
249 // the reviewer was looking at the floor, which in an indoor scene is
250 // most of the time.
251 let (sin_yaw, cos_yaw) = self.yaw.sin_cos();
252 let ahead = Vec3::new(sin_yaw, 0.0, -cos_yaw);
253 let aside = Vec3::new(cos_yaw, 0.0, sin_yaw);
254 let step = ahead * axis(self.held.forward, self.held.back)
255 + aside * axis(self.held.right, self.held.left)
256 + Vec3::Y * axis(self.held.up, self.held.down);
257 let step = step.normalize_or_zero() * self.speed * dt;
258
259 if step != Vec3::ZERO || turn != 0.0 || tilt != 0.0 {
260 self.moved = true;
261 }
262 self.eye += step;
263 }
264
265 /// The camera this flyer is, with `projection` taken from the fixed one.
266 ///
267 /// The projection is the caller's rather than a field here because it is
268 /// the *lens*, and the whole point of the pair is that the free camera and
269 /// the golden camera see through the same one.
270 #[must_use]
271 pub fn camera(&self, projection: Projection) -> Camera {
272 let (sin_yaw, cos_yaw) = self.yaw.sin_cos();
273 let (sin_pitch, cos_pitch) = self.pitch.sin_cos();
274 let forward = Vec3::new(sin_yaw * cos_pitch, sin_pitch, -cos_yaw * cos_pitch);
275 Camera {
276 eye: self.eye,
277 target: self.eye + forward,
278 up: Vec3::Y,
279 projection,
280 }
281 }
282}
283
284#[cfg(test)]
285mod tests {
286 use super::*;
287
288 /// The pose every test here starts from.
289 ///
290 /// **Deliberately skew**: the forward vector `(-2.2, -0.7, -6.0)` has a
291 /// non-zero component on all three axes and no two of them equal, so it is
292 /// neither axis-aligned nor 45°-symmetric. That is what
293 /// [`the_turn_arrows_swing_the_view_toward_the_side_they_name`] and
294 /// [`the_mouse_swings_the_view_the_way_it_moved`] need to keep their teeth:
295 /// against a level camera looking straight down `-Z`, a swapped `atan2`
296 /// argument or a flipped sign lands on a pose that is still symmetric and
297 /// still passes.
298 fn fixture() -> Camera {
299 Camera {
300 eye: Vec3::new(1.5, 1.6, 4.0),
301 target: Vec3::new(-0.7, 0.9, -2.0),
302 up: Vec3::Y,
303 projection: Projection::default(),
304 }
305 }
306
307 /// **A flyer built from a camera reproduces that camera**, which is what
308 /// makes a sample's free-camera first frame the golden's frame.
309 ///
310 /// Round-tripping through two angles is where a sign or a swapped argument
311 /// hides: every candidate mistake produces a camera pointing somewhere
312 /// plausible in a room with walls on all sides.
313 #[test]
314 fn a_flyer_starts_looking_exactly_where_the_fixed_camera_looks() {
315 let fixed = fixture();
316 let flyer = Flyer::at(&fixed);
317 let rebuilt = flyer.camera(fixed.projection);
318 assert_eq!(rebuilt.eye, fixed.eye);
319 let want = (fixed.target - fixed.eye).normalize();
320 let got = (rebuilt.target - rebuilt.eye).normalize();
321 assert!(
322 got.dot(want) > 0.9999,
323 "the flyer looks {got:?} where the fixed camera looks {want:?}"
324 );
325 assert!(!flyer.has_moved(), "building one is not flying it");
326 }
327
328 /// Holding a key moves the camera, and letting go stops it.
329 ///
330 /// The observable is the eye, not the flag: a `moved` bit set by the key
331 /// handler rather than by the integration would report movement for a
332 /// camera that never went anywhere.
333 #[test]
334 fn holding_forward_walks_and_releasing_it_stops() {
335 let fixed = fixture();
336 let mut flyer = Flyer::at(&fixed);
337 assert!(flyer.key(KeyCode::KeyW, true), "W is the camera's");
338 flyer.advance(0.5);
339 let walked = flyer.eye();
340 assert_ne!(walked, fixed.eye, "a held key did not move the camera");
341 assert!(flyer.has_moved());
342
343 flyer.key(KeyCode::KeyW, false);
344 flyer.advance(0.5);
345 assert_eq!(flyer.eye(), walked, "a released key kept walking");
346
347 // And losing focus drops a key nobody will send a release for.
348 flyer.key(KeyCode::KeyW, true);
349 flyer.release_all();
350 flyer.advance(0.5);
351 assert_eq!(
352 flyer.eye(),
353 walked,
354 "a key held across a focus loss kept walking"
355 );
356 }
357
358 /// **[`SPEED`] is the default and [`Flyer::with_speed`] is how a scene that
359 /// is not room-sized replaces it**, both measured in metres walked.
360 ///
361 /// The observable is the distance a second of held `W` covers, not the
362 /// field: an `advance` that read the constant instead of the field would
363 /// report the new speed from [`Flyer::speed`] and still walk the old one.
364 #[test]
365 fn a_second_of_forward_walks_the_flyers_own_speed() {
366 let mut standard = Flyer::at(&fixture());
367 assert_eq!(standard.speed(), SPEED, "the default is the constant");
368 standard.key(KeyCode::KeyW, true);
369 standard.advance(1.0);
370 let walked = standard.eye().distance(fixture().eye);
371 assert!(
372 (walked - SPEED).abs() < 1e-4,
373 "a second of forward walked {walked} m at the default speed of {SPEED} m/s"
374 );
375
376 // Far enough from the default that no rounding could confuse the two,
377 // and the scale a hundred-metre subject actually wants.
378 let quick = 20.0;
379 let mut fast = Flyer::at(&fixture()).with_speed(quick);
380 assert_eq!(fast.speed(), quick, "with_speed did not take");
381 fast.key(KeyCode::KeyW, true);
382 fast.advance(1.0);
383 let flown = fast.eye().distance(fixture().eye);
384 assert!(
385 (flown - quick).abs() < 1e-3,
386 "a second of forward walked {flown} m at {quick} m/s"
387 );
388 }
389
390 /// Walking is level: looking at the floor and pressing forward walks
391 /// forward rather than down.
392 #[test]
393 fn walking_forward_does_not_follow_the_pitch_into_the_floor() {
394 let fixed = fixture();
395 let mut flyer = Flyer::at(&fixed);
396 flyer.key(KeyCode::ArrowDown, true);
397 flyer.advance(1.0);
398 flyer.key(KeyCode::ArrowDown, false);
399 let looking_down = flyer.eye();
400
401 flyer.key(KeyCode::KeyW, true);
402 flyer.advance(1.0);
403 assert!(
404 (flyer.eye().y - looking_down.y).abs() < 1e-5,
405 "walking while looking down changed the height: {:?} -> {:?}",
406 looking_down,
407 flyer.eye(),
408 );
409 // Space is what changes it.
410 flyer.key(KeyCode::KeyW, false);
411 flyer.key(KeyCode::Space, true);
412 flyer.advance(1.0);
413 assert!(flyer.eye().y > looking_down.y, "space did not rise");
414 }
415
416 /// The pitch cannot reach vertical, where the view matrix is degenerate and
417 /// the frame comes back empty.
418 #[test]
419 fn the_pitch_stops_short_of_straight_up_and_straight_down() {
420 for (key, sign) in [(KeyCode::ArrowUp, 1.0f32), (KeyCode::ArrowDown, -1.0)] {
421 let mut flyer = Flyer::at(&fixture());
422 flyer.key(key, true);
423 // Far more turning than the limit is away, so a missing clamp runs
424 // past vertical and comes back the other side.
425 for _ in 0..200 {
426 flyer.advance(0.1);
427 }
428 let camera = flyer.camera(fixture().projection);
429 let forward = (camera.target - camera.eye).normalize();
430 assert!(
431 forward.y * sign > 0.9 && forward.y.abs() < 1.0,
432 "{key:?} reached {forward:?}, which is a degenerate view"
433 );
434 let level = Vec3::new(forward.x, 0.0, forward.z).length();
435 assert!(level > 0.01, "{key:?} left no horizontal component at all");
436 }
437 }
438
439 /// **The arrow that says right turns right**, which shipped inverted.
440 ///
441 /// The pitch axis beside this one has had
442 /// [`the_pitch_stops_short_of_straight_up_and_straight_down`] asserting its
443 /// *sign* since it was written; yaw had nothing, so
444 /// `axis(turn_left, turn_right)` — whose positive argument is the left key —
445 /// added to a yaw that rises toward `+X` and reached a user turning the
446 /// camera the wrong way.
447 ///
448 /// The claim is made against the camera's **own** starting basis rather than
449 /// against a world axis, so it holds at every yaw and needs no arithmetic
450 /// about where [`fixture`] happens to look: after turning right the new
451 /// forward leans toward the old *right* vector, and after turning left, away
452 /// from it. A test comparing `yaw` would pass on a camera that stored the
453 /// angle correctly and built its basis backwards.
454 #[test]
455 fn the_turn_arrows_swing_the_view_toward_the_side_they_name() {
456 for (key, sign) in [(KeyCode::ArrowRight, 1.0f32), (KeyCode::ArrowLeft, -1.0)] {
457 let mut flyer = Flyer::at(&fixture());
458 let before = flyer.camera(fixture().projection);
459 let start = (before.target - before.eye).normalize();
460 // `cross(forward, up)` is the right-hand side in this engine's
461 // right-handed, `+Y` up, `-Z` forward world — the same vector
462 // `Flyer::advance` calls `aside` and strafes along.
463 let right = start.cross(Vec3::Y).normalize();
464
465 flyer.key(key, true);
466 // A tenth of a radian or so: far enough that the sign is not
467 // floating-point noise, short enough that the view cannot swing past
468 // the perpendicular and make a wrong sign read as a right one.
469 flyer.advance(0.05);
470
471 let after = flyer.camera(fixture().projection);
472 let turned = (after.target - after.eye).normalize();
473 let leaned = turned.dot(right);
474 assert!(
475 leaned * sign > 0.01,
476 "{key:?} moved the view {leaned} of the way toward the camera's own right \
477 vector {right:?}, and the sign says it turned the other way"
478 );
479 assert!(
480 turned.dot(start) > 0.99,
481 "{key:?} swung {turned:?} from {start:?} in one step, which is too far for the \
482 sign above to mean what it says"
483 );
484 }
485 }
486
487 /// **The mouse swings the view the way the hand moved**, which is the same
488 /// claim [`the_turn_arrows_swing_the_view_toward_the_side_they_name`] makes
489 /// for the arrow keys and the same way of making it: against the camera's
490 /// own starting basis, so it holds at every yaw and says nothing about where
491 /// [`fixture`] happens to point.
492 ///
493 /// Both axes, because a look with one sign right and the other inverted is
494 /// the ordinary shape of this bug — `motion` is **Y down** while the pitch
495 /// is measured positive up, so the two lines in [`Flyer::look`] must not
496 /// read the same way round.
497 #[test]
498 fn the_mouse_swings_the_view_the_way_it_moved() {
499 // Fifty pixels, which is five degrees: far enough that the sign is not
500 // floating-point noise, short enough that the view cannot swing past the
501 // perpendicular and make a wrong sign read as a right one.
502 let sweep = 50.0;
503 for (motion, toward_right, toward_up) in [
504 (Vec2::new(sweep, 0.0), 1.0f32, 0.0f32),
505 (Vec2::new(-sweep, 0.0), -1.0, 0.0),
506 // Y down, so a *negative* delta is the hand pushing away from the
507 // body, which raises the view.
508 (Vec2::new(0.0, -sweep), 0.0, 1.0),
509 (Vec2::new(0.0, sweep), 0.0, -1.0),
510 ] {
511 let mut flyer = Flyer::at(&fixture());
512 let before = flyer.camera(fixture().projection);
513 let start = (before.target - before.eye).normalize();
514 let right = start.cross(Vec3::Y).normalize();
515 let up = right.cross(start).normalize();
516
517 flyer.look(motion);
518
519 let after = flyer.camera(fixture().projection);
520 let turned = (after.target - after.eye).normalize();
521 assert!(
522 turned.dot(right) * toward_right > 0.01 || toward_right == 0.0,
523 "{motion:?} leaned {} toward the camera's own right {right:?}",
524 turned.dot(right),
525 );
526 assert!(
527 turned.dot(up) * toward_up > 0.01 || toward_up == 0.0,
528 "{motion:?} leaned {} toward the camera's own up {up:?}",
529 turned.dot(up),
530 );
531 assert!(
532 turned.dot(start) > 0.99,
533 "{motion:?} swung {turned:?} from {start:?} in one step, which is too far for \
534 the signs above to mean what they say"
535 );
536 assert!(flyer.has_moved(), "a look is a movement");
537 }
538
539 // And a frame that reported no movement is not one.
540 let mut still = Flyer::at(&fixture());
541 still.look(Vec2::ZERO);
542 assert!(!still.has_moved());
543 }
544
545 /// The mouse cannot flip the view over the top either.
546 ///
547 /// [`the_pitch_stops_short_of_straight_up_and_straight_down`] makes this
548 /// claim for the keys, and the clamp is shared — but the *call* is not, and
549 /// a [`Flyer::look`] that assigned the pitch without going through
550 /// [`PITCH_LIMIT`] would pass every keyboard test in this file.
551 #[test]
552 fn the_mouse_pitch_stops_short_of_vertical_too() {
553 for sign in [1.0f32, -1.0] {
554 let mut flyer = Flyer::at(&fixture());
555 // Far more than the limit is away, in one shove and then in many
556 // small ones, because a clamp applied to the delta rather than to
557 // the accumulated angle survives the first and not the second.
558 flyer.look(Vec2::new(0.0, -sign * 100_000.0));
559 for _ in 0..200 {
560 flyer.look(Vec2::new(0.0, -sign * 50.0));
561 }
562 let camera = flyer.camera(fixture().projection);
563 let forward = (camera.target - camera.eye).normalize();
564 assert!(
565 forward.y * sign > 0.9 && forward.y.abs() < 1.0,
566 "the mouse reached {forward:?}, which is a degenerate view"
567 );
568 let level = Vec3::new(forward.x, 0.0, forward.z).length();
569 assert!(
570 level > 0.01,
571 "the mouse left no horizontal component at all"
572 );
573 }
574 }
575
576 /// A key this camera does not bind is reported as somebody else's, so an app
577 /// can grow one later without the camera having swallowed it.
578 #[test]
579 fn an_unbound_key_is_not_claimed() {
580 let mut flyer = Flyer::at(&fixture());
581 assert!(!flyer.key(KeyCode::KeyQ, true));
582 flyer.advance(1.0);
583 assert!(!flyer.has_moved());
584 }
585}