RectAreaLight.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // this.shadow = new THREE.RectAreaLightShadow( new THREE.PerspectiveCamera( 90, 1, 0.5, 500 ) );
  16. }
  17. // TODO (abelnation): RectAreaLight update when light shape is changed
  18. RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
  19. constructor: RectAreaLight,
  20. isRectAreaLight: true,
  21. copy: function ( source ) {
  22. Light.prototype.copy.call( this, source );
  23. this.width = source.width;
  24. this.height = source.height;
  25. // this.shadow = source.shadow.clone();
  26. return this;
  27. },
  28. toJSON: function ( meta ) {
  29. var data = Light.prototype.toJSON.call( this, meta );
  30. data.object.width = this.width;
  31. data.object.height = this.height;
  32. return data;
  33. }
  34. } );
  35. export { RectAreaLight };
粤ICP备19079148号