OrthographicCamera look at target

Hi all,

I want to setup an OrthographicCamera for a custom shadow mapping computation and I would like this camera to look at a specific target.

This is what I am doing:

const boundSphere = target.boundingSphere;

const lightCamera = new THREE.OrthographicCamera(
  -boundSphere.radius, boundSphere.radius, 
  boundSphere.radius, -boundSphere.radius, 
  0., 2 * boundSphere.radius
);
lightCamera.position.set(0., 0., boundSphere.radius);
lightCamera.lookAt(boundSphere.center);

Is there a better approach than this? Is there a builtin ThreeJS function/method that I can use?

Nope, it is necessary to directly specify the dimensions of the shadow frustum. The same approach is used by all internal LightShadow classes.

1 Like

Thanks for your answer. I will look at the internal LightShadow classes then. I want to be sure to have a solution that will work in most cases.