Skip to content

Commit 1e9e253

Browse files
committed
scene_viewer: Initialize CameraController yaw, pitch with the Transform
1 parent dadfdd9 commit 1e9e253

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/tools/scene_viewer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ fn update_lights(
263263
#[derive(Component)]
264264
struct CameraController {
265265
pub enabled: bool,
266+
pub initialized: bool,
266267
pub sensitivity: f32,
267268
pub key_forward: KeyCode,
268269
pub key_back: KeyCode,
@@ -283,6 +284,7 @@ impl Default for CameraController {
283284
fn default() -> Self {
284285
Self {
285286
enabled: true,
287+
initialized: false,
286288
sensitivity: 0.5,
287289
key_forward: KeyCode::W,
288290
key_back: KeyCode::S,
@@ -316,6 +318,12 @@ fn camera_controller(
316318
}
317319

318320
for (mut transform, mut options) in query.iter_mut() {
321+
if !options.initialized {
322+
let (_roll, yaw, pitch) = transform.rotation.to_euler(EulerRot::ZYX);
323+
options.yaw = yaw;
324+
options.pitch = pitch;
325+
options.initialized = true;
326+
}
319327
if !options.enabled {
320328
continue;
321329
}

0 commit comments

Comments
 (0)