Light.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.Light = function ( color ) {
  6. THREE.Object3D.call( this );
  7. this.type = 'Light';
  8. this.color = new THREE.Color( color );
  9. this.receiveShadow = undefined;
  10. };
  11. THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
  12. THREE.Light.prototype.constructor = THREE.Light;
  13. Object.defineProperties( THREE.Light.prototype, {
  14. onlyShadow: {
  15. set: function ( value ) {
  16. console.warn( 'THREE.Light: .onlyShadow has been removed.' );
  17. }
  18. },
  19. shadowCamera: {
  20. get: function () {
  21. return this.shadow.camera;
  22. }
  23. },
  24. shadowCameraFov: {
  25. get: function () {
  26. return this.shadow.camera.fov;
  27. },
  28. set: function ( value ) {
  29. this.shadow.camera.fov = value;
  30. }
  31. },
  32. shadowCameraLeft: {
  33. get: function () {
  34. return this.shadow.camera.left;
  35. },
  36. set: function ( value ) {
  37. this.shadow.camera.left = value;
  38. }
  39. },
  40. shadowCameraRight: {
  41. get: function () {
  42. return this.shadow.camera.right;
  43. },
  44. set: function ( value ) {
  45. this.shadow.camera.right = value;
  46. }
  47. },
  48. shadowCameraTop: {
  49. get: function () {
  50. return this.shadow.camera.top;
  51. },
  52. set: function ( value ) {
  53. this.shadow.camera.top = value;
  54. }
  55. },
  56. shadowCameraBottom: {
  57. get: function () {
  58. return this.shadow.camera.bottom;
  59. },
  60. set: function ( value ) {
  61. this.shadow.camera.bottom = value;
  62. }
  63. },
  64. shadowCameraNear: {
  65. get: function () {
  66. return this.shadow.camera.near;
  67. },
  68. set: function ( value ) {
  69. this.shadow.camera.near = value;
  70. }
  71. },
  72. shadowCameraFar: {
  73. get: function () {
  74. return this.shadow.camera.far;
  75. },
  76. set: function ( value ) {
  77. this.shadow.camera.far = value;
  78. }
  79. },
  80. shadowCameraVisible: {
  81. set: function ( value ) {
  82. console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow ) instead.' );
  83. }
  84. },
  85. shadowBias: {
  86. get: function () {
  87. return this.shadow.bias;
  88. },
  89. set: function ( value ) {
  90. this.shadow.bias = value;
  91. }
  92. },
  93. shadowDarkness: {
  94. get: function () {
  95. return this.shadow.darkness;
  96. },
  97. set: function ( value ) {
  98. this.shadow.darkness = value;
  99. }
  100. },
  101. shadowMap: {
  102. get: function () {
  103. return this.shadow.map;
  104. },
  105. set: function ( value ) {
  106. this.shadow.map = value;
  107. }
  108. },
  109. shadowMapWidth: {
  110. get: function () {
  111. return this.shadow.mapSize.width;
  112. },
  113. set: function ( value ) {
  114. this.shadow.mapSize.width = value;
  115. }
  116. },
  117. shadowMapHeight: {
  118. get: function () {
  119. return this.shadow.mapSize.height;
  120. },
  121. set: function ( value ) {
  122. this.shadow.mapSize.height = value;
  123. }
  124. },
  125. shadowMatrix: {
  126. get: function () {
  127. return this.shadow.matrix;
  128. },
  129. set: function ( value ) {
  130. this.shadow.matrix = value;
  131. }
  132. }
  133. } );
  134. THREE.Light.prototype.copy = function ( source ) {
  135. THREE.Object3D.prototype.copy.call( this, source );
  136. this.color.copy( source.color );
  137. return this;
  138. };
  139. THREE.Light.prototype.toJSON = function ( meta ) {
  140. var data = THREE.Object3D.prototype.toJSON.call( this, meta );
  141. data.object.color = this.color.getHex();
  142. if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();
  143. if ( this.intensity !== undefined ) data.object.intensity = this.intensity;
  144. if ( this.distance !== undefined ) data.object.distance = this.distance;
  145. if ( this.angle !== undefined ) data.object.angle = this.angle;
  146. if ( this.decay !== undefined ) data.object.decay = this.decay;
  147. if ( this.exponent !== undefined ) data.object.exponent = this.exponent;
  148. return data;
  149. };