DepthOfFieldNode.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>DepthOfFieldNode - 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">DepthOfFieldNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Post processing node for creating depth of field (DOF) effect.</p>
  17. <p>References:</p>
  18. <ul>
  19. <li><a href="https://pixelmischiefblog.wordpress.com/2016/11/25/bokeh-depth-of-field/">https://pixelmischiefblog.wordpress.com/2016/11/25/bokeh-depth-of-field/</a></li>
  20. <li><a href="https://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/">https://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/</a></li>
  21. </ul></div>
  22. </header>
  23. <article>
  24. <h2 class="subsection-title">Import</h2>
  25. <p><span translate="no">DepthOfFieldNode</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  26. <pre><code class="language-js">import { dof } from 'three/addons/tsl/display/DepthOfFieldNode.js';</code></pre>
  27. <div class="container-overview">
  28. <h2>Constructor</h2>
  29. <h3 class="name name-method" id="DepthOfFieldNode" translate="no">new <a href="#DepthOfFieldNode">DepthOfFieldNode</a><span class="signature">( textureNode : <span class="param-type">TextureNode</span>, viewZNode : <span class="param-type">Node.&lt;float></span>, focusDistanceNode : <span class="param-type">Node.&lt;float></span>, focalLengthNode : <span class="param-type">Node.&lt;float></span>, bokehScaleNode : <span class="param-type">Node.&lt;float></span> )</span> </h3>
  30. <div class="method">
  31. <div class="description">
  32. <p>Constructs a new DOF node.</p>
  33. </div>
  34. <table class="params">
  35. <tbody>
  36. <tr>
  37. <td class="name"><code>textureNode</code></td>
  38. <td class="description last"><p>The texture node that represents the input of the effect.</p></td>
  39. </tr>
  40. <tr>
  41. <td class="name"><code>viewZNode</code></td>
  42. <td class="description last"><p>Represents the viewZ depth values of the scene.</p></td>
  43. </tr>
  44. <tr>
  45. <td class="name"><code>focusDistanceNode</code></td>
  46. <td class="description last"><p>Defines the effect's focus which is the distance along the camera's look direction in world units.</p></td>
  47. </tr>
  48. <tr>
  49. <td class="name"><code>focalLengthNode</code></td>
  50. <td class="description last"><p>How far an object can be from the focal plane before it goes completely out-of-focus in world units.</p></td>
  51. </tr>
  52. <tr>
  53. <td class="name"><code>bokehScaleNode</code></td>
  54. <td class="description last"><p>A unitless value for artistic purposes to adjust the size of the bokeh.</p></td>
  55. </tr>
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. <h2 class="subsection-title">Properties</h2>
  61. <div class="member">
  62. <h3 class="name" id="bokehScaleNode" translate="no">.<a href="#bokehScaleNode">bokehScaleNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  63. <div class="description">
  64. <p>A unitless value for artistic purposes to adjust the size of the bokeh.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="focalLengthNode" translate="no">.<a href="#focalLengthNode">focalLengthNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  69. <div class="description">
  70. <p>How far an object can be from the focal plane before it goes completely out-of-focus in world units.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="focusDistanceNode" translate="no">.<a href="#focusDistanceNode">focusDistanceNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  75. <div class="description">
  76. <p>Defines the effect's focus which is the distance along the camera's look direction in world units.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="textureNode" translate="no">.<a href="#textureNode">textureNode</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  81. <div class="description">
  82. <p>The texture node that represents the input of the effect.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  87. <div class="description">
  88. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node updates
  89. its internal uniforms once per frame in <code>updateBefore()</code>.<br/>Default is <code>'frame'</code>.</p>
  90. </div>
  91. <dl class="details">
  92. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  93. </dl>
  94. </div>
  95. <div class="member">
  96. <h3 class="name" id="viewZNode" translate="no">.<a href="#viewZNode">viewZNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  97. <div class="description">
  98. <p>Represents the viewZ depth values of the scene.</p>
  99. </div>
  100. </div>
  101. <h2 class="subsection-title">Methods</h2>
  102. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  103. <div class="method">
  104. <div class="description">
  105. <p>Frees internal resources. This method should be called
  106. when the effect is no longer required.</p>
  107. </div>
  108. <dl class="details">
  109. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  110. </dl>
  111. </div>
  112. <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>
  113. <div class="method">
  114. <div class="description">
  115. <p>Returns the result of the effect as a texture node.</p>
  116. </div>
  117. <dl class="details">
  118. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  119. </dl>
  120. </div>
  121. <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>
  122. <div class="method">
  123. <div class="description">
  124. <p>Sets the size of the effect.</p>
  125. </div>
  126. <table class="params">
  127. <tbody>
  128. <tr>
  129. <td class="name"><code>width</code></td>
  130. <td class="description last"><p>The width of the effect.</p></td>
  131. </tr>
  132. <tr>
  133. <td class="name"><code>height</code></td>
  134. <td class="description last"><p>The height of the effect.</p></td>
  135. </tr>
  136. </tbody>
  137. </table>
  138. </div>
  139. <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"> : ShaderCallNodeInternal</span> </h3>
  140. <div class="method">
  141. <div class="description">
  142. <p>This method is used to setup the effect's TSL code.</p>
  143. </div>
  144. <table class="params">
  145. <tbody>
  146. <tr>
  147. <td class="name"><code>builder</code></td>
  148. <td class="description last"><p>The current node builder.</p></td>
  149. </tr>
  150. </tbody>
  151. </table>
  152. <dl class="details">
  153. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  154. </dl>
  155. <dl class="details">
  156. <dt class="tag-returns"><strong>Returns:</strong> </dt>
  157. </dl>
  158. </div>
  159. <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>
  160. <div class="method">
  161. <div class="description">
  162. <p>This method is used to update the effect's uniforms once per frame.</p>
  163. </div>
  164. <table class="params">
  165. <tbody>
  166. <tr>
  167. <td class="name"><code>frame</code></td>
  168. <td class="description last"><p>The current node frame.</p></td>
  169. </tr>
  170. </tbody>
  171. </table>
  172. <dl class="details">
  173. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  174. </dl>
  175. </div>
  176. <h2 class="subsection-title">Source</h2>
  177. <p>
  178. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/DepthOfFieldNode.js" target="_blank" rel="noopener" translate="no">examples/jsm/tsl/display/DepthOfFieldNode.js</a>
  179. </p>
  180. </article>
  181. </section>
  182. <script src="../scripts/linenumber.js"></script>
  183. <script src="../scripts/page.js"></script>
  184. </body>
  185. </html>
粤ICP备19079148号