Skip to content

Commit

Permalink
use in example
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Jun 3, 2024
1 parent a65bdc3 commit d0f453c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion examples/mobile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use bevy::{
color::palettes::basic::*,
input::touch::TouchPhase,
input::{gestures::RotationGesture, touch::TouchPhase},
prelude::*,
window::{AppLifecycle, WindowMode},
};
Expand All @@ -15,6 +15,9 @@ fn main() {
primary_window: Some(Window {
resizable: false,
mode: WindowMode::BorderlessFullscreen,
// on iOS, gestures must be enabled.
// This doesn't work on Android
recognize_rotation_gesture: true,
..default()
}),
..default()
Expand All @@ -35,6 +38,7 @@ fn touch_camera(
mut touches: EventReader<TouchInput>,
mut camera: Query<&mut Transform, With<Camera3d>>,
mut last_position: Local<Option<Vec2>>,
mut rotations: EventReader<RotationGesture>,
) {
let window = windows.single();

Expand All @@ -55,6 +59,12 @@ fn touch_camera(
}
*last_position = Some(touch.position);
}
/// Rotation gestures only work on iOS
for rotation in rotations.read() {
let mut transform = camera.single_mut();
let forward = transform.forward();
transform.rotate_axis(forward, rotation.0 / 10.0)
}
}

/// set up a simple 3D scene
Expand Down

0 comments on commit d0f453c

Please sign in to comment.