LightShadow.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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>BasicShadowMap</code>.</p>
  146. <p>Default is <code>1</code>.</p>
  147. </div>
  148. </div>
  149. <h2 class="subsection-title">Methods</h2>
  150. <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>
  151. <div class="method">
  152. <div class="description">
  153. <p>Returns a new light shadow instance with copied values from this instance.</p>
  154. </div>
  155. <dl class="details">
  156. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  157. </dl>
  158. </div>
  159. <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>
  160. <div class="method">
  161. <div class="description">
  162. <p>Copies the values of the given light shadow instance to this instance.</p>
  163. </div>
  164. <table class="params">
  165. <tbody>
  166. <tr>
  167. <td class="name">
  168. <strong>source</strong>
  169. </td>
  170. <td class="description last">
  171. <p>The light shadow to copy.</p>
  172. </td>
  173. </tr>
  174. </tbody>
  175. </table>
  176. <dl class="details">
  177. <dt class="tag-returns"><strong>Returns:</strong> A reference to this light shadow instance.</dt>
  178. </dl>
  179. </div>
  180. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  181. <div class="method">
  182. <div class="description">
  183. <p>Frees the GPU-related resources allocated by this instance. Call this
  184. method whenever this instance is no longer used in your app.</p>
  185. </div>
  186. </div>
  187. <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>
  188. <div class="method">
  189. <div class="description">
  190. <p>Returns the frame extends.</p>
  191. </div>
  192. <dl class="details">
  193. <dt class="tag-returns"><strong>Returns:</strong> The frame extends.</dt>
  194. </dl>
  195. </div>
  196. <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>
  197. <div class="method">
  198. <div class="description">
  199. <p>Gets the shadow cameras frustum. Used internally by the renderer to cull objects.</p>
  200. </div>
  201. <dl class="details">
  202. <dt class="tag-returns"><strong>Returns:</strong> The shadow camera frustum.</dt>
  203. </dl>
  204. </div>
  205. <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>
  206. <div class="method">
  207. <div class="description">
  208. <p>Returns a viewport definition for the given viewport index.</p>
  209. </div>
  210. <table class="params">
  211. <tbody>
  212. <tr>
  213. <td class="name">
  214. <strong>viewportIndex</strong>
  215. </td>
  216. <td class="description last">
  217. <p>The viewport index.</p>
  218. </td>
  219. </tr>
  220. </tbody>
  221. </table>
  222. <dl class="details">
  223. <dt class="tag-returns"><strong>Returns:</strong> The viewport.</dt>
  224. </dl>
  225. </div>
  226. <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>
  227. <div class="method">
  228. <div class="description">
  229. <p>Used internally by the renderer to get the number of viewports that need
  230. to be rendered for this shadow.</p>
  231. </div>
  232. <dl class="details">
  233. <dt class="tag-returns"><strong>Returns:</strong> The viewport count.</dt>
  234. </dl>
  235. </div>
  236. <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>
  237. <div class="method">
  238. <div class="description">
  239. <p>Serializes the light shadow into JSON.</p>
  240. </div>
  241. <dl class="details">
  242. <dt class="tag-see">See:</dt>
  243. <dd class="tag-see">
  244. <ul>
  245. <li><a href="ObjectLoader.html#parse">ObjectLoader#parse</a></li>
  246. </ul>
  247. </dd>
  248. </dl>
  249. <dl class="details">
  250. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized light shadow.</dt>
  251. </dl>
  252. </div>
  253. <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>
  254. <div class="method">
  255. <div class="description">
  256. <p>Update the matrices for the camera and shadow, used internally by the renderer.</p>
  257. </div>
  258. <table class="params">
  259. <tbody>
  260. <tr>
  261. <td class="name">
  262. <strong>light</strong>
  263. </td>
  264. <td class="description last">
  265. <p>The light for which the shadow is being rendered.</p>
  266. </td>
  267. </tr>
  268. </tbody>
  269. </table>
  270. </div>
  271. <h2 class="subsection-title">Source</h2>
  272. <p>
  273. <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>
  274. </p>
  275. </article>
  276. </section>
  277. <script src="../scripts/linenumber.js"></script>
  278. <script src="../scripts/page.js"></script>
  279. </body>
  280. </html>
粤ICP备19079148号