LensflareNode.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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" target="_blank" rel="noopener">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" target="_blank" rel="noopener">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" rel="noopener">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"><a href="TextureNode.html">TextureNode</a></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">
  39. <strong>textureNode</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The texture node that represents the scene's bloom.</p>
  43. </td>
  44. </tr>
  45. <tr>
  46. <td class="name">
  47. <strong>params</strong>
  48. </td>
  49. <td class="description last">
  50. <p>The parameter object for configuring the effect.</p>
  51. <table class="params">
  52. <tbody>
  53. <tr>
  54. <td class="name">
  55. <strong>ghostTint</strong>
  56. </td>
  57. <td class="description last">
  58. <p>Defines the tint of the flare/ghosts.</p>
  59. <p>Default is <code>vec3(1, 1, 1)</code>.</p>
  60. </td>
  61. </tr>
  62. <tr>
  63. <td class="name">
  64. <strong>threshold</strong>
  65. </td>
  66. <td class="description last">
  67. <p>Controls the size and strength of the effect. A higher threshold results in smaller flares.</p>
  68. <p>Default is <code>float(0.5)</code>.</p>
  69. </td>
  70. </tr>
  71. <tr>
  72. <td class="name">
  73. <strong>ghostSamples</strong>
  74. </td>
  75. <td class="description last">
  76. <p>Represents the number of flares/ghosts per bright spot which pivot around the center.</p>
  77. <p>Default is <code>float(4)</code>.</p>
  78. </td>
  79. </tr>
  80. <tr>
  81. <td class="name">
  82. <strong>ghostSpacing</strong>
  83. </td>
  84. <td class="description last">
  85. <p>Defines the spacing of the flares/ghosts.</p>
  86. <p>Default is <code>float(0.25)</code>.</p>
  87. </td>
  88. </tr>
  89. <tr>
  90. <td class="name">
  91. <strong>ghostAttenuationFactor</strong>
  92. </td>
  93. <td class="description last">
  94. <p>Defines the attenuation factor of flares/ghosts.</p>
  95. <p>Default is <code>float(25)</code>.</p>
  96. </td>
  97. </tr>
  98. <tr>
  99. <td class="name">
  100. <strong>downSampleRatio</strong>
  101. </td>
  102. <td class="description last">
  103. <p>Defines how downsampling since the effect is usually not rendered at full resolution.</p>
  104. <p>Default is <code>4</code>.</p>
  105. </td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. </td>
  110. </tr>
  111. </tbody>
  112. </table>
  113. </div>
  114. </div>
  115. <h2 class="subsection-title">Properties</h2>
  116. <div class="member">
  117. <h3 class="name" id="downSampleRatio" translate="no">.<a href="#downSampleRatio">downSampleRatio</a><span class="type-signature"> : number</span> </h3>
  118. <div class="description">
  119. <p>Defines how downsampling since the effect is usually not rendered at full resolution.</p>
  120. </div>
  121. </div>
  122. <div class="member">
  123. <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>
  124. <div class="description">
  125. <p>Defines the attenuation factor of flares/ghosts.</p>
  126. </div>
  127. </div>
  128. <div class="member">
  129. <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>
  130. <div class="description">
  131. <p>Represents the number of flares/ghosts per bright spot which pivot around the center.</p>
  132. </div>
  133. </div>
  134. <div class="member">
  135. <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>
  136. <div class="description">
  137. <p>Defines the spacing of the flares/ghosts.</p>
  138. </div>
  139. </div>
  140. <div class="member">
  141. <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>
  142. <div class="description">
  143. <p>Defines the tint of the flare/ghosts.</p>
  144. </div>
  145. </div>
  146. <div class="member">
  147. <h3 class="name" id="textureNode" translate="no">.<a href="#textureNode">textureNode</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  148. <div class="description">
  149. <p>The texture node that represents the scene's bloom.</p>
  150. </div>
  151. </div>
  152. <div class="member">
  153. <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>
  154. <div class="description">
  155. <p>Controls the size and strength of the effect. A higher threshold results in smaller flares.</p>
  156. </div>
  157. </div>
  158. <div class="member">
  159. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  160. <div class="description">
  161. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  162. its effect once per frame in <code>updateBefore()</code>.</p>
  163. <p>Default is <code>'frame'</code>.</p>
  164. </div>
  165. <dl class="details">
  166. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  167. </dl>
  168. </div>
  169. <h2 class="subsection-title">Methods</h2>
  170. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  171. <div class="method">
  172. <div class="description">
  173. <p>Frees internal resources. This method should be called
  174. when the effect is no longer required.</p>
  175. </div>
  176. <dl class="details">
  177. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  178. </dl>
  179. </div>
  180. <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>
  181. <div class="method">
  182. <div class="description">
  183. <p>Returns the result of the effect as a texture node.</p>
  184. </div>
  185. <dl class="details">
  186. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  187. </dl>
  188. </div>
  189. <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>
  190. <div class="method">
  191. <div class="description">
  192. <p>Sets the size of the effect.</p>
  193. </div>
  194. <table class="params">
  195. <tbody>
  196. <tr>
  197. <td class="name">
  198. <strong>width</strong>
  199. </td>
  200. <td class="description last">
  201. <p>The width of the effect.</p>
  202. </td>
  203. </tr>
  204. <tr>
  205. <td class="name">
  206. <strong>height</strong>
  207. </td>
  208. <td class="description last">
  209. <p>The height of the effect.</p>
  210. </td>
  211. </tr>
  212. </tbody>
  213. </table>
  214. </div>
  215. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  216. <div class="method">
  217. <div class="description">
  218. <p>This method is used to setup the effect's TSL code.</p>
  219. </div>
  220. <table class="params">
  221. <tbody>
  222. <tr>
  223. <td class="name">
  224. <strong>builder</strong>
  225. </td>
  226. <td class="description last">
  227. <p>The current node builder.</p>
  228. </td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. <dl class="details">
  233. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  234. </dl>
  235. </div>
  236. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  237. <div class="method">
  238. <div class="description">
  239. <p>This method is used to render the effect once per frame.</p>
  240. </div>
  241. <table class="params">
  242. <tbody>
  243. <tr>
  244. <td class="name">
  245. <strong>frame</strong>
  246. </td>
  247. <td class="description last">
  248. <p>The current node frame.</p>
  249. </td>
  250. </tr>
  251. </tbody>
  252. </table>
  253. <dl class="details">
  254. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  255. </dl>
  256. </div>
  257. <h2 class="subsection-title">Source</h2>
  258. <p>
  259. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/LensflareNode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/LensflareNode.js</a>
  260. </p>
  261. </article>
  262. </section>
  263. <script src="../scripts/linenumber.js"></script>
  264. <script src="../scripts/page.js"></script>
  265. </body>
  266. </html>
粤ICP备19079148号