Light.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Object3D } from '../core/Object3D.js';
  2. import { Color } from '../math/Color.js';
  3. /**
  4. * @author mrdoob / http://mrdoob.com/
  5. * @author alteredq / http://alteredqualia.com/
  6. */
  7. function Light( color, intensity ) {
  8. Object3D.call( this );
  9. this.type = 'Light';
  10. this.color = new Color( color );
  11. this.intensity = intensity !== undefined ? intensity : 1;
  12. this.receiveShadow = undefined;
  13. }
  14. Light.prototype = Object.assign( Object.create( Object3D.prototype ), {
  15. constructor: Light,
  16. isLight: true,
  17. copy: function ( source ) {
  18. Object3D.prototype.copy.call( this, source );
  19. this.color.copy( source.color );
  20. this.intensity = source.intensity;
  21. return this;
  22. },
  23. toJSON: function ( meta ) {
  24. var data = Object3D.prototype.toJSON.call( this, meta );
  25. data.object.color = this.color.getHex();
  26. data.object.intensity = this.intensity;
  27. if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();
  28. if ( this.distance !== undefined ) data.object.distance = this.distance;
  29. if ( this.angle !== undefined ) data.object.angle = this.angle;
  30. if ( this.decay !== undefined ) data.object.decay = this.decay;
  31. if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;
  32. if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();
  33. return data;
  34. }
  35. } );
  36. export { Light };
粤ICP备19079148号