RectAreaLight.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { Light } from './Light';
  2. /**
  3. * @author abelnation / http://github.com/abelnation
  4. */
  5. function RectAreaLight( color, intensity, width, height ) {
  6. Light.call( this, color, intensity );
  7. this.type = 'RectAreaLight';
  8. this.position.set( 0, 1, 0 );
  9. this.updateMatrix();
  10. this.width = ( width !== undefined ) ? width : 10;
  11. this.height = ( height !== undefined ) ? height : 10;
  12. // TODO (abelnation): distance/decay
  13. // TODO (abelnation): update method for RectAreaLight to update transform to lookat target
  14. // TODO (abelnation): shadows
  15. }
  16. // TODO (abelnation): RectAreaLight update when light shape is changed
  17. RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
  18. constructor: RectAreaLight,
  19. isRectAreaLight: true,
  20. copy: function ( source ) {
  21. Light.prototype.copy.call( this, source );
  22. this.width = source.width;
  23. this.height = source.height;
  24. return this;
  25. },
  26. toJSON: function ( meta ) {
  27. var data = Light.prototype.toJSON.call( this, meta );
  28. data.object.width = this.width;
  29. data.object.height = this.height;
  30. return data;
  31. }
  32. } );
  33. export { RectAreaLight };