TextureNode.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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"><a href="Texture.html">Texture</a></span>, uvNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;(vec2|vec3)></span>, levelNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;int></span>, biasNode : <span class="param-type"><a href="Node.html">Node</a>.&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">
  30. <strong translate="no">value</strong>
  31. </td>
  32. <td class="description last">
  33. <p>The texture.</p>
  34. <p>Default is <code>EmptyTexture</code>.</p>
  35. </td>
  36. </tr>
  37. <tr>
  38. <td class="name">
  39. <strong translate="no">uvNode</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The uv node.</p>
  43. <p>Default is <code>null</code>.</p>
  44. </td>
  45. </tr>
  46. <tr>
  47. <td class="name">
  48. <strong translate="no">levelNode</strong>
  49. </td>
  50. <td class="description last">
  51. <p>The level node.</p>
  52. <p>Default is <code>null</code>.</p>
  53. </td>
  54. </tr>
  55. <tr>
  56. <td class="name">
  57. <strong translate="no">biasNode</strong>
  58. </td>
  59. <td class="description last">
  60. <p>The bias node.</p>
  61. <p>Default is <code>null</code>.</p>
  62. </td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. </div>
  67. </div>
  68. <h2 class="subsection-title">Properties</h2>
  69. <div class="member">
  70. <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>
  71. <div class="description">
  72. <p>Represents the bias to be applied during level-of-detail computation.</p>
  73. <p>Default is <code>null</code>.</p>
  74. </div>
  75. </div>
  76. <div class="member">
  77. <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>
  78. <div class="description">
  79. <p>Represents a reference value a texture sample is compared to.</p>
  80. <p>Default is <code>null</code>.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <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>
  85. <div class="description">
  86. <p>When using texture arrays, the depth node defines the layer to select.</p>
  87. <p>Default is <code>null</code>.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <h3 class="name" id="gatherNode" translate="no">.<a href="#gatherNode">gatherNode</a><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;int></span> </h3>
  92. <div class="description">
  93. <p>Represents the optional index constant of the channel to gather.
  94. This must be in range [0, 3] and a compile-time constant.</p>
  95. <p>Default is <code>null</code>.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <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>
  100. <div class="description">
  101. <p>When defined, a texture is sampled using explicit gradients.</p>
  102. <p>Default is <code>null</code>.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <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>
  107. <div class="description">
  108. <p>This flag can be used for type testing.</p>
  109. <p>Default is <code>true</code>.</p>
  110. </div>
  111. </div>
  112. <div class="member">
  113. <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>
  114. <div class="description">
  115. <p>Represents the mip level that should be selected.</p>
  116. <p>Default is <code>null</code>.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <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>
  121. <div class="description">
  122. <p>Represents the optional texel offset applied to the unnormalized texture
  123. coordinate before sampling the texture.</p>
  124. <p>Default is <code>null</code>.</p>
  125. </div>
  126. </div>
  127. <div class="member">
  128. <h3 class="name" id="referenceNode" translate="no">.<a href="#referenceNode">referenceNode</a><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  129. <div class="description">
  130. <p>The reference node.</p>
  131. <p>Default is <code>null</code>.</p>
  132. </div>
  133. </div>
  134. <div class="member">
  135. <h3 class="name" id="sampler" translate="no">.<a href="#sampler">sampler</a><span class="type-signature"> : boolean</span> </h3>
  136. <div class="description">
  137. <p>Whether texture values should be sampled or fetched.</p>
  138. <p>Default is <code>true</code>.</p>
  139. </div>
  140. </div>
  141. <div class="member">
  142. <h3 class="name" id="updateMatrix" translate="no">.<a href="#updateMatrix">updateMatrix</a><span class="type-signature"> : boolean</span> </h3>
  143. <div class="description">
  144. <p>Whether the uv transformation matrix should be
  145. automatically updated or not. Use <code>setUpdateMatrix()</code>
  146. if you want to change the value of the property.</p>
  147. <p>Default is <code>false</code>.</p>
  148. </div>
  149. </div>
  150. <div class="member">
  151. <h3 class="name" id="updateType" translate="no">.<a href="#updateType">updateType</a><span class="type-signature"> : string</span> </h3>
  152. <div class="description">
  153. <p>By default the <code>update()</code> method is not executed. Depending on
  154. whether a uv transformation matrix and/or flipY is applied, <code>update()</code>
  155. is executed per object.</p>
  156. <p>Default is <code>'none'</code>.</p>
  157. </div>
  158. <dl class="details">
  159. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#updateType">UniformNode#updateType</a></dt>
  160. </dl>
  161. </div>
  162. <div class="member">
  163. <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>
  164. <div class="description">
  165. <p>Represents the texture coordinates.</p>
  166. <p>Default is <code>null</code>.</p>
  167. </div>
  168. </div>
  169. <div class="member">
  170. <h3 class="name" id="value" translate="no">.<a href="#value">value</a><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  171. <div class="description">
  172. <p>The texture value.</p>
  173. </div>
  174. <dl class="details">
  175. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#value">UniformNode#value</a></dt>
  176. </dl>
  177. </div>
  178. <h2 class="subsection-title">Methods</h2>
  179. <h3 class="name name-method" id="bias" translate="no">.<a href="#bias">bias</a><span class="signature">( biasNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  180. <div class="method">
  181. <div class="description">
  182. <p>Samples the texture with the given bias.</p>
  183. </div>
  184. <table class="params">
  185. <tbody>
  186. <tr>
  187. <td class="name">
  188. <strong translate="no">biasNode</strong>
  189. </td>
  190. <td class="description last">
  191. <p>The bias node.</p>
  192. </td>
  193. </tr>
  194. </tbody>
  195. </table>
  196. <dl class="details">
  197. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  198. </dl>
  199. </div>
  200. <h3 class="name name-method" id="blur" translate="no">.<a href="#blur">blur</a><span class="signature">( amountNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  201. <div class="method">
  202. <div class="description">
  203. <p>Samples a blurred version of the texture by defining an internal bias.</p>
  204. </div>
  205. <table class="params">
  206. <tbody>
  207. <tr>
  208. <td class="name">
  209. <strong translate="no">amountNode</strong>
  210. </td>
  211. <td class="description last">
  212. <p>How blurred the texture should be.</p>
  213. </td>
  214. </tr>
  215. </tbody>
  216. </table>
  217. <dl class="details">
  218. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  219. </dl>
  220. </div>
  221. <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>
  222. <div class="method">
  223. <div class="description">
  224. <p>Clones the texture node.</p>
  225. </div>
  226. <dl class="details">
  227. <dt class="tag-returns"><strong>Returns:</strong> The cloned texture node.</dt>
  228. </dl>
  229. </div>
  230. <h3 class="name name-method" id="compare" translate="no">.<a href="#compare">compare</a><span class="signature">( compareNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  231. <div class="method">
  232. <div class="description">
  233. <p>Samples the texture by executing a compare operation.</p>
  234. </div>
  235. <table class="params">
  236. <tbody>
  237. <tr>
  238. <td class="name">
  239. <strong translate="no">compareNode</strong>
  240. </td>
  241. <td class="description last">
  242. <p>The node that defines the compare value.</p>
  243. </td>
  244. </tr>
  245. </tbody>
  246. </table>
  247. <dl class="details">
  248. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  249. </dl>
  250. </div>
  251. <h3 class="name name-method" id="depth" translate="no">.<a href="#depth">depth</a><span class="signature">( depthNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;int></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  252. <div class="method">
  253. <div class="description">
  254. <p>Samples the texture by defining a depth node.</p>
  255. </div>
  256. <table class="params">
  257. <tbody>
  258. <tr>
  259. <td class="name">
  260. <strong translate="no">depthNode</strong>
  261. </td>
  262. <td class="description last">
  263. <p>The depth node.</p>
  264. </td>
  265. </tr>
  266. </tbody>
  267. </table>
  268. <dl class="details">
  269. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  270. </dl>
  271. </div>
  272. <h3 class="name name-method" id="gather" translate="no">.<a href="#gather">gather</a><span class="signature">( gatherNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;int></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  273. <div class="method">
  274. <div class="description">
  275. <p>Gathers four texels from the texture.</p>
  276. </div>
  277. <table class="params">
  278. <tbody>
  279. <tr>
  280. <td class="name">
  281. <strong translate="no">gatherNode</strong>
  282. </td>
  283. <td class="description last">
  284. <p>The index of the channel to read. This must be in range [0, 3] and a compile-time constant.</p>
  285. <p>Default is <code>0</code>.</p>
  286. </td>
  287. </tr>
  288. </tbody>
  289. </table>
  290. <dl class="details">
  291. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  292. </dl>
  293. </div>
  294. <h3 class="name name-method" id="generate" translate="no">.<a href="#generate">generate</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, output : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  295. <div class="method">
  296. <div class="description">
  297. <p>Generates the code snippet of the texture node.</p>
  298. </div>
  299. <table class="params">
  300. <tbody>
  301. <tr>
  302. <td class="name">
  303. <strong translate="no">builder</strong>
  304. </td>
  305. <td class="description last">
  306. <p>The current node builder.</p>
  307. </td>
  308. </tr>
  309. <tr>
  310. <td class="name">
  311. <strong translate="no">output</strong>
  312. </td>
  313. <td class="description last">
  314. <p>The current output.</p>
  315. </td>
  316. </tr>
  317. </tbody>
  318. </table>
  319. <dl class="details">
  320. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#generate">UniformNode#generate</a></dt>
  321. </dl>
  322. <dl class="details">
  323. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  324. </dl>
  325. </div>
  326. <h3 class="name name-method" id="generateNodeType" translate="no">.<a href="#generateNodeType">generateNodeType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  327. <div class="method">
  328. <div class="description">
  329. <p>Overwritten since the node type is inferred from the texture type.</p>
  330. </div>
  331. <table class="params">
  332. <tbody>
  333. <tr>
  334. <td class="name">
  335. <strong translate="no">builder</strong>
  336. </td>
  337. <td class="description last">
  338. <p>The current node builder.</p>
  339. </td>
  340. </tr>
  341. </tbody>
  342. </table>
  343. <dl class="details">
  344. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#generateNodeType">UniformNode#generateNodeType</a></dt>
  345. </dl>
  346. <dl class="details">
  347. <dt class="tag-returns"><strong>Returns:</strong> The node type.</dt>
  348. </dl>
  349. </div>
  350. <h3 class="name name-method" id="generateOffset" translate="no">.<a href="#generateOffset">generateOffset</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, offsetNode : <span class="param-type"><a href="Node.html">Node</a></span> )</span><span class="type-signature"> : string</span> </h3>
  351. <div class="method">
  352. <div class="description">
  353. <p>Generates the offset code snippet.</p>
  354. </div>
  355. <table class="params">
  356. <tbody>
  357. <tr>
  358. <td class="name">
  359. <strong translate="no">builder</strong>
  360. </td>
  361. <td class="description last">
  362. <p>The current node builder.</p>
  363. </td>
  364. </tr>
  365. <tr>
  366. <td class="name">
  367. <strong translate="no">offsetNode</strong>
  368. </td>
  369. <td class="description last">
  370. <p>The offset node to generate code for.</p>
  371. </td>
  372. </tr>
  373. </tbody>
  374. </table>
  375. <dl class="details">
  376. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  377. </dl>
  378. </div>
  379. <h3 class="name name-method" id="generateSnippet" translate="no">.<a href="#generateSnippet">generateSnippet</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></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>, gatherSnippet : <span class="param-type">string</span>, offsetSnippet : <span class="param-type">string</span>, flipYSnippet : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  380. <div class="method">
  381. <div class="description">
  382. <p>Generates the snippet for the texture sampling.</p>
  383. </div>
  384. <table class="params">
  385. <tbody>
  386. <tr>
  387. <td class="name">
  388. <strong translate="no">builder</strong>
  389. </td>
  390. <td class="description last">
  391. <p>The current node builder.</p>
  392. </td>
  393. </tr>
  394. <tr>
  395. <td class="name">
  396. <strong translate="no">textureProperty</strong>
  397. </td>
  398. <td class="description last">
  399. <p>The texture property.</p>
  400. </td>
  401. </tr>
  402. <tr>
  403. <td class="name">
  404. <strong translate="no">uvSnippet</strong>
  405. </td>
  406. <td class="description last">
  407. <p>The uv snippet.</p>
  408. </td>
  409. </tr>
  410. <tr>
  411. <td class="name">
  412. <strong translate="no">levelSnippet</strong>
  413. </td>
  414. <td class="description last">
  415. <p>The level snippet.</p>
  416. </td>
  417. </tr>
  418. <tr>
  419. <td class="name">
  420. <strong translate="no">biasSnippet</strong>
  421. </td>
  422. <td class="description last">
  423. <p>The bias snippet.</p>
  424. </td>
  425. </tr>
  426. <tr>
  427. <td class="name">
  428. <strong translate="no">depthSnippet</strong>
  429. </td>
  430. <td class="description last">
  431. <p>The depth snippet.</p>
  432. </td>
  433. </tr>
  434. <tr>
  435. <td class="name">
  436. <strong translate="no">compareSnippet</strong>
  437. </td>
  438. <td class="description last">
  439. <p>The compare snippet.</p>
  440. </td>
  441. </tr>
  442. <tr>
  443. <td class="name">
  444. <strong translate="no">gradSnippet</strong>
  445. </td>
  446. <td class="description last">
  447. <p>The grad snippet.</p>
  448. </td>
  449. </tr>
  450. <tr>
  451. <td class="name">
  452. <strong translate="no">gatherSnippet</strong>
  453. </td>
  454. <td class="description last">
  455. <p>The gather snippet.</p>
  456. </td>
  457. </tr>
  458. <tr>
  459. <td class="name">
  460. <strong translate="no">offsetSnippet</strong>
  461. </td>
  462. <td class="description last">
  463. <p>The offset snippet.</p>
  464. </td>
  465. </tr>
  466. <tr>
  467. <td class="name">
  468. <strong translate="no">flipYSnippet</strong>
  469. </td>
  470. <td class="description last">
  471. <p>The y-flip snippet. Only used for WebGL.</p>
  472. </td>
  473. </tr>
  474. </tbody>
  475. </table>
  476. <dl class="details">
  477. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  478. </dl>
  479. </div>
  480. <h3 class="name name-method" id="generateUV" translate="no">.<a href="#generateUV">generateUV</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, uvNode : <span class="param-type"><a href="Node.html">Node</a></span> )</span><span class="type-signature"> : string</span> </h3>
  481. <div class="method">
  482. <div class="description">
  483. <p>Generates the uv code snippet.</p>
  484. </div>
  485. <table class="params">
  486. <tbody>
  487. <tr>
  488. <td class="name">
  489. <strong translate="no">builder</strong>
  490. </td>
  491. <td class="description last">
  492. <p>The current node builder.</p>
  493. </td>
  494. </tr>
  495. <tr>
  496. <td class="name">
  497. <strong translate="no">uvNode</strong>
  498. </td>
  499. <td class="description last">
  500. <p>The uv node to generate code for.</p>
  501. </td>
  502. </tr>
  503. </tbody>
  504. </table>
  505. <dl class="details">
  506. <dt class="tag-returns"><strong>Returns:</strong> The generated code snippet.</dt>
  507. </dl>
  508. </div>
  509. <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>
  510. <div class="method">
  511. <div class="description">
  512. <p>Returns the base texture of this node.</p>
  513. </div>
  514. <dl class="details">
  515. <dt class="tag-returns"><strong>Returns:</strong> The base texture node.</dt>
  516. </dl>
  517. </div>
  518. <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>
  519. <div class="method">
  520. <div class="description">
  521. <p>Returns a default uvs based on the current texture's channel.</p>
  522. </div>
  523. <dl class="details">
  524. <dt class="tag-returns"><strong>Returns:</strong> The default uvs.</dt>
  525. </dl>
  526. </div>
  527. <h3 class="name name-method" id="getInputType" translate="no">.<a href="#getInputType">getInputType</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  528. <div class="method">
  529. <div class="description">
  530. <p>Overwrites the default implementation to return a fixed value <code>'texture'</code>.</p>
  531. </div>
  532. <table class="params">
  533. <tbody>
  534. <tr>
  535. <td class="name">
  536. <strong translate="no">builder</strong>
  537. </td>
  538. <td class="description last">
  539. <p>The current node builder.</p>
  540. </td>
  541. </tr>
  542. </tbody>
  543. </table>
  544. <dl class="details">
  545. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#getInputType">UniformNode#getInputType</a></dt>
  546. </dl>
  547. <dl class="details">
  548. <dt class="tag-returns"><strong>Returns:</strong> The input type.</dt>
  549. </dl>
  550. </div>
  551. <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>
  552. <div class="method">
  553. <div class="description">
  554. <p>Returns the sampler value.</p>
  555. </div>
  556. <dl class="details">
  557. <dt class="tag-returns"><strong>Returns:</strong> The sampler value.</dt>
  558. </dl>
  559. </div>
  560. <h3 class="name name-method" id="getTransformedUV" translate="no">.<a href="#getTransformedUV">getTransformedUV</a><span class="signature">( uvNode : <span class="param-type"><a href="Node.html">Node</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  561. <div class="method">
  562. <div class="description">
  563. <p>Transforms the given uv node with the texture transformation matrix.</p>
  564. </div>
  565. <table class="params">
  566. <tbody>
  567. <tr>
  568. <td class="name">
  569. <strong translate="no">uvNode</strong>
  570. </td>
  571. <td class="description last">
  572. <p>The uv node to transform.</p>
  573. </td>
  574. </tr>
  575. </tbody>
  576. </table>
  577. <dl class="details">
  578. <dt class="tag-returns"><strong>Returns:</strong> The transformed uv node.</dt>
  579. </dl>
  580. </div>
  581. <h3 class="name name-method" id="getUniformHash" translate="no">.<a href="#getUniformHash">getUniformHash</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : string</span> </h3>
  582. <div class="method">
  583. <div class="description">
  584. <p>Overwritten since the uniform hash is defined by the texture's UUID.</p>
  585. </div>
  586. <table class="params">
  587. <tbody>
  588. <tr>
  589. <td class="name">
  590. <strong translate="no">builder</strong>
  591. </td>
  592. <td class="description last">
  593. <p>The current node builder.</p>
  594. </td>
  595. </tr>
  596. </tbody>
  597. </table>
  598. <dl class="details">
  599. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#getUniformHash">UniformNode#getUniformHash</a></dt>
  600. </dl>
  601. <dl class="details">
  602. <dt class="tag-returns"><strong>Returns:</strong> The uniform hash.</dt>
  603. </dl>
  604. </div>
  605. <h3 class="name name-method" id="grad" translate="no">.<a href="#grad">grad</a><span class="signature">( gradNodeX : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec2></span>, gradNodeY : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec2></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  606. <div class="method">
  607. <div class="description">
  608. <p>Samples the texture using an explicit gradient.</p>
  609. </div>
  610. <table class="params">
  611. <tbody>
  612. <tr>
  613. <td class="name">
  614. <strong translate="no">gradNodeX</strong>
  615. </td>
  616. <td class="description last">
  617. <p>The gradX node.</p>
  618. </td>
  619. </tr>
  620. <tr>
  621. <td class="name">
  622. <strong translate="no">gradNodeY</strong>
  623. </td>
  624. <td class="description last">
  625. <p>The gradY node.</p>
  626. </td>
  627. </tr>
  628. </tbody>
  629. </table>
  630. <dl class="details">
  631. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  632. </dl>
  633. </div>
  634. <h3 class="name name-method" id="level" translate="no">.<a href="#level">level</a><span class="signature">( levelNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;int></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  635. <div class="method">
  636. <div class="description">
  637. <p>Samples a specific mip of the texture.</p>
  638. </div>
  639. <table class="params">
  640. <tbody>
  641. <tr>
  642. <td class="name">
  643. <strong translate="no">levelNode</strong>
  644. </td>
  645. <td class="description last">
  646. <p>The mip level to sample.</p>
  647. </td>
  648. </tr>
  649. </tbody>
  650. </table>
  651. <dl class="details">
  652. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  653. </dl>
  654. </div>
  655. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( uvNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;uvec2></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  656. <div class="method">
  657. <div class="description">
  658. <p>TSL function for creating a texture node that fetches/loads texels without interpolation.</p>
  659. </div>
  660. <table class="params">
  661. <tbody>
  662. <tr>
  663. <td class="name">
  664. <strong translate="no">uvNode</strong>
  665. </td>
  666. <td class="description last">
  667. <p>The uv node.</p>
  668. </td>
  669. </tr>
  670. </tbody>
  671. </table>
  672. <dl class="details">
  673. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture load.</dt>
  674. </dl>
  675. </div>
  676. <h3 class="name name-method" id="offset" translate="no">.<a href="#offset">offset</a><span class="signature">( offsetNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;ivec2></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  677. <div class="method">
  678. <div class="description">
  679. <p>Samples the texture by defining an offset node.</p>
  680. </div>
  681. <table class="params">
  682. <tbody>
  683. <tr>
  684. <td class="name">
  685. <strong translate="no">offsetNode</strong>
  686. </td>
  687. <td class="description last">
  688. <p>The offset node.</p>
  689. </td>
  690. </tr>
  691. </tbody>
  692. </table>
  693. <dl class="details">
  694. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  695. </dl>
  696. </div>
  697. <h3 class="name name-method" id="sample" translate="no">.<a href="#sample">sample</a><span class="signature">( uvNode : <span class="param-type"><a href="Node.html">Node</a></span> )</span><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  698. <div class="method">
  699. <div class="description">
  700. <p>Samples the texture with the given uv node.</p>
  701. </div>
  702. <table class="params">
  703. <tbody>
  704. <tr>
  705. <td class="name">
  706. <strong translate="no">uvNode</strong>
  707. </td>
  708. <td class="description last">
  709. <p>The uv node.</p>
  710. </td>
  711. </tr>
  712. </tbody>
  713. </table>
  714. <dl class="details">
  715. <dt class="tag-returns"><strong>Returns:</strong> A texture node representing the texture sample.</dt>
  716. </dl>
  717. </div>
  718. <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>
  719. <div class="method">
  720. <div class="description">
  721. <p>Sets the sampler value.</p>
  722. </div>
  723. <table class="params">
  724. <tbody>
  725. <tr>
  726. <td class="name">
  727. <strong translate="no">value</strong>
  728. </td>
  729. <td class="description last">
  730. <p>The sampler value to set.</p>
  731. </td>
  732. </tr>
  733. </tbody>
  734. </table>
  735. <dl class="details">
  736. <dt class="tag-returns"><strong>Returns:</strong> A reference to this texture node.</dt>
  737. </dl>
  738. </div>
  739. <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>
  740. <div class="method">
  741. <div class="description">
  742. <p>Defines whether the uv transformation matrix should automatically be updated or not.</p>
  743. </div>
  744. <table class="params">
  745. <tbody>
  746. <tr>
  747. <td class="name">
  748. <strong translate="no">value</strong>
  749. </td>
  750. <td class="description last">
  751. <p>The update toggle.</p>
  752. </td>
  753. </tr>
  754. </tbody>
  755. </table>
  756. <dl class="details">
  757. <dt class="tag-returns"><strong>Returns:</strong> A reference to this node.</dt>
  758. </dl>
  759. </div>
  760. <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> </h3>
  761. <div class="method">
  762. <div class="description">
  763. <p>Setups texture node by preparing the internal nodes for code generation.</p>
  764. </div>
  765. <table class="params">
  766. <tbody>
  767. <tr>
  768. <td class="name">
  769. <strong translate="no">builder</strong>
  770. </td>
  771. <td class="description last">
  772. <p>The current node builder.</p>
  773. </td>
  774. </tr>
  775. </tbody>
  776. </table>
  777. <dl class="details">
  778. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#setup">UniformNode#setup</a></dt>
  779. </dl>
  780. </div>
  781. <h3 class="name name-method" id="setupUV" translate="no">.<a href="#setupUV">setupUV</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span>, uvNode : <span class="param-type"><a href="Node.html">Node</a></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  782. <div class="method">
  783. <div class="description">
  784. <p>Setups the uv node. Depending on the backend as well as texture's image and type, it might be necessary
  785. to modify the uv node for correct sampling.</p>
  786. </div>
  787. <table class="params">
  788. <tbody>
  789. <tr>
  790. <td class="name">
  791. <strong translate="no">builder</strong>
  792. </td>
  793. <td class="description last">
  794. <p>The current node builder.</p>
  795. </td>
  796. </tr>
  797. <tr>
  798. <td class="name">
  799. <strong translate="no">uvNode</strong>
  800. </td>
  801. <td class="description last">
  802. <p>The uv node to setup.</p>
  803. </td>
  804. </tr>
  805. </tbody>
  806. </table>
  807. <dl class="details">
  808. <dt class="tag-returns"><strong>Returns:</strong> The updated uv node.</dt>
  809. </dl>
  810. </div>
  811. <h3 class="name name-method" id="size" translate="no">.<a href="#size">size</a><span class="signature">( levelNode : <span class="param-type"><a href="Node.html">Node</a>.&lt;int></span> )</span><span class="type-signature"> : <a href="TextureSizeNode.html">TextureSizeNode</a></span> </h3>
  812. <div class="method">
  813. <div class="description">
  814. <p>Returns the texture size of the requested level.</p>
  815. </div>
  816. <table class="params">
  817. <tbody>
  818. <tr>
  819. <td class="name">
  820. <strong translate="no">levelNode</strong>
  821. </td>
  822. <td class="description last">
  823. <p>The level to compute the size for.</p>
  824. </td>
  825. </tr>
  826. </tbody>
  827. </table>
  828. <dl class="details">
  829. <dt class="tag-returns"><strong>Returns:</strong> The texture size.</dt>
  830. </dl>
  831. </div>
  832. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  833. <div class="method">
  834. <div class="description">
  835. <p>The update is used to implement the update of the uv transformation matrix.</p>
  836. </div>
  837. <dl class="details">
  838. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#update">UniformNode#update</a></dt>
  839. </dl>
  840. </div>
  841. <h3 class="name name-method" id="updateReference" translate="no">.<a href="#updateReference">updateReference</a><span class="signature">( state : <span class="param-type"><a href="global.html#any">any</a></span> )</span><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  842. <div class="method">
  843. <div class="description">
  844. <p>Overwritten to always return the texture reference of the node.</p>
  845. </div>
  846. <table class="params">
  847. <tbody>
  848. <tr>
  849. <td class="name">
  850. <strong translate="no">state</strong>
  851. </td>
  852. <td class="description last">
  853. <p>This method can be invocated in different contexts so <code>state</code> can refer to any object type.</p>
  854. </td>
  855. </tr>
  856. </tbody>
  857. </table>
  858. <dl class="details">
  859. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="UniformNode.html#updateReference">UniformNode#updateReference</a></dt>
  860. </dl>
  861. <dl class="details">
  862. <dt class="tag-returns"><strong>Returns:</strong> The texture reference.</dt>
  863. </dl>
  864. </div>
  865. <h2 class="subsection-title">Source</h2>
  866. <p>
  867. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/accessors/TextureNode.js" translate="no" target="_blank" rel="noopener">src/nodes/accessors/TextureNode.js</a>
  868. </p>
  869. </article>
  870. </section>
  871. <script src="../scripts/linenumber.js"></script>
  872. <script src="../scripts/page.js"></script>
  873. </body>
  874. </html>
粤ICP备19079148号