Skip to content

Commit 24d4ca2

Browse files
committed
Fix near plane.
1 parent 8f3bf0f commit 24d4ca2

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

crates/processing_render/src/graphics.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,12 @@ pub fn mode_3d(
303303
let fov = std::f32::consts::PI / 3.0; // 60 degrees
304304
let aspect = width / height;
305305
let camera_z = (height / 2.0) / (fov / 2.0).tan();
306-
let near = camera_z / 10.0;
306+
// Processing4 uses near = camera_z / 10, but that clips anything closer
307+
// than ~camera_z/10 to the camera. Since `transform_set_position` lets the
308+
// user move the camera without recomputing the projection, a small fixed
309+
// near is safer and matches most engines' defaults.
310+
let near = 1.0;
307311
let far = camera_z * 10.0;
308-
309-
// TODO: Setting this as a default, but we need to think about API around
310-
// a user defined value
311312
let near_clip_plane = vec4(0.0, 0.0, -1.0, -near);
312313

313314
let mut projection = projections

0 commit comments

Comments
 (0)