LightProbe.js 679 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { SphericalHarmonics3 } from '../math/SphericalHarmonics3.js';
  2. import { Light } from './Light.js';
  3. class LightProbe extends Light {
  4. constructor( sh = new SphericalHarmonics3(), intensity = 1 ) {
  5. super( undefined, intensity );
  6. this.isLightProbe = true;
  7. this.sh = sh;
  8. }
  9. copy( source ) {
  10. super.copy( source );
  11. this.sh.copy( source.sh );
  12. return this;
  13. }
  14. fromJSON( json ) {
  15. this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON();
  16. this.sh.fromArray( json.sh );
  17. return this;
  18. }
  19. toJSON( meta ) {
  20. const data = super.toJSON( meta );
  21. data.object.sh = this.sh.toArray();
  22. return data;
  23. }
  24. }
  25. export { LightProbe };