BokehPass.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>BokehPass - 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="Pass.html">Pass</a> → </p>
  13. <h1 translate="no">BokehPass</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Pass for creating depth of field (DOF) effect.</p></div>
  17. <h2>Code Example</h2>
  18. <div translate="no"><pre><code class="language-js">const bokehPass = new BokehPass( scene, camera, {
  19. focus: 500
  20. aperture: 5,
  21. maxblur: 0.01
  22. } );
  23. composer.addPass( bokehPass );
  24. </code></pre></div>
  25. </header>
  26. <article>
  27. <h2 class="subsection-title">Import</h2>
  28. <p><span translate="no">BokehPass</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  29. <pre><code class="language-js">import { BokehPass } from 'three/addons/postprocessing/BokehPass.js';</code></pre>
  30. <div class="container-overview">
  31. <h2>Constructor</h2>
  32. <h3 class="name name-method" id="BokehPass" translate="no">new <a href="#BokehPass">BokehPass</a><span class="signature">( scene : <span class="param-type">Scene</span>, camera : <span class="param-type">Camera</span>, params : <span class="param-type">BokehPass~Options</span> )</span> </h3>
  33. <div class="method">
  34. <div class="description">
  35. <p>Constructs a new Bokeh pass.</p>
  36. </div>
  37. <table class="params">
  38. <tbody>
  39. <tr>
  40. <td class="name"><code>scene</code></td>
  41. <td class="description last"><p>The scene to render the DOF for.</p></td>
  42. </tr>
  43. <tr>
  44. <td class="name"><code>camera</code></td>
  45. <td class="description last"><p>The camera.</p></td>
  46. </tr>
  47. <tr>
  48. <td class="name"><code>params</code></td>
  49. <td class="description last"><p>The pass options.</p></td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. </div>
  55. <h2 class="subsection-title">Properties</h2>
  56. <div class="member">
  57. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  58. <div class="description">
  59. <p>The camera.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="materialBokeh" translate="no">.<a href="#materialBokeh">materialBokeh</a><span class="type-signature"> : <a href="ShaderMaterial.html">ShaderMaterial</a></span> </h3>
  64. <div class="description">
  65. <p>The pass bokeh material.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  70. <div class="description">
  71. <p>The scene to render the DOF for.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="uniforms" translate="no">.<a href="#uniforms">uniforms</a><span class="type-signature"> : Object</span> </h3>
  76. <div class="description">
  77. <p>The pass uniforms. Use this object if you want to update the
  78. <code>focus</code>, <code>aperture</code> or <code>maxblur</code> values at runtime.</p>
  79. <pre><code class="language-js">pass.uniforms.focus.value = focus;
  80. pass.uniforms.aperture.value = aperture;
  81. pass.uniforms.maxblur.value = maxblur;
  82. </code></pre>
  83. </div>
  84. </div>
  85. <h2 class="subsection-title">Methods</h2>
  86. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  87. <div class="method">
  88. <div class="description">
  89. <p>Frees the GPU-related resources allocated by this instance. Call this
  90. method whenever the pass is no longer used in your app.</p>
  91. </div>
  92. <dl class="details">
  93. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#dispose">Pass#dispose</a></dt>
  94. </dl>
  95. </div>
  96. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( renderer : <span class="param-type">WebGLRenderer</span>, writeBuffer : <span class="param-type">WebGLRenderTarget</span>, readBuffer : <span class="param-type">WebGLRenderTarget</span>, deltaTime : <span class="param-type">number</span>, maskActive : <span class="param-type">boolean</span> )</span> </h3>
  97. <div class="method">
  98. <div class="description">
  99. <p>Performs the Bokeh pass.</p>
  100. </div>
  101. <table class="params">
  102. <tbody>
  103. <tr>
  104. <td class="name"><code>renderer</code></td>
  105. <td class="description last"><p>The renderer.</p></td>
  106. </tr>
  107. <tr>
  108. <td class="name"><code>writeBuffer</code></td>
  109. <td class="description last"><p>The write buffer. This buffer is intended as the rendering
  110. destination for the pass.</p></td>
  111. </tr>
  112. <tr>
  113. <td class="name"><code>readBuffer</code></td>
  114. <td class="description last"><p>The read buffer. The pass can access the result from the
  115. previous pass from this buffer.</p></td>
  116. </tr>
  117. <tr>
  118. <td class="name"><code>deltaTime</code></td>
  119. <td class="description last"><p>The delta time in seconds.</p></td>
  120. </tr>
  121. <tr>
  122. <td class="name"><code>maskActive</code></td>
  123. <td class="description last"><p>Whether masking is active or not.</p></td>
  124. </tr>
  125. </tbody>
  126. </table>
  127. <dl class="details">
  128. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#render">Pass#render</a></dt>
  129. </dl>
  130. </div>
  131. <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>
  132. <div class="method">
  133. <div class="description">
  134. <p>Sets the size of the pass.</p>
  135. </div>
  136. <table class="params">
  137. <tbody>
  138. <tr>
  139. <td class="name"><code>width</code></td>
  140. <td class="description last"><p>The width to set.</p></td>
  141. </tr>
  142. <tr>
  143. <td class="name"><code>height</code></td>
  144. <td class="description last"><p>The height to set.</p></td>
  145. </tr>
  146. </tbody>
  147. </table>
  148. <dl class="details">
  149. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#setSize">Pass#setSize</a></dt>
  150. </dl>
  151. </div>
  152. <h2 class="subsection-title">Type Definitions</h2>
  153. <div class="member">
  154. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  155. <div class="description">
  156. <p>Constructor options of <code>BokehPass</code>.</p>
  157. </div>
  158. <h5 class="subsection-title">Properties:</h5>
  159. <table class="props">
  160. <thead>
  161. <tr>
  162. <th>Name</th>
  163. <th>Type</th>
  164. <th>Attributes</th>
  165. <th>Default</th>
  166. <th class="last">Description</th>
  167. </tr>
  168. </thead>
  169. <tbody>
  170. <tr>
  171. <td class="name"><code>focus</code></td>
  172. <td class="type">
  173. <span class="param-type">number</span>
  174. </td>
  175. <td class="attributes">
  176. &lt;optional><br>
  177. </td>
  178. <td class="default">
  179. 1
  180. </td>
  181. <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>
  182. </tr>
  183. <tr>
  184. <td class="name"><code>aperture</code></td>
  185. <td class="type">
  186. <span class="param-type">number</span>
  187. </td>
  188. <td class="attributes">
  189. &lt;optional><br>
  190. </td>
  191. <td class="default">
  192. 0.025
  193. </td>
  194. <td class="description last"><p>Defines the effect's aperture.</p></td>
  195. </tr>
  196. <tr>
  197. <td class="name"><code>maxblur</code></td>
  198. <td class="type">
  199. <span class="param-type">number</span>
  200. </td>
  201. <td class="attributes">
  202. &lt;optional><br>
  203. </td>
  204. <td class="default">
  205. 1
  206. </td>
  207. <td class="description last"><p>Defines the effect's maximum blur.</p></td>
  208. </tr>
  209. </tbody>
  210. </table>
  211. </div>
  212. <h2 class="subsection-title">Source</h2>
  213. <p>
  214. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/BokehPass.js" target="_blank" rel="noopener" translate="no">examples/jsm/postprocessing/BokehPass.js</a>
  215. </p>
  216. </article>
  217. </section>
  218. <script src="../scripts/linenumber.js"></script>
  219. <script src="../scripts/page.js"></script>
  220. </body>
  221. </html>
粤ICP备19079148号