DirectionalLight.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <script src="../../list.js"></script>
  6. <script src="../../page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="../../page.css" />
  8. </head>
  9. <body>
  10. [page:Object3D] &rarr; [page:Light] &rarr;
  11. <h1>[name]</h1>
  12. <div class="desc">
  13. Affects objects using [page:MeshLambertMaterial] or [page:MeshPhongMaterial].
  14. </div>
  15. <h2>Example</h2>
  16. <div>[example:canvas_morphtargets_horse morphtargets / horse ]</div>
  17. <div>[example:misc_controls_fly controls / fly ]</div>
  18. <div>[example:misc_lights_test lights / test ]</div>
  19. <div>[example:vr_cubes cubes ]</div>
  20. <div>[example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]</div>
  21. <div>[example:webgl_effects_stereo effects / stereo ]</div>
  22. <div>[example:webgl_geometry_extrude_splines geometry / extrude / splines ]</div>
  23. <div>[example:webgl_materials_bumpmap materials / bumpmap ]</div>
  24. <div>[example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection ]</div>
  25. <code>// White directional light at half intensity shining from the top.
  26. var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
  27. directionalLight.position.set( 0, 1, 0 );
  28. scene.add( directionalLight );</code>
  29. <h2>Constructor</h2>
  30. <h3>[name]([page:Integer hex], [page:Float intensity])</h3>
  31. <div>
  32. [page:Integer hex] -- Numeric value of the RGB component of the color. <br />
  33. [page:Float intensity] -- Numeric value of the light's strength/intensity.
  34. </div>
  35. <div>
  36. Creates a light that shines from a specific direction not from a specific position. This light will behave
  37. as though it is infinitely far away and the rays produced from it are all parallel. The best
  38. analogy would be a light source that acts like the sun: the sun is so far away that all sunlight
  39. hitting objects comes from the same angle.
  40. </div>
  41. <h2>Properties</h2>
  42. <h3>[property:Object3D target]</h3>
  43. <div>
  44. Target used for shadow camera orientation.
  45. </div>
  46. <h3>[property:Float intensity]</h3>
  47. <div>
  48. Light's intensity.<br />
  49. Default — *1.0*.
  50. </div>
  51. <h3>[property:Boolean onlyShadow]</h3>
  52. <div>
  53. If set to *true* light will only cast shadow but not contribute any lighting (as if *intensity* was 0 but cheaper to compute).<br />
  54. Default — *false*.
  55. </div>
  56. <h3>[property:Boolean castShadow]</h3>
  57. <div>
  58. If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right.<br />
  59. Default — *false*.
  60. </div>
  61. <h3>[property:Float shadowCameraNear]</h3>
  62. <div>
  63. Orthographic shadow camera frustum parameter.<br />
  64. Default — *50*.
  65. </div>
  66. <h3>[property:Float shadowCameraFar]</h3>
  67. <div>
  68. Orthographic shadow camera frustum parameter.<br />
  69. Default — *5000*.
  70. </div>
  71. <h3>[property:Float shadowCameraLeft]</h3>
  72. <div>
  73. Orthographic shadow camera frustum parameter.<br />
  74. Default — *-500*.
  75. </div>
  76. <h3>[property:Float shadowCameraRight]</h3>
  77. <div>
  78. Orthographic shadow camera frustum parameter.<br />
  79. Default — *500*.
  80. </div>
  81. <h3>[property:Float shadowCameraTop]</h3>
  82. <div>
  83. Orthographic shadow camera frustum parameter.<br />
  84. Default — *500*.
  85. </div>
  86. <h3>[property:Float shadowCameraBottom]</h3>
  87. <div>
  88. Orthographic shadow camera frustum parameter.<br />
  89. Default — *-500*.
  90. </div>
  91. <h3>[property:Boolean shadowCameraVisible]</h3>
  92. <div>
  93. Show debug shadow camera frustum.<br />
  94. Default — *false*.
  95. </div>
  96. <h3>[property:Float shadowBias]</h3>
  97. <div>
  98. Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.<br />
  99. Default — *0*.
  100. </div>
  101. <h3>[property:Float shadowDarkness]</h3>
  102. <div>
  103. Darkness of shadow casted by this light (from *0* to *1*).<br />
  104. Default — *0.5*.
  105. </div>
  106. <h3>[property:Integer shadowMapWidth]</h3>
  107. <div>
  108. Shadow map texture width in pixels.<br />
  109. Default — *512*.
  110. </div>
  111. <h3>[property:Integer shadowMapHeight]</h3>
  112. <div>
  113. Shadow map texture height in pixels.<br />
  114. Default — *512*.
  115. </div>
  116. <h3>[property:Boolean shadowCascade]</h3>
  117. <div>
  118. **Experimental** If true, use a series of shadow maps in a cascade. This can give better z-depth resolution for a directional light. <br />
  119. Default — *false*.
  120. </div>
  121. <h3>[property:Integer shadowCascadeCount]</h3>
  122. <div>
  123. Number of shadow maps to allocate in a cascade (one after another). <br />
  124. Default — *2*.
  125. </div>
  126. <h3>[property:Vector3 shadowCascadeOffset]</h3>
  127. <div>
  128. A relative position to real camera where virtual shadow cameras are attached. A magic vector; scene and light orientation dependent. <br />
  129. Default — *Three.Vector3( 0, 0, -1000 )*.
  130. </div>
  131. <h3>[property:Array shadowCascadeBias]</h3>
  132. <div>
  133. An array of shadowMapBias values for the corresponding shadow map in the cascade, near to far. <br />
  134. Default — <strong>[ 0, 0, 0 ]</strong>.
  135. </div>
  136. <h3>[property:Array shadowCascadeWidth]</h3>
  137. <div>
  138. An array of shadowMapWidth values for the corresponding shadow map in the cascade, near to far. <br />
  139. Default — <strong>[ 512, 512, 512 ]</strong>.
  140. </div>
  141. <h3>[property:Array shadowCascadeHeight]</h3>
  142. <div>
  143. An array of shadowMapHeight values for the corresponding shadow map in the cascade, near to far. <br />
  144. Default — <strong>[ 512, 512, 512 ]</strong>.
  145. </div>
  146. <h3>[property:Array shadowCascadeNearZ]</h3>
  147. <div>
  148. An array of shadowMapNear values for the corresponding shadow map in the cascade, near to far. These typically start with -1.0 (near plane) and match with the previous shadowCascadeFarZ array value.<br />
  149. Default — <strong>[ -1.000, 0.990, 0.998 ]</strong>.
  150. </div>
  151. <h3>[property:Array shadowCascadeFarZ]</h3>
  152. <div>
  153. An array of shadowMapFar values for the corresponding shadow map in the cascade, near to far. These typically match with the next shadowCascadeNearZ array value, ending in 1.0.<br />
  154. Default — <strong>[ 0.990, 0.998, 1.000 ]</strong>.
  155. </div>
  156. <h3>[property:Array shadowCascadeArray]</h3>
  157. <div>
  158. Array of size shadowCascadeCount of [page:DirectionalLight THREE.DirectionalLight] objects. This holds the series of separate shadow maps in a cascade, near to far. Created internally.
  159. </div>
  160. <h3>[property:Vector2 shadowMapSize]</h3>
  161. <div>
  162. The shadowMapWidth and shadowMapHeight stored in a [page:Vector2 THREE.Vector2]. Set internally during rendering.
  163. </div>
  164. <h3>[property:OrthographicCamera shadowCamera]</h3>
  165. <div>
  166. The shadow's view of the world. Computed internally during rendering from the shadowCamera* settings.
  167. </div>
  168. <h3>[property:Matrix4 shadowMatrix]</h3>
  169. <div>
  170. Model to shadow camera space, to compute location and depth in shadow map. Computed internally during rendering.
  171. </div>
  172. <h3>[property:WebGLRenderTarget shadowMap]</h3>
  173. <div>
  174. The depth map generated using the shadowCamera; a location beyond a pixel's depth is in shadow. Computed internally during rendering.
  175. </div>
  176. <h2>Methods</h2>
  177. <h3>[method:DirectionalLight clone]()</h3>
  178. <div>
  179. It returns a clone of DirectionalLight.
  180. </div>
  181. <h3>[method:JSON toJSON]()</h3>
  182. <div>
  183. Return DirectionalLight data in JSON format.
  184. </div>
  185. <h2>Source</h2>
  186. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  187. </body>
  188. </html>