OutlineNode.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>OutlineNode - 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">OutlineNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Post processing node for rendering outlines around selected objects. The node
  17. gives you great flexibility in composing the final outline look depending on
  18. your requirements.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const postProcessing = new THREE.PostProcessing( renderer );
  21. const scenePass = pass( scene, camera );
  22. // outline parameter
  23. const edgeStrength = uniform( 3.0 );
  24. const edgeGlow = uniform( 0.0 );
  25. const edgeThickness = uniform( 1.0 );
  26. const visibleEdgeColor = uniform( new THREE.Color( 0xffffff ) );
  27. const hiddenEdgeColor = uniform( new THREE.Color( 0x4e3636 ) );
  28. outlinePass = outline( scene, camera, {
  29. selectedObjects,
  30. edgeGlow,
  31. edgeThickness
  32. } );
  33. // compose custom outline
  34. const { visibleEdge, hiddenEdge } = outlinePass;
  35. const outlineColor = visibleEdge.mul( visibleEdgeColor ).add( hiddenEdge.mul( hiddenEdgeColor ) ).mul( edgeStrength );
  36. postProcessing.outputNode = outlineColor.add( scenePass );
  37. </code></pre></div>
  38. </header>
  39. <article>
  40. <h2 class="subsection-title">Import</h2>
  41. <p><span translate="no">OutlineNode</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  42. <pre><code class="language-js">import { outline } from 'three/addons/tsl/display/OutlineNode.js';</code></pre>
  43. <div class="container-overview">
  44. <h2>Constructor</h2>
  45. <h3 class="name name-method" id="OutlineNode" translate="no">new <a href="#OutlineNode">OutlineNode</a><span class="signature">( scene : <span class="param-type">Scene</span>, camera : <span class="param-type">Camera</span>, params : <span class="param-type">Object</span> )</span> </h3>
  46. <div class="method">
  47. <div class="description">
  48. <p>Constructs a new outline node.</p>
  49. </div>
  50. <table class="params">
  51. <tbody>
  52. <tr>
  53. <td class="name"><code>scene</code></td>
  54. <td class="description last"><p>A reference to the scene.</p></td>
  55. </tr>
  56. <tr>
  57. <td class="name"><code>camera</code></td>
  58. <td class="description last"><p>The camera the scene is rendered with.</p></td>
  59. </tr>
  60. <tr>
  61. <td class="name"><code>params</code></td>
  62. <td class="description last"><p>The configuration parameters.</p>
  63. <h6>Properties</h6>
  64. <table class="params">
  65. <tbody>
  66. <tr>
  67. <td class="name"><code>selectedObjects</code></td>
  68. <td class="description last"><p>An array of selected objects.</p></td>
  69. </tr>
  70. <tr>
  71. <td class="name"><code>edgeThickness</code></td>
  72. <td class="description last"><p>The thickness of the edges.<br/>Default is <code>float(1)</code>.</p></td>
  73. </tr>
  74. <tr>
  75. <td class="name"><code>edgeGlow</code></td>
  76. <td class="description last"><p>Can be used for an animated glow/pulse effects.<br/>Default is <code>float(0)</code>.</p></td>
  77. </tr>
  78. <tr>
  79. <td class="name"><code>downSampleRatio</code></td>
  80. <td class="description last"><p>The downsample ratio.<br/>Default is <code>2</code>.</p></td>
  81. </tr>
  82. </tbody>
  83. </table>
  84. </td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </div>
  89. </div>
  90. <h2 class="subsection-title">Properties</h2>
  91. <div class="member">
  92. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  93. <div class="description">
  94. <p>The camera the scene is rendered with.</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <h3 class="name" id="downSampleRatio" translate="no">.<a href="#downSampleRatio">downSampleRatio</a><span class="type-signature"> : number</span> </h3>
  99. <div class="description">
  100. <p>The downsample ratio.<br/>Default is <code>2</code>.</p>
  101. </div>
  102. </div>
  103. <div class="member">
  104. <h3 class="name" id="edgeGlowNode" translate="no">.<a href="#edgeGlowNode">edgeGlowNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  105. <div class="description">
  106. <p>Can be used for an animated glow/pulse effect.</p>
  107. </div>
  108. </div>
  109. <div class="member">
  110. <h3 class="name" id="edgeThicknessNode" translate="no">.<a href="#edgeThicknessNode">edgeThicknessNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  111. <div class="description">
  112. <p>The thickness of the edges.</p>
  113. </div>
  114. </div>
  115. <div class="member">
  116. <h3 class="name" id="hiddenEdge" translate="no">.<a href="#hiddenEdge">hiddenEdge</a> </h3>
  117. <div class="description">
  118. <p>A mask value that represents the hidden edge.</p>
  119. </div>
  120. </div>
  121. <div class="member">
  122. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  123. <div class="description">
  124. <p>A reference to the scene.</p>
  125. </div>
  126. </div>
  127. <div class="member">
  128. <h3 class="name" id="selectedObjects" translate="no">.<a href="#selectedObjects">selectedObjects</a><span class="type-signature"> : Array.&lt;<a href="Object3D.html">Object3D</a>></span> </h3>
  129. <div class="description">
  130. <p>An array of selected objects.</p>
  131. </div>
  132. </div>
  133. <div class="member">
  134. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  135. <div class="description">
  136. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  137. its effect once per frame in <code>updateBefore()</code>.<br/>Default is <code>'frame'</code>.</p>
  138. </div>
  139. <dl class="details">
  140. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  141. </dl>
  142. </div>
  143. <div class="member">
  144. <h3 class="name" id="visibleEdge" translate="no">.<a href="#visibleEdge">visibleEdge</a> </h3>
  145. <div class="description">
  146. <p>A mask value that represents the visible edge.</p>
  147. </div>
  148. </div>
  149. <h2 class="subsection-title">Methods</h2>
  150. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  151. <div class="method">
  152. <div class="description">
  153. <p>Frees internal resources. This method should be called
  154. when the effect is no longer required.</p>
  155. </div>
  156. <dl class="details">
  157. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  158. </dl>
  159. </div>
  160. <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>
  161. <div class="method">
  162. <div class="description">
  163. <p>Returns the result of the effect as a texture node.</p>
  164. </div>
  165. <dl class="details">
  166. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  167. </dl>
  168. </div>
  169. <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>
  170. <div class="method">
  171. <div class="description">
  172. <p>Sets the size of the effect.</p>
  173. </div>
  174. <table class="params">
  175. <tbody>
  176. <tr>
  177. <td class="name"><code>width</code></td>
  178. <td class="description last"><p>The width of the effect.</p></td>
  179. </tr>
  180. <tr>
  181. <td class="name"><code>height</code></td>
  182. <td class="description last"><p>The height of the effect.</p></td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. </div>
  187. <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"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  188. <div class="method">
  189. <div class="description">
  190. <p>This method is used to setup the effect's TSL code.</p>
  191. </div>
  192. <table class="params">
  193. <tbody>
  194. <tr>
  195. <td class="name"><code>builder</code></td>
  196. <td class="description last"><p>The current node builder.</p></td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. <dl class="details">
  201. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  202. </dl>
  203. <dl class="details">
  204. <dt class="tag-returns"><strong>Returns:</strong> </dt>
  205. </dl>
  206. </div>
  207. <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>
  208. <div class="method">
  209. <div class="description">
  210. <p>This method is used to render the effect once per frame.</p>
  211. </div>
  212. <table class="params">
  213. <tbody>
  214. <tr>
  215. <td class="name"><code>frame</code></td>
  216. <td class="description last"><p>The current node frame.</p></td>
  217. </tr>
  218. </tbody>
  219. </table>
  220. <dl class="details">
  221. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  222. </dl>
  223. </div>
  224. <h2 class="subsection-title">Source</h2>
  225. <p>
  226. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/OutlineNode.js" target="_blank" rel="noopener" translate="no">examples/jsm/tsl/display/OutlineNode.js</a>
  227. </p>
  228. </article>
  229. </section>
  230. <script src="../scripts/linenumber.js"></script>
  231. <script src="../scripts/page.js"></script>
  232. </body>
  233. </html>
粤ICP备19079148号