RectAreaLight.js 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Light } from './Light.js';
  2. class RectAreaLight extends Light {
  3. constructor( color, intensity, width = 10, height = 10 ) {
  4. super( color, intensity );
  5. this.isRectAreaLight = true;
  6. this.type = 'RectAreaLight';
  7. this.width = width;
  8. this.height = height;
  9. }
  10. get power() {
  11. // compute the light's luminous power (in lumens) from its intensity (in nits)
  12. return this.intensity * this.width * this.height * Math.PI;
  13. }
  14. set power( power ) {
  15. // set the light's intensity (in nits) from the desired luminous power (in lumens)
  16. this.intensity = power / ( this.width * this.height * Math.PI );
  17. }
  18. copy( source ) {
  19. super.copy( source );
  20. this.width = source.width;
  21. this.height = source.height;
  22. return this;
  23. }
  24. toJSON( meta ) {
  25. const data = super.toJSON( meta );
  26. data.object.width = this.width;
  27. data.object.height = this.height;
  28. return data;
  29. }
  30. }
  31. export { RectAreaLight };
粤ICP备19079148号