make reflection probe example frame rate independent (#12065)
# Objective
- Example reflection_probe is not frame rate independent
## Solution
- Use time delta to rotate the camera, use the same rotation speed as
the load_gltf example
31d7fcd9cb/examples/3d/load_gltf.rs (L63)
---
This commit is contained in:
parent
52f88e5672
commit
dc696c0e11
@ -9,10 +9,10 @@
|
|||||||
use bevy::core_pipeline::Skybox;
|
use bevy::core_pipeline::Skybox;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::{
|
||||||
|
f32::consts::PI,
|
||||||
// Rotation speed in radians per frame.
|
fmt::{Display, Formatter, Result as FmtResult},
|
||||||
const ROTATION_SPEED: f32 = 0.005;
|
};
|
||||||
|
|
||||||
static STOP_ROTATION_HELP_TEXT: &str = "Press Enter to stop rotation";
|
static STOP_ROTATION_HELP_TEXT: &str = "Press Enter to stop rotation";
|
||||||
static START_ROTATION_HELP_TEXT: &str = "Press Enter to start rotation";
|
static START_ROTATION_HELP_TEXT: &str = "Press Enter to start rotation";
|
||||||
@ -311,6 +311,7 @@ fn create_camera_environment_map_light(cubemaps: &Cubemaps) -> EnvironmentMapLig
|
|||||||
|
|
||||||
// Rotates the camera a bit every frame.
|
// Rotates the camera a bit every frame.
|
||||||
fn rotate_camera(
|
fn rotate_camera(
|
||||||
|
time: Res<Time>,
|
||||||
mut camera_query: Query<&mut Transform, With<Camera3d>>,
|
mut camera_query: Query<&mut Transform, With<Camera3d>>,
|
||||||
app_status: Res<AppStatus>,
|
app_status: Res<AppStatus>,
|
||||||
) {
|
) {
|
||||||
@ -319,7 +320,7 @@ fn rotate_camera(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for mut transform in camera_query.iter_mut() {
|
for mut transform in camera_query.iter_mut() {
|
||||||
transform.translation = Vec2::from_angle(ROTATION_SPEED)
|
transform.translation = Vec2::from_angle(time.delta_seconds() * PI / 5.0)
|
||||||
.rotate(transform.translation.xz())
|
.rotate(transform.translation.xz())
|
||||||
.extend(transform.translation.y)
|
.extend(transform.translation.y)
|
||||||
.xzy();
|
.xzy();
|
||||||
|
Loading…
Reference in New Issue
Block a user