TextureNode.html 35 KB

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