Forked from ayamflow/gist:96a1f554c3f88eef2f9d0024fc42940f
Created
April 21, 2021 16:29
-
-
Save BABAK0T0/bdbe6798a0025bc9dfe9691172fb8ed2 to your computer and use it in GitHub Desktop.
Revisions
-
ayamflow revised this gist
Sep 11, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ var cameraZ = camera.position.z; var planeZ = 5; var distance = cameraZ - planeZ; var aspect = viewWidth / viewHeight; var vFov = camera.fov * Math.PI / 180; var planeHeightAtDistance = 2 * Math.tan(vFov / 2) * distance; -
ayamflow revised this gist
Sep 7, 2017 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,4 +11,8 @@ var planeWidthAtDistance = planeHeightAtDistance * aspect; let dist = camera.position.z - mesh.position.z; let height = ... // desired height to fit camera.fov = 2 * Math.atan(height / (2 * dist)) * (180 / Math.PI); camera.updateProjectionMatrix(); // Basically solving an AAS triangle https://www.mathsisfun.com/algebra/trig-solving-aas-triangles.html https://i.stack.imgur.com/PgSn3.jpg -
ayamflow revised this gist
Jul 13, 2017 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,7 @@ var planeWidthAtDistance = planeHeightAtDistance * aspect; // or let dist = camera.position.z - mesh.position.z; let height = ... // desired height to fit camera.fov = 2 * Math.atan(height / (2 * dist)) * (180 / Math.PI); camera.updateProjectionMatrix(); -
ayamflow revised this gist
Jul 13, 2017 . 2 changed files with 15 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ var cameraZ = camera.position.z; var planeZ = 5; var distance = cameraZ — planeZ; var aspect = viewWidth / viewHeight; var vFov = camera.fov * Math.PI / 180; var planeHeightAtDistance = 2 * Math.tan(vFov / 2) * distance; var planeWidthAtDistance = planeHeightAtDistance * aspect; // or var box = geometry.boundingBox; var meshHeight = box.max.y - box.min.y; camera.fov = 2 * Math.atan(meshHeight / (2 * (camera.position.z - mesh.position.z))) * (180 / Math.PI); camera.aspect = width / height; camera.updateProjectionMatrix(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ -
ayamflow created this gist
Apr 20, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ var cameraZ = camera.position.z; var planeZ = 5; var distance = cameraZ — planeZ; var aspect = viewWidth / viewHeight; var vFov = camera.fov * Math.PI / 180; var planeHeightAtDistance = 2 * Math.tan(vFov / 2) * distance; var planeWidthAtDistance = planeHeightAtDistance * aspect;