TextureNode.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TextureNode - 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="InputNode.html">InputNode</a> → <a href="UniformNode.html">UniformNode</a> → </p>
  13. <h1 translate="no">TextureNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This type of uniform node represents a 2D texture.</p></div>
  17. </header>
  18. <article>
  19. <div class="container-overview">
  20. <h2>Constructor</h2>
  21. <h3 class="name name-method" id="TextureNode" translate="no">new <a href="#TextureNode">TextureNode</a><span class="signature">( value : <span class="param-type">Texture</span>, uvNode : <span class="param-type">Node.&lt;(vec2|vec3)></span>, levelNode : <span class="param-type">Node.&lt;int></span>, biasNode : <span class="param-type">Node.&lt;float></span> )</span> </h3>
  22. <div class="method">
  23. <div class="description">
  24. <p>Constructs a new texture node.</p>
  25. </div>
  26. <table class="params">
  27. <tbody>
  28. <tr>
  29. <td class="name"><code>value</code></td>
  30. <td class="description last"><p>The texture.<br/>Default is <code>EmptyTexture</code>.</p></td>
  31. </tr>
  32. <tr>
  33. <td class="name"><code>uvNode</code></td>
  34. <td class="description last"><p>The uv node.<br/>Default is <code>null</code>.</p></td>
  35. </tr>
  36. <tr>
  37. <td class="name"><code>levelNode</code></td>
  38. <td class="description last"><p>The level node.<br/>Default is <code>null</code>.</p></td>
  39. </tr>
  40. <tr>
  41. <td class="name"><code>biasNode</code></td>
  42. <td class="description last"><p>The bias node.<br/>Default is <code>null</code>.</p></td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. </div>
  47. </div>
  48. <h2 class="subsection-title">Properties</h2>
  49. <div class="member">
  50. <h3 class="name" id="biasNode" translate="no">.<a href="#biasNode">biasNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  51. <div class="description">
  52. <p>Represents the bias to be applied during level-of-detail computation.<br/>Default is <code>null</code>.</p>
  53. </div>
  54. </div>
  55. <div class="member">
  56. <h3 class="name" id="compareNode" translate="no">.<a href="#compareNode">compareNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;float></span> </h3>
  57. <div class="description">
  58. <p>Represents a reference value a texture sample is compared to.<br/>Default is <code>null</code>.</p>
  59. </div>
  60. </div>
  61. <div class="member">
  62. <h3 class="name" id="depthNode" translate="no">.<a href="#depthNode">depthNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;int></span> </h3>
  63. <div class="description">
  64. <p>When using texture arrays, the depth node defines the layer to select.<br/>Default is <code>null</code>.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="gradNode" translate="no">.<a href="#gradNode">gradNode</a><span class="type-signature"> : Array.&lt;<a href="Node.html">Node</a>.&lt;vec2>></span> </h3>
  69. <div class="description">
  70. <p>When defined, a texture is sampled using explicit gradients.<br/>Default is <code>null</code>.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="isTextureNode" translate="no">.<a href="#isTextureNode">isTextureNode</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  75. <div class="description">
  76. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="levelNode" translate="no">.<a href="#levelNode">levelNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;int></span> </h3>
  81. <div class="description">
  82. <p>Represents the mip level that should be selected.<br/>Default is <code>null</code>.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="offsetNode" translate="no">.<a href="#offsetNode">offsetNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;(ivec2|ivec3)></span> </h3>
  87. <div class="description">
  88. <p>Represents the optional texel offset applied to the unnormalized texture
  89. coordinate before sampling the texture.<br/>Default is <code>null</code>.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="referenceNode" translate="no">.<a href="#referenceNode">referenceNode</a><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  94. <div class="description">
  95. <p>The reference node.<br/>Default is <code>null</code>.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <h3 class="name" id="sampler" translate="no">.<a href="#sampler">sampler</a><span class="type-signature"> : boolean</span> </h3>
  100. <div class="description">
  101. <p>Whether texture values should be sampled or fetched.<br/>Default is <code>true</code>.</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="updateMatrix" translate="no">.<a href="#updateMatrix">updateMatrix</a><span class="type-signature"> : boolean</span> </h3>
  106. <div class="description">
  107. <p>Whether the uv transformation matrix should be
  108. automatically updated or not. Use <code>setUpdateMatrix()</code>
  109. if you want to change the value of the property.<br/>Default is <code>false</code>.</p>
  110. </div>
  111. </div>
  112. <div class="member">
  113. <h3 class="name" id="updateType" translate="no">.<a href="#updateType">updateType</a><span class="type-signature"> : string</span> </h3>
  114. <div class="description">
  115. <p>By default the <code>update()</code> method is not executed. Depending on
  116. whether a uv transformation matrix and/or flipY is applied, <code>update()</code>
  117. is executed per object.<br/>Default is <code>'none'</code>.</p>
  118. </div>
  119. <dl class="details">
  120. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#updateType">UniformNode#updateType</a></dt>
  121. </dl>
  122. </div>
  123. <div class="member">
  124. <h3 class="name" id="uvNode" translate="no">.<a href="#uvNode">uvNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;(vec2|vec3)></span> </h3>
  125. <div class="description">
  126. <p>Represents the texture coordinates.<br/>Default is <code>null</code>.</p>
  127. </div>
  128. </div>
  129. <div class="member">
  130. <h3 class="name" id="value" translate="no">.<a href="#value">value</a><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  131. <div class="description">
  132. <p>The texture value.</p>
  133. </div>
  134. <dl class="details">
  135. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#value">UniformNode#value</a></dt>
  136. </dl>
  137. </div>
  138. <h2 class="subsection-title">Methods</h2>
  139. <h3 class="name name-method" id="bias" translate="no">.<a href="#bias">bias</a><span class="signature">( biasNode : <span class="param-type">Node.&lt;float></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  140. <div class="method">
  141. <div class="description">
  142. <p>Samples the texture with the given bias.</p>
  143. </div>
  144. <table class="params">
  145. <tbody>
  146. <tr>
  147. <td class="name"><code>biasNode</code></td>
  148. <td class="description last"><p>The bias node.</p></td>
  149. </tr>
  150. </tbody>
  151. </table>
  152. <dl class="details">
  153. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  154. </dl>
  155. </div>
  156. <h3 class="name name-method" id="blur" translate="no">.<a href="#blur">blur</a><span class="signature">( amountNode : <span class="param-type">Node.&lt;float></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  157. <div class="method">
  158. <div class="description">
  159. <p>Samples a blurred version of the texture by defining an internal bias.</p>
  160. </div>
  161. <table class="params">
  162. <tbody>
  163. <tr>
  164. <td class="name"><code>amountNode</code></td>
  165. <td class="description last"><p>How blurred the texture should be.</p></td>
  166. </tr>
  167. </tbody>
  168. </table>
  169. <dl class="details">
  170. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  171. </dl>
  172. </div>
  173. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  174. <div class="method">
  175. <div class="description">
  176. <p>Clones the texture node.</p>
  177. </div>
  178. <dl class="details">
  179. <dt class="tag-returns"><strong>Returns:</strong> The cloned texture node.</dt>
  180. </dl>
  181. </div>
  182. <h3 class="name name-method" id="compare" translate="no">.<a href="#compare">compare</a><span class="signature">( compareNode : <span class="param-type">Node.&lt;float></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  183. <div class="method">
  184. <div class="description">
  185. <p>Samples the texture by executing a compare operation.</p>
  186. </div>
  187. <table class="params">
  188. <tbody>
  189. <tr>
  190. <td class="name"><code>compareNode</code></td>
  191. <td class="description last"><p>The node that defines the compare value.</p></td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. <dl class="details">
  196. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  197. </dl>
  198. </div>
  199. <h3 class="name name-method" id="depth" translate="no">.<a href="#depth">depth</a><span class="signature">( depthNode : <span class="param-type">Node.&lt;int></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  200. <div class="method">
  201. <div class="description">
  202. <p>Samples the texture by defining a depth node.</p>
  203. </div>
  204. <table class="params">
  205. <tbody>
  206. <tr>
  207. <td class="name"><code>depthNode</code></td>
  208. <td class="description last"><p>The depth node.</p></td>
  209. </tr>
  210. </tbody>
  211. </table>
  212. <dl class="details">
  213. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  214. </dl>
  215. </div>
  216. <h3 class="name name-method" id="generate" translate="no">.<a href="#generate">generate</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span>, output : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  217. <div class="method">
  218. <div class="description">
  219. <p>Generates the code snippet of the texture node.</p>
  220. </div>
  221. <table class="params">
  222. <tbody>
  223. <tr>
  224. <td class="name"><code>builder</code></td>
  225. <td class="description last"><p>The current node builder.</p></td>
  226. </tr>
  227. <tr>
  228. <td class="name"><code>output</code></td>
  229. <td class="description last"><p>The current output.</p></td>
  230. </tr>
  231. </tbody>
  232. </table>
  233. <dl class="details">
  234. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#generate">UniformNode#generate</a></dt>
  235. </dl>
  236. <dl class="details">
  237. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  238. </dl>
  239. </div>
  240. <h3 class="name name-method" id="generateOffset" translate="no">.<a href="#generateOffset">generateOffset</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span>, offsetNode : <span class="param-type">Node</span> )</span><span class="type-signature"> : string</span> </h3>
  241. <div class="method">
  242. <div class="description">
  243. <p>Generates the offset code snippet.</p>
  244. </div>
  245. <table class="params">
  246. <tbody>
  247. <tr>
  248. <td class="name"><code>builder</code></td>
  249. <td class="description last"><p>The current node builder.</p></td>
  250. </tr>
  251. <tr>
  252. <td class="name"><code>offsetNode</code></td>
  253. <td class="description last"><p>The offset node to generate code for.</p></td>
  254. </tr>
  255. </tbody>
  256. </table>
  257. <dl class="details">
  258. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  259. </dl>
  260. </div>
  261. <h3 class="name name-method" id="generateSnippet" translate="no">.<a href="#generateSnippet">generateSnippet</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span>, textureProperty : <span class="param-type">string</span>, uvSnippet : <span class="param-type">string</span>, levelSnippet : <span class="param-type">string</span>, biasSnippet : <span class="param-type">string</span>, depthSnippet : <span class="param-type">string</span>, compareSnippet : <span class="param-type">string</span>, gradSnippet : <span class="param-type">Array.&lt;string></span>, offsetSnippet : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  262. <div class="method">
  263. <div class="description">
  264. <p>Generates the snippet for the texture sampling.</p>
  265. </div>
  266. <table class="params">
  267. <tbody>
  268. <tr>
  269. <td class="name"><code>builder</code></td>
  270. <td class="description last"><p>The current node builder.</p></td>
  271. </tr>
  272. <tr>
  273. <td class="name"><code>textureProperty</code></td>
  274. <td class="description last"><p>The texture property.</p></td>
  275. </tr>
  276. <tr>
  277. <td class="name"><code>uvSnippet</code></td>
  278. <td class="description last"><p>The uv snippet.</p></td>
  279. </tr>
  280. <tr>
  281. <td class="name"><code>levelSnippet</code></td>
  282. <td class="description last"><p>The level snippet.</p></td>
  283. </tr>
  284. <tr>
  285. <td class="name"><code>biasSnippet</code></td>
  286. <td class="description last"><p>The bias snippet.</p></td>
  287. </tr>
  288. <tr>
  289. <td class="name"><code>depthSnippet</code></td>
  290. <td class="description last"><p>The depth snippet.</p></td>
  291. </tr>
  292. <tr>
  293. <td class="name"><code>compareSnippet</code></td>
  294. <td class="description last"><p>The compare snippet.</p></td>
  295. </tr>
  296. <tr>
  297. <td class="name"><code>gradSnippet</code></td>
  298. <td class="description last"><p>The grad snippet.</p></td>
  299. </tr>
  300. <tr>
  301. <td class="name"><code>offsetSnippet</code></td>
  302. <td class="description last"><p>The offset snippet.</p></td>
  303. </tr>
  304. </tbody>
  305. </table>
  306. <dl class="details">
  307. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  308. </dl>
  309. </div>
  310. <h3 class="name name-method" id="generateUV" translate="no">.<a href="#generateUV">generateUV</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span>, uvNode : <span class="param-type">Node</span> )</span><span class="type-signature"> : string</span> </h3>
  311. <div class="method">
  312. <div class="description">
  313. <p>Generates the uv code snippet.</p>
  314. </div>
  315. <table class="params">
  316. <tbody>
  317. <tr>
  318. <td class="name"><code>builder</code></td>
  319. <td class="description last"><p>The current node builder.</p></td>
  320. </tr>
  321. <tr>
  322. <td class="name"><code>uvNode</code></td>
  323. <td class="description last"><p>The uv node to generate code for.</p></td>
  324. </tr>
  325. </tbody>
  326. </table>
  327. <dl class="details">
  328. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  329. </dl>
  330. </div>
  331. <h3 class="name name-method" id="getBase" translate="no">.<a href="#getBase">getBase</a><span class="signature">()</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  332. <div class="method">
  333. <div class="description">
  334. <p>Returns the base texture of this node.</p>
  335. </div>
  336. <dl class="details">
  337. <dt class="tag-returns"><strong>Returns:</strong> The base texture node.</dt>
  338. </dl>
  339. </div>
  340. <h3 class="name name-method" id="getDefaultUV" translate="no">.<a href="#getDefaultUV">getDefaultUV</a><span class="signature">()</span><span class="type-signature"> : <a href="AttributeNode.html">AttributeNode</a>.&lt;vec2></span> </h3>
  341. <div class="method">
  342. <div class="description">
  343. <p>Returns a default uvs based on the current texture's channel.</p>
  344. </div>
  345. <dl class="details">
  346. <dt class="tag-returns"><strong>Returns:</strong> The default uvs.</dt>
  347. </dl>
  348. </div>
  349. <h3 class="name name-method" id="getInputType" translate="no">.<a href="#getInputType">getInputType</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : string</span> </h3>
  350. <div class="method">
  351. <div class="description">
  352. <p>Overwrites the default implementation to return a fixed value <code>'texture'</code>.</p>
  353. </div>
  354. <table class="params">
  355. <tbody>
  356. <tr>
  357. <td class="name"><code>builder</code></td>
  358. <td class="description last"><p>The current node builder.</p></td>
  359. </tr>
  360. </tbody>
  361. </table>
  362. <dl class="details">
  363. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#getInputType">UniformNode#getInputType</a></dt>
  364. </dl>
  365. <dl class="details">
  366. <dt class="tag-returns"><strong>Returns:</strong> The input type.</dt>
  367. </dl>
  368. </div>
  369. <h3 class="name name-method" id="getNodeType" translate="no">.<a href="#getNodeType">getNodeType</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : string</span> </h3>
  370. <div class="method">
  371. <div class="description">
  372. <p>Overwritten since the node type is inferred from the texture type.</p>
  373. </div>
  374. <table class="params">
  375. <tbody>
  376. <tr>
  377. <td class="name"><code>builder</code></td>
  378. <td class="description last"><p>The current node builder.</p></td>
  379. </tr>
  380. </tbody>
  381. </table>
  382. <dl class="details">
  383. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#getNodeType">UniformNode#getNodeType</a></dt>
  384. </dl>
  385. <dl class="details">
  386. <dt class="tag-returns"><strong>Returns:</strong> The node type.</dt>
  387. </dl>
  388. </div>
  389. <h3 class="name name-method" id="getSampler" translate="no">.<a href="#getSampler">getSampler</a><span class="signature">()</span><span class="type-signature"> : boolean</span> </h3>
  390. <div class="method">
  391. <div class="description">
  392. <p>Returns the sampler value.</p>
  393. </div>
  394. <dl class="details">
  395. <dt class="tag-returns"><strong>Returns:</strong> The sampler value.</dt>
  396. </dl>
  397. </div>
  398. <h3 class="name name-method" id="getTransformedUV" translate="no">.<a href="#getTransformedUV">getTransformedUV</a><span class="signature">( uvNode : <span class="param-type">Node</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  399. <div class="method">
  400. <div class="description">
  401. <p>Transforms the given uv node with the texture transformation matrix.</p>
  402. </div>
  403. <table class="params">
  404. <tbody>
  405. <tr>
  406. <td class="name"><code>uvNode</code></td>
  407. <td class="description last"><p>The uv node to transform.</p></td>
  408. </tr>
  409. </tbody>
  410. </table>
  411. <dl class="details">
  412. <dt class="tag-returns"><strong>Returns:</strong> The transformed uv node.</dt>
  413. </dl>
  414. </div>
  415. <h3 class="name name-method" id="getUniformHash" translate="no">.<a href="#getUniformHash">getUniformHash</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : string</span> </h3>
  416. <div class="method">
  417. <div class="description">
  418. <p>Overwritten since the uniform hash is defined by the texture's UUID.</p>
  419. </div>
  420. <table class="params">
  421. <tbody>
  422. <tr>
  423. <td class="name"><code>builder</code></td>
  424. <td class="description last"><p>The current node builder.</p></td>
  425. </tr>
  426. </tbody>
  427. </table>
  428. <dl class="details">
  429. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#getUniformHash">UniformNode#getUniformHash</a></dt>
  430. </dl>
  431. <dl class="details">
  432. <dt class="tag-returns"><strong>Returns:</strong> The uniform hash.</dt>
  433. </dl>
  434. </div>
  435. <h3 class="name name-method" id="grad" translate="no">.<a href="#grad">grad</a><span class="signature">( gradNodeX : <span class="param-type">Node.&lt;vec2></span>, gradNodeY : <span class="param-type">Node.&lt;vec2></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  436. <div class="method">
  437. <div class="description">
  438. <p>Samples the texture using an explicit gradient.</p>
  439. </div>
  440. <table class="params">
  441. <tbody>
  442. <tr>
  443. <td class="name"><code>gradNodeX</code></td>
  444. <td class="description last"><p>The gradX node.</p></td>
  445. </tr>
  446. <tr>
  447. <td class="name"><code>gradNodeY</code></td>
  448. <td class="description last"><p>The gradY node.</p></td>
  449. </tr>
  450. </tbody>
  451. </table>
  452. <dl class="details">
  453. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  454. </dl>
  455. </div>
  456. <h3 class="name name-method" id="level" translate="no">.<a href="#level">level</a><span class="signature">( levelNode : <span class="param-type">Node.&lt;int></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  457. <div class="method">
  458. <div class="description">
  459. <p>Samples a specific mip of the texture.</p>
  460. </div>
  461. <table class="params">
  462. <tbody>
  463. <tr>
  464. <td class="name"><code>levelNode</code></td>
  465. <td class="description last"><p>The mip level to sample.</p></td>
  466. </tr>
  467. </tbody>
  468. </table>
  469. <dl class="details">
  470. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  471. </dl>
  472. </div>
  473. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( uvNode : <span class="param-type">Node.&lt;uvec2></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  474. <div class="method">
  475. <div class="description">
  476. <p>TSL function for creating a texture node that fetches/loads texels without interpolation.</p>
  477. </div>
  478. <table class="params">
  479. <tbody>
  480. <tr>
  481. <td class="name"><code>uvNode</code></td>
  482. <td class="description last"><p>The uv node.</p></td>
  483. </tr>
  484. </tbody>
  485. </table>
  486. <dl class="details">
  487. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture load.</dt>
  488. </dl>
  489. </div>
  490. <h3 class="name name-method" id="offset" translate="no">.<a href="#offset">offset</a><span class="signature">( offsetNode : <span class="param-type">Node.&lt;ivec2></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  491. <div class="method">
  492. <div class="description">
  493. <p>Samples the texture by defining an offset node.</p>
  494. </div>
  495. <table class="params">
  496. <tbody>
  497. <tr>
  498. <td class="name"><code>offsetNode</code></td>
  499. <td class="description last"><p>The offset node.</p></td>
  500. </tr>
  501. </tbody>
  502. </table>
  503. <dl class="details">
  504. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  505. </dl>
  506. </div>
  507. <h3 class="name name-method" id="sample" translate="no">.<a href="#sample">sample</a><span class="signature">( uvNode : <span class="param-type">Node</span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  508. <div class="method">
  509. <div class="description">
  510. <p>Samples the texture with the given uv node.</p>
  511. </div>
  512. <table class="params">
  513. <tbody>
  514. <tr>
  515. <td class="name"><code>uvNode</code></td>
  516. <td class="description last"><p>The uv node.</p></td>
  517. </tr>
  518. </tbody>
  519. </table>
  520. <dl class="details">
  521. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  522. </dl>
  523. </div>
  524. <h3 class="name name-method" id="setSampler" translate="no">.<a href="#setSampler">setSampler</a><span class="signature">( value : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  525. <div class="method">
  526. <div class="description">
  527. <p>Sets the sampler value.</p>
  528. </div>
  529. <table class="params">
  530. <tbody>
  531. <tr>
  532. <td class="name"><code>value</code></td>
  533. <td class="description last"><p>The sampler value to set.</p></td>
  534. </tr>
  535. </tbody>
  536. </table>
  537. <dl class="details">
  538. <dt class="tag-returns"><strong>Returns:</strong> A reference to this texture node.</dt>
  539. </dl>
  540. </div>
  541. <h3 class="name name-method" id="setUpdateMatrix" translate="no">.<a href="#setUpdateMatrix">setUpdateMatrix</a><span class="signature">( value : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  542. <div class="method">
  543. <div class="description">
  544. <p>Defines whether the uv transformation matrix should automatically be updated or not.</p>
  545. </div>
  546. <table class="params">
  547. <tbody>
  548. <tr>
  549. <td class="name"><code>value</code></td>
  550. <td class="description last"><p>The update toggle.</p></td>
  551. </tr>
  552. </tbody>
  553. </table>
  554. <dl class="details">
  555. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  556. </dl>
  557. </div>
  558. <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> </h3>
  559. <div class="method">
  560. <div class="description">
  561. <p>Setups texture node by preparing the internal nodes for code generation.</p>
  562. </div>
  563. <table class="params">
  564. <tbody>
  565. <tr>
  566. <td class="name"><code>builder</code></td>
  567. <td class="description last"><p>The current node builder.</p></td>
  568. </tr>
  569. </tbody>
  570. </table>
  571. <dl class="details">
  572. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#setup">UniformNode#setup</a></dt>
  573. </dl>
  574. </div>
  575. <h3 class="name name-method" id="setupUV" translate="no">.<a href="#setupUV">setupUV</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span>, uvNode : <span class="param-type">Node</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  576. <div class="method">
  577. <div class="description">
  578. <p>Setups the uv node. Depending on the backend as well as texture's image and type, it might be necessary
  579. to modify the uv node for correct sampling.</p>
  580. </div>
  581. <table class="params">
  582. <tbody>
  583. <tr>
  584. <td class="name"><code>builder</code></td>
  585. <td class="description last"><p>The current node builder.</p></td>
  586. </tr>
  587. <tr>
  588. <td class="name"><code>uvNode</code></td>
  589. <td class="description last"><p>The uv node to setup.</p></td>
  590. </tr>
  591. </tbody>
  592. </table>
  593. <dl class="details">
  594. <dt class="tag-returns"><strong>Returns:</strong> The updated uv node.</dt>
  595. </dl>
  596. </div>
  597. <h3 class="name name-method" id="size" translate="no">.<a href="#size">size</a><span class="signature">( levelNode : <span class="param-type">Node.&lt;int></span> )</span><span class="type-signature"> : <a href="TextureSizeNode.html">TextureSizeNode</a></span> </h3>
  598. <div class="method">
  599. <div class="description">
  600. <p>Returns the texture size of the requested level.</p>
  601. </div>
  602. <table class="params">
  603. <tbody>
  604. <tr>
  605. <td class="name"><code>levelNode</code></td>
  606. <td class="description last"><p>The level to compute the size for.</p></td>
  607. </tr>
  608. </tbody>
  609. </table>
  610. <dl class="details">
  611. <dt class="tag-returns"><strong>Returns:</strong> The texture size.</dt>
  612. </dl>
  613. </div>
  614. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  615. <div class="method">
  616. <div class="description">
  617. <p>The update is used to implement the update of the uv transformation matrix.</p>
  618. </div>
  619. <dl class="details">
  620. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#update">UniformNode#update</a></dt>
  621. </dl>
  622. </div>
  623. <h3 class="name name-method" id="updateReference" translate="no">.<a href="#updateReference">updateReference</a><span class="signature">( state : <span class="param-type">any</span> )</span><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  624. <div class="method">
  625. <div class="description">
  626. <p>Overwritten to always return the texture reference of the node.</p>
  627. </div>
  628. <table class="params">
  629. <tbody>
  630. <tr>
  631. <td class="name"><code>state</code></td>
  632. <td class="description last"><p>This method can be invocated in different contexts so <code>state</code> can refer to any object type.</p></td>
  633. </tr>
  634. </tbody>
  635. </table>
  636. <dl class="details">
  637. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#updateReference">UniformNode#updateReference</a></dt>
  638. </dl>
  639. <dl class="details">
  640. <dt class="tag-returns"><strong>Returns:</strong> The texture reference.</dt>
  641. </dl>
  642. </div>
  643. <h3 class="name name-method" id="uv" translate="no">.<a href="#uv">uv</a><span class="signature">( uvNode : <span class="param-type">Node</span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  644. <div class="method">
  645. <table class="params">
  646. <tbody>
  647. <tr>
  648. <td class="name"><code>uvNode</code></td>
  649. <td class="description last"><p>The uv node.</p></td>
  650. </tr>
  651. </tbody>
  652. </table>
  653. <dl class="details">
  654. <dt class="important tag-deprecated"><strong>Deprecated:</strong> since r172. Use <a href="TextureNode.html#sample">TextureNode#sample</a> instead.</dt>
  655. </dl>
  656. <dl class="details">
  657. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  658. </dl>
  659. </div>
  660. <h2 class="subsection-title">Source</h2>
  661. <p>
  662. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/TextureNode.js" target="_blank" rel="noopener" translate="no">src/nodes/accessors/TextureNode.js</a>
  663. </p>
  664. </article>
  665. </section>
  666. <script src="../scripts/linenumber.js"></script>
  667. <script src="../scripts/page.js"></script>
  668. </body>
  669. </html>
粤ICP备19079148号