File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
crates/bevy_render/src/camera Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,9 @@ impl Default for DepthCalculation {
122
122
123
123
impl Camera {
124
124
/// Given a position in world space, use the camera to compute the screen space coordinates.
125
+ ///
126
+ /// To get the coordinates in Normalized Device Coordinates, you should use
127
+ /// [`world_to_ndc`](Self::world_to_ndc).
125
128
pub fn world_to_screen (
126
129
& self ,
127
130
windows : & Windows ,
@@ -138,14 +141,17 @@ impl Camera {
138
141
}
139
142
140
143
// Once in NDC space, we can discard the z element and rescale x/y to fit the screen
141
- let screen_space_coords = ( ndc_space_coords. truncate ( ) + Vec2 :: ONE ) / 2.0 * window_size;
142
- Some ( screen_space_coords)
144
+ Some ( ( ndc_space_coords. truncate ( ) + Vec2 :: ONE ) / 2.0 * window_size)
143
145
} else {
144
146
None
145
147
}
146
148
}
147
149
148
- /// Given a position in world space, use the camera to compute the normalized device coordinates.
150
+ /// Given a position in world space, use the camera to compute the Normalized Device Coordinates.
151
+ ///
152
+ /// Values returned will be between -1.0 and 1.0 when the position is in screen space.
153
+ /// To get the coordinates in the render target dimensions, you should use
154
+ /// [`world_to_screen`](Self::world_to_screen).
149
155
pub fn world_to_ndc (
150
156
& self ,
151
157
camera_transform : & GlobalTransform ,
You can’t perform that action at this time.
0 commit comments