AmbientLightProbe.js 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @author WestLangley / http://github.com/WestLangley
  3. */
  4. import { Color } from '../math/Color.js';
  5. import { LightProbe } from './LightProbe.js';
  6. function AmbientLightProbe( color, intensity ) {
  7. LightProbe.call( this, undefined, intensity );
  8. var color1 = new Color().set( color );
  9. // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );
  10. this.sh.coefficients[ 0 ].set( color1.r, color1.g, color1.b ).multiplyScalar( 2 * Math.sqrt( Math.PI ) );
  11. }
  12. AmbientLightProbe.prototype = Object.assign( Object.create( LightProbe.prototype ), {
  13. constructor: AmbientLightProbe,
  14. isAmbientLightProbe: true,
  15. copy: function ( source ) { // modifying color not currently supported
  16. LightProbe.prototype.copy.call( this, source );
  17. return this;
  18. },
  19. toJSON: function ( meta ) {
  20. var data = LightProbe.prototype.toJSON.call( this, meta );
  21. // data.sh = this.sh.toArray(); // todo
  22. return data;
  23. }
  24. } );
  25. export { AmbientLightProbe };