Skip to content

Commit

Permalink
direction-independent far plane calc
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheumann committed Apr 28, 2024
1 parent b8c5ffd commit 58fa1a0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Elements/src/extension.dib
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ const fitCameraToObject = function (scene, offset = 1.25) {
camera.position.copy(center.clone().add(size.clone().multiplyScalar(offset)))
}

const minZ = boundingBox.min.y;
const cameraToFarEdge = (minZ < 0) ? -minZ + cameraZ : cameraZ - minZ;
const cameraToFarEdge = camera.position.distanceTo(center) + maxDim;

camera.far = cameraToFarEdge * 30;
camera.far = cameraToFarEdge * 5;
camera.updateProjectionMatrix();

if (controls) {
Expand Down

0 comments on commit 58fa1a0

Please sign in to comment.