From 105a0d1d0f9970e77b04efd5c9e067c9e68f34ba Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Mon, 14 Jul 2025 13:24:39 +0200 Subject: [PATCH] Rename option --- crates/bevy_gltf/src/lib.rs | 27 +++++++-------- crates/bevy_gltf/src/loader/mod.rs | 55 +++++++++++++----------------- 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index bbcb13a908..817f0e2dea 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -159,20 +159,17 @@ pub struct GltfPlugin { /// Can be modified with the [`DefaultGltfImageSampler`] resource. pub default_sampler: ImageSamplerDescriptor, - /// Whether to convert glTF coordinates to Bevy's coordinate system by default. - /// If set to `true`, the loader will convert the coordinate system of loaded glTF assets to Bevy's coordinate system - /// such that objects looking forward in glTF will also look forward in Bevy. + /// How to convert glTF coordinates on import. Assuming glTF cameras, glTF lights, and glTF meshes had global unit transforms, + /// their Bevy [`Transform::forward`](bevy_transform::components::Transform::forward) will be pointing in the following global directions: + /// - When set to `false` + /// - glTF cameras and glTF lights: global -Z, + /// - glTF models: global +Z. + /// - When set to `true` + /// - glTF cameras and glTF lights: global +Z, + /// - glTF models: global -Z. /// - /// The exact coordinate system conversion is as follows: - /// - glTF: - /// - forward: Z - /// - up: Y - /// - right: -X - /// - Bevy: - /// - forward: -Z - /// - up: Y - /// - right: X - pub convert_coordinates: bool, + /// The default is `false`. + pub favor_model_coordinates: bool, /// Registry for custom vertex attributes. /// @@ -185,7 +182,7 @@ impl Default for GltfPlugin { GltfPlugin { default_sampler: ImageSamplerDescriptor::linear(), custom_vertex_attributes: HashMap::default(), - convert_coordinates: false, + favor_model_coordinates: false, } } } @@ -241,7 +238,7 @@ impl Plugin for GltfPlugin { supported_compressed_formats, custom_vertex_attributes: self.custom_vertex_attributes.clone(), default_sampler, - default_convert_coordinates: self.convert_coordinates, + default_favor_model_coordinates: self.favor_model_coordinates, }); } } diff --git a/crates/bevy_gltf/src/loader/mod.rs b/crates/bevy_gltf/src/loader/mod.rs index a326af0526..fea13d95eb 100644 --- a/crates/bevy_gltf/src/loader/mod.rs +++ b/crates/bevy_gltf/src/loader/mod.rs @@ -151,20 +151,17 @@ pub struct GltfLoader { pub custom_vertex_attributes: HashMap, MeshVertexAttribute>, /// Arc to default [`ImageSamplerDescriptor`]. pub default_sampler: Arc>, - /// Whether to convert glTF coordinates to Bevy's coordinate system by default. - /// If set to `true`, the loader will convert the coordinate system of loaded glTF assets to Bevy's coordinate system - /// such that objects looking forward in glTF will also look forward in Bevy. + /// How to convert glTF coordinates on import. Assuming glTF cameras, glTF lights, and glTF meshes had global unit transforms, + /// their Bevy [`Transform::forward`](bevy_transform::components::Transform::forward) will be pointing in the following global directions: + /// - When set to `false` + /// - glTF cameras and glTF lights: global -Z, + /// - glTF models: global +Z. + /// - When set to `true` + /// - glTF cameras and glTF lights: global +Z, + /// - glTF models: global -Z. /// - /// The exact coordinate system conversion is as follows: - /// - glTF: - /// - forward: Z - /// - up: Y - /// - right: -X - /// - Bevy: - /// - forward: -Z - /// - up: Y - /// - right: X - pub default_convert_coordinates: bool, + /// The default is `false`. + pub default_favor_model_coordinates: bool, } /// Specifies optional settings for processing gltfs at load time. By default, all recognized contents of @@ -206,23 +203,17 @@ pub struct GltfLoaderSettings { pub default_sampler: Option, /// If true, the loader will ignore sampler data from gltf and use the default sampler. pub override_sampler: bool, - /// Overrides the default glTF coordinate conversion setting. + /// How to convert glTF coordinates on import. Assuming glTF cameras, glTF lights, and glTF meshes had global unit transforms, + /// their Bevy [`Transform::forward`](bevy_transform::components::Transform::forward) will be pointing in the following global directions: + /// - When set to `false` + /// - glTF cameras and glTF lights: global -Z, + /// - glTF models: global +Z. + /// - When set to `true` + /// - glTF cameras and glTF lights: global +Z, + /// - glTF models: global -Z. /// - /// If set to `Some(true)`, the loader will convert the coordinate system of loaded glTF assets to Bevy's coordinate system - /// such that objects looking forward in glTF will also look forward in Bevy. - /// - /// The exact coordinate system conversion is as follows: - /// - glTF: - /// - forward: Z - /// - up: Y - /// - right: -X - /// - Bevy: - /// - forward: -Z - /// - up: Y - /// - right: X - /// - /// If `None`, uses the global default set by [`GltfPlugin::convert_coordinates`](crate::GltfPlugin::convert_coordinates). - pub convert_coordinates: Option, + /// If `None`, uses the global default set by [`GltfPlugin::favor_model_coordinates`](crate::GltfPlugin::favor_model_coordinates). + pub favor_model_coordinates: Option, } impl Default for GltfLoaderSettings { @@ -235,7 +226,7 @@ impl Default for GltfLoaderSettings { include_source: false, default_sampler: None, override_sampler: false, - convert_coordinates: None, + favor_model_coordinates: None, } } } @@ -295,9 +286,9 @@ async fn load_gltf<'a, 'b, 'c>( paths }; - let convert_coordinates = match settings.convert_coordinates { + let convert_coordinates = match settings.favor_model_coordinates { Some(convert_coordinates) => convert_coordinates, - None => loader.default_convert_coordinates, + None => loader.default_favor_model_coordinates, }; #[cfg(feature = "bevy_animation")]