DirectionalLight.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.DirectionalLight = function ( color, intensity ) {
  6. THREE.Light.call( this, color );
  7. this.position.set( 0, 1, 0 );
  8. this.target = new THREE.Object3D();
  9. this.intensity = ( intensity !== undefined ) ? intensity : 1;
  10. this.castShadow = false;
  11. this.onlyShadow = false;
  12. //
  13. this.shadowCameraNear = 50;
  14. this.shadowCameraFar = 5000;
  15. this.shadowCameraLeft = -500;
  16. this.shadowCameraRight = 500;
  17. this.shadowCameraTop = 500;
  18. this.shadowCameraBottom = -500;
  19. this.shadowCameraVisible = false;
  20. this.shadowBias = 0;
  21. this.shadowDarkness = 0.5;
  22. this.shadowMapWidth = 512;
  23. this.shadowMapHeight = 512;
  24. //
  25. this.shadowCascade = false;
  26. this.shadowCascadeOffset = new THREE.Vector3( 0, 0, -1000 );
  27. this.shadowCascadeCount = 2;
  28. this.shadowCascadeBias = [ 0, 0, 0 ];
  29. this.shadowCascadeWidth = [ 512, 512, 512 ];
  30. this.shadowCascadeHeight = [ 512, 512, 512 ];
  31. this.shadowCascadeNearZ = [ -1.000, 0.990, 0.998 ];
  32. this.shadowCascadeFarZ = [ 0.990, 0.998, 1.000 ];
  33. this.shadowCascadeArray = [];
  34. //
  35. this.shadowMap = null;
  36. this.shadowMapSize = null;
  37. this.shadowCamera = null;
  38. this.shadowMatrix = null;
  39. };
  40. THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype );
  41. THREE.DirectionalLight.prototype.clone = function () {
  42. var light = new THREE.DirectionalLight();
  43. THREE.Light.prototype.clone.call( this, light );
  44. light.target = this.target.clone();
  45. light.intensity = this.intensity;
  46. light.castShadow = this.castShadow;
  47. light.onlyShadow = this.onlyShadow;
  48. return light;
  49. };
粤ICP备19079148号