LightProbe.js 882 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { SphericalHarmonics3 } from '../math/SphericalHarmonics3.js';
  2. import { Light } from './Light.js';
  3. function LightProbe( sh, intensity ) {
  4. Light.call( this, undefined, intensity );
  5. this.type = 'LightProbe';
  6. this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3();
  7. }
  8. LightProbe.prototype = Object.assign( Object.create( Light.prototype ), {
  9. constructor: LightProbe,
  10. isLightProbe: true,
  11. copy: function ( source ) {
  12. Light.prototype.copy.call( this, source );
  13. this.sh.copy( source.sh );
  14. return this;
  15. },
  16. fromJSON: function ( json ) {
  17. this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON();
  18. this.sh.fromArray( json.sh );
  19. return this;
  20. },
  21. toJSON: function ( meta ) {
  22. const data = Light.prototype.toJSON.call( this, meta );
  23. data.object.sh = this.sh.toArray();
  24. return data;
  25. }
  26. } );
  27. export { LightProbe };
粤ICP备19079148号