AreaLight.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @author MPanknin / http://www.redplant.de/
  3. * @author alteredq / http://alteredqualia.com/
  4. * @author prafullit
  5. */
  6. THREE.AreaLight = function ( color, intensity ) {
  7. THREE.Light.call( this, color );
  8. this.type = 'AreaLight';
  9. this.normal = new THREE.Vector3( 0, - 1, 0 );
  10. this.right = new THREE.Vector3( 1, 0, 0 );
  11. this.intensity = ( intensity !== undefined ) ? intensity : 1;
  12. this.width = 1.0;
  13. this.height = 1.0;
  14. this.constantAttenuation = 1.5;
  15. this.linearAttenuation = 0.5;
  16. this.quadraticAttenuation = 0.1;
  17. };
  18. THREE.AreaLight.prototype = Object.create( THREE.Light.prototype );
  19. THREE.AreaLight.prototype.constructor = THREE.AreaLight;
  20. THREE.AreaLight.prototype.copy = function ( source ) {
  21. THREE.Light.prototype.copy.call( this, source );
  22. this.intensity = source.intensity;
  23. this.normal.copy( source.normal );
  24. this.right.copy( source.right );
  25. this.width = source.width;
  26. this.height = source.height;
  27. this.constantAttenuation = source.constantAttenuation;
  28. this.linearAttenuation = source.linearAttenuation;
  29. this.quadraticAttenuation = source.quadraticAttenuation;
  30. return this;
  31. };
  32. THREE.AreaLight.prototype.toJSON = function ( meta ) {
  33. var data = THREE.Object3D.prototype.toJSON.call( this, meta );
  34. data.object.color = this.color.getHex();
  35. data.object.intensity = this.intensity;
  36. return data;
  37. };
粤ICP备19079148号