Light.js 1.2 KB

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