OutlineNode.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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" rel="noopener">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"><a href="Scene.html">Scene</a></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></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">
  54. <strong>scene</strong>
  55. </td>
  56. <td class="description last">
  57. <p>A reference to the scene.</p>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="name">
  62. <strong>camera</strong>
  63. </td>
  64. <td class="description last">
  65. <p>The camera the scene is rendered with.</p>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td class="name">
  70. <strong>params</strong>
  71. </td>
  72. <td class="description last">
  73. <p>The configuration parameters.</p>
  74. <table class="params">
  75. <tbody>
  76. <tr>
  77. <td class="name">
  78. <strong>selectedObjects</strong>
  79. </td>
  80. <td class="description last">
  81. <p>An array of selected objects.</p>
  82. </td>
  83. </tr>
  84. <tr>
  85. <td class="name">
  86. <strong>edgeThickness</strong>
  87. </td>
  88. <td class="description last">
  89. <p>The thickness of the edges.</p>
  90. <p>Default is <code>float(1)</code>.</p>
  91. </td>
  92. </tr>
  93. <tr>
  94. <td class="name">
  95. <strong>edgeGlow</strong>
  96. </td>
  97. <td class="description last">
  98. <p>Can be used for an animated glow/pulse effects.</p>
  99. <p>Default is <code>float(0)</code>.</p>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td class="name">
  104. <strong>downSampleRatio</strong>
  105. </td>
  106. <td class="description last">
  107. <p>The downsample ratio.</p>
  108. <p>Default is <code>2</code>.</p>
  109. </td>
  110. </tr>
  111. </tbody>
  112. </table>
  113. </td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. </div>
  118. </div>
  119. <h2 class="subsection-title">Properties</h2>
  120. <div class="member">
  121. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  122. <div class="description">
  123. <p>The camera the scene is rendered with.</p>
  124. </div>
  125. </div>
  126. <div class="member">
  127. <h3 class="name" id="downSampleRatio" translate="no">.<a href="#downSampleRatio">downSampleRatio</a><span class="type-signature"> : number</span> </h3>
  128. <div class="description">
  129. <p>The downsample ratio.</p>
  130. <p>Default is <code>2</code>.</p>
  131. </div>
  132. </div>
  133. <div class="member">
  134. <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>
  135. <div class="description">
  136. <p>Can be used for an animated glow/pulse effect.</p>
  137. </div>
  138. </div>
  139. <div class="member">
  140. <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>
  141. <div class="description">
  142. <p>The thickness of the edges.</p>
  143. </div>
  144. </div>
  145. <div class="member">
  146. <h3 class="name" id="hiddenEdge" translate="no">.<a href="#hiddenEdge">hiddenEdge</a> </h3>
  147. <div class="description">
  148. <p>A mask value that represents the hidden edge.</p>
  149. </div>
  150. </div>
  151. <div class="member">
  152. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  153. <div class="description">
  154. <p>A reference to the scene.</p>
  155. </div>
  156. </div>
  157. <div class="member">
  158. <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>
  159. <div class="description">
  160. <p>An array of selected objects.</p>
  161. </div>
  162. </div>
  163. <div class="member">
  164. <h3 class="name" id="updateBeforeType" translate="no">.<a href="#updateBeforeType">updateBeforeType</a><span class="type-signature"> : string</span> </h3>
  165. <div class="description">
  166. <p>The <code>updateBeforeType</code> is set to <code>NodeUpdateType.FRAME</code> since the node renders
  167. its effect once per frame in <code>updateBefore()</code>.</p>
  168. <p>Default is <code>'frame'</code>.</p>
  169. </div>
  170. <dl class="details">
  171. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBeforeType">TempNode#updateBeforeType</a></dt>
  172. </dl>
  173. </div>
  174. <div class="member">
  175. <h3 class="name" id="visibleEdge" translate="no">.<a href="#visibleEdge">visibleEdge</a> </h3>
  176. <div class="description">
  177. <p>A mask value that represents the visible edge.</p>
  178. </div>
  179. </div>
  180. <h2 class="subsection-title">Methods</h2>
  181. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  182. <div class="method">
  183. <div class="description">
  184. <p>Frees internal resources. This method should be called
  185. when the effect is no longer required.</p>
  186. </div>
  187. <dl class="details">
  188. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#dispose">TempNode#dispose</a></dt>
  189. </dl>
  190. </div>
  191. <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>
  192. <div class="method">
  193. <div class="description">
  194. <p>Returns the result of the effect as a texture node.</p>
  195. </div>
  196. <dl class="details">
  197. <dt class="tag-returns"><strong>Returns:</strong> A texture node that represents the result of the effect.</dt>
  198. </dl>
  199. </div>
  200. <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>
  201. <div class="method">
  202. <div class="description">
  203. <p>Sets the size of the effect.</p>
  204. </div>
  205. <table class="params">
  206. <tbody>
  207. <tr>
  208. <td class="name">
  209. <strong>width</strong>
  210. </td>
  211. <td class="description last">
  212. <p>The width of the effect.</p>
  213. </td>
  214. </tr>
  215. <tr>
  216. <td class="name">
  217. <strong>height</strong>
  218. </td>
  219. <td class="description last">
  220. <p>The height of the effect.</p>
  221. </td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. </div>
  226. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : <a href="PassTextureNode.html">PassTextureNode</a></span> </h3>
  227. <div class="method">
  228. <div class="description">
  229. <p>This method is used to setup the effect's TSL code.</p>
  230. </div>
  231. <table class="params">
  232. <tbody>
  233. <tr>
  234. <td class="name">
  235. <strong>builder</strong>
  236. </td>
  237. <td class="description last">
  238. <p>The current node builder.</p>
  239. </td>
  240. </tr>
  241. </tbody>
  242. </table>
  243. <dl class="details">
  244. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#setup">TempNode#setup</a></dt>
  245. </dl>
  246. </div>
  247. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  248. <div class="method">
  249. <div class="description">
  250. <p>This method is used to render the effect once per frame.</p>
  251. </div>
  252. <table class="params">
  253. <tbody>
  254. <tr>
  255. <td class="name">
  256. <strong>frame</strong>
  257. </td>
  258. <td class="description last">
  259. <p>The current node frame.</p>
  260. </td>
  261. </tr>
  262. </tbody>
  263. </table>
  264. <dl class="details">
  265. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="TempNode.html#updateBefore">TempNode#updateBefore</a></dt>
  266. </dl>
  267. </div>
  268. <h2 class="subsection-title">Source</h2>
  269. <p>
  270. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/display/OutlineNode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/display/OutlineNode.js</a>
  271. </p>
  272. </article>
  273. </section>
  274. <script src="../scripts/linenumber.js"></script>
  275. <script src="../scripts/page.js"></script>
  276. </body>
  277. </html>
粤ICP备19079148号