LightProbe.js 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @author WestLangley / http://github.com/WestLangley
  3. *
  4. * A LightProbe is a source of indirect-diffuse light
  5. */
  6. import { SphericalHarmonics3 } from '../math/SphericalHarmonics3.js';
  7. import { Light } from './Light.js';
  8. function LightProbe( sh, intensity ) {
  9. Light.call( this, undefined, intensity );
  10. this.type = 'LightProbe';
  11. this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3();
  12. }
  13. LightProbe.prototype = Object.assign( Object.create( Light.prototype ), {
  14. constructor: LightProbe,
  15. isLightProbe: true,
  16. copy: function ( source ) {
  17. Light.prototype.copy.call( this, source );
  18. this.sh.copy( source.sh );
  19. return this;
  20. },
  21. fromJSON: function ( json ) {
  22. this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON();
  23. this.sh.fromArray( json.sh );
  24. return this;
  25. },
  26. toJSON: function ( meta ) {
  27. var data = Light.prototype.toJSON.call( this, meta );
  28. data.object.sh = this.sh.toArray();
  29. return data;
  30. }
  31. } );
  32. export { LightProbe };
粤ICP备19079148号