BokehPass.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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" rel="noopener">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"><a href="Scene.html">Scene</a></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></span>, params : <span class="param-type"><a href="BokehPass.html#~Options">BokehPass~Options</a></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">
  41. <strong>scene</strong>
  42. </td>
  43. <td class="description last">
  44. <p>The scene to render the DOF for.</p>
  45. </td>
  46. </tr>
  47. <tr>
  48. <td class="name">
  49. <strong>camera</strong>
  50. </td>
  51. <td class="description last">
  52. <p>The camera.</p>
  53. </td>
  54. </tr>
  55. <tr>
  56. <td class="name">
  57. <strong>params</strong>
  58. </td>
  59. <td class="description last">
  60. <p>The pass options.</p>
  61. </td>
  62. </tr>
  63. </tbody>
  64. </table>
  65. </div>
  66. </div>
  67. <h2 class="subsection-title">Properties</h2>
  68. <div class="member">
  69. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  70. <div class="description">
  71. <p>The camera.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="materialBokeh" translate="no">.<a href="#materialBokeh">materialBokeh</a><span class="type-signature"> : <a href="ShaderMaterial.html">ShaderMaterial</a></span> </h3>
  76. <div class="description">
  77. <p>The pass bokeh material.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  82. <div class="description">
  83. <p>The scene to render the DOF for.</p>
  84. </div>
  85. </div>
  86. <div class="member">
  87. <h3 class="name" id="uniforms" translate="no">.<a href="#uniforms">uniforms</a><span class="type-signature"> : Object</span> </h3>
  88. <div class="description">
  89. <p>The pass uniforms. Use this object if you want to update the
  90. <code>focus</code>, <code>aperture</code> or <code>maxblur</code> values at runtime.</p>
  91. <pre><code class="language-js">pass.uniforms.focus.value = focus;
  92. pass.uniforms.aperture.value = aperture;
  93. pass.uniforms.maxblur.value = maxblur;
  94. </code></pre>
  95. </div>
  96. </div>
  97. <h2 class="subsection-title">Methods</h2>
  98. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  99. <div class="method">
  100. <div class="description">
  101. <p>Frees the GPU-related resources allocated by this instance. Call this
  102. method whenever the pass is no longer used in your app.</p>
  103. </div>
  104. <dl class="details">
  105. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#dispose">Pass#dispose</a></dt>
  106. </dl>
  107. </div>
  108. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( renderer : <span class="param-type"><a href="WebGLRenderer.html">WebGLRenderer</a></span>, writeBuffer : <span class="param-type"><a href="WebGLRenderTarget.html">WebGLRenderTarget</a></span>, readBuffer : <span class="param-type"><a href="WebGLRenderTarget.html">WebGLRenderTarget</a></span>, deltaTime : <span class="param-type">number</span>, maskActive : <span class="param-type">boolean</span> )</span> </h3>
  109. <div class="method">
  110. <div class="description">
  111. <p>Performs the Bokeh pass.</p>
  112. </div>
  113. <table class="params">
  114. <tbody>
  115. <tr>
  116. <td class="name">
  117. <strong>renderer</strong>
  118. </td>
  119. <td class="description last">
  120. <p>The renderer.</p>
  121. </td>
  122. </tr>
  123. <tr>
  124. <td class="name">
  125. <strong>writeBuffer</strong>
  126. </td>
  127. <td class="description last">
  128. <p>The write buffer. This buffer is intended as the rendering
  129. destination for the pass.</p>
  130. </td>
  131. </tr>
  132. <tr>
  133. <td class="name">
  134. <strong>readBuffer</strong>
  135. </td>
  136. <td class="description last">
  137. <p>The read buffer. The pass can access the result from the
  138. previous pass from this buffer.</p>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td class="name">
  143. <strong>deltaTime</strong>
  144. </td>
  145. <td class="description last">
  146. <p>The delta time in seconds.</p>
  147. </td>
  148. </tr>
  149. <tr>
  150. <td class="name">
  151. <strong>maskActive</strong>
  152. </td>
  153. <td class="description last">
  154. <p>Whether masking is active or not.</p>
  155. </td>
  156. </tr>
  157. </tbody>
  158. </table>
  159. <dl class="details">
  160. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#render">Pass#render</a></dt>
  161. </dl>
  162. </div>
  163. <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>
  164. <div class="method">
  165. <div class="description">
  166. <p>Sets the size of the pass.</p>
  167. </div>
  168. <table class="params">
  169. <tbody>
  170. <tr>
  171. <td class="name">
  172. <strong>width</strong>
  173. </td>
  174. <td class="description last">
  175. <p>The width to set.</p>
  176. </td>
  177. </tr>
  178. <tr>
  179. <td class="name">
  180. <strong>height</strong>
  181. </td>
  182. <td class="description last">
  183. <p>The height to set.</p>
  184. </td>
  185. </tr>
  186. </tbody>
  187. </table>
  188. <dl class="details">
  189. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Pass.html#setSize">Pass#setSize</a></dt>
  190. </dl>
  191. </div>
  192. <h2 class="subsection-title">Type Definitions</h2>
  193. <div class="member">
  194. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  195. <div class="description">
  196. <p>Constructor options of <code>BokehPass</code>.</p>
  197. </div>
  198. <table class="props">
  199. <tbody>
  200. <tr>
  201. <td class="name">
  202. <strong>focus</strong>
  203. <br>
  204. <span class="param-type">number</span>
  205. </td>
  206. <td class="description last">
  207. <p>Defines the effect's focus which is the distance along the camera's look direction in world units.</p>
  208. <p>Default is <code>1</code>.</p>
  209. </td>
  210. </tr>
  211. <tr>
  212. <td class="name">
  213. <strong>aperture</strong>
  214. <br>
  215. <span class="param-type">number</span>
  216. </td>
  217. <td class="description last">
  218. <p>Defines the effect's aperture.</p>
  219. <p>Default is <code>0.025</code>.</p>
  220. </td>
  221. </tr>
  222. <tr>
  223. <td class="name">
  224. <strong>maxblur</strong>
  225. <br>
  226. <span class="param-type">number</span>
  227. </td>
  228. <td class="description last">
  229. <p>Defines the effect's maximum blur.</p>
  230. <p>Default is <code>1</code>.</p>
  231. </td>
  232. </tr>
  233. </tbody>
  234. </table>
  235. </div>
  236. <h2 class="subsection-title">Source</h2>
  237. <p>
  238. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/BokehPass.js" translate="no" target="_blank" rel="noopener">examples/jsm/postprocessing/BokehPass.js</a>
  239. </p>
  240. </article>
  241. </section>
  242. <script src="../scripts/linenumber.js"></script>
  243. <script src="../scripts/page.js"></script>
  244. </body>
  245. </html>
粤ICP备19079148号