Skip to content

Commit 33d5169

Browse files
committed
adjust distance to orthographic camera
1 parent 19f41ae commit 33d5169

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

scene.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,20 @@ function createScene(options) {
577577
//Compute camera parameters
578578

579579
if(cameraOptions.ortho === true) {
580+
var Q = 0.5 * Math.pow(
581+
Math.pow(cameraOptions.eye.x - cameraOptions.center.x, 2) +
582+
Math.pow(cameraOptions.eye.y - cameraOptions.center.y, 2) +
583+
Math.pow(cameraOptions.eye.z - cameraOptions.center.z, 2),
584+
0.5
585+
)
586+
580587
ortho(projection,
581-
-0.5 * width/height, 0.5 * width/height,
582-
-0.5, 0.5,
583-
scene.zNear,
584-
scene.zFar
588+
Q * -0.5 * width/height,
589+
Q * 0.5 * width/height,
590+
Q * -0.5,
591+
Q * 0.5,
592+
Q * scene.zNear,
593+
Q * scene.zFar
585594
)
586595
cameraParams.ortho = true
587596
} else {

0 commit comments

Comments
 (0)