LightShadow.html 13 KB

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