MCPcopy
hub / github.com/mapillary/OpenSfM / updateShadowCamera

Function updateShadowCamera

viewer/js/three.js:25664–25704  ·  view source on GitHub ↗
( camera, light )

Source from the content-addressed store, hash-verified

25662 // Fit shadow camera's ortho frustum to camera frustum
25663
25664 function updateShadowCamera( camera, light ) {
25665
25666 var shadowCamera = light.shadowCamera,
25667 pointsFrustum = light.pointsFrustum,
25668 pointsWorld = light.pointsWorld;
25669
25670 _min.set( Infinity, Infinity, Infinity );
25671 _max.set( - Infinity, - Infinity, - Infinity );
25672
25673 for ( var i = 0; i < 8; i ++ ) {
25674
25675 var p = pointsWorld[ i ];
25676
25677 p.copy( pointsFrustum[ i ] );
25678 p.unproject( camera );
25679
25680 p.applyMatrix4( shadowCamera.matrixWorldInverse );
25681
25682 if ( p.x < _min.x ) _min.x = p.x;
25683 if ( p.x > _max.x ) _max.x = p.x;
25684
25685 if ( p.y < _min.y ) _min.y = p.y;
25686 if ( p.y > _max.y ) _max.y = p.y;
25687
25688 if ( p.z < _min.z ) _min.z = p.z;
25689 if ( p.z > _max.z ) _max.z = p.z;
25690
25691 }
25692
25693 shadowCamera.left = _min.x;
25694 shadowCamera.right = _max.x;
25695 shadowCamera.top = _max.y;
25696 shadowCamera.bottom = _min.y;
25697
25698 // can't really fit near/far
25699 //shadowCamera.near = _min.z;
25700 //shadowCamera.far = _max.z;
25701
25702 shadowCamera.updateProjectionMatrix();
25703
25704 }
25705
25706 // For the moment just ignore objects that have multiple materials with different animation methods
25707 // Only the first material will be taken into account for deciding which depth material to use for shadow maps

Callers 1

three.jsFile · 0.85

Calls 1

setMethod · 0.80

Tested by

no test coverage detected