OutlineEffect.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>OutlineEffect - 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. <h1 translate="no">OutlineEffect</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>An outline effect for toon shaders.</p>
  16. <p>Note that this class can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>.
  17. When using <a href="WebGPURenderer.html">WebGPURenderer</a>, use <a href="ToonOutlinePassNode.html">ToonOutlinePassNode</a>.</p></div>
  18. <h2>Code Example</h2>
  19. <div translate="no"><pre><code class="language-js">const effect = new OutlineEffect( renderer );
  20. function render() {
  21. effect.render( scene, camera );
  22. }
  23. </code></pre></div>
  24. </header>
  25. <article>
  26. <h2 class="subsection-title">Import</h2>
  27. <p><span translate="no">OutlineEffect</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  28. <pre><code class="language-js">import { OutlineEffect } from 'three/addons/effects/OutlineEffect.js';</code></pre>
  29. <div class="container-overview">
  30. <h2>Constructor</h2>
  31. <h3 class="name name-method" id="OutlineEffect" translate="no">new <a href="#OutlineEffect">OutlineEffect</a><span class="signature">( renderer : <span class="param-type">WebGLRenderer</span>, parameters : <span class="param-type">OutlineEffect~Options</span> )</span> </h3>
  32. <div class="method">
  33. <div class="description">
  34. <p>Constructs a new outline effect.</p>
  35. </div>
  36. <table class="params">
  37. <tbody>
  38. <tr>
  39. <td class="name"><code>renderer</code></td>
  40. <td class="description last"><p>The renderer.</p></td>
  41. </tr>
  42. <tr>
  43. <td class="name"><code>parameters</code></td>
  44. <td class="description last"><p>The configuration parameter.</p></td>
  45. </tr>
  46. </tbody>
  47. </table>
  48. </div>
  49. </div>
  50. <h2 class="subsection-title">Methods</h2>
  51. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( scene : <span class="param-type">Object3D</span>, camera : <span class="param-type">Camera</span> )</span> </h3>
  52. <div class="method">
  53. <div class="description">
  54. <p>When using this effect, this method should be called instead of the
  55. default <a href="WebGLRenderer.html#render">WebGLRenderer#render</a>.</p>
  56. </div>
  57. <table class="params">
  58. <tbody>
  59. <tr>
  60. <td class="name"><code>scene</code></td>
  61. <td class="description last"><p>The scene to render.</p></td>
  62. </tr>
  63. <tr>
  64. <td class="name"><code>camera</code></td>
  65. <td class="description last"><p>The camera.</p></td>
  66. </tr>
  67. </tbody>
  68. </table>
  69. </div>
  70. <h3 class="name name-method" id="renderOutline" translate="no">.<a href="#renderOutline">renderOutline</a><span class="signature">( scene : <span class="param-type">Object3D</span>, camera : <span class="param-type">Camera</span> )</span> </h3>
  71. <div class="method">
  72. <div class="description">
  73. <p>This method can be used to render outlines in VR.</p>
  74. <pre><code class="language-js">const effect = new OutlineEffect( renderer );
  75. let renderingOutline = false;
  76. scene.onAfterRender = function () {
  77. if ( renderingOutline ) return;
  78. renderingOutline = true;
  79. effect.renderOutline( scene, camera );
  80. renderingOutline = false;
  81. };
  82. function render() {
  83. renderer.render( scene, camera );
  84. }
  85. </code></pre>
  86. </div>
  87. <table class="params">
  88. <tbody>
  89. <tr>
  90. <td class="name"><code>scene</code></td>
  91. <td class="description last"><p>The scene to render.</p></td>
  92. </tr>
  93. <tr>
  94. <td class="name"><code>camera</code></td>
  95. <td class="description last"><p>The camera.</p></td>
  96. </tr>
  97. </tbody>
  98. </table>
  99. </div>
  100. <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>
  101. <div class="method">
  102. <div class="description">
  103. <p>Resizes the effect.</p>
  104. </div>
  105. <table class="params">
  106. <tbody>
  107. <tr>
  108. <td class="name"><code>width</code></td>
  109. <td class="description last"><p>The width of the effect in logical pixels.</p></td>
  110. </tr>
  111. <tr>
  112. <td class="name"><code>height</code></td>
  113. <td class="description last"><p>The height of the effect in logical pixels.</p></td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. </div>
  118. <h2 class="subsection-title">Type Definitions</h2>
  119. <div class="member">
  120. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  121. <div class="description">
  122. <p>This type represents configuration settings of <code>OutlineEffect</code>.</p>
  123. </div>
  124. <h5 class="subsection-title">Properties:</h5>
  125. <table class="props">
  126. <thead>
  127. <tr>
  128. <th>Name</th>
  129. <th>Type</th>
  130. <th>Attributes</th>
  131. <th>Default</th>
  132. <th class="last">Description</th>
  133. </tr>
  134. </thead>
  135. <tbody>
  136. <tr>
  137. <td class="name"><code>defaultThickness</code></td>
  138. <td class="type">
  139. <span class="param-type">number</span>
  140. </td>
  141. <td class="attributes">
  142. &lt;optional><br>
  143. </td>
  144. <td class="default">
  145. 0.003
  146. </td>
  147. <td class="description last"><p>The outline thickness.</p></td>
  148. </tr>
  149. <tr>
  150. <td class="name"><code>defaultColor</code></td>
  151. <td class="type">
  152. <span class="param-type">Array.&lt;number></span>
  153. </td>
  154. <td class="attributes">
  155. &lt;optional><br>
  156. </td>
  157. <td class="default">
  158. [0,0,0]
  159. </td>
  160. <td class="description last"><p>The outline color.</p></td>
  161. </tr>
  162. <tr>
  163. <td class="name"><code>defaultAlpha</code></td>
  164. <td class="type">
  165. <span class="param-type">number</span>
  166. </td>
  167. <td class="attributes">
  168. &lt;optional><br>
  169. </td>
  170. <td class="default">
  171. 1
  172. </td>
  173. <td class="description last"><p>The outline alpha value.</p></td>
  174. </tr>
  175. <tr>
  176. <td class="name"><code>defaultKeepAlive</code></td>
  177. <td class="type">
  178. <span class="param-type">boolean</span>
  179. </td>
  180. <td class="attributes">
  181. &lt;optional><br>
  182. </td>
  183. <td class="default">
  184. false
  185. </td>
  186. <td class="description last"><p>Whether to keep alive cached internal materials or not.</p></td>
  187. </tr>
  188. </tbody>
  189. </table>
  190. </div>
  191. <h2 class="subsection-title">Source</h2>
  192. <p>
  193. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/effects/OutlineEffect.js" target="_blank" rel="noopener" translate="no">examples/jsm/effects/OutlineEffect.js</a>
  194. </p>
  195. </article>
  196. </section>
  197. <script src="../scripts/linenumber.js"></script>
  198. <script src="../scripts/page.js"></script>
  199. </body>
  200. </html>
粤ICP备19079148号