SpotLightShadow.js 925 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { LightShadow } from './LightShadow.js';
  2. import * as MathUtils from '../math/MathUtils.js';
  3. import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';
  4. class SpotLightShadow extends LightShadow {
  5. constructor() {
  6. super( new PerspectiveCamera( 50, 1, 0.5, 500 ) );
  7. this.isSpotLightShadow = true;
  8. this.focus = 1;
  9. }
  10. updateMatrices( light ) {
  11. const camera = this.camera;
  12. const fov = MathUtils.RAD2DEG * 2 * light.angle * this.focus;
  13. const aspect = this.mapSize.width / this.mapSize.height;
  14. const far = light.distance || camera.far;
  15. if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {
  16. camera.fov = fov;
  17. camera.aspect = aspect;
  18. camera.far = far;
  19. camera.updateProjectionMatrix();
  20. }
  21. super.updateMatrices( light );
  22. }
  23. copy( source ) {
  24. super.copy( source );
  25. this.focus = source.focus;
  26. return this;
  27. }
  28. }
  29. export { SpotLightShadow };