examples/lib/three.js
function updateShadowCamera( camera, light ) {

		var shadowCamera = light.shadowCamera,
			pointsFrustum = light.pointsFrustum,
			pointsWorld = light.pointsWorld;

		_min.set( Infinity, Infinity, Infinity );
		_max.set( -Infinity, -Infinity, -Infinity );

		for ( var i = 0; i < 8; i ++ ) {

			var p = pointsWorld[ i ];

			p.copy( pointsFrustum[ i ] );
			THREE.ShadowMapPlugin.__projector.unprojectVector( p, camera );

			p.applyMatrix4( shadowCamera.matrixWorldInverse );

			if ( p.x < _min.x ) _min.x = p.x;
			if ( p.x > _max.x ) _max.x = p.x;

			if ( p.y < _min.y ) _min.y = p.y;
			if ( p.y > _max.y ) _max.y = p.y;

			if ( p.z < _min.z ) _min.z = p.z;
			if ( p.z > _max.z ) _max.z = p.z;

		}

		shadowCamera.left = _min.x;
		shadowCamera.right = _max.x;
		shadowCamera.top = _max.y;
		shadowCamera.bottom = _min.y;

		// can't really fit near/far
		//shadowCamera.near = _min.z;
		//shadowCamera.far = _max.z;

		shadowCamera.updateProjectionMatrix();

	}
function updateShadowCamera( camera, light ) {

		var shadowCamera = light.shadowCamera,
			pointsFrustum = light.pointsFrustum,
			pointsWorld = light.pointsWorld;

		_min.set( Infinity, Infinity, Infinity );
		_max.set( -Infinity, -Infinity, -Infinity );

		for ( var i = 0; i < 8; i ++ ) {

			var p = pointsWorld[ i ];

			p.copy( pointsFrustum[ i ] );
			THREE.ShadowMapPlugin.__projector.unprojectVector( p, camera );

			p.applyMatrix4( shadowCamera.matrixWorldInverse );

			if ( p.x < _min.x ) _min.x = p.x;
			if ( p.x > _max.x ) _max.x = p.x;

			if ( p.y < _min.y ) _min.y = p.y;
			if ( p.y > _max.y ) _max.y = p.y;

			if ( p.z < _min.z ) _min.z = p.z;
			if ( p.z > _max.z ) _max.z = p.z;

		}

		shadowCamera.left = _min.x;
		shadowCamera.right = _max.x;
		shadowCamera.top = _max.y;
		shadowCamera.bottom = _min.y;

		// can't really fit near/far
		//shadowCamera.near = _min.z;
		//shadowCamera.far = _max.z;

		shadowCamera.updateProjectionMatrix();

	}
function updateShadowCamera ( camera , light ) { var shadowCamera = light . shadowCamera , pointsFrustum = light . pointsFrustum , pointsWorld = light . pointsWorld ; _min . set ( Infinity , Infinity , Infinity ) ; _max . set ( - Infinity , - Infinity , - Infinity ) ; for ( var i = 0 ; i < 8 ; i ++ ) { var p = pointsWorld [ i ] ; p . copy ( pointsFrustum [ i ] ) ; THREE . ShadowMapPlugin . __projector . unprojectVector ( p , camera ) ; p . applyMatrix4 ( shadowCamera . matrixWorldInverse ) ; if ( p . x < _min . x ) _min . x = p . x ; if ( p . x > _max . x ) _max . x = p . x ; if ( p . y < _min . y ) _min . y = p . y ; if ( p . y > _max . y ) _max . y = p . y ; if ( p . z < _min . z ) _min . z = p . z ; if ( p . z > _max . z ) _max . z = p . z ; } shadowCamera . left = _min . x ; shadowCamera . right = _max . x ; shadowCamera . top = _max . y ; shadowCamera . bottom = _min . y ; // can't really fit near/far //shadowCamera.near = _min.z; //shadowCamera.far = _max.z; shadowCamera . updateProjectionMatrix ( ) ; }
Fit shadow camera's ortho frustum to camera frustum
Fit shadow camera s ortho frustum to camera frustum