From c927f3cb31b93fe3320196c57e3bbc3345bb401e Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 02:26:49 +0200 Subject: [PATCH 01/50] Enable glTF coordinate conversion in examples --- Cargo.toml | 248 +++++++++++++++++++++++++++-------------------------- 1 file changed, 126 insertions(+), 122 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f047040bdc..6c92a5efa9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,29 +15,29 @@ rust-version = "1.88.0" [workspace] resolver = "2" members = [ - # All of Bevy's official crates are within the `crates` folder! - "crates/*", - # Several crates with macros have "compile fail" tests nested inside them, also known as UI - # tests, that verify diagnostic output does not accidentally change. - # TODO: Use a glob pattern once they are fixed in `dependabot-core` - # TODO: See https://github.com/bevyengine/bevy/issues/17876 for context. - "crates/bevy_derive/compile_fail", - "crates/bevy_ecs/compile_fail", - "crates/bevy_reflect/compile_fail", - # Examples of compiling Bevy for mobile platforms. - "examples/mobile", - # Examples of using Bevy on no_std platforms. - "examples/no_std/*", - # Benchmarks - "benches", - # Internal tools that are not published. - "tools/*", - # Bevy's error codes. This is a crate so we can automatically check all of the code blocks. - "errors", + # All of Bevy's official crates are within the `crates` folder! + "crates/*", + # Several crates with macros have "compile fail" tests nested inside them, also known as UI + # tests, that verify diagnostic output does not accidentally change. + # TODO: Use a glob pattern once they are fixed in `dependabot-core` + # TODO: See https://github.com/bevyengine/bevy/issues/17876 for context. + "crates/bevy_derive/compile_fail", + "crates/bevy_ecs/compile_fail", + "crates/bevy_reflect/compile_fail", + # Examples of compiling Bevy for mobile platforms. + "examples/mobile", + # Examples of using Bevy on no_std platforms. + "examples/no_std/*", + # Benchmarks + "benches", + # Internal tools that are not published. + "tools/*", + # Bevy's error codes. This is a crate so we can automatically check all of the code blocks. + "errors", ] exclude = [ - # Integration tests are not part of the workspace - "tests-integration", + # Integration tests are not part of the workspace + "tests-integration", ] [workspace.lints.clippy] @@ -124,49 +124,49 @@ unused_qualifications = "warn" [features] default = [ - "std", - "async_executor", - "android-game-activity", - "android_shared_stdcxx", - "animation", - "bevy_asset", - "bevy_audio", - "bevy_color", - "bevy_core_pipeline", - "bevy_core_widgets", - "bevy_anti_aliasing", - "bevy_gilrs", - "bevy_gizmos", - "bevy_gltf", - "bevy_input_focus", - "bevy_log", - "bevy_mesh_picking_backend", - "bevy_pbr", - "bevy_picking", - "bevy_render", - "bevy_scene", - "bevy_sprite", - "bevy_sprite_picking_backend", - "bevy_state", - "bevy_text", - "bevy_ui", - "bevy_ui_picking_backend", - "bevy_ui_render", - "bevy_window", - "bevy_winit", - "custom_cursor", - "default_font", - "hdr", - "multi_threaded", - "png", - "smaa_luts", - "sysinfo_plugin", - "tonemapping_luts", - "vorbis", - "webgl2", - "x11", - "debug", - "zstd_rust", + "std", + "async_executor", + "android-game-activity", + "android_shared_stdcxx", + "animation", + "bevy_asset", + "bevy_audio", + "bevy_color", + "bevy_core_pipeline", + "bevy_core_widgets", + "bevy_anti_aliasing", + "bevy_gilrs", + "bevy_gizmos", + "bevy_gltf", + "bevy_input_focus", + "bevy_log", + "bevy_mesh_picking_backend", + "bevy_pbr", + "bevy_picking", + "bevy_render", + "bevy_scene", + "bevy_sprite", + "bevy_sprite_picking_backend", + "bevy_state", + "bevy_text", + "bevy_ui", + "bevy_ui_picking_backend", + "bevy_ui_render", + "bevy_window", + "bevy_winit", + "custom_cursor", + "default_font", + "hdr", + "multi_threaded", + "png", + "smaa_luts", + "sysinfo_plugin", + "tonemapping_luts", + "vorbis", + "webgl2", + "x11", + "debug", + "zstd_rust", ] # Recommended defaults for no_std applications @@ -174,20 +174,20 @@ default_no_std = ["libm", "critical-section", "bevy_color", "bevy_state"] # Provides an implementation for picking meshes bevy_mesh_picking_backend = [ - "bevy_picking", - "bevy_internal/bevy_mesh_picking_backend", + "bevy_picking", + "bevy_internal/bevy_mesh_picking_backend", ] # Provides an implementation for picking sprites bevy_sprite_picking_backend = [ - "bevy_picking", - "bevy_internal/bevy_sprite_picking_backend", + "bevy_picking", + "bevy_internal/bevy_sprite_picking_backend", ] # Provides an implementation for picking UI bevy_ui_picking_backend = [ - "bevy_picking", - "bevy_internal/bevy_ui_picking_backend", + "bevy_picking", + "bevy_internal/bevy_ui_picking_backend", ] # Provides a debug overlay for bevy UI @@ -213,16 +213,16 @@ bevy_color = ["bevy_internal/bevy_color"] # Provides cameras and other basic render pipeline features bevy_core_pipeline = [ - "bevy_internal/bevy_core_pipeline", - "bevy_asset", - "bevy_render", + "bevy_internal/bevy_core_pipeline", + "bevy_asset", + "bevy_render", ] # Provides various anti aliasing solutions bevy_anti_aliasing = [ - "bevy_internal/bevy_anti_aliasing", - "bevy_asset", - "bevy_render", + "bevy_internal/bevy_anti_aliasing", + "bevy_asset", + "bevy_render", ] # Adds gamepad support @@ -233,11 +233,11 @@ bevy_gltf = ["bevy_internal/bevy_gltf", "bevy_asset", "bevy_scene", "bevy_pbr"] # Adds PBR rendering bevy_pbr = [ - "bevy_internal/bevy_pbr", - "bevy_asset", - "bevy_render", - "bevy_core_pipeline", - "bevy_anti_aliasing", + "bevy_internal/bevy_pbr", + "bevy_asset", + "bevy_render", + "bevy_core_pipeline", + "bevy_anti_aliasing", ] # Provides picking functionality @@ -251,20 +251,20 @@ bevy_scene = ["bevy_internal/bevy_scene", "bevy_asset"] # Provides raytraced lighting (experimental) bevy_solari = [ - "bevy_internal/bevy_solari", - "bevy_asset", - "bevy_core_pipeline", - "bevy_pbr", - "bevy_render", + "bevy_internal/bevy_solari", + "bevy_asset", + "bevy_core_pipeline", + "bevy_pbr", + "bevy_render", ] # Provides sprite functionality bevy_sprite = [ - "bevy_internal/bevy_sprite", - "bevy_render", - "bevy_core_pipeline", - "bevy_color", - "bevy_anti_aliasing", + "bevy_internal/bevy_sprite", + "bevy_render", + "bevy_core_pipeline", + "bevy_color", + "bevy_anti_aliasing", ] # Provides text functionality @@ -272,12 +272,12 @@ bevy_text = ["bevy_internal/bevy_text", "bevy_asset", "bevy_sprite"] # A custom ECS-driven UI framework bevy_ui = [ - "bevy_internal/bevy_ui", - "bevy_core_pipeline", - "bevy_text", - "bevy_sprite", - "bevy_color", - "bevy_anti_aliasing", + "bevy_internal/bevy_ui", + "bevy_core_pipeline", + "bevy_text", + "bevy_sprite", + "bevy_color", + "bevy_anti_aliasing", ] # Provides rendering functionality for bevy_ui @@ -327,9 +327,9 @@ trace_tracy = ["trace", "bevy_internal/trace_tracy"] # Tracing support, with memory profiling, exposing a port for Tracy trace_tracy_memory = [ - "trace", - "bevy_internal/trace_tracy", - "bevy_internal/trace_tracy_memory", + "trace", + "bevy_internal/trace_tracy", + "bevy_internal/trace_tracy_memory", ] # Tracing support @@ -499,7 +499,7 @@ pbr_light_textures = ["bevy_internal/pbr_light_textures"] # Enable support for multi-layer material textures in the `StandardMaterial`, at the risk of blowing past the global, per-shader texture limit on older/lower-end GPUs pbr_multi_layer_material_textures = [ - "bevy_internal/pbr_multi_layer_material_textures", + "bevy_internal/pbr_multi_layer_material_textures", ] # Enable support for anisotropy texture in the `StandardMaterial`, at the risk of blowing past the global, per-shader texture limit on older/lower-end GPUs @@ -528,8 +528,8 @@ embedded_watcher = ["bevy_internal/embedded_watcher"] # Enable stepping-based debugging of Bevy systems bevy_debug_stepping = [ - "bevy_internal/bevy_debug_stepping", - "bevy_internal/debug", + "bevy_internal/bevy_debug_stepping", + "bevy_internal/debug", ] # Enables the meshlet renderer for dense high-poly scenes (experimental) @@ -576,7 +576,7 @@ hotpatching = ["bevy_internal/hotpatching"] # Enable converting glTF coordinates to Bevy's coordinate system by default. This will be Bevy's default behavior starting in 0.18. gltf_convert_coordinates_default = [ - "bevy_internal/gltf_convert_coordinates_default", + "bevy_internal/gltf_convert_coordinates_default", ] # Enable collecting debug information about systems and components to help with diagnostics @@ -605,6 +605,10 @@ bevy_state = { path = "crates/bevy_state", version = "0.17.0-dev", default-featu bevy_asset = { path = "crates/bevy_asset", version = "0.17.0-dev", default-features = false } bevy_reflect = { path = "crates/bevy_reflect", version = "0.17.0-dev", default-features = false } bevy_image = { path = "crates/bevy_image", version = "0.17.0-dev", default-features = false } +# Opt into the new default glTF coordinate conversion that will be the default in 0.18.0 +bevy_gltf = { path = "crates/bevy_gltf", version = "0.17.0-dev", default-features = false, features = [ + "gltf_convert_coordinates_default", +] } bevy_gizmos = { path = "crates/bevy_gizmos", version = "0.17.0-dev", default-features = false } # Needed to poll Task examples futures-lite = "2.0.1" @@ -1467,17 +1471,17 @@ category = "3D Rendering" # Requires compute shaders and WGPU extensions, not supported by WebGL nor WebGPU. wasm = false setup = [ - [ - "mkdir", - "-p", - "assets/external/models", - ], - [ - "curl", - "-o", - "assets/external/models/bunny.meshlet_mesh", - "https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/7a7c14138021f63904b584d5f7b73b695c7f4bbf/bunny.meshlet_mesh", - ], + [ + "mkdir", + "-p", + "assets/external/models", + ], + [ + "curl", + "-o", + "assets/external/models/bunny.meshlet_mesh", + "https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/7a7c14138021f63904b584d5f7b73b695c7f4bbf/bunny.meshlet_mesh", + ], ] [[example]] @@ -4368,13 +4372,13 @@ panic = "abort" # with `--cfg docsrs` (and thus fail to compile) we use a different cfg. rustc-args = ["--cfg", "docsrs_dep"] rustdoc-args = [ - "-Zunstable-options", - "--generate-link-to-definition", - # Embed tags to the top of documentation pages for common Bevy traits - # that are implemented by the current type, like `Component` or `Resource`. - # This makes it easier to see at a glance what types are used for. - "--html-after-content", - "docs-rs/trait-tags.html", + "-Zunstable-options", + "--generate-link-to-definition", + # Embed tags to the top of documentation pages for common Bevy traits + # that are implemented by the current type, like `Component` or `Resource`. + # This makes it easier to see at a glance what types are used for. + "--html-after-content", + "docs-rs/trait-tags.html", ] all-features = true cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] From 4c66c3c5f5fd736f87f488a7fe430326fadd4cce Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 02:30:49 +0200 Subject: [PATCH 02/50] Port anisotropy --- examples/3d/anisotropy.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/3d/anisotropy.rs b/examples/3d/anisotropy.rs index edb0e92539..9db1316349 100644 --- a/examples/3d/anisotropy.rs +++ b/examples/3d/anisotropy.rs @@ -11,7 +11,7 @@ use bevy::{ }; /// The initial position of the camera. -const CAMERA_INITIAL_POSITION: Vec3 = vec3(-0.4, 0.0, 0.0); +const CAMERA_INITIAL_POSITION: Vec3 = vec3(0.4, 0.0, 0.0); /// The current settings of the app, as chosen by the user. #[derive(Resource)] @@ -107,7 +107,7 @@ fn setup(mut commands: Commands, asset_server: Res, app_status: Res commands.spawn(( SceneRoot(asset_server.load("models/AnisotropyBarnLamp/AnisotropyBarnLamp.gltf#Scene0")), - Transform::from_xyz(0.0, 0.07, -0.13), + Transform::from_xyz(0.0, 0.07, 0.13), Scene::BarnLamp, )); From 0fc670fbd4e1e43e40c78e88e901b41fba6b9bb7 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 02:34:35 +0200 Subject: [PATCH 03/50] Port anti_aliasing --- examples/3d/anti_aliasing.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/3d/anti_aliasing.rs b/examples/3d/anti_aliasing.rs index fd93625c0e..101a61ee16 100644 --- a/examples/3d/anti_aliasing.rs +++ b/examples/3d/anti_aliasing.rs @@ -279,9 +279,13 @@ fn setup( } // Flight Helmet - commands.spawn(SceneRoot(asset_server.load( - GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf"), - ))); + commands.spawn(( + SceneRoot( + asset_server + .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")), + ), + Transform::from_rotation(Quat::from_rotation_y(PI)), + )); // Light commands.spawn(( From f695bef4c7f1f3909278a1c492fc3bbef4c7f0de Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 02:37:50 +0200 Subject: [PATCH 04/50] Port atmosphere --- examples/3d/atmosphere.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/3d/atmosphere.rs b/examples/3d/atmosphere.rs index edc6d04dab..acda245244 100644 --- a/examples/3d/atmosphere.rs +++ b/examples/3d/atmosphere.rs @@ -110,7 +110,7 @@ fn setup_terrain_scene( ), Transform::from_xyz(-1.0, 0.0, -0.5) .with_scale(Vec3::splat(0.5)) - .with_rotation(Quat::from_rotation_y(PI / 2.0)), + .with_rotation(Quat::from_rotation_y(-PI / 2.0)), )); } From 12dda344d8c138666c585e39da69553c3f0fddb8 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 02:40:32 +0200 Subject: [PATCH 05/50] Port atmospheric_fog --- examples/3d/atmospheric_fog.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/3d/atmospheric_fog.rs b/examples/3d/atmospheric_fog.rs index e24736cdd1..84760d14a3 100644 --- a/examples/3d/atmospheric_fog.rs +++ b/examples/3d/atmospheric_fog.rs @@ -7,6 +7,8 @@ //! | `Spacebar` | Toggle Atmospheric Fog | //! | `S` | Toggle Directional Light Fog Influence | +use std::f32::consts::PI; + use bevy::{ pbr::{CascadeShadowConfigBuilder, NotShadowCaster}, prelude::*, @@ -66,9 +68,12 @@ fn setup_terrain_scene( )); // Terrain - commands.spawn(SceneRoot(asset_server.load( - GltfAssetLabel::Scene(0).from_asset("models/terrain/Mountains.gltf"), - ))); + commands.spawn(( + SceneRoot( + asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/terrain/Mountains.gltf")), + ), + Transform::from_rotation(Quat::from_rotation_y(PI)), + )); // Sky commands.spawn(( From 58ff9704d9b773953faa2058f11ceac4bcee2622 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 02:56:01 +0200 Subject: [PATCH 06/50] Port color_grading --- examples/3d/color_grading.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/3d/color_grading.rs b/examples/3d/color_grading.rs index 7a9971b5c2..65bc5ed919 100644 --- a/examples/3d/color_grading.rs +++ b/examples/3d/color_grading.rs @@ -335,7 +335,7 @@ fn add_camera(commands: &mut Commands, asset_server: &AssetServer, color_grading commands.spawn(( Camera3d::default(), Hdr, - Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), + Transform::from_xyz(-0.7, 0.7, -1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y), color_grading, DistanceFog { color: Color::srgb_u8(43, 44, 47), @@ -366,7 +366,7 @@ fn add_basic_scene(commands: &mut Commands, asset_server: &AssetServer) { asset_server .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")), ), - Transform::from_xyz(0.5, 0.0, -0.5).with_rotation(Quat::from_rotation_y(-0.15 * PI)), + Transform::from_xyz(-0.5, 0.0, 0.5).with_rotation(Quat::from_rotation_y(-0.15 * PI)), )); // Spawn the light. @@ -376,7 +376,12 @@ fn add_basic_scene(commands: &mut Commands, asset_server: &AssetServer) { shadows_enabled: true, ..default() }, - Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + Transform::from_rotation(Quat::from_euler( + EulerRot::ZYX, + 0.0, + PI * -0.15 + PI, + PI * -0.15, + )), CascadeShadowConfigBuilder { maximum_distance: 3.0, first_cascade_far_bound: 0.9, From 1c57fa2eaaeb1aaa6e5cd671cb5c7a661c3beabc Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 02:59:12 +0200 Subject: [PATCH 07/50] Port deferred_rendering --- examples/3d/deferred_rendering.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/3d/deferred_rendering.rs b/examples/3d/deferred_rendering.rs index 6f51cff8c2..cc9fa05125 100644 --- a/examples/3d/deferred_rendering.rs +++ b/examples/3d/deferred_rendering.rs @@ -75,10 +75,13 @@ fn setup( let helmet_scene = asset_server .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")); - commands.spawn(SceneRoot(helmet_scene.clone())); + commands.spawn(( + SceneRoot(helmet_scene.clone()), + Transform::from_rotation(Quat::from_rotation_y(PI)), + )); commands.spawn(( SceneRoot(helmet_scene), - Transform::from_xyz(-4.0, 0.0, -3.0), + Transform::from_xyz(-4.0, 0.0, -3.0).with_rotation(Quat::from_rotation_y(PI)), )); let mut forward_mat: StandardMaterial = Color::srgb(0.1, 0.2, 0.1).into(); From 29d92bf9dda159de043fe48add6d0fa91380e7b3 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 03:12:15 +0200 Subject: [PATCH 08/50] Convert lights with the camera transform --- crates/bevy_gltf/src/convert_coordinates.rs | 1 + crates/bevy_gltf/src/loader/gltf_ext/scene.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bevy_gltf/src/convert_coordinates.rs b/crates/bevy_gltf/src/convert_coordinates.rs index 4148cecd9a..e289929348 100644 --- a/crates/bevy_gltf/src/convert_coordinates.rs +++ b/crates/bevy_gltf/src/convert_coordinates.rs @@ -24,6 +24,7 @@ pub(crate) trait ConvertCameraCoordinates { /// - up: Y /// - right: X /// + /// The same convention is used for lights. /// See fn convert_camera_coordinates(self) -> Self; } diff --git a/crates/bevy_gltf/src/loader/gltf_ext/scene.rs b/crates/bevy_gltf/src/loader/gltf_ext/scene.rs index 3fce51d527..d02a131002 100644 --- a/crates/bevy_gltf/src/loader/gltf_ext/scene.rs +++ b/crates/bevy_gltf/src/loader/gltf_ext/scene.rs @@ -45,7 +45,7 @@ pub(crate) fn node_transform(node: &Node, convert_coordinates: bool) -> Transfor }, }; if convert_coordinates { - if node.camera().is_some() { + if node.camera().is_some() || node.light().is_some() { transform.convert_camera_coordinates() } else { transform.convert_coordinates() From 38e6eb0a7d9bd02290733b9a8c30178b24cef3c0 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 03:12:22 +0200 Subject: [PATCH 09/50] Port depth_of_field --- examples/3d/depth_of_field.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/3d/depth_of_field.rs b/examples/3d/depth_of_field.rs index 7658fdea07..709f616fa2 100644 --- a/examples/3d/depth_of_field.rs +++ b/examples/3d/depth_of_field.rs @@ -9,6 +9,8 @@ //! //! [a blog post on depth of field in Unity]: https://catlikecoding.com/unity/tutorials/advanced-rendering/depth-of-field/ +use std::f32::consts::PI; + use bevy::{ core_pipeline::{ bloom::Bloom, @@ -84,9 +86,15 @@ fn setup(mut commands: Commands, asset_server: Res, app_settings: R } // Spawn the scene. - commands.spawn(SceneRoot(asset_server.load( - GltfAssetLabel::Scene(0).from_asset("models/DepthOfFieldExample/DepthOfFieldExample.glb"), - ))); + commands.spawn(( + SceneRoot( + asset_server.load( + GltfAssetLabel::Scene(0) + .from_asset("models/DepthOfFieldExample/DepthOfFieldExample.glb"), + ), + ), + Transform::from_rotation(Quat::from_rotation_y(PI)), + )); // Spawn the help text. commands.spawn(( From a37456cc25d24a394fe25cb4633c4c1b60444df2 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 03:16:58 +0200 Subject: [PATCH 10/50] Port edit_material_on_gltf --- examples/3d/edit_material_on_gltf.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/3d/edit_material_on_gltf.rs b/examples/3d/edit_material_on_gltf.rs index 97c3c48296..2fa537a505 100644 --- a/examples/3d/edit_material_on_gltf.rs +++ b/examples/3d/edit_material_on_gltf.rs @@ -29,12 +29,12 @@ struct ColorOverride(Color); fn setup_scene(mut commands: Commands, asset_server: Res) { commands.spawn(( Camera3d::default(), - Transform::from_xyz(0., 1., 2.5).looking_at(Vec3::new(0., 0.25, 0.), Dir3::Y), + Transform::from_xyz(0., 1., -2.5).looking_at(Vec3::new(0., 0.25, 0.), Dir3::Y), )); commands.spawn(( DirectionalLight::default(), - Transform::from_xyz(0., 1., 0.25).looking_at(Vec3::ZERO, Dir3::Y), + Transform::from_xyz(0., 1., -0.25).looking_at(Vec3::ZERO, Dir3::Y), )); // FlightHelmet handle @@ -42,18 +42,18 @@ fn setup_scene(mut commands: Commands, asset_server: Res) { .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")); // This model will keep its original materials commands.spawn(SceneRoot(flight_helmet.clone())); - // This model will be tinted red - commands.spawn(( - SceneRoot(flight_helmet.clone()), - Transform::from_xyz(-1.25, 0., 0.), - ColorOverride(palettes::tailwind::RED_300.into()), - )); // This model will be tinted green commands.spawn(( - SceneRoot(flight_helmet), + SceneRoot(flight_helmet.clone()), Transform::from_xyz(1.25, 0., 0.), ColorOverride(palettes::tailwind::GREEN_300.into()), )); + // This model will be tinted red + commands.spawn(( + SceneRoot(flight_helmet), + Transform::from_xyz(-1.25, 0., 0.), + ColorOverride(palettes::tailwind::RED_300.into()), + )); } fn change_material( From ebd0ad50127727b11c2883cc7bbd9a7a089632a1 Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sat, 12 Jul 2025 03:23:28 +0200 Subject: [PATCH 11/50] Fix frame dependent rotation speed while I'm on it --- examples/3d/light_textures.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/3d/light_textures.rs b/examples/3d/light_textures.rs index c7cfb86f88..bbb5d0f4bd 100644 --- a/examples/3d/light_textures.rs +++ b/examples/3d/light_textures.rs @@ -22,8 +22,8 @@ use widgets::{ #[path = "../helpers/widgets.rs"] mod widgets; -/// The speed at which the cube rotates, in radians per frame. -const CUBE_ROTATION_SPEED: f32 = 0.02; +/// The speed at which the cube rotates, in radians per second. +const CUBE_ROTATION_SPEED: f32 = FRAC_PI_2; /// The speed at which the selection can be moved, in spherical coordinate /// radians per mouse unit. @@ -381,9 +381,9 @@ fn draw_gizmos(mut gizmos: Gizmos, spotlight: Query<(&GlobalTransform, &SpotLigh } /// Rotates the cube a bit every frame. -fn rotate_cube(mut meshes: Query<&mut Transform, With>) { +fn rotate_cube(mut meshes: Query<&mut Transform, With>, time: Res