question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

calculate size of frustum as a function of z distance to camera

See original GitHub issue

hi,

i want to create a rectangle which fills the screen exactly, example:

camera.position.z = 500;
...
var cube = new THREE.CubeGeometry( 1, 1, 1);
...
cubeMesh.position.x = 0; cubeMesh.position.y = 0; cubeMesh.position.z = 0;
cubeMesh.scale.x = ???;
cubeMesh.scale.y = ???;

so here is the distance from the camera to the object 500. is there a easy way to calculate ???

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alteredqcommented, Nov 8, 2011

Usually for having screen-filling rectangle we use OrthographicCamera and then just create window-pixel sized PlaneGeometry.

See for example here:

https://github.com/mrdoob/three.js/blob/master/examples/webgl_postprocessing_dof.html#L240

https://github.com/mrdoob/three.js/blob/master/examples/webgl_postprocessing_dof.html#L264

(for things like HUD the easiest is to have a separate scene just used for sticking things to the screen)

If you need a distance from object to camera, it can be computed using world matrices:

var point1 = camera.matrixWorld.getPosition().clone();
var point2 = cubeMesh.matrixWorld.getPosition().clone();

var distance = point1.distanceTo( point2 );
Read more comments on GitHub >

github_iconTop Results From Across the Web

The Size of the Frustum at a Given Distance from the Camera
It is sometimes useful to calculate the size of this rectangle at a given distance, or find the distance where the rectangle is...
Read more >
The Size of the Frustum at a Given Distance from the Camera ...
First, get the corners of the frustum at the distance you choose, then subtract the elements of the array returned to determine the...
Read more >
[SOLVED] How to get the size of the frustum at a distance from ...
I have an camera at an determined position, looking at 0,0,0. The idea is to get the fustrum size on z=0 to be...
Read more >
How to compute the size of the rectangle that is visible to the ...
You know FOV and distance from camera to a circle, so you can calculate upper and lower points (y-axis). You know FOV, aspect...
Read more >
Frustum Culling - LearnOpenGL
Camera frustum represents the zone of vision of a camera. ... transform) const final { //Get global scale is computed by doing the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found