@@ -4469,7 +4469,7 @@ protected void defaultCamera() {
4469
4469
*/
4470
4470
@ Override
4471
4471
public void ortho () {
4472
- ortho (0 , width , 0 , height , cameraNear , cameraFar );
4472
+ ortho (0 , width , 0 , height , 0 , cameraEyeZ * 10 );
4473
4473
}
4474
4474
4475
4475
@@ -4480,7 +4480,7 @@ public void ortho() {
4480
4480
@ Override
4481
4481
public void ortho (float left , float right ,
4482
4482
float bottom , float top ) {
4483
- ortho (left , right , bottom , top , cameraNear , cameraFar );
4483
+ ortho (left , right , bottom , top , 0 , cameraEyeZ * 10 );
4484
4484
}
4485
4485
4486
4486
@@ -4492,24 +4492,27 @@ public void ortho(float left, float right,
4492
4492
public void ortho (float left , float right ,
4493
4493
float bottom , float top ,
4494
4494
float near , float far ) {
4495
- // Translating the origin to (widht/2, height/2) since the matrix math
4496
- // below assumes the center of the screen to be (0, 0), but in Processing
4497
- // it is (w/2, h/2).
4498
- left -= width /2f ;
4499
- right -= width /2f ;
4500
- bottom -= height /2f ;
4501
- top -= height /2f ;
4495
+ float w = right - left ;
4496
+ float h = top - bottom ;
4497
+ float d = far - near ;
4498
+
4499
+ // Applying the camera translation (only on x and y, as near and far
4500
+ // are given as distances from the viewer)
4501
+ left -= cameraEyeX ;
4502
+ right -= cameraEyeX ;
4503
+ bottom -= cameraEyeY ;
4504
+ top -= cameraEyeY ;
4502
4505
4503
4506
// Flushing geometry with a different perspective configuration.
4504
4507
flush ();
4505
4508
4506
- float x = +2.0f / ( right - left ) ;
4507
- float y = +2.0f / ( top - bottom ) ;
4508
- float z = -2.0f / ( far - near ) ;
4509
+ float x = +2.0f / w ;
4510
+ float y = +2.0f / h ;
4511
+ float z = -2.0f / d ;
4509
4512
4510
- float tx = -(right + left ) / ( right - left ) ;
4511
- float ty = -(top + bottom ) / ( top - bottom ) ;
4512
- float tz = -(far + near ) / ( far - near ) ;
4513
+ float tx = -(right + left ) / w ;
4514
+ float ty = -(top + bottom ) / h ;
4515
+ float tz = -(far + near ) / d ;
4513
4516
4514
4517
// The minus sign is needed to invert the Y axis.
4515
4518
projection .set (x , 0 , 0 , tx ,
0 commit comments