LightShadow.js 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Matrix4 } from '../math/Matrix4';
  2. import { Vector2 } from '../math/Vector2';
  3. /**
  4. * @author mrdoob / http://mrdoob.com/
  5. */
  6. function LightShadow( camera ) {
  7. this.camera = camera;
  8. this.bias = 0;
  9. this.radius = 1;
  10. this.mapSize = new Vector2( 512, 512 );
  11. this.map = null;
  12. this.matrix = new Matrix4();
  13. }
  14. Object.assign( LightShadow.prototype, {
  15. copy: function ( source ) {
  16. this.camera = source.camera.clone();
  17. this.bias = source.bias;
  18. this.radius = source.radius;
  19. this.mapSize.copy( source.mapSize );
  20. return this;
  21. },
  22. clone: function () {
  23. return new this.constructor().copy( this );
  24. },
  25. toJSON: function () {
  26. var object = {};
  27. if ( this.bias !== 0 ) object.bias = this.bias;
  28. if ( this.radius !== 1 ) object.radius = this.radius;
  29. if ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();
  30. object.camera = this.camera.toJSON( false ).object;
  31. delete object.camera.matrix;
  32. return object;
  33. }
  34. } );
  35. export { LightShadow };