DirectionalLight.html 7.3 KB

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