LensflareNode.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>LensflareNode - 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. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Node.html">Node</a> → <a href="TempNode.html">TempNode</a> → </p>
  13. <h1 translate="no">LensflareNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Post processing node for adding a bloom-based lens flare effect. This effect
  17. requires that you extract the bloom of the scene via a bloom pass first.</p>
  18. <p>References:</p>
  19. <ul>
  20. <li><a href="https://john-chapman-graphics.blogspot.com/2013/02/pseudo-lens-flare.html">https://john-chapman-graphics.blogspot.com/2013/02/pseudo-lens-flare.html</a>.</li>
  21. <li><a href="https://john-chapman.github.io/2017/11/05/pseudo-lens-flare.html">https://john-chapman.github.io/2017/11/05/pseudo-lens-flare.html</a>.</li>
  22. </ul></div>
  23. </header>
  24. <article>
  25. <h2 class="subsection-title">Import</h2>
  26. <p><span translate="no">LensflareNode</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  27. <pre><code class="language-js">import { lensflare } from 'three/addons/tsl/display/LensflareNode.js';</code></pre>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="LensflareNode" translate="no">new <a href="#LensflareNode">LensflareNode</a><span class="signature">( textureNode : <span class="param-type">TextureNode</span>, params : <span class="param-type">Object</span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new lens flare node.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name"><code>textureNode</code></td>
  39. <td class="description last"><p>The texture node that represents the scene's bloom.</p></td>
  40. </tr>
  41. <tr>
  42. <td class="name"><code>params</code></td>
  43. <td class="description last"><p>The parameter object for configuring the effect.</p>
  44. <h6>Properties</h6>
  45. <table class="params">
  46. <tbody>
  47. <tr>
  48. <td class="name"><code>ghostTint</code></td>
  49. <td class="description last"><p>Defines the tint of the flare/ghosts.<br/>Default is <code>vec3(1, 1, 1)</code>.</p></td>
  50. </tr>
  51. <tr>
  52. <td class="name"><code>threshold</code></td>
  53. <td class="description last"><p>Controls the size and strength of the effect. A higher threshold results in smaller flares.<br/>Default is <code>float(0.5)</code>.</p></td>
  54. </tr>
  55. <tr>
  56. <td class="name"><code>ghostSamples</code></td>
  57. <td class="description last"><p>Represents the number of flares/ghosts per bright spot which pivot around the center.<br/>Default is <code>float(4)</code>.</p></td>
  58. </tr>
  59. <tr>
  60. <td class="name"><code>ghostSpacing</code></td>
  61. <td class="description last"><p>Defines the spacing of the flares/ghosts.<br/>Default is <code>float(0.25)</code>.</p></td>
  62. </tr>
  63. <tr>
  64. <td class="name"><code>ghostAttenuationFactor</code></td>
  65. <td class="description last"><p>Defines the attenuation factor of flares/ghosts.<br/>Default is <code>float(25)</code>.</p></td>
  66. </tr>
  67. <tr>
  68. <td class="name"><code>downSampleRatio</code></td>
  69. <td class="description last"><p>Defines how downsampling since the effect is usually not rendered at full resolution.<br/>Default is <code>4</code>.</p></td>
  70. </tr>
  71. </tbody>
  72. </table>
  73. </td>
  74. </tr>
  75. </tbody>
  76. </table>
  77. </div>
  78. </div>
  79. <h2 class="subsection-title">Properties</h2>
  80. <div class="member">
  81. <h3 class="name" id="downSampleRatio" translate="no">.<a href="#downSampleRatio">downSampleRatio</a><span class="type-signature"> : number</span> </h3>
  82. <div class="description">
  83. <p>Defines how downsampling since the effect is usually not rendered at full resolution.</p>
  84. </div>
  85. </div>
  86. <div class="member">
  87. <h3 class="name" id="ghostAttenuationFactorNode" translate="no">.<a href="#ghostAttenuationFactorNode">ghostAttenuationFactorNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  88. <div class="description">
  89. <p>Defines the attenuation factor of flares/ghosts.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="ghostSamplesNode" translate="no">.<a href="#ghostSamplesNode">ghostSamplesNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  94. <div class="description">
  95. <p>Represents the number of flares/ghosts per bright spot which pivot around the center.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <h3 class="name" id="ghostSpacingNode" translate="no">.<a href="#ghostSpacingNode">ghostSpacingNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  100. <div class="description">
  101. <p>Defines the spacing of the flares/ghosts.</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="ghostTintNode" translate="no">.<a href="#ghostTintNode">ghostTintNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  106. <div class="description">
  107. <p>Defines the tint of the flare/ghosts.</p>
  108. </div>
  109. </div>
  110. <div class="member">
  111. <h3 class="name" id="textureNode" translate="no">.<a href="#textureNode">textureNode</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  112. <div class="description">
  113. <p>The texture node that represents the scene's bloom.</p>
  114. </div>
  115. </div>
  116. <div class="member">
  117. <h3 class="name" id="thresholdNode" translate="no">.<a href="#thresholdNode">thresholdNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  118. <div class="description">
  119. <p>Controls the size and strength of the effect. A higher threshold results in smaller flares.</p>
  120. </div>
  121. </div>
  122. <div class="member">
  123. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  124. <div class="description">
  125. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  126. its effect once per frame in <code>updateBefore()</code>.<br/>Default is <code>'frame'</code>.</p>
  127. </div>
  128. <dl class="details">
  129. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  130. </dl>
  131. </div>
  132. <h2 class="subsection-title">Methods</h2>
  133. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  134. <div class="method">
  135. <div class="description">
  136. <p>Frees internal resources. This method should be called
  137. when the effect is no longer required.</p>
  138. </div>
  139. <dl class="details">
  140. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  141. </dl>
  142. </div>
  143. <h3 class="name name-method" id="getTextureNode" translate="no">.<a href="#getTextureNode">getTextureNode</a><span class="signature">()</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  144. <div class="method">
  145. <div class="description">
  146. <p>Returns the result of the effect as a texture node.</p>
  147. </div>
  148. <dl class="details">
  149. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  150. </dl>
  151. </div>
  152. <h3 class="name name-method" id="setSize" translate="no">.<a href="#setSize">setSize</a><span class="signature">( width : <span class="param-type">number</span>, height : <span class="param-type">number</span> )</span> </h3>
  153. <div class="method">
  154. <div class="description">
  155. <p>Sets the size of the effect.</p>
  156. </div>
  157. <table class="params">
  158. <tbody>
  159. <tr>
  160. <td class="name"><code>width</code></td>
  161. <td class="description last"><p>The width of the effect.</p></td>
  162. </tr>
  163. <tr>
  164. <td class="name"><code>height</code></td>
  165. <td class="description last"><p>The height of the effect.</p></td>
  166. </tr>
  167. </tbody>
  168. </table>
  169. </div>
  170. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  171. <div class="method">
  172. <div class="description">
  173. <p>This method is used to setup the effect's TSL code.</p>
  174. </div>
  175. <table class="params">
  176. <tbody>
  177. <tr>
  178. <td class="name"><code>builder</code></td>
  179. <td class="description last"><p>The current node builder.</p></td>
  180. </tr>
  181. </tbody>
  182. </table>
  183. <dl class="details">
  184. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  185. </dl>
  186. <dl class="details">
  187. <dt class="tag-returns"><strong>Returns:</strong> </dt>
  188. </dl>
  189. </div>
  190. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  191. <div class="method">
  192. <div class="description">
  193. <p>This method is used to render the effect once per frame.</p>
  194. </div>
  195. <table class="params">
  196. <tbody>
  197. <tr>
  198. <td class="name"><code>frame</code></td>
  199. <td class="description last"><p>The current node frame.</p></td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. <dl class="details">
  204. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  205. </dl>
  206. </div>
  207. <h2 class="subsection-title">Source</h2>
  208. <p>
  209. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/LensflareNode.js" target="_blank" rel="noopener" translate="no">examples/jsm/tsl/display/LensflareNode.js</a>
  210. </p>
  211. </article>
  212. </section>
  213. <script src="../scripts/linenumber.js"></script>
  214. <script src="../scripts/page.js"></script>
  215. </body>
  216. </html>
粤ICP备19079148号