LightProbe.js 693 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.sh = sh;
  7. }
  8. copy( source ) {
  9. super.copy( source );
  10. this.sh.copy( source.sh );
  11. return this;
  12. }
  13. fromJSON( json ) {
  14. this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON();
  15. this.sh.fromArray( json.sh );
  16. return this;
  17. }
  18. toJSON( meta ) {
  19. const data = super.toJSON( meta );
  20. data.object.sh = this.sh.toArray();
  21. return data;
  22. }
  23. }
  24. LightProbe.prototype.isLightProbe = true;
  25. export { LightProbe };
粤ICP备19079148号