LightShadow.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>LightShadow - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">LightShadow</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Abstract base class for light shadow classes. These classes
  16. represent the shadow configuration for different light types.</p></div>
  17. </header>
  18. <article>
  19. <div class="container-overview">
  20. <h2>Constructor</h2>
  21. <h3 class="name name-method" id="LightShadow" translate="no">new <a href="#LightShadow">LightShadow</a><span class="signature">( camera : <span class="param-type">Camera</span> )</span> <span class="type-signature">(abstract) </span></h3>
  22. <div class="method">
  23. <div class="description">
  24. <p>Constructs a new light shadow.</p>
  25. </div>
  26. <table class="params">
  27. <tbody>
  28. <tr>
  29. <td class="name"><code>camera</code></td>
  30. <td class="description last"><p>The light's view of the world.</p></td>
  31. </tr>
  32. </tbody>
  33. </table>
  34. </div>
  35. </div>
  36. <h2 class="subsection-title">Properties</h2>
  37. <div class="member">
  38. <h3 class="name" id="autoUpdate" translate="no">.<a href="#autoUpdate">autoUpdate</a><span class="type-signature"> : boolean</span> </h3>
  39. <div class="description">
  40. <p>Enables automatic updates of the light's shadow. If you do not require dynamic
  41. lighting / shadows, you may set this to <code>false</code>.<br/>Default is <code>true</code>.</p>
  42. </div>
  43. </div>
  44. <div class="member">
  45. <h3 class="name" id="bias" translate="no">.<a href="#bias">bias</a><span class="type-signature"> : number</span> </h3>
  46. <div class="description">
  47. <p>Shadow map bias, how much to add or subtract from the normalized depth
  48. when deciding whether a surface is in shadow.</p>
  49. <p>The default is <code>0</code>. Very tiny adjustments here (in the order of <code>0.0001</code>)
  50. may help reduce artifacts in shadows.<br/>Default is <code>0</code>.</p>
  51. </div>
  52. </div>
  53. <div class="member">
  54. <h3 class="name" id="blurSamples" translate="no">.<a href="#blurSamples">blurSamples</a><span class="type-signature"> : number</span> </h3>
  55. <div class="description">
  56. <p>The amount of samples to use when blurring a VSM shadow map.<br/>Default is <code>8</code>.</p>
  57. </div>
  58. </div>
  59. <div class="member">
  60. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  61. <div class="description">
  62. <p>The light's view of the world.</p>
  63. </div>
  64. </div>
  65. <div class="member">
  66. <h3 class="name" id="intensity" translate="no">.<a href="#intensity">intensity</a><span class="type-signature"> : number</span> </h3>
  67. <div class="description">
  68. <p>The intensity of the shadow. The default is <code>1</code>.
  69. Valid values are in the range <code>[0, 1]</code>.<br/>Default is <code>1</code>.</p>
  70. </div>
  71. </div>
  72. <div class="member">
  73. <h3 class="name" id="map" translate="no">.<a href="#map">map</a><span class="type-signature"> : <a href="RenderTarget.html">RenderTarget</a></span> </h3>
  74. <div class="description">
  75. <p>The depth map generated using the internal camera; a location beyond a
  76. pixel's depth is in shadow. Computed internally during rendering.<br/>Default is <code>null</code>.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="mapPass" translate="no">.<a href="#mapPass">mapPass</a><span class="type-signature"> : <a href="RenderTarget.html">RenderTarget</a></span> </h3>
  81. <div class="description">
  82. <p>The distribution map generated using the internal camera; an occlusion is
  83. calculated based on the distribution of depths. Computed internally during
  84. rendering.<br/>Default is <code>null</code>.</p>
  85. </div>
  86. </div>
  87. <div class="member">
  88. <h3 class="name" id="mapSize" translate="no">.<a href="#mapSize">mapSize</a><span class="type-signature"> : <a href="Vector2.html">Vector2</a></span> </h3>
  89. <div class="description">
  90. <p>Defines the width and height of the shadow map. Higher values give better quality
  91. shadows at the cost of computation time. Values must be powers of two.<br/>Default is <code>(512,512)</code>.</p>
  92. </div>
  93. </div>
  94. <div class="member">
  95. <h3 class="name" id="mapType" translate="no">.<a href="#mapType">mapType</a><span class="type-signature"> : number</span> </h3>
  96. <div class="description">
  97. <p>The type of shadow texture. The default is <code>UnsignedByteType</code>.<br/>Default is <code>UnsignedByteType</code>.</p>
  98. </div>
  99. </div>
  100. <div class="member">
  101. <h3 class="name" id="matrix" translate="no">.<a href="#matrix">matrix</a><span class="type-signature"> : <a href="Matrix4.html">Matrix4</a></span> </h3>
  102. <div class="description">
  103. <p>Model to shadow camera space, to compute location and depth in shadow map.
  104. This is computed internally during rendering.</p>
  105. </div>
  106. </div>
  107. <div class="member">
  108. <h3 class="name" id="needsUpdate" translate="no">.<a href="#needsUpdate">needsUpdate</a><span class="type-signature"> : boolean</span> </h3>
  109. <div class="description">
  110. <p>When set to <code>true</code>, shadow maps will be updated in the next <code>render</code> call.
  111. If you have set <a href="LightShadow.html#autoUpdate">LightShadow#autoUpdate</a> to <code>false</code>, you will need to
  112. set this property to <code>true</code> and then make a render call to update the light's shadow.<br/>Default is <code>false</code>.</p>
  113. </div>
  114. </div>
  115. <div class="member">
  116. <h3 class="name" id="normalBias" translate="no">.<a href="#normalBias">normalBias</a><span class="type-signature"> : number</span> </h3>
  117. <div class="description">
  118. <p>Defines how much the position used to query the shadow map is offset along
  119. the object normal. The default is <code>0</code>. Increasing this value can be used to
  120. reduce shadow acne especially in large scenes where light shines onto
  121. geometry at a shallow angle. The cost is that shadows may appear distorted.<br/>Default is <code>0</code>.</p>
  122. </div>
  123. </div>
  124. <div class="member">
  125. <h3 class="name" id="radius" translate="no">.<a href="#radius">radius</a><span class="type-signature"> : number</span> </h3>
  126. <div class="description">
  127. <p>Setting this to values greater than 1 will blur the edges of the shadow.
  128. High values will cause unwanted banding effects in the shadows - a greater
  129. map size will allow for a higher value to be used here before these effects
  130. become visible.</p>
  131. <p>The property has no effect when the shadow map type is <code>PCFSoftShadowMap</code> and
  132. and it is recommended to increase softness by decreasing the shadow map size instead.</p>
  133. <p>The property has no effect when the shadow map type is <code>BasicShadowMap</code>.<br/>Default is <code>1</code>.</p>
  134. </div>
  135. </div>
  136. <h2 class="subsection-title">Methods</h2>
  137. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="LightShadow.html">LightShadow</a></span> </h3>
  138. <div class="method">
  139. <div class="description">
  140. <p>Returns a new light shadow instance with copied values from this instance.</p>
  141. </div>
  142. <dl class="details">
  143. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  144. </dl>
  145. </div>
  146. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( source : <span class="param-type">LightShadow</span> )</span><span class="type-signature"> : <a href="LightShadow.html">LightShadow</a></span> </h3>
  147. <div class="method">
  148. <div class="description">
  149. <p>Copies the values of the given light shadow instance to this instance.</p>
  150. </div>
  151. <table class="params">
  152. <tbody>
  153. <tr>
  154. <td class="name"><code>source</code></td>
  155. <td class="description last"><p>The light shadow to copy.</p></td>
  156. </tr>
  157. </tbody>
  158. </table>
  159. <dl class="details">
  160. <dt class="tag-returns"><strong>Returns:</strong> A reference to this light shadow instance.</dt>
  161. </dl>
  162. </div>
  163. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  164. <div class="method">
  165. <div class="description">
  166. <p>Frees the GPU-related resources allocated by this instance. Call this
  167. method whenever this instance is no longer used in your app.</p>
  168. </div>
  169. </div>
  170. <h3 class="name name-method" id="getFrameExtents" translate="no">.<a href="#getFrameExtents">getFrameExtents</a><span class="signature">()</span><span class="type-signature"> : <a href="Vector2.html">Vector2</a></span> </h3>
  171. <div class="method">
  172. <div class="description">
  173. <p>Returns the frame extends.</p>
  174. </div>
  175. <dl class="details">
  176. <dt class="tag-returns"><strong>Returns:</strong> The frame extends.</dt>
  177. </dl>
  178. </div>
  179. <h3 class="name name-method" id="getFrustum" translate="no">.<a href="#getFrustum">getFrustum</a><span class="signature">()</span><span class="type-signature"> : <a href="Frustum.html">Frustum</a></span> </h3>
  180. <div class="method">
  181. <div class="description">
  182. <p>Gets the shadow cameras frustum. Used internally by the renderer to cull objects.</p>
  183. </div>
  184. <dl class="details">
  185. <dt class="tag-returns"><strong>Returns:</strong> The shadow camera frustum.</dt>
  186. </dl>
  187. </div>
  188. <h3 class="name name-method" id="getViewport" translate="no">.<a href="#getViewport">getViewport</a><span class="signature">( viewportIndex : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
  189. <div class="method">
  190. <div class="description">
  191. <p>Returns a viewport definition for the given viewport index.</p>
  192. </div>
  193. <table class="params">
  194. <tbody>
  195. <tr>
  196. <td class="name"><code>viewportIndex</code></td>
  197. <td class="description last"><p>The viewport index.</p></td>
  198. </tr>
  199. </tbody>
  200. </table>
  201. <dl class="details">
  202. <dt class="tag-returns"><strong>Returns:</strong> The viewport.</dt>
  203. </dl>
  204. </div>
  205. <h3 class="name name-method" id="getViewportCount" translate="no">.<a href="#getViewportCount">getViewportCount</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  206. <div class="method">
  207. <div class="description">
  208. <p>Used internally by the renderer to get the number of viewports that need
  209. to be rendered for this shadow.</p>
  210. </div>
  211. <dl class="details">
  212. <dt class="tag-returns"><strong>Returns:</strong> The viewport count.</dt>
  213. </dl>
  214. </div>
  215. <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">()</span><span class="type-signature"> : Object</span> </h3>
  216. <div class="method">
  217. <div class="description">
  218. <p>Serializes the light shadow into JSON.</p>
  219. </div>
  220. <dl class="details">
  221. <dt class="tag-see">See:</dt>
  222. <dd class="tag-see">
  223. <ul>
  224. <li><a href="ObjectLoader.html#parse">ObjectLoader#parse</a></li>
  225. </ul>
  226. </dd>
  227. </dl>
  228. <dl class="details">
  229. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized light shadow.</dt>
  230. </dl>
  231. </div>
  232. <h3 class="name name-method" id="updateMatrices" translate="no">.<a href="#updateMatrices">updateMatrices</a><span class="signature">( light : <span class="param-type">Light</span> )</span> </h3>
  233. <div class="method">
  234. <div class="description">
  235. <p>Update the matrices for the camera and shadow, used internally by the renderer.</p>
  236. </div>
  237. <table class="params">
  238. <tbody>
  239. <tr>
  240. <td class="name"><code>light</code></td>
  241. <td class="description last"><p>The light for which the shadow is being rendered.</p></td>
  242. </tr>
  243. </tbody>
  244. </table>
  245. </div>
  246. <h2 class="subsection-title">Source</h2>
  247. <p>
  248. <a href="https://github.com/mrdoob/three.js/blob/master/src/lights/LightShadow.js" target="_blank" rel="noopener" translate="no">src/lights/LightShadow.js</a>
  249. </p>
  250. </article>
  251. </section>
  252. <script src="../scripts/linenumber.js"></script>
  253. <script src="../scripts/page.js"></script>
  254. </body>
  255. </html>
粤ICP备19079148号