DirectionalLight.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. //
  49. light.shadowCameraNear = this.shadowCameraNear;
  50. light.shadowCameraFar = this.shadowCameraFar;
  51. light.shadowCameraLeft = this.shadowCameraLeft;
  52. light.shadowCameraRight = this.shadowCameraRight;
  53. light.shadowCameraTop = this.shadowCameraTop;
  54. light.shadowCameraBottom = this.shadowCameraBottom;
  55. light.shadowCameraVisible = this.shadowCameraVisible;
  56. light.shadowBias = this.shadowBias;
  57. light.shadowDarkness = this.shadowDarkness;
  58. light.shadowMapWidth = this.shadowMapWidth;
  59. light.shadowMapHeight = this.shadowMapHeight;
  60. //
  61. light.shadowCascade = this.shadowCascade;
  62. light.shadowCascadeOffset.copy( this.shadowCascadeOffset );
  63. light.shadowCascadeCount = this.shadowCascadeCount;
  64. light.shadowCascadeBias = this.shadowCascadeBias.slice( 0 );
  65. light.shadowCascadeWidth = this.shadowCascadeWidth.slice( 0 );
  66. light.shadowCascadeHeight = this.shadowCascadeHeight.slice( 0 );
  67. light.shadowCascadeNearZ = this.shadowCascadeNearZ.slice( 0 );
  68. light.shadowCascadeFarZ = this.shadowCascadeFarZ.slice( 0 );
  69. return light;
  70. };
粤ICP备19079148号