SpotLightShadow.js 882 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { LightShadow } from './LightShadow';
  2. import { _Math } from '../math/Math';
  3. import { PerspectiveCamera } from '../cameras/PerspectiveCamera';
  4. /**
  5. * @author mrdoob / http://mrdoob.com/
  6. */
  7. function SpotLightShadow() {
  8. LightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );
  9. }
  10. SpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {
  11. constructor: SpotLightShadow,
  12. isSpotLightShadow: true,
  13. update: function ( light ) {
  14. var camera = this.camera;
  15. var fov = _Math.RAD2DEG * 2 * light.angle;
  16. var aspect = this.mapSize.width / this.mapSize.height;
  17. var far = light.distance || camera.far;
  18. if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {
  19. camera.fov = fov;
  20. camera.aspect = aspect;
  21. camera.far = far;
  22. camera.updateProjectionMatrix();
  23. }
  24. }
  25. } );
  26. export { SpotLightShadow };